From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0075.outbound.protection.outlook.com [104.47.36.75]) by dpdk.org (Postfix) with ESMTP id 3FF92CF68 for ; Wed, 22 Mar 2017 15:12:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tgtKKUcVe0xzOEQxwQQsrXhI70ie/VJj6ku5wVA2QwQ=; b=CDYd3PTccKEAE/HUx8x550djOFppXwp0QDgKRNHW8Be2Uj8Uw0rkaocNHxGb3eIoSTMVRdadGq0bH0XIitDa2qqwM/lEpo4YNEb1uA/N/sp/Aln1iiZuNQPlV/Tq2uT+tYMZsUAw45JWGmNAMYhsIoVWxswotHS9/gQUUkXd4jc= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BLUPR0701MB1714.namprd07.prod.outlook.com (10.163.85.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Wed, 22 Mar 2017 14:12:13 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, ferruh.yigit@intel.com, gprathyusha@caviumnetworks.com, Jerin Jacob Date: Wed, 22 Mar 2017 19:41:30 +0530 Message-Id: <1490191892-10396-6-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1490191892-10396-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1490191892-10396-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0061.INDPRD01.PROD.OUTLOOK.COM (10.164.146.161) To BLUPR0701MB1714.namprd07.prod.outlook.com (10.163.85.140) X-MS-Office365-Filtering-Correlation-Id: b75f42da-16d9-46d7-1efe-08d4712d72b7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 3:qCYtCNOu2Nv9RTh5xRTRo+PU3M7vyAUh32JwndT5ZZJpBcif7LPzIkw7Cxxy36DUa4nHsGVhwwBLyw8CRaO+5f2wrwK8btB+y/EIDYn/8UkxgBuL2z+norNjAgKCbjZLocONqnjxoL6XhtAzpts/msuNkgtKrCWkSDTvuAhJX5TOBIO1U0bCk18bvSlaw1Q/W8Zw9GkkWKMli6Vq//GA3E9O/pTfTWYKdVXchht7AdOC3H4zdyOXYoFt2FN+zo4HBNyhXfXj20yaZYk7uc6cBA==; 25:gaJVmYpqVBYDoiEkXXyBQchCw2/OXtjF92xUeusjo5b1yhFCY0aJ6a3GT/qUSNPQZwzrL1clzX8PPHzth/PM4w2cLoSPjkmtEYr5bh+6+IUBeVy4KxHLdWlC0jpx0sTwxQEhHwHHq1qvVWaN8849HM7/OsrNVpjU0H6yXtYrB6cZCGQ5JhvWgIo0cUAJ8BzS/RBMh8vRHM7s3pUx4N9SRpk7VlAPTvJvkmDwr8LJfF56YKhYd/1aICVs1rVWr9bZ8RItL3Qteb4h/+5Uabl1eYX4hSRVjwXEQ9EBka9vWZQwprhVA+LzcDTjwhLxMOnRl6KVVkXzsJhInh8He43DNLGjUk2UfkOdTQDpF38+Pn0FupWPnFKMKq7BZIzorn7iL70OcHpWvdPmgoLfBmYlDWL18J+NwMeQvvJR+XivG7gznFDjknT6V0MzokO3ceCO2g/EX5ztNEuj7J3wCs3WOA== X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 31:bxxyjIGHsGNLBNG7c2zpZRAEPMi6ExtUKoczIDYVrpgu46xTvEMaXONA5r7/ebOQxhdAYu7MG3Gl5WM/5XBaeGpuOxTpkPVYVi3ebzwe3d9k6jsPI60dtZ7MVyjh30PyVu4c9fXxwty210/d7ODMwOT0z5aRgZqqdo3oFlfY8lLAMyxwDcX3D3iJvvqDDz7WdFGhCdOQGDb4Gch/JSXmqKVTI4uVroz+uFdU71sGFB/IgulBD2UaBsizKC9cfVZi; 20:FRHllmu4Dj1E71/XBRYL660HzNnWih/k/7U1nD9KTJ/RCC8ESmzLSuRt98kWGD1GweMwqXZJEIRAtmZIhLbpL+pkS9c+aECUMFHxmkTO0Y0ZjWhIWupGQ+K1kGxDtAeG0536AsmADRYSjbgEJNqrwoL4pLcphkfdJ3oyVvnqRrt+NheJMIWZhFWyU9/BHTjnJQel4dr8x+LPnZa3iugthKegzAeIOwT5rwhlA1aFxe21mD+lA2HCWxT2MHPRzfP8g9MGxovY3eoUC1mbdCr+o9vEBvLNbPFHxH0NQBsbKndAA7NjYQAG2rBNXj7g+fo1NFy8Az2LEXLAgJd4Xw/GC5J4UQbUMi57zMHjThRBL1GZwiUWYfzyFSGI932A50no595IXDjD+qmiZprrAiS2K8nM3yXjOQTxWppTJGtV9wCdUtxMOaa+TatBxH9bkUaESNYMY/zK4HLZySIftRzerv2r5y98lBGtiQd4R/TRtuF5DyCiHPJIGVUddAe+fK7CICGvNb6z1xbaf3ZMJSsnP1U6XCDEQxditpU7NsnE7mNeWacAJ9SlhKmLJvnMFw/IQbicpI+S5oSa6gDB367vX04Hya/R7LbAwAVlmuyQHZo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123555025)(20161123558025)(20161123560025)(20161123562025)(6072148); SRVR:BLUPR0701MB1714; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 4:2xVe93EE9dBjxOWdUIb0nOaHgG7PK7XZu1QAbudi5pfzhwPdj5smgazdsETycq9SCMZAdX27gwe2wGyt1zCRiQ2wTwLv/daEGRQk5hZJYp9pQ2Htxat2+Zu1E3bhlsl43Pmpm3WpwcmVK1PnjyCrNc1z7RIRJMIBkEzQBmL7gMwdDMoJPTKAoeM/ToTAzeVZnPAgS91JTwSQ+/zWassSKtixrw1AXDDUicZdGkCfKvRYgLzDUOp543dR1/7e9N++DSKIa+dUHMlLLAtXTexDzPS5IJwNPVmcVionrgx+06jMEmhruM3+glzDUok3IKfQw52CTxFcopIZtZoCUxPZVsDsTtuQKE4R8XAfeFvEAHLCZLzrpmhDpWxtBW5HlH7qaELhUCHsqQN470qyVAAmL27Lx7JP69H6J6H+8LF4TL6ZTlK0+k1jGqkQ6LoOORySYTEJkX33UnF1/8zrTn49S/MF75JrSSPKOKpSou3Zq5/mZ5MO+LWysrl1CEjbRL8Wa84VpQB0119orCw9PW17PbpFtbwDrzsgyahSXjO1uu+rAqS8Ky2UxVhJ9LWO25pl9A/j6FQBw3gPtDdHZ4TZYpJ/H072PAA0Yn3ad84GMg/VVqoKmOCtLS0bemtOIA0iwN2uAIQocunPsfoAeTBVDw== X-Forefront-PRVS: 02543CD7CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(6486002)(53936002)(4326008)(6506006)(50466002)(48376002)(189998001)(36756003)(25786009)(6512007)(33646002)(53416004)(2906002)(6666003)(2950100002)(42882006)(47776003)(66066001)(6916009)(76506005)(42186005)(38730400002)(107886003)(110136004)(5660300001)(5009440100003)(50226002)(305945005)(575784001)(7736002)(2361001)(3846002)(6116002)(81166006)(2351001)(8676002)(50986999)(76176999)(5003940100001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1714; H:localhost.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1714; 23:g/WZuZ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YmEhaIFzW2+ShF170rfPeU8sMz2rxx0TPaGnFtkWn2ONB2kroKuB?= =?us-ascii?Q?dV7QPJ9gi72mpbmiv6fx7pw9P/IzP2L7rWzD1mQlg19qxMhgV3mTR/yuO7in?= =?us-ascii?Q?RKirQJpS/aXlkbWenX3J2RTkqTqe02McJjOW2JpOB4KJe7Lbt/rEmeuOnr8b?= =?us-ascii?Q?Ebv0DT09g20mzB3BRkHAGDFXD8WDJ?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 6:Dluohjh4020EObAmPDr6pC6DE9t9LWlKA5OmtK0vhCoFaP8Rw7mTWa+j3ol7kKbp2FmHo/jCTHbMWDatCvvJixOgtTLpIbw6CSmkaGIwdWz3DHMMob93Hc412ga50A29718i/VYvmTBWGKhxJYyR6KTIc9vPh6N9+hH22Emna8tII13hSgzqosmxBU5t7UOht0nnN/xj1oB05cWZCkAzocpfST1XOeD9lDZbGfe3TwfigMPu828FibhWmc96HN19vqdJ3hugCctHNgJCJ0FxWix0NphhDxuPUE1nC48qYVR+9CIUwsiIDXbShkfvuAiDcUmKZPxB2vje3+Br4mb7UHUQ/aZM8FCbkMkz0Kx0dOQ5ENbGcBP+A+vhdl7Pw/APqdIv8PnJTBx9inFzeh0aWw==; 5:CU8B+Cf2ne3gnFbsaG3h4tQXBqSt19gzv5yB40G39x60MtrNpGumiv9UoAP2G3Ni3TwyrgDRtbs7LP5+tKvKjCJm+55F8SKxl9z5KRSJn+XJOP/Ce2Ywdd87GU9LDSD+aFdV3hfQrowGF+X3lzVDpg==; 24:55AheTb3/6NtpyPTumH1Wj76slUpw+nIrRIy+lKL5jycpwgS9nVmyZHT6Qi5O+rrxQFEy/v5O4mj7b+63XQPMCfE8a2b3zeX93AXozDvt+U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 7:FDeKL5z83PfISaMZ2iE1gK3LP49WiWvqLWM4+7LSGFFe/0iUxY/bshxEyihq5ZTovCjTPs4NqsqFoUck56EvxMVxpcVtIzF/UmxYRHJKeAz37oCe/McXWi6i/SFTECRK4tkDwEJSIxcbGF4q0ViCn1nvi5LN6lejuOkB9uDckhIbZR4wsduV+sTpgKlfaZmS8Bi9QYwb5qSbpdSsoBMytOqA2PLq+lkIv+ejAMd8xJgjzgK2IxQNGYhKqUSiU92+LV6sOH/yjbL0nbYmOGk/yd45CUrOPDdISjLhL9dQJCDyrVSAD2Qn70ruG1uqhgJutZUFx/r9RErD0Vpv4Pf8ew== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 14:12:13.0389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1714 Subject: [dpdk-dev] [PATCH 5/7] usertools: define DPDK PCI functional device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 14:12:20 -0000 From: Guduri Prathyusha This patch creates the framework to define the DPDK PCI functional device by specifying the pci attributes like Vendor ID, Device ID, Sub Vendor ID, Sub Device ID and Class.This enables a flexible way to add DPDK function devices based on PCI attributes. Crypto devices can belong to Encryption class(0x10) or Processor class(0x0b) based on the vendor preference. Using this framework, The above disparity can be encoded in the following format encryption_class = [{'Class': '10', 'Vendor': None, 'Device': None, 'SVendor': None, 'SDevice': None}] intel_processor_class = [{'Class': '0b', 'Vendor': '8086', 'Device': None, 'SVendor': None, 'SDevice': None}] crypto_devices = [encryption_class, intel_processor_class] Signed-off-by: Guduri Prathyusha Signed-off-by: Jerin Jacob --- usertools/dpdk-devbind.py | 67 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py index 4dc6a66..4ea0adf 100755 --- a/usertools/dpdk-devbind.py +++ b/usertools/dpdk-devbind.py @@ -38,9 +38,16 @@ import subprocess from os.path import exists, abspath, dirname, basename -# The PCI base class for NETWORK devices -NETWORK_BASE_CLASS = "02" -CRYPTO_BASE_CLASS = "0b" +# The PCI base class for all devices +network_class = {'Class': '02', 'Vendor': None, 'Device': None, + 'SVendor': None, 'SDevice': None} +encryption_class = {'Class': '10', 'Vendor': None, 'Device': None, + 'SVendor': None, 'SDevice': None} +intel_processor_class = {'Class': '0b', 'Vendor': '8086', 'Device': None, + 'SVendor': None, 'SDevice': None} + +network_devices = [network_class] +crypto_devices = [encryption_class, intel_processor_class] # global dict ethernet devices present. Dictionary indexed by PCI address. # Each device within this is itself a dictionary of device properties @@ -252,10 +259,9 @@ def get_device_details(devices_type): dev_lines = check_output(["lspci", "-Dvmmnnk"]).splitlines() for dev_line in dev_lines: if len(dev_line) == 0: - if dev["Class"][0:2] == devices_type: - # convert device and vendor ids to numbers, then add to global - dev["Vendor"] = int(dev["Vendor"], 16) - dev["Device"] = int(dev["Device"], 16) + if device_type_match(dev, devices_type): + # Replace "Driver" with "Driver_str" to have consistency of + # of dictionary key names if "Driver" in dev.keys(): dev["Driver_str"] = dev.pop("Driver") # use dict to make copy of dev @@ -272,7 +278,7 @@ def get_device_details(devices_type): dev[name.rstrip(":")] = value_list[len(value_list) - 1] \ .rstrip("]").lstrip("[") - if devices_type == NETWORK_BASE_CLASS: + if devices_type == network_devices: # check what is the interface if any for an ssh connection if # any to this host, so we can mark it later. ssh_if = [] @@ -287,7 +293,7 @@ def get_device_details(devices_type): # based on the basic info, get extended text details for d in devices.keys(): - if devices[d]["Class"][0:2] != devices_type: + if not device_type_match(devices[d], devices_type): continue # get additional info and add it to existing data @@ -295,7 +301,7 @@ def get_device_details(devices_type): # No need to probe lspci devices[d].update(get_pci_device_details(d, False).items()) - if devices_type == NETWORK_BASE_CLASS: + if devices_type == network_devices: for _if in ssh_if: if _if in devices[d]["Interface"].split(","): devices[d]["Ssh_if"] = True @@ -319,6 +325,25 @@ def get_device_details(devices_type): devices[d]["Module_str"] = ",".join(modules) +def device_type_match(dev, devices_type): + for i in range(len(devices_type)): + param_count = len( + [x for x in devices_type[i].values() if x is not None]) + match_count = 0 + if dev["Class"][0:2] == devices_type[i]["Class"]: + match_count = match_count + 1 + for key in devices_type[i].keys(): + if key != 'Class' and devices_type[i][key]: + value_list = devices_type[i][key].split(',') + for value in value_list: + if value.strip(' ') == dev[key]: + match_count = match_count + 1 + # count must be the number of non None parameters to match + if match_count == param_count: + return True + else: + return False + 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 @@ -441,7 +466,9 @@ def bind_one(dev_id, driver, force): % (dev_id, filename)) return try: - f.write("%04x %04x" % (dev["Vendor"], dev["Device"])) + # Convert Device and Vendor Id to int to write to new_id + f.write("%04x %04x" % (int(dev["Vendor"],16), + int(dev["Device"], 16))) f.close() except: print("Error: bind failed for %s - Cannot write new PCI ID to " @@ -542,7 +569,7 @@ def show_device_status(devices_type, device_name): # split our list of network devices into the three categories above for d in devices.keys(): - if devices_type in devices[d]["Class"]: + if device_type_match(devices[d], devices_type): if not has_driver(d): no_drv.append(devices[d]) continue @@ -552,12 +579,13 @@ def show_device_status(devices_type, device_name): kernel_drv.append(devices[d]) # print each category separately, so we can clearly see what's used by DPDK - display_devices("%s devices using DPDK-compatible driver" % device_name, dpdk_drv, - "drv=%(Driver_str)s unused=%(Module_str)s") + display_devices("%s devices using DPDK-compatible driver" % device_name, + dpdk_drv, "drv=%(Driver_str)s unused=%(Module_str)s") display_devices("%s devices using kernel driver" % device_name, kernel_drv, "if=%(Interface)s drv=%(Driver_str)s " "unused=%(Module_str)s %(Active)s") - display_devices("Other %s devices" % device_name, no_drv, "unused=%(Module_str)s") + display_devices("Other %s devices" % device_name, no_drv, + "unused=%(Module_str)s") def show_status(): '''Function called when the script is passed the "--status" option. @@ -630,8 +658,9 @@ def do_arg_actions(): if status_flag: if b_flag is not None: clear_data() - get_device_details(NETWORK_BASE_CLASS) # refresh if we have changed anything - get_device_details(CRYPTO_BASE_CLASS) # refresh if we have changed anything + # refresh if we have changed anything + get_device_details(network_devices) + get_device_details(crypto_devices) show_status() @@ -640,8 +669,8 @@ def main(): parse_args() check_modules() clear_data() - get_device_details(NETWORK_BASE_CLASS) - get_device_details(CRYPTO_BASE_CLASS) + get_device_details(network_devices) + get_device_details(crypto_devices) do_arg_actions() if __name__ == "__main__": -- 2.5.5