All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: add crypto device details
@ 2016-08-25 10:04 Eoin Breen
  2016-08-25 10:32 ` Mcnamara, John
  2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
  0 siblings, 2 replies; 9+ messages in thread
From: Eoin Breen @ 2016-08-25 10:04 UTC (permalink / raw)
  To: deepak.k.jain, fiona.trahe, john.griffin; +Cc: dev, Eoin Breen

Adding the support to bind/unbind crypto devices with
dpdk-devbind.py script, as now it is not restricted
to network devices anymore.

Signed-off-by: Eoin Breen <eoin.breen@intel.com>
---
 tools/dpdk-devbind.py | 106 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 98 insertions(+), 8 deletions(-)

diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index b69ca2a..39fc5c0 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -40,6 +40,7 @@ from os.path import exists, abspath, dirname, basename
 
 # The PCI base class for NETWORK devices
 NETWORK_BASE_CLASS = "02"
+CRYPTO_BASE_CLASS = "0b"
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -298,6 +299,70 @@ def get_nic_details():
                 modules.remove(devices[d]["Driver_str"])
                 devices[d]["Module_str"] = ",".join(modules)
 
+def get_crypto_details():
+    '''This function populates the "devices" dictionary. The keys used are
+    the pci addresses (domain:bus:slot.func). The values are themselves
+    dictionaries - one for each NIC.'''
+    global devices
+    global dpdk_drivers
+
+    # clear any old data
+    # devices = {}
+    # first loop through and read details for all devices
+    # request machine readable format, with numeric IDs
+    dev = {}
+    dev_lines = check_output(["lspci", "-Dvmmn"]).splitlines()
+    for dev_line in dev_lines:
+        if (len(dev_line) == 0):
+            if (dev["Class"][0:2] == CRYPTO_BASE_CLASS):
+                # convert device and vendor ids to numbers, then add to global
+                dev["Vendor"] = int(dev["Vendor"], 16)
+                dev["Device"] = int(dev["Device"], 16)
+                # use dict to make copy of dev
+                devices[dev["Slot"]] = dict(dev)
+        else:
+            name, value = dev_line.decode().split("\t", 1)
+            dev[name.rstrip(":")] = value
+    # check what is the interface if any for an ssh connection if
+    # any to this host, so we can mark it later.
+    ssh_if = []
+    route = check_output(["ip", "-o", "route"])
+    # filter out all lines for 169.254 routes
+    route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
+                             route.decode().splitlines()))
+    rt_info = route.split()
+    for i in range(len(rt_info) - 1):
+        if rt_info[i] == "dev":
+            ssh_if.append(rt_info[i+1])
+
+    # based on the basic info, get extended text details
+    for d in devices.keys():
+        # get additional info and add it to existing data
+        devices[d] = devices[d].copy()
+        devices[d].update(get_pci_device_details(d).items())
+
+        for _if in ssh_if:
+            if _if in devices[d]["Interface"].split(","):
+                devices[d]["Ssh_if"] = True
+                devices[d]["Active"] = "*Active*"
+                break
+
+        # add igb_uio to list of supporting modules if needed
+        if "Module_str" in devices[d]:
+            for driver in dpdk_drivers:
+                if driver not in devices[d]["Module_str"]:
+                    devices[d]["Module_str"] = \
+                        devices[d]["Module_str"] + ",%s" % driver
+        else:
+            devices[d]["Module_str"] = ",".join(dpdk_drivers)
+
+        # make sure the driver and module strings do not have any duplicates
+        if has_driver(d):
+            modules = devices[d]["Module_str"].split(",")
+            if devices[d]["Driver_str"] in modules:
+                modules.remove(devices[d]["Driver_str"])
+                devices[d]["Module_str"] = ",".join(modules)
+
 
 def dev_id_from_dev_name(dev_name):
     '''Take a device "name" - a string passed in by user to identify a NIC
@@ -480,15 +545,16 @@ def show_status():
     dpdk_drv = []
     no_drv = []
 
-    # split our list of devices into the three categories above
+    # split our list of network devices into the three categories above
     for d in devices.keys():
-        if not has_driver(d):
-            no_drv.append(devices[d])
-            continue
-        if devices[d]["Driver_str"] in dpdk_drivers:
-            dpdk_drv.append(devices[d])
-        else:
-            kernel_drv.append(devices[d])
+        if (NETWORK_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
 
     # print each category separately, so we can clearly see what's used by DPDK
     display_devices("Network devices using DPDK-compatible driver", dpdk_drv,
@@ -498,6 +564,28 @@ def show_status():
                     "unused=%(Module_str)s %(Active)s")
     display_devices("Other network devices", no_drv, "unused=%(Module_str)s")
 
+    # split our list of crypto devices into the three categories above
+    kernel_drv = []
+    dpdk_drv = []
+    no_drv = []
+
+    for d in devices.keys():
+        if (CRYPTO_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
+
+    display_devices("Crypto devices using DPDK-compatible driver", dpdk_drv,
+                    "drv=%(Driver_str)s unused=%(Module_str)s")
+    display_devices("Crypto devices using kernel driver", kernel_drv,
+                    "if=%(Interface)s drv=%(Driver_str)s "
+                    "unused=%(Module_str)s %(Active)s")
+    display_devices("Other crypto devices", no_drv, "unused=%(Module_str)s")
+
 
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
@@ -562,6 +650,7 @@ def do_arg_actions():
     if status_flag:
         if b_flag is not None:
             get_nic_details()  # refresh if we have changed anything
+            get_crypto_details() # refresh if we have changed anything
         show_status()
 
 
@@ -570,6 +659,7 @@ def main():
     parse_args()
     check_modules()
     get_nic_details()
+    get_crypto_details()
     do_arg_actions()
 
 if __name__ == "__main__":
-- 
2.5.5

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] tools: add crypto device details
  2016-08-25 10:04 [PATCH] tools: add crypto device details Eoin Breen
@ 2016-08-25 10:32 ` Mcnamara, John
  2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
  1 sibling, 0 replies; 9+ messages in thread
From: Mcnamara, John @ 2016-08-25 10:32 UTC (permalink / raw)
  To: Breen, Eoin, Jain, Deepak K, Trahe, Fiona, Griffin, John; +Cc: dev, Breen, Eoin

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Eoin Breen
> Sent: Thursday, August 25, 2016 11:05 AM
> To: Jain, Deepak K <deepak.k.jain@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; Griffin, John <john.griffin@intel.com>
> Cc: dev@dpdk.org; Breen, Eoin <eoin.breen@intel.com>
> Subject: [dpdk-dev] [PATCH] tools: add crypto device details
> 
> Adding the support to bind/unbind crypto devices with dpdk-devbind.py
> script, as now it is not restricted to network devices anymore.
> 

Hi Eoin,

There are a couple of small pep8 issues to fix:


    $ pep8 tools/dpdk-devbind.py   
    tools/dpdk-devbind.py:302:1: E302 expected 2 blank lines, found 1
    tools/dpdk-devbind.py:653:33: E261 at least two spaces before inline comment

See: http://dpdk.org/doc/guides/contributing/coding_style.html#python-code

John

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] tools: add crypto device details
  2016-08-25 10:04 [PATCH] tools: add crypto device details Eoin Breen
  2016-08-25 10:32 ` Mcnamara, John
@ 2016-08-25 13:52 ` Eoin Breen
  2016-08-25 20:31   ` Jain, Deepak K
                     ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Eoin Breen @ 2016-08-25 13:52 UTC (permalink / raw)
  To: deepak.k.jain, fiona.trahe, john.griffin; +Cc: dev, Eoin Breen

Adding the support to bind/unbind crypto devices with
dpdk-devbind.py script, as now it is not restricted
to network devices anymore.

Signed-off-by: Eoin Breen <eoin.breen@intel.com>
---
Changes since v1:
* Resolved coding issues

 tools/dpdk-devbind.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 99 insertions(+), 8 deletions(-)

diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index b69ca2a..c7576b9 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -40,6 +40,7 @@ from os.path import exists, abspath, dirname, basename
 
 # The PCI base class for NETWORK devices
 NETWORK_BASE_CLASS = "02"
+CRYPTO_BASE_CLASS = "0b"
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -299,6 +300,71 @@ def get_nic_details():
                 devices[d]["Module_str"] = ",".join(modules)
 
 
+def get_crypto_details():
+    '''This function populates the "devices" dictionary. The keys used are
+    the pci addresses (domain:bus:slot.func). The values are themselves
+    dictionaries - one for each NIC.'''
+    global devices
+    global dpdk_drivers
+
+    # clear any old data
+    # devices = {}
+    # first loop through and read details for all devices
+    # request machine readable format, with numeric IDs
+    dev = {}
+    dev_lines = check_output(["lspci", "-Dvmmn"]).splitlines()
+    for dev_line in dev_lines:
+        if (len(dev_line) == 0):
+            if (dev["Class"][0:2] == CRYPTO_BASE_CLASS):
+                # convert device and vendor ids to numbers, then add to global
+                dev["Vendor"] = int(dev["Vendor"], 16)
+                dev["Device"] = int(dev["Device"], 16)
+                # use dict to make copy of dev
+                devices[dev["Slot"]] = dict(dev)
+        else:
+            name, value = dev_line.decode().split("\t", 1)
+            dev[name.rstrip(":")] = value
+    # check what is the interface if any for an ssh connection if
+    # any to this host, so we can mark it later.
+    ssh_if = []
+    route = check_output(["ip", "-o", "route"])
+    # filter out all lines for 169.254 routes
+    route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
+                             route.decode().splitlines()))
+    rt_info = route.split()
+    for i in range(len(rt_info) - 1):
+        if rt_info[i] == "dev":
+            ssh_if.append(rt_info[i+1])
+
+    # based on the basic info, get extended text details
+    for d in devices.keys():
+        # get additional info and add it to existing data
+        devices[d] = devices[d].copy()
+        devices[d].update(get_pci_device_details(d).items())
+
+        for _if in ssh_if:
+            if _if in devices[d]["Interface"].split(","):
+                devices[d]["Ssh_if"] = True
+                devices[d]["Active"] = "*Active*"
+                break
+
+        # add igb_uio to list of supporting modules if needed
+        if "Module_str" in devices[d]:
+            for driver in dpdk_drivers:
+                if driver not in devices[d]["Module_str"]:
+                    devices[d]["Module_str"] = \
+                        devices[d]["Module_str"] + ",%s" % driver
+        else:
+            devices[d]["Module_str"] = ",".join(dpdk_drivers)
+
+        # make sure the driver and module strings do not have any duplicates
+        if has_driver(d):
+            modules = devices[d]["Module_str"].split(",")
+            if devices[d]["Driver_str"] in modules:
+                modules.remove(devices[d]["Driver_str"])
+                devices[d]["Module_str"] = ",".join(modules)
+
+
 def dev_id_from_dev_name(dev_name):
     '''Take a device "name" - a string passed in by user to identify a NIC
     device, and determine the device id - i.e. the domain:bus:slot.func - for
@@ -480,15 +546,16 @@ def show_status():
     dpdk_drv = []
     no_drv = []
 
-    # split our list of devices into the three categories above
+    # split our list of network devices into the three categories above
     for d in devices.keys():
-        if not has_driver(d):
-            no_drv.append(devices[d])
-            continue
-        if devices[d]["Driver_str"] in dpdk_drivers:
-            dpdk_drv.append(devices[d])
-        else:
-            kernel_drv.append(devices[d])
+        if (NETWORK_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
 
     # print each category separately, so we can clearly see what's used by DPDK
     display_devices("Network devices using DPDK-compatible driver", dpdk_drv,
@@ -498,6 +565,28 @@ def show_status():
                     "unused=%(Module_str)s %(Active)s")
     display_devices("Other network devices", no_drv, "unused=%(Module_str)s")
 
+    # split our list of crypto devices into the three categories above
+    kernel_drv = []
+    dpdk_drv = []
+    no_drv = []
+
+    for d in devices.keys():
+        if (CRYPTO_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
+
+    display_devices("Crypto devices using DPDK-compatible driver", dpdk_drv,
+                    "drv=%(Driver_str)s unused=%(Module_str)s")
+    display_devices("Crypto devices using kernel driver", kernel_drv,
+                    "if=%(Interface)s drv=%(Driver_str)s "
+                    "unused=%(Module_str)s %(Active)s")
+    display_devices("Other crypto devices", no_drv, "unused=%(Module_str)s")
+
 
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
@@ -562,6 +651,7 @@ def do_arg_actions():
     if status_flag:
         if b_flag is not None:
             get_nic_details()  # refresh if we have changed anything
+            get_crypto_details()  # refresh if we have changed anything
         show_status()
 
 
@@ -570,6 +660,7 @@ def main():
     parse_args()
     check_modules()
     get_nic_details()
+    get_crypto_details()
     do_arg_actions()
 
 if __name__ == "__main__":
-- 
2.5.5

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] tools: add crypto device details
  2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
@ 2016-08-25 20:31   ` Jain, Deepak K
  2016-09-13 22:50   ` De Lara Guarch, Pablo
  2016-09-15 23:57   ` [PATCH v3] " Pablo de Lara
  2 siblings, 0 replies; 9+ messages in thread
From: Jain, Deepak K @ 2016-08-25 20:31 UTC (permalink / raw)
  To: Breen, Eoin, Trahe, Fiona, Griffin, John; +Cc: dev



> -----Original Message-----
> From: Breen, Eoin
> Sent: Thursday, August 25, 2016 2:52 PM
> To: Jain, Deepak K <deepak.k.jain@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; Griffin, John <john.griffin@intel.com>
> Cc: dev@dpdk.org; Breen, Eoin <eoin.breen@intel.com>
> Subject: [PATCH v2] tools: add crypto device details
> 
> Adding the support to bind/unbind crypto devices with dpdk-devbind.py
> script, as now it is not restricted to network devices anymore.
> 
> Signed-off-by: Eoin Breen <eoin.breen@intel.com>
> ---
> Changes since v1:
> * Resolved coding issues
> 
>  tools/dpdk-devbind.py | 107
> ++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 99 insertions(+), 8 deletions(-)
> --
> 2.5.5
Acked-by: Deepak Kumar Jain <deepak.k.jain@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] tools: add crypto device details
  2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
  2016-08-25 20:31   ` Jain, Deepak K
@ 2016-09-13 22:50   ` De Lara Guarch, Pablo
  2016-09-15 23:57   ` [PATCH v3] " Pablo de Lara
  2 siblings, 0 replies; 9+ messages in thread
From: De Lara Guarch, Pablo @ 2016-09-13 22:50 UTC (permalink / raw)
  To: Breen, Eoin, Jain, Deepak K, Trahe, Fiona, Griffin, John; +Cc: dev, Breen, Eoin


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Eoin Breen
> Sent: Thursday, August 25, 2016 6:52 AM
> To: Jain, Deepak K; Trahe, Fiona; Griffin, John
> Cc: dev@dpdk.org; Breen, Eoin
> Subject: [dpdk-dev] [PATCH v2] tools: add crypto device details
> 
> Adding the support to bind/unbind crypto devices with
> dpdk-devbind.py script, as now it is not restricted
> to network devices anymore.
> 
> Signed-off-by: Eoin Breen <eoin.breen@intel.com>
> ---
> Changes since v1:
> * Resolved coding issues
> 
>  tools/dpdk-devbind.py | 107
> ++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 99 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
> index b69ca2a..c7576b9 100755
> --- a/tools/dpdk-devbind.py
> +++ b/tools/dpdk-devbind.py

...

> +    # check what is the interface if any for an ssh connection if
> +    # any to this host, so we can mark it later.
> +    ssh_if = []
> +    route = check_output(["ip", "-o", "route"])
> +    # filter out all lines for 169.254 routes
> +    route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
> +                             route.decode().splitlines()))
> +    rt_info = route.split()
> +    for i in range(len(rt_info) - 1):
> +        if rt_info[i] == "dev":
> +            ssh_if.append(rt_info[i+1])

This is relevant only to network devices, so it should not be included here.
> +
> +    # based on the basic info, get extended text details
> +    for d in devices.keys():
> +        # get additional info and add it to existing data
> +        devices[d] = devices[d].copy()
> +        devices[d].update(get_pci_device_details(d).items())
> +
> +        for _if in ssh_if:
> +            if _if in devices[d]["Interface"].split(","):
> +                devices[d]["Ssh_if"] = True
> +                devices[d]["Active"] = "*Active*"
> +                break

Same here.

> +
> +        # add igb_uio to list of supporting modules if needed
> +        if "Module_str" in devices[d]:
> +            for driver in dpdk_drivers:
> +                if driver not in devices[d]["Module_str"]:
> +                    devices[d]["Module_str"] = \
> +                        devices[d]["Module_str"] + ",%s" % driver
> +        else:
> +            devices[d]["Module_str"] = ",".join(dpdk_drivers)
> +
> +        # make sure the driver and module strings do not have any duplicates
> +        if has_driver(d):
> +            modules = devices[d]["Module_str"].split(",")
> +            if devices[d]["Driver_str"] in modules:
> +                modules.remove(devices[d]["Driver_str"])
> +                devices[d]["Module_str"] = ",".join(modules)
> +
> +
>  def dev_id_from_dev_name(dev_name):
>      '''Take a device "name" - a string passed in by user to identify a NIC
>      device, and determine the device id - i.e. the domain:bus:slot.func - for
> @@ -480,15 +546,16 @@ def show_status():
>      dpdk_drv = []
>      no_drv = []
> 
> -    # split our list of devices into the three categories above
> +    # split our list of network devices into the three categories above
>      for d in devices.keys():
> -        if not has_driver(d):
> -            no_drv.append(devices[d])
> -            continue
> -        if devices[d]["Driver_str"] in dpdk_drivers:
> -            dpdk_drv.append(devices[d])
> -        else:
> -            kernel_drv.append(devices[d])
> +        if (NETWORK_BASE_CLASS in devices[d]["Class"]):
> +            if not has_driver(d):
> +                no_drv.append(devices[d])
> +                continue
> +            if devices[d]["Driver_str"] in dpdk_drivers:
> +                dpdk_drv.append(devices[d])
> +            else:
> +                kernel_drv.append(devices[d])
> 
>      # print each category separately, so we can clearly see what's used by
> DPDK
>      display_devices("Network devices using DPDK-compatible driver",
> dpdk_drv,
> @@ -498,6 +565,28 @@ def show_status():
>                      "unused=%(Module_str)s %(Active)s")
>      display_devices("Other network devices", no_drv,
> "unused=%(Module_str)s")
> 
> +    # split our list of crypto devices into the three categories above
> +    kernel_drv = []
> +    dpdk_drv = []
> +    no_drv = []
> +
> +    for d in devices.keys():
> +        if (CRYPTO_BASE_CLASS in devices[d]["Class"]):
> +            if not has_driver(d):
> +                no_drv.append(devices[d])
> +                continue
> +            if devices[d]["Driver_str"] in dpdk_drivers:
> +                dpdk_drv.append(devices[d])
> +            else:
> +                kernel_drv.append(devices[d])
> +
> +    display_devices("Crypto devices using DPDK-compatible driver",
> dpdk_drv,
> +                    "drv=%(Driver_str)s unused=%(Module_str)s")
> +    display_devices("Crypto devices using kernel driver", kernel_drv,
> +                    "if=%(Interface)s drv=%(Driver_str)s "
> +                    "unused=%(Module_str)s %(Active)s")
> +    display_devices("Other crypto devices", no_drv,
> "unused=%(Module_str)s")
> +
> 
>  def parse_args():
>      '''Parses the command-line arguments given by the user and takes the
> @@ -562,6 +651,7 @@ def do_arg_actions():
>      if status_flag:
>          if b_flag is not None:
>              get_nic_details()  # refresh if we have changed anything
> +            get_crypto_details()  # refresh if we have changed anything
>          show_status()
> 
> 
> @@ -570,6 +660,7 @@ def main():
>      parse_args()
>      check_modules()
>      get_nic_details()
> +    get_crypto_details()
>      do_arg_actions()
> 
>  if __name__ == "__main__":
> --
> 2.5.5
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] tools: add crypto device details
  2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
  2016-08-25 20:31   ` Jain, Deepak K
  2016-09-13 22:50   ` De Lara Guarch, Pablo
@ 2016-09-15 23:57   ` Pablo de Lara
  2016-09-20  0:05     ` [PATCH v4] " Pablo de Lara
  2 siblings, 1 reply; 9+ messages in thread
From: Pablo de Lara @ 2016-09-15 23:57 UTC (permalink / raw)
  To: dev; +Cc: deepak.k.jain, Eoin Breen, Pablo de Lara

From: Eoin Breen <eoin.breen@intel.com>

Adding the support to bind/unbind crypto devices with
dpdk-devbind.py script, as now it is not restricted
to network devices anymore.

Signed-off-by: Eoin Breen <eoin.breen@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes since v2:
* Removed network specific parameters from crypto parameters

Changes since v1:
* Resolved coding issues

 tools/dpdk-devbind.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 82 insertions(+), 8 deletions(-)

diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index b69ca2a..f4fda4b 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -40,6 +40,7 @@ from os.path import exists, abspath, dirname, basename
 
 # The PCI base class for NETWORK devices
 NETWORK_BASE_CLASS = "02"
+CRYPTO_BASE_CLASS = "0b"
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -299,6 +300,54 @@ def get_nic_details():
                 devices[d]["Module_str"] = ",".join(modules)
 
 
+def get_crypto_details():
+    '''This function populates the "devices" dictionary. The keys used are
+    the pci addresses (domain:bus:slot.func). The values are themselves
+    dictionaries - one for each NIC.'''
+    global devices
+    global dpdk_drivers
+
+    # clear any old data
+    # devices = {}
+    # first loop through and read details for all devices
+    # request machine readable format, with numeric IDs
+    dev = {}
+    dev_lines = check_output(["lspci", "-Dvmmn"]).splitlines()
+    for dev_line in dev_lines:
+        if (len(dev_line) == 0):
+            if (dev["Class"][0:2] == CRYPTO_BASE_CLASS):
+                # convert device and vendor ids to numbers, then add to global
+                dev["Vendor"] = int(dev["Vendor"], 16)
+                dev["Device"] = int(dev["Device"], 16)
+                # use dict to make copy of dev
+                devices[dev["Slot"]] = dict(dev)
+        else:
+            name, value = dev_line.decode().split("\t", 1)
+            dev[name.rstrip(":")] = value
+
+    # based on the basic info, get extended text details
+    for d in devices.keys():
+        # get additional info and add it to existing data
+        devices[d] = devices[d].copy()
+        devices[d].update(get_pci_device_details(d).items())
+
+        # add igb_uio to list of supporting modules if needed
+        if "Module_str" in devices[d]:
+            for driver in dpdk_drivers:
+                if driver not in devices[d]["Module_str"]:
+                    devices[d]["Module_str"] = \
+                        devices[d]["Module_str"] + ",%s" % driver
+        else:
+            devices[d]["Module_str"] = ",".join(dpdk_drivers)
+
+        # make sure the driver and module strings do not have any duplicates
+        if has_driver(d):
+            modules = devices[d]["Module_str"].split(",")
+            if devices[d]["Driver_str"] in modules:
+                modules.remove(devices[d]["Driver_str"])
+                devices[d]["Module_str"] = ",".join(modules)
+
+
 def dev_id_from_dev_name(dev_name):
     '''Take a device "name" - a string passed in by user to identify a NIC
     device, and determine the device id - i.e. the domain:bus:slot.func - for
@@ -480,15 +529,16 @@ def show_status():
     dpdk_drv = []
     no_drv = []
 
-    # split our list of devices into the three categories above
+    # split our list of network devices into the three categories above
     for d in devices.keys():
-        if not has_driver(d):
-            no_drv.append(devices[d])
-            continue
-        if devices[d]["Driver_str"] in dpdk_drivers:
-            dpdk_drv.append(devices[d])
-        else:
-            kernel_drv.append(devices[d])
+        if (NETWORK_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
 
     # print each category separately, so we can clearly see what's used by DPDK
     display_devices("Network devices using DPDK-compatible driver", dpdk_drv,
@@ -498,6 +548,28 @@ def show_status():
                     "unused=%(Module_str)s %(Active)s")
     display_devices("Other network devices", no_drv, "unused=%(Module_str)s")
 
+    # split our list of crypto devices into the three categories above
+    kernel_drv = []
+    dpdk_drv = []
+    no_drv = []
+
+    for d in devices.keys():
+        if (CRYPTO_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
+
+    display_devices("Crypto devices using DPDK-compatible driver", dpdk_drv,
+                    "drv=%(Driver_str)s unused=%(Module_str)s")
+    display_devices("Crypto devices using kernel driver", kernel_drv,
+                    "drv=%(Driver_str)s "
+                    "unused=%(Module_str)s")
+    display_devices("Other crypto devices", no_drv, "unused=%(Module_str)s")
+
 
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
@@ -562,6 +634,7 @@ def do_arg_actions():
     if status_flag:
         if b_flag is not None:
             get_nic_details()  # refresh if we have changed anything
+            get_crypto_details()  # refresh if we have changed anything
         show_status()
 
 
@@ -570,6 +643,7 @@ def main():
     parse_args()
     check_modules()
     get_nic_details()
+    get_crypto_details()
     do_arg_actions()
 
 if __name__ == "__main__":
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4] tools: add crypto device details
  2016-09-15 23:57   ` [PATCH v3] " Pablo de Lara
@ 2016-09-20  0:05     ` Pablo de Lara
  2016-09-21 10:04       ` Jain, Deepak K
  0 siblings, 1 reply; 9+ messages in thread
From: Pablo de Lara @ 2016-09-20  0:05 UTC (permalink / raw)
  To: dev; +Cc: deepak.k.jain, Eoin Breen, Pablo de Lara

From: Eoin Breen <eoin.breen@intel.com>

Adding the support to bind/unbind crypto devices with
dpdk-devbind.py script, as now it is not restricted
to network devices anymore.

Signed-off-by: Eoin Breen <eoin.breen@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes since v3:
* Modified setup.sh script to show crypto details
* Added script usage in qat.rst doc
* Modified help script, to include crypto references

Changes since v2:
* Removed network specific parameters from crypto parameters

Changes since v1:
* Resolved coding issues

 doc/guides/cryptodevs/qat.rst |  5 +++
 tools/dpdk-devbind.py         | 94 ++++++++++++++++++++++++++++++++++++++-----
 tools/dpdk-setup.sh           | 32 +++++++--------
 3 files changed, 105 insertions(+), 26 deletions(-)

diff --git a/doc/guides/cryptodevs/qat.rst b/doc/guides/cryptodevs/qat.rst
index 326b228..e212b29 100644
--- a/doc/guides/cryptodevs/qat.rst
+++ b/doc/guides/cryptodevs/qat.rst
@@ -257,3 +257,8 @@ The unbind command below assumes ``bdfs`` of ``03:01.00-03:04.07``, if yours are
    echo "8086 0443" > /sys/bus/pci/drivers/igb_uio/new_id
 
 You can use ``lspci -vvd:443`` to confirm that all devices are now in use by igb_uio kernel driver.
+
+The other way to bind the VFs to the DPDK UIO driver is by using the ``dpdk-devbind.py`` script::
+
+  cd $RTE_SDK
+  ./tools/dpdk-devbind.py -b igb_uio 0000:03:01.1
diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index b69ca2a..a36535e 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -40,6 +40,7 @@ from os.path import exists, abspath, dirname, basename
 
 # The PCI base class for NETWORK devices
 NETWORK_BASE_CLASS = "02"
+CRYPTO_BASE_CLASS = "0b"
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -72,7 +73,7 @@ Options:
         Display usage information and quit
 
     -s, --status:
-        Print the current status of all known network interfaces.
+        Print the current status of all known network and crypto devices.
         For each device, it displays the PCI domain, bus, slot and function,
         along with a text description of the device. Depending upon whether the
         device is being used by a kernel driver, the igb_uio driver, or no
@@ -92,7 +93,7 @@ Options:
         Unbind a device (Equivalent to \"-b none\")
 
     --force:
-        By default, devices which are used by Linux - as indicated by having
+        By default, network devices which are used by Linux - as indicated by having
         routes in the routing table - cannot be modified. Using the --force
         flag overrides this behavior, allowing active links to be forcibly
         unbound.
@@ -299,6 +300,54 @@ def get_nic_details():
                 devices[d]["Module_str"] = ",".join(modules)
 
 
+def get_crypto_details():
+    '''This function populates the "devices" dictionary. The keys used are
+    the pci addresses (domain:bus:slot.func). The values are themselves
+    dictionaries - one for each NIC.'''
+    global devices
+    global dpdk_drivers
+
+    # clear any old data
+    # devices = {}
+    # first loop through and read details for all devices
+    # request machine readable format, with numeric IDs
+    dev = {}
+    dev_lines = check_output(["lspci", "-Dvmmn"]).splitlines()
+    for dev_line in dev_lines:
+        if (len(dev_line) == 0):
+            if (dev["Class"][0:2] == CRYPTO_BASE_CLASS):
+                # convert device and vendor ids to numbers, then add to global
+                dev["Vendor"] = int(dev["Vendor"], 16)
+                dev["Device"] = int(dev["Device"], 16)
+                # use dict to make copy of dev
+                devices[dev["Slot"]] = dict(dev)
+        else:
+            name, value = dev_line.decode().split("\t", 1)
+            dev[name.rstrip(":")] = value
+
+    # based on the basic info, get extended text details
+    for d in devices.keys():
+        # get additional info and add it to existing data
+        devices[d] = devices[d].copy()
+        devices[d].update(get_pci_device_details(d).items())
+
+        # add igb_uio to list of supporting modules if needed
+        if "Module_str" in devices[d]:
+            for driver in dpdk_drivers:
+                if driver not in devices[d]["Module_str"]:
+                    devices[d]["Module_str"] = \
+                        devices[d]["Module_str"] + ",%s" % driver
+        else:
+            devices[d]["Module_str"] = ",".join(dpdk_drivers)
+
+        # make sure the driver and module strings do not have any duplicates
+        if has_driver(d):
+            modules = devices[d]["Module_str"].split(",")
+            if devices[d]["Driver_str"] in modules:
+                modules.remove(devices[d]["Driver_str"])
+                devices[d]["Module_str"] = ",".join(modules)
+
+
 def dev_id_from_dev_name(dev_name):
     '''Take a device "name" - a string passed in by user to identify a NIC
     device, and determine the device id - i.e. the domain:bus:slot.func - for
@@ -480,15 +529,16 @@ def show_status():
     dpdk_drv = []
     no_drv = []
 
-    # split our list of devices into the three categories above
+    # split our list of network devices into the three categories above
     for d in devices.keys():
-        if not has_driver(d):
-            no_drv.append(devices[d])
-            continue
-        if devices[d]["Driver_str"] in dpdk_drivers:
-            dpdk_drv.append(devices[d])
-        else:
-            kernel_drv.append(devices[d])
+        if (NETWORK_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
 
     # print each category separately, so we can clearly see what's used by DPDK
     display_devices("Network devices using DPDK-compatible driver", dpdk_drv,
@@ -498,6 +548,28 @@ def show_status():
                     "unused=%(Module_str)s %(Active)s")
     display_devices("Other network devices", no_drv, "unused=%(Module_str)s")
 
+    # split our list of crypto devices into the three categories above
+    kernel_drv = []
+    dpdk_drv = []
+    no_drv = []
+
+    for d in devices.keys():
+        if (CRYPTO_BASE_CLASS in devices[d]["Class"]):
+            if not has_driver(d):
+                no_drv.append(devices[d])
+                continue
+            if devices[d]["Driver_str"] in dpdk_drivers:
+                dpdk_drv.append(devices[d])
+            else:
+                kernel_drv.append(devices[d])
+
+    display_devices("Crypto devices using DPDK-compatible driver", dpdk_drv,
+                    "drv=%(Driver_str)s unused=%(Module_str)s")
+    display_devices("Crypto devices using kernel driver", kernel_drv,
+                    "drv=%(Driver_str)s "
+                    "unused=%(Module_str)s")
+    display_devices("Other crypto devices", no_drv, "unused=%(Module_str)s")
+
 
 def parse_args():
     '''Parses the command-line arguments given by the user and takes the
@@ -562,6 +634,7 @@ def do_arg_actions():
     if status_flag:
         if b_flag is not None:
             get_nic_details()  # refresh if we have changed anything
+            get_crypto_details()  # refresh if we have changed anything
         show_status()
 
 
@@ -570,6 +643,7 @@ def main():
     parse_args()
     check_modules()
     get_nic_details()
+    get_crypto_details()
     do_arg_actions()
 
 if __name__ == "__main__":
diff --git a/tools/dpdk-setup.sh b/tools/dpdk-setup.sh
index ac81b2e..14ed590 100755
--- a/tools/dpdk-setup.sh
+++ b/tools/dpdk-setup.sh
@@ -422,23 +422,23 @@ grep_meminfo()
 }
 
 #
-# Calls dpdk-devbind.py --status to show the NIC and what they
+# Calls dpdk-devbind.py --status to show the devices and what they
 # are all bound to, in terms of drivers.
 #
-show_nics()
+show_devices()
 {
 	if [ -d /sys/module/vfio_pci -o -d /sys/module/igb_uio ]; then
 		${RTE_SDK}/tools/dpdk-devbind.py --status
 	else
 		echo "# Please load the 'igb_uio' or 'vfio-pci' kernel module before "
-		echo "# querying or adjusting NIC device bindings"
+		echo "# querying or adjusting device bindings"
 	fi
 }
 
 #
 # Uses dpdk-devbind.py to move devices to work with vfio-pci
 #
-bind_nics_to_vfio()
+bind_devices_to_vfio()
 {
 	if [ -d /sys/module/vfio_pci ]; then
 		${RTE_SDK}/tools/dpdk-devbind.py --status
@@ -449,14 +449,14 @@ bind_nics_to_vfio()
 			echo "OK"
 	else
 		echo "# Please load the 'vfio-pci' kernel module before querying or "
-		echo "# adjusting NIC device bindings"
+		echo "# adjusting device bindings"
 	fi
 }
 
 #
 # Uses dpdk-devbind.py to move devices to work with igb_uio
 #
-bind_nics_to_igb_uio()
+bind_devices_to_igb_uio()
 {
 	if [ -d /sys/module/igb_uio ]; then
 		${RTE_SDK}/tools/dpdk-devbind.py --status
@@ -466,14 +466,14 @@ bind_nics_to_igb_uio()
 		sudo ${RTE_SDK}/tools/dpdk-devbind.py -b igb_uio $PCI_PATH && echo "OK"
 	else
 		echo "# Please load the 'igb_uio' kernel module before querying or "
-		echo "# adjusting NIC device bindings"
+		echo "# adjusting device bindings"
 	fi
 }
 
 #
 # Uses dpdk-devbind.py to move devices to work with kernel drivers again
 #
-unbind_nics()
+unbind_devices()
 {
 	${RTE_SDK}/tools/dpdk-devbind.py --status
 	echo ""
@@ -525,14 +525,14 @@ step2_func()
 	TEXT[5]="Setup hugepage mappings for NUMA systems"
 	FUNC[5]="set_numa_pages"
 
-	TEXT[6]="Display current Ethernet device settings"
-	FUNC[6]="show_nics"
+	TEXT[6]="Display current Ethernet/Crypto device settings"
+	FUNC[6]="show_devices"
 
-	TEXT[7]="Bind Ethernet device to IGB UIO module"
-	FUNC[7]="bind_nics_to_igb_uio"
+	TEXT[7]="Bind Ethernet/Crypto device to IGB UIO module"
+	FUNC[7]="bind_devices_to_igb_uio"
 
-	TEXT[8]="Bind Ethernet device to VFIO module"
-	FUNC[8]="bind_nics_to_vfio"
+	TEXT[8]="Bind Ethernet/Crypto device to VFIO module"
+	FUNC[8]="bind_devices_to_vfio"
 
 	TEXT[9]="Setup VFIO permissions"
 	FUNC[9]="set_vfio_permissions"
@@ -571,8 +571,8 @@ step5_func()
 {
 	TITLE="Uninstall and system cleanup"
 
-	TEXT[1]="Unbind NICs from IGB UIO or VFIO driver"
-	FUNC[1]="unbind_nics"
+	TEXT[1]="Unbind devices from IGB UIO or VFIO driver"
+	FUNC[1]="unbind_devices"
 
 	TEXT[2]="Remove IGB UIO module"
 	FUNC[2]="remove_igb_uio_module"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4] tools: add crypto device details
  2016-09-20  0:05     ` [PATCH v4] " Pablo de Lara
@ 2016-09-21 10:04       ` Jain, Deepak K
  2016-09-21 18:56         ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 9+ messages in thread
From: Jain, Deepak K @ 2016-09-21 10:04 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev


> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Tuesday, September 20, 2016 1:05 AM
> To: dev@dpdk.org
> Cc: Jain, Deepak K <deepak.k.jain@intel.com>; Eoin Breen
> <eoin.breen@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH v4] tools: add crypto device details
> 
> From: Eoin Breen <eoin.breen@intel.com>
> 
> Adding the support to bind/unbind crypto devices with dpdk-devbind.py
> script, as now it is not restricted to network devices anymore.
> 
> Signed-off-by: Eoin Breen <eoin.breen@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
> Changes since v3:
> * Modified setup.sh script to show crypto details
> * Added script usage in qat.rst doc
> * Modified help script, to include crypto references
> 
> Changes since v2:
> * Removed network specific parameters from crypto parameters
> 
> Changes since v1:
> * Resolved coding issues
> 
>  doc/guides/cryptodevs/qat.rst |  5 +++
>  tools/dpdk-devbind.py         | 94
> ++++++++++++++++++++++++++++++++++++++-----
>  tools/dpdk-setup.sh           | 32 +++++++--------
>  3 files changed, 105 insertions(+), 26 deletions(-)
> --
> 2.7.4
Acked-by: Deepak Kumar Jain <deepak.k.jain@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4] tools: add crypto device details
  2016-09-21 10:04       ` Jain, Deepak K
@ 2016-09-21 18:56         ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 9+ messages in thread
From: De Lara Guarch, Pablo @ 2016-09-21 18:56 UTC (permalink / raw)
  To: Jain, Deepak K, dev



> -----Original Message-----
> From: Jain, Deepak K
> Sent: Wednesday, September 21, 2016 3:04 AM
> To: De Lara Guarch, Pablo; dev@dpdk.org
> Subject: RE: [PATCH v4] tools: add crypto device details
> 
> 
> > -----Original Message-----
> > From: De Lara Guarch, Pablo
> > Sent: Tuesday, September 20, 2016 1:05 AM
> > To: dev@dpdk.org
> > Cc: Jain, Deepak K <deepak.k.jain@intel.com>; Eoin Breen
> > <eoin.breen@intel.com>; De Lara Guarch, Pablo
> > <pablo.de.lara.guarch@intel.com>
> > Subject: [PATCH v4] tools: add crypto device details
> >
> > From: Eoin Breen <eoin.breen@intel.com>
> >
> > Adding the support to bind/unbind crypto devices with dpdk-devbind.py
> > script, as now it is not restricted to network devices anymore.
> >
> > Signed-off-by: Eoin Breen <eoin.breen@intel.com>
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> > Changes since v3:
> > * Modified setup.sh script to show crypto details
> > * Added script usage in qat.rst doc
> > * Modified help script, to include crypto references
> >
> > Changes since v2:
> > * Removed network specific parameters from crypto parameters
> >
> > Changes since v1:
> > * Resolved coding issues
> >
> >  doc/guides/cryptodevs/qat.rst |  5 +++
> >  tools/dpdk-devbind.py         | 94
> > ++++++++++++++++++++++++++++++++++++++-----
> >  tools/dpdk-setup.sh           | 32 +++++++--------
> >  3 files changed, 105 insertions(+), 26 deletions(-)
> > --
> > 2.7.4
> Acked-by: Deepak Kumar Jain <deepak.k.jain@intel.com>

Applied to dpdk-next-crypto.
Thanks,

Pablo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-09-21 18:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 10:04 [PATCH] tools: add crypto device details Eoin Breen
2016-08-25 10:32 ` Mcnamara, John
2016-08-25 13:52 ` [PATCH v2] " Eoin Breen
2016-08-25 20:31   ` Jain, Deepak K
2016-09-13 22:50   ` De Lara Guarch, Pablo
2016-09-15 23:57   ` [PATCH v3] " Pablo de Lara
2016-09-20  0:05     ` [PATCH v4] " Pablo de Lara
2016-09-21 10:04       ` Jain, Deepak K
2016-09-21 18:56         ` De Lara Guarch, Pablo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.