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 B1E8EA0548; Mon, 22 Mar 2021 03:55:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C2F3140E8F; Mon, 22 Mar 2021 03:55:29 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 152CE4069C for ; Mon, 22 Mar 2021 03:55:27 +0100 (CET) IronPort-SDR: qrZ903CnGm1R2mWeurCFId6JARetWo4g/gf9ooLzKXpktKQEWPGXbJC/3imm9ByHfn8N0z1Bft 5G5VK2X3dwcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9930"; a="254189564" X-IronPort-AV: E=Sophos;i="5.81,266,1610438400"; d="scan'208";a="254189564" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2021 19:55:27 -0700 IronPort-SDR: uEhInUlG9EubUrw7HvZTA2Njvb06ZQh/M4LXby6rnAqUpNqpjyCF88rpIt7/uOvZsETpg65zxo Sy7sSfnyp6CA== X-IronPort-AV: E=Sophos;i="5.81,266,1610438400"; d="scan'208";a="407623001" Received: from unknown (HELO localhost.localdomain) ([10.240.183.57]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2021 19:55:26 -0700 From: Haiyang Zhao To: dts@dpdk.org Cc: lijuan.tu@intel.com, Haiyang Zhao Date: Mon, 22 Mar 2021 10:46:11 +0800 Message-Id: <20210322024616.14499-2-haiyangx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210322024616.14499-1-haiyangx.zhao@intel.com> References: <20210322024616.14499-1-haiyangx.zhao@intel.com> Subject: [dts] [PATCH V1 1/6] nics/net_device: add driver/firmware 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 driver/firmware and the related methods for NetDevice. Signed-off-by: Haiyang Zhao --- nics/net_device.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/nics/net_device.py b/nics/net_device.py index 6a26d1eb..98d31237 100644 --- a/nics/net_device.py +++ b/nics/net_device.py @@ -71,7 +71,9 @@ class NetDevice(object): self.intf2_name = None self.get_interface_name() self.socket = self.get_nic_socket() - self.pkg = {} + self.driver_version = '' + self.firmware = '' + self.pkg = None def stop(self): pass @@ -123,6 +125,7 @@ class NetDevice(object): """ Get the NIC pkg. """ + self.pkg = {'type': '', 'version': ''} out = self.__send_expect('dmesg | grep "DDP package" | tail -1', '# ') if 'could not load' in out: print(RED(out)) @@ -140,6 +143,36 @@ class NetDevice(object): self.pkg['version'] = pkg_info[1].strip() return self.pkg + @nic_has_driver + def get_driver_firmware(self): + """ + Get NIC driver and firmware version. + """ + get_driver_firmware = getattr( + self, 'get_driver_firmware_%s' % + self.__get_os_type()) + get_driver_firmware() + + def get_driver_firmware_linux(self): + """ + Get NIC driver and firmware version. + """ + rexp = 'version:\s.+' + pattern = re.compile(rexp) + out = self.__send_expect('ethtool -i {} | grep version'.format(self.intf_name), '# ') + driver_firmware = pattern.findall(out) + if len(driver_firmware) > 1: + self.driver_version = driver_firmware[0].split(': ')[-1].strip() + self.firmware = driver_firmware[1].split(': ')[-1].strip() + + return self.driver_version, self.firmware + + def get_driver_firmware_freebsd(self): + """ + Get the NIC driver and firmware version. + """ + NotImplemented + def get_nic_socket(self): """ Get socket id of specified pci device. -- 2.17.1