From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BAF97A0561; Thu, 18 Mar 2021 10:31:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5B49140F32; Thu, 18 Mar 2021 10:31:19 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 0D87B140F17 for ; Thu, 18 Mar 2021 10:31:17 +0100 (CET) IronPort-SDR: tBdNwrPQ8KBzaF6jfPoSugoPki+ea5Hw1BwG8GeCs7GG3kjmuL+SKxQ3g5r+3qDQtb2IIrQqVE 8JmD+5hYpJ1w== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189731922" X-IronPort-AV: E=Sophos;i="5.81,258,1610438400"; d="scan'208";a="189731922" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 02:31:17 -0700 IronPort-SDR: nQy7hR1r16I+kLnBl90zGcxOUvEZ5X4KEI7vzL970DlNS0NEvdL9jZtx49EgdfzxwqER/9h+9m GWjFK85xlR3A== X-IronPort-AV: E=Sophos;i="5.81,258,1610438400"; d="scan'208";a="413013400" Received: from unknown (HELO localhost.localdomain) ([10.240.183.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 02:31:16 -0700 From: Haiyang Zhao To: dts@dpdk.org Cc: lijuan.tu@intel.com, Haiyang Zhao Date: Thu, 18 Mar 2021 17:22:13 +0800 Message-Id: <20210318092215.27270-4-haiyangx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210318092215.27270-1-haiyangx.zhao@intel.com> References: <20210318092215.27270-1-haiyangx.zhao@intel.com> Subject: [dts] [PATCH V2 3/5] nics/net_device: add attribute pkg and get method X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" add attribute pkg to record nic current package and add the related get method. Signed-off-by: Haiyang Zhao --- nics/net_device.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/nics/net_device.py b/nics/net_device.py index bdc9d37d..6a26d1eb 100644 --- a/nics/net_device.py +++ b/nics/net_device.py @@ -71,6 +71,7 @@ class NetDevice(object): self.intf2_name = None self.get_interface_name() self.socket = self.get_nic_socket() + self.pkg = {} def stop(self): pass @@ -118,6 +119,27 @@ class NetDevice(object): """ return self.crb.get_pci_dev_driver(self.domain_id, self.bus_id, self.devfun_id) + def get_nic_pkg(self): + """ + Get the NIC pkg. + """ + out = self.__send_expect('dmesg | grep "DDP package" | tail -1', '# ') + if 'could not load' in out: + print(RED(out)) + print(RED('Warning: The loaded DDP package version may not as you expected')) + try: + pkg_info = out.split('. ')[1].lower() + self.pkg['type'] = re.findall(".*package '(.*)'", pkg_info)[0].strip() + self.pkg['version'] = re.findall("version(.*)", pkg_info)[0].strip() + except: + print(RED('Warning: get pkg info failed')) + else: + pkg_info = out.split(': ')[-1].lower().split('package version') + if len(pkg_info) > 1: + self.pkg['type'] = pkg_info[0].strip() + self.pkg['version'] = pkg_info[1].strip() + return self.pkg + def get_nic_socket(self): """ Get socket id of specified pci device. @@ -428,7 +450,6 @@ class NetDevice(object): self.__send_expect("ifconfig %s down" % intf, "# ") self.__send_expect("ifconfig %s up" % intf, "# ") - @nic_has_driver def disable_ipv6(self): """ -- 2.17.1