From patchwork Thu Sep 15 23:57:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 15844 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id AEE4B567F; Fri, 16 Sep 2016 01:56:33 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id B8305532E for ; Fri, 16 Sep 2016 01:56:31 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 15 Sep 2016 16:56:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,341,1470726000"; d="scan'208";a="9266967" Received: from sie-lab-214-036.ir.intel.com (HELO silpixa00394365.ir.intel.com) ([10.237.214.36]) by fmsmga006.fm.intel.com with ESMTP; 15 Sep 2016 16:56:29 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: deepak.k.jain@intel.com, Eoin Breen , Pablo de Lara Date: Fri, 16 Sep 2016 00:57:06 +0100 Message-Id: <1473983826-28291-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472133122-77377-1-git-send-email-eoin.breen@intel.com> References: <1472133122-77377-1-git-send-email-eoin.breen@intel.com> Subject: [dpdk-dev] [PATCH v3] tools: add crypto device details X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: 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 Signed-off-by: Pablo de Lara --- 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__":