From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (unknown [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D1D2F6A80 for ; Tue, 27 Oct 2015 07:08:14 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from root@r-aa-dragon7.rdmz.labs.mlnx) with ESMTPS (AES256-SHA encrypted); 27 Oct 2015 08:08:00 +0200 Received: from r-aa-dragon7.rdmz.labs.mlnx (r-aa-dragon7.rdmz.labs.mlnx [10.224.14.90]) by filer01.rdmz.labs.mlnx (8.13.8/8.13.8) with ESMTP id t9R680ks010152; Tue, 27 Oct 2015 08:08:00 +0200 Received: from r-aa-dragon7.rdmz.labs.mlnx (localhost [127.0.0.1]) by r-aa-dragon7.rdmz.labs.mlnx (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id t9R680xN031891; Tue, 27 Oct 2015 08:08:00 +0200 Received: (from root@localhost) by r-aa-dragon7.rdmz.labs.mlnx (8.14.4/8.14.4/Submit) id t9R6802T031890; Tue, 27 Oct 2015 08:08:00 +0200 From: Raslan Darawsheh To: dts@dpdk.org Date: Tue, 27 Oct 2015 08:07:54 +0200 Message-Id: <1445926076-31279-5-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445926076-31279-1-git-send-email-rasland@mellanox.com> References: <1445926076-31279-1-git-send-email-rasland@mellanox.com> Cc: rdarawsheh@asaltech.com Subject: [dts] [PATCH 5/6] framework:net_device : adding function get_interface_name_Mellanox to get the ConnectX_3_Pro interfaces X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2015 06:08:15 -0000 From: Raslsn Darawsheh Signed-off-by: Raslsn Darawsheh --- framework/net_device.py | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/framework/net_device.py b/framework/net_device.py index 37495bd..ac121cc 100644 --- a/framework/net_device.py +++ b/framework/net_device.py @@ -127,17 +127,42 @@ class NetDevice(object): Get interface name of specified pci device. Cal this function will update intf_name everytime """ - get_interface_name = getattr( - self, 'get_interface_name_%s' % - self.__get_os_type()) - out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver) - if "No such file or directory" in out: - self.intf_name = 'N/A' + if self.crb.isMellanox and self.crb.mellanoxCardType == "cx3": + self.intf_name = self.get_interface_name_Mellanox(self.bus_id,self.devfun_id) else: - self.intf_name = out + get_interface_name = getattr( + self, 'get_interface_name_%s' % + self.__get_os_type()) + out = get_interface_name(self.bus_id, self.devfun_id, self.current_driver) + if "No such file or directory" in out: + self.intf_name = 'N/A' + else: + self.intf_name = out return self.intf_name + def get_interface_name_Mellanox(self,bus_id,devfun_id): + """ + Get interface name of specified pci device for Mellanox. + """ + command = 'ls --color=never /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id) + out = self.crb.send_expect(command, '# ', verify=True) + + if out == -1: + name = "" + else: + if self.crb.mellanoxPortCount == 0 : + name = out.split()[0] + self.crb.mellanoxPortCount = 1 + else : + if len(out.split()) < 2 : + self.crb.isMellanox = False + name = out.split()[0] + return name + name = out.split()[1] + self.crb.mellanoxPortCount = 0 + return name + def get_interface_name_linux(self, bus_id, devfun_id, driver): """ Get interface name of specified pci device on linux. -- 1.8.3.1