From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0074.outbound.protection.outlook.com [104.47.41.74]) by dpdk.org (Postfix) with ESMTP id 55FB42C50 for ; Wed, 26 Apr 2017 11:26:17 +0200 (CEST) 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=eSbRDzo1PwLi+NvK3JSDyYY4vF5NTGaTrcZZxbnL+TI=; b=f7+ULqW6M/cbzYzkZOMMnh08r5kP+GvCC3FV0bDGCRGEZnuSOj5kQ82f58CdNilTEUw1f+PKkwVfJsBigcS7c7lmvtNRinIrYMuawDE3LCurKSPD7Ev9Uy4UT8fMrdK5DL7cIIZv5Vget2/9rZwczDyC4lfdpck5PvEEjTO+MYA= Received: from BY2PR0701MB2101.namprd07.prod.outlook.com (10.163.156.154) by BY2PR0701MB2101.namprd07.prod.outlook.com (10.163.156.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Wed, 26 Apr 2017 09:26:14 +0000 Received: from BY2PR0701MB2101.namprd07.prod.outlook.com ([10.163.156.154]) by BY2PR0701MB2101.namprd07.prod.outlook.com ([10.163.156.154]) with mapi id 15.01.1047.019; Wed, 26 Apr 2017 09:26:14 +0000 From: "Prathyusha, Guduri" To: "Tu, LijuanX A" CC: "dev@dpdk.org" , "Chen, WeichunX" , "Liu, Yu Y" , "Xu, Qian Q" , "Liu, Yong" , "Lu, PeipeiX" Thread-Topic: dpdk-devbind can't be used misc with kernel tools Thread-Index: AdK+VR5nRmMI8Le0RKq3YEicQoOMyQAGUTNG Date: Wed, 26 Apr 2017 09:26:14 +0000 Message-ID: References: <38D041F150D4184C8114E499040E62343DBC1438@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <38D041F150D4184C8114E499040E62343DBC1438@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=cavium.com; x-originating-ip: [132.245.59.53] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY2PR0701MB2101; 7:Srb6AGm+4iMIjQwvDfgqSEJKSUDal5D+noeUcfGP4fzB0zVtzsL12lkFw/S9kYPn+vMIdhV3RypaRzCbnYbyTl/hvNVA7mr8jkjJhzR5QPM/dQl5Un0qlsAtCcstAF4CBX6w3SoU4I9bhCJ8u4GgZ36KNLAdB5umbuqJGymhmwhLd0hXnxqAZ3PlsXLDSDzHRmwspf+KzoimWgkcGPTqFPYIj3ZaYXSVYLFw+wErqBlmpd+vndhJGlSnQ5xTziRoc/rPxnw+HhWFrxq0pwdklW+trqgy73/KEU4pDAcwi5qslN02J9BDIU0xIJMZMVKm39xHjmCCeNmVWaM7m8wuSw== x-ms-office365-filtering-correlation-id: c0ac371a-21fa-445d-257a-08d48c864941 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BY2PR0701MB2101; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148); SRVR:BY2PR0701MB2101; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0701MB2101; x-forefront-prvs: 0289B6431E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39850400002)(39410400002)(39840400002)(39450400003)(45984002)(377454003)(2900100001)(53546009)(53936002)(25786009)(38730400002)(2906002)(54906002)(4326008)(110136004)(102836003)(33656002)(3280700002)(3846002)(6116002)(5660300001)(6246003)(8936002)(229853002)(86362001)(122556002)(76176999)(3660700001)(8676002)(7736002)(50986999)(54356999)(81166006)(189998001)(305945005)(9686003)(74316002)(6916009)(2950100002)(6506006)(99286003)(77096006)(55016002)(7696004)(6436002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB2101; H:BY2PR0701MB2101.namprd07.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2017 09:26:14.6403 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB2101 Subject: Re: [dpdk-dev] dpdk-devbind can't be used misc with kernel tools 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, 26 Apr 2017 09:26:17 -0000 Hi LijuanX A Response inline... Kindly apply the patch below (inline) and let me know the result. I will su= bmit a formal patch once you confirm. Thanks, Prathyusha From: Tu, LijuanX A Sent: Wednesday, April 26, 2017 11:49 AM To: Prathyusha, Guduri Cc: dev@dpdk.org; Chen, WeichunX; Liu, Yu Y; Xu, Qian Q; Liu, Yong; Lu, Pei= peiX Subject: dpdk-devbind can't be used misc with kernel tools =A0=20 Hi Guduri, =A0 I am a tester from intel dpdk team. I get a issues on usertools/dpdk-devbin= d.py =A0 With the usertools/dpdk-devbind.py , I can=92t bind driver as expect. =A0 I use the =93dpdk-devbind.py=94 bind pci to igb_uio, then I using kernel to= ols=A0 bind pci =A0to ixgbe, I can bind pci to igb_uio successfully ,but it =A0bind back to ixgbe failed= .. /sys/bus/pci/devices/xxxxxx/driver_override is used to bind and unbind devi= ces to drivers in kernels >=3D 3.15 driver_override must be written to null for a device to bind to a driver. I= n the current script, null is written before unbinding a device. Hence when you bind a device using script and unbind using kernel tools (/s= ys/bus/pci/drivers/xx/new_id, >>/sys/bus/pci/devices/xx/driver/unbind, /sys= /bus/pci/drivers/xx/bind), driver_override is still set to the previous dri= ver. To avoid this, writing null to driver_override after binding a device to a = driver. This will let the kernel tools unbind after binding using the dpdk = script. =A0 Bind pci to igb_uio and then =A0bind to ixgbe ,both use =93dpdk-devbind.py= =94, it works well. =A0 Could you . have a look at this as soon as possible ,it block the daily reg= ression test. Thank you very much. Here is the patch to be applied=20 diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py = =20 index bb4d536e0..1dc1065b1 100755 = =20 --- a/usertools/dpdk-devbind.py = =20 +++ b/usertools/dpdk-devbind.py = =20 @@ -386,25 +386,6 @@ def unbind_one(dev_id, force): = =20 "Skipping unbind" % (dev_id)) = =20 return = =20 = =20 - # For kernels > 3.15 driver_override is used to bind a device to a dri= ver.=20 - # Before unbinding it, overwrite driver_override with empty string so = that=20 - # the device can be bound to any other driver = =20 - filename =3D "/sys/bus/pci/devices/%s/driver_override" % dev_id = =20 - if os.path.exists(filename): = =20 - try: = =20 - f =3D open(filename, "w") = =20 - except: = =20 - print("Error: unbind failed for %s - Cannot open %s" = =20 - % (dev_id, filename)) = =20 - sys.exit(1) = =20 - try: = =20 - f.write("\00") = =20 - f.close() = =20 - except: = =20 - print("Error: unbind failed for %s - Cannot open %s" = =20 - % (dev_id, filename)) = =20 - sys.exit(1) = =20 - = =20 # write to /sys to unbind = =20 filename =3D "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"] = =20 try: = =20 @@ -507,6 +488,25 @@ def bind_one(dev_id, driver, force): = =20 bind_one(dev_id, saved_driver, force) = =20 return = =20 = =20 + # For kernels > 3.15 driver_override is used to bind a device to a dri= ver.=20 + # Before unbinding it, overwrite driver_override with empty string so = that=20 + # the device can be bound to any other driver = =20 + filename =3D "/sys/bus/pci/devices/%s/driver_override" % dev_id = =20 + if os.path.exists(filename): = =20 + try: = =20 + f =3D open(filename, "w") = =20 + except: = =20 + print("Error: unbind failed for %s - Cannot open %s" = =20 + % (dev_id, filename)) = =20 + sys.exit(1) = =20 + try: = =20 + f.write("\00") = =20 + f.close() = =20 + except: = =20 + print("Error: unbind failed for %s - Cannot open %s" = =20 + % (dev_id, filename)) = =20 + sys.exit(1) = =20 + = =20 = =20 def unbind_all(dev_list, force=3DFalse): =20 """Unbind method, takes a list of device locations""" =A0 =A0 There are my test env and steps:=20 =A0 dpdk commit eba33e87ad37626604be7186e746751f99691084 Components: usertools/dpdk-devbind.py kernel: 4.8.6-300.fc25.x86_64 driver: ixgbe version: 5.0.4 firmware-version: 0x61bf0001 Expect: we can use dpdk-devbind.py to bind or unbind PCI-device, we also ca= n use kernel tools to bind or unbind PCI-device, such as : steps: # ./dpdk-devbind.py --bind=3Digb_uio 0000:05:00.0 status: 0000:05:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection 10fb' drv=3Dig= b_uio unused=3D =A0 # echo "8086 10fd" >/sys/bus/pci/drivers/ixgbe/new_id # echo "0000:05:00.0" >/sys/bus/pci/devices/0000\:05\:00.0/driver/unbind # echo "0000:05:00.0" >/sys/bus/pci/drivers/ixgbe/ # echo "0000:05:00.0" >/sys/bus/pci/drivers/ixgbe/bind -bash: echo: write error: No such device status 0000:05:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' unused=3Dixgb= e,igb_uio Result: It can't bind to ixgbe, expect it can bind to ixgbe. I think the related commit are :: commit 2fc3502935700243d9a6d903166e6fd11e429843 Author: Guduri Prathyusha Date:=A0=A0 Wed Mar 22 19:41:29 2017 +0530 usertools: use optimized driver override scheme to bind =A0 commit c3ce205d5729867bd1c4c4429a80e01a528d5905 Author: Guduri Prathyusha Date:=A0=A0 Wed Mar 22 19:41:28 2017 +0530 =A0=A0=A0 usertools: optimize lspci invocation =A0 =