From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 2DCAE58E4 for ; Tue, 24 Mar 2015 02:07:38 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 23 Mar 2015 18:07:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,455,1422950400"; d="scan'208";a="669552967" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by orsmga001.jf.intel.com with ESMTP; 23 Mar 2015 18:07:36 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 24 Mar 2015 09:07:34 +0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.149]) by shsmsx102.ccr.corp.intel.com ([169.254.2.198]) with mapi id 14.03.0224.002; Tue, 24 Mar 2015 09:07:33 +0800 From: "Zhang, Helin" To: Thomas Monjalon , "Liu, Yong" Thread-Topic: [dpdk-dev] [PATCH] scripts: enable extended tag of PCIe Thread-Index: AQHQZV/7iSxi/8yIgUSoVN75yH23SJ0q0hnw Date: Tue, 24 Mar 2015 01:07:32 +0000 Message-ID: References: <1422593822-15531-1-git-send-email-zhida.zang@intel.com> <3200414.B2YSnFKgSE@xps13> In-Reply-To: <3200414.B2YSnFKgSE@xps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] scripts: enable extended tag of PCIe 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: , X-List-Received-Date: Tue, 24 Mar 2015 01:07:38 -0000 Hi Thomas Zhida is our intern who has already been back to university. I think Yong m= ight have reviewed it. It is good supplementation for setting extended tag on Linux, though not ne= cessary. I am OK to have it merged or not. Thanks! Marvin, could you help to ack it, as I know you have reviewed it? Regards, Helin > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Monday, March 23, 2015 7:53 PM > To: Zang, Zhida > Cc: dev@dpdk.org; Butler, Siobhan A; Zhang, Helin > Subject: Re: [dpdk-dev] [PATCH] scripts: enable extended tag of PCIe >=20 > Hi, >=20 > This patch needs review and documentation. > It's going to be dropped if nobody cares. >=20 > There were some previous discussions about it: > http://dpdk.org/ml/archives/dev/2015-February/012708.html >=20 >=20 > 2015-01-30 12:57, zhida zang: > > As 'extended tag' of PCIe needs to be enabled for i40e high > > performance, Linux command of 'setpci' can be used to check and set > > the corresponding bit of 'extended tag' of PCIe configuration space. > > The script is to check and set the right bit in PCIe configuration spac= e to > enable 'extended tag'. > > > > Signed-off-by: Zhida Zang > > --- > > tools/set_pci.py | 124 > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 124 insertions(+) > > create mode 100755 tools/set_pci.py > > > > diff --git a/tools/set_pci.py b/tools/set_pci.py new file mode 100755 > > index 0000000..e242efb > > --- /dev/null > > +++ b/tools/set_pci.py > > @@ -0,0 +1,124 @@ > > +#! /usr/bin/python > > +import sys > > +import os > > +import subprocess > > +import getopt > > +from os.path import basename > > + > > +# The register to check if extended tag is supported or not. > > +PCI_DEV_CAP_REG =3D 0xA4 > > +# The control register which contains the bit to enable/disable 'exten= ded > tag'. > > +PCI_DEV_CTRL_REG =3D 0xA8 > > +# The mask of 'extended tag' in capability register. > > +PCI_DEV_CAP_EXT_TAG_MASK =3D 0x20 > > +# The mask of 'extended tag' in control register. > > +PCI_DEV_CTRL_EXT_TAG_MASK =3D 0x100 > > + > > +dev_ids =3D {} > > +flag =3D "Set" > > + > > + > > +def usage(): > > + '''Print usage information for the program''' > > + argv0 =3D basename(sys.argv[0]) > > + print """ > > +Usage: > > +------ > > + > > + %(argv0)s [options] DEVICE1 DEVICE2 .... > > + > > +where DEVICE1, DEVICE2 etc, are specified via PCI > > +"domain:bus:slot.func" syntax or "bus:slot.func" syntax. For devices > > +bound to Linux kernel drivers, they may also be referred to by Linux i= nterface > name e.g. eth0, eth1, em0, em1, etc. > > + > > +Options: > > + --help, --usage: > > + Display usage information and quit > > + > > + -s --set: > > + Set the following pci device > > + > > + -u --Unset: > > + Unset the following pci device > > + > > +Examples: > > +--------- > > +To set pci 0a:00.0 > > + %(argv0)s -s 0a:00.0 > > + %(argv0)s --set 0a:00.0 > > + > > +To unset 0000:01:00.0 > > + %(argv0)s -u 0000:01:00.0 > > + %(argv0)s --unset 0000:01:00.0 > > + > > +To set 0000:02:00.0 and 0000:02:00.1 > > + %(argv0)s -s 02:00.0 02:00.1 > > + > > + """ % locals() # replace items from local variables > > + > > + > > +def parse_args(): > > + global flag > > + global dev_ids > > + if len(sys.argv) <=3D 1: > > + usage() > > + sys.exit(0) > > + try: > > + opts, dev_ids =3D getopt.getopt( > > + sys.argv[1:], > > + "su", > > + ["help", "usage", "set", "unset"] > > + ) > > + except getopt.GetoptError, error: > > + print str(error) > > + print "Run '%s --usage' for further information" % sys.argv[0] > > + sys.exit(1) > > + > > + for opt, arg in opts: > > + if opt =3D=3D "--help" or opt =3D=3D "--usage": > > + usage() > > + sys.exit(0) > > + if opt =3D=3D "-s" or opt =3D=3D "--set": > > + flag =3D "Set" > > + if opt =3D=3D "-u" or opt =3D=3D "--unset": > > + flag =3D "Unset" > > + > > + > > +def check_output(args, stderr=3DNone): > > + '''Run a command and capture its output''' > > + return subprocess.Popen( > > + args, > > + stdout=3Dsubprocess.PIPE, > > + stderr=3Dstderr > > + ).communicate()[0] > > + > > + > > +def set_pci(): > > + if len(dev_ids) =3D=3D 0: > > + print "Error: No devices specified." > > + print "Run '%s --usage' for further information" % sys.argv[0] > > + sys.exit(1) > > + param_cap =3D "%x.W" % PCI_DEV_CAP_REG > > + for k in range(len(dev_ids)): > > + val =3D check_output(["setpci", "-s", dev_ids[k], param_cap]) > > + if (not (int(val, 16) & PCI_DEV_CAP_EXT_TAG_MASK)): > > + print dev_ids[k], "Not supported" > > + continue > > + if (int(val, 16) & PCI_DEV_CTRL_EXT_TAG_MASK): > > + continue > > + param_ctrl =3D "%x.W" % PCI_DEV_CTRL_REG > > + val =3D check_output(["setpci", "-s", dev_ids[k], param_ctrl]) > > + if flag =3D=3D "Set": > > + val =3D int(val, 16) | PCI_DEV_CTRL_EXT_TAG_MASK > > + else: > > + val =3D int(val, 16) & ~PCI_DEV_CTRL_EXT_TAG_MASK > > + param_ctrl =3D "%x.W=3D%x" % (PCI_DEV_CTRL_REG, val) > > + check_output(["setpci", "-s", dev_ids[k], param_ctrl]) > > + > > + > > +def main(): > > + parse_args() > > + set_pci() > > + > > +if __name__ =3D=3D "__main__": > > + main() > > >=20