Subject: Re: incomplete firmware-version shown in ethtool -i

From: "John W. Linville" <[email-masked]>
Date: Mon, 2 Jul 2018 11:06:42 -0400

On Wed, Jun 27, 2018 at 07:54:39AM +0000, Gang Gang10 Liu wrote:
> Dear,
> 
> I study that the ethtool only can show 31 characters firmware version, is it NIC driver not followed ethtool spec or
> Can we have any other way to get the full firmware version?
> 

I think the bnxt team is doing what they can to make as much
information available as possible. In this case, they seem to be
trying to make versioning info about the firmware package available
along with the info about the firmware version itself, and together
just barely overflowing the available space in the ethtool structure.
I'll leave it to you and/or Broadcom to determine whether or not that
is a bug that needs to be changed.

In the meanwhile, from your quoted message it seems that lspci can
give you the correct package version information for the device.

Good luck!

John

> 
> Thanks!
> 
> 
> [http://lenovocentral.lenovo.com/marketing/branding/email_signature/images/gradient.gif]
> 
> Gang Liu 刘刚
> Global Advisory Testing Engineer
> 
> DCG Test Strategy and Automation
> Lenovo SZ
> 
> [http://lenovocentral.lenovo.com/marketing/branding/email_signature/images/Email%20Gifs/T.gif]+86 13620981830
> [http://lenovocentral.lenovo.com/marketing/branding/email_signature/images/Email%20Gifs/E.gif][email-masked]<mailto:[email-masked]>
> 
> 
> 
> Lenovo.com <http://www.lenovo.com/>
> Twitter<http://twitter.com/lenovo> | Facebook<http://www.facebook.com/lenovo> | Instagram<https://instagram.com/lenovo> | Blogs<http://blog.lenovo.com/> | Forums<http://forums.lenovo.com/>
> 
> 
> [The-Lenovo-Way]
> 
> 
> 
> 
> 
> 
> From: Gang Gang10 Liu
> Sent: Wednesday, June 27, 2018 3:13 PM
> To: Ken Cheng4 <[email-masked]>; Yuhong YH6 Wu <[email-masked]>; Qinwei QW1 Yu <[email-masked]>; Vincent HY1 Long <[email-masked]>; -Product GTE <[email-masked]>
> Cc: Frank Y Wu <[email-masked]>
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Hi all,
> 
> 
> From ethtool source code, the root cause for this issue is:
> 
> the internal buffer for firmware-version in ethtool is 32 (include the string tail zero), so it only can show 31 characters version.
> But the actual firmware-version got from NIC driver is large than 32.
> 
> struct ethtool_drvinfo {
>                 __u32   cmd;
>                 char       driver[32];
>                 char       version[32];
>                 char       fw_version[ETHTOOL_FWVERS_LEN];
> …
> 
> #define ETHTOOL_FWVERS_LEN               32
> 
> 
> 
> 
> From: Ken Cheng4
> Sent: Wednesday, June 27, 2018 2:44 PM
> To: Yuhong YH6 Wu <[email-masked]<mailto:[email-masked]>>; Qinwei QW1 Yu <[email-masked]<mailto:[email-masked]>>; Vincent HY1 Long <[email-masked]<mailto:[email-masked]>>; -Product GTE <[email-masked]<mailto:[email-masked]>>; Gang Gang10 Liu <[email-masked]<mailto:[email-masked]>>
> Cc: Frank Y Wu <[email-masked]<mailto:[email-masked]>>
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Yuhong,
> 
> A merge request for common had been raised to fix the failure from this ethtool bug while testing firmware level of Broadcom cards.
> https://l3-prd01-rtp.labs.lenovo.com:4443/te/common/merge_requests/1513
> 
> 
> ===Background===
> Ethtool can not return correctly when the last number is zero like "212.0.107/1.9.1 pkg 212.0.112." <--missing 0 in the end.
> 
> Code change is to:
> 
> (1) get incomplete version like: 212.0.112
> (2) get complete version from lspci like "[V0] Vendor specific: 212.0.112.0"
> (3) compare the first three numbers with the firmware level from ethtool, ex:212.0.112
> (4) if the first three numbers match, fill incomplete firmware version from ethtool with correct one from lspci like: "212.0.107/1.9.1 pkg 212.0.112.0"
> 
> I will let Liu Gang to review first and then submit another merge request for more_common.
> 
> 
> 
> Ken Cheng
> Global TE Engineer
> LME
> Taiwan
> 
> 
> [email-masked]<mailto:e-mail>
> Ph: +886 2 8170-7580
> Fax: +886 2 2651-8246
> 
> 
> Shipping Address:
> Lenovo Technology B.V. Taiwan Branch
> 4F, No. 66 SanChong Road, NanGang,
> Taipei, Taiwan, 11502
> 荷蘭商聯想股份有限公司台灣分公司
> 台北市南港區三重路66號4樓
> 
> [描述: Lenovo-For-Those-Who-Do]
> 
> 
> 
> From: Ken Cheng4
> Sent: Tuesday, June 26, 2018 12:35 PM
> To: Yuhong YH6 Wu; Qinwei QW1 Yu; Vincent HY1 Long; -Product GTE
> Cc: Frank Y Wu
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Yuhong,
> 
> We may need more time to investigate whether his statement is valid for the other component cards:
> 
>                          === quoted from Qinwei ===
> I believe it has same problem for other vendor adapters when the last number of FW version is 0.
> 
> But for now I think a quick patch might be better for EOQ support. I was thinking to add an additional zero in the end of fw string when the last digit returned from ethtool is period ‘.’ in order to avoid that tuple error.
> 
> For example, to add an additional 0 after “212.0.112.” before it is sent to tuple actual_parts = version_tuple(actual)
> 
> 
> Ken Cheng
> Global TE Engineer
> LME
> Taiwan
> 
> 
> [email-masked]<mailto:e-mail>
> Ph: +886 2 8170-7580
> Fax: +886 2 2651-8246
> 
> 
> Shipping Address:
> Lenovo Technology B.V. Taiwan Branch
> 4F, No. 66 SanChong Road, NanGang,
> Taipei, Taiwan, 11502
> 荷蘭商聯想股份有限公司台灣分公司
> 台北市南港區三重路66號4樓
> 
> [描述: Lenovo-For-Those-Who-Do]
> 
> 
> 
> From: Yuhong YH6 Wu
> Sent: Tuesday, June 26, 2018 10:41 AM
> To: Qinwei QW1 Yu; Vincent HY1 Long; -Product GTE; Ken Cheng4
> Cc: Frank Y Wu
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Hi Ken,
> 
> Pre talk with Dev Qinwei brcm fw show have some problem by ethtool  whether able to use lspci common replace ethtool to read fw level as below.
> 
> [‎6/‎26/‎2018 10:07 AM] Yuhong YH6 Wu:
> 
> [root@localhost ~]# ethtool -i eth2
> driver: bnxt_en
> version: 1.7.25
> firmware-version: 212.0.107/1.9.1 pkg 212.0.112.   – missing 0
> expansion-rom-version:
> bus-info: 0000:06:00.0
> supports-statistics: yes
> supports-test: yes
> supports-eeprom-access: yes
> supports-register-dump: no
> supports-priv-flags: no
> 重启之后那个0就没了
> [‎6/‎26/‎2018 10:09 AM] Yuhong YH6 Wu:
> 
> [root@localhost ~]# lspci -vv -s 06:00.0 |grep V0   -- lspci can read out complete string character.
>                         [V0] Vendor specific: 212.0.112.0
> 这里看到有
> 
> 
> 
> From: Yuhong YH6 Wu
> Sent: Tuesday, June 26, 2018 9:20 AM
> To: Qinwei QW1 Yu <[email-masked]<mailto:[email-masked]>>; Vincent HY1 Long <[email-masked]<mailto:[email-masked]>>; -Product GTE <[email-masked]<mailto:[email-masked]>>; Ken Cheng4 <[email-masked]<mailto:[email-masked]>>
> Cc: Frank Y Wu <[email-masked]<mailto:[email-masked]>>
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Hi Qinwei，
> But actual fw level is ‘212.0.112.’ and chg log  is ‘Firmware Version: 212.0.112.0’  are you sure this is correct ?
> 
> Hi Ken,
> 
> If ‘212.0.112.’ fw is correct we need change the common code fix below issue from Broadcom.py.
> 
> 180625-11:26:32 INFO  ----------------------------------------------------------------------------------------------------
> 180625-11:26:32 INFO  |                                        Broadcom FW Flash                                         |
> 180625-11:26:32 INFO  ----------------------------------------------------------------------------------------------------
> 180625-11:26:32 INFO  Fetching Broadcom information for location Rear Slot 2
> 180625-11:26:36 INFO  Configuring <eth0>...
> 180625-11:26:36 INFO  Configuring <eth1>...
> 180625-11:26:38 INFO  Configuring <eth2>...
> 180625-11:26:40 INFO  Configuring <eth3>...
> 180625-11:26:42 INFO  Configuring <eth4>...
> 180625-11:26:44 INFO  Configuring <eth5>...
> 180625-11:26:46 INFO  Configuring <eth6>...
> 180625-11:26:46 INFO  Configuring <eth7>...
> 180625-11:26:48 INFO  Configuring <eth8>...
> 180625-11:26:50 INFO  Configuring <eth9>...
> 180625-11:26:52 INFO  Configuring <eth10>...
> 180625-11:26:54 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:54 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  pattern:\.|-v|-,version:5719-v1.47
> 180625-11:26:56 INFO  pattern:\.|-v|-,version:5719-v1.47
> 180625-11:26:56 INFO  Verified Broadcom [Slot 2] firmware level actual(=5719-v1.47) == expected(=5719-v1.47)
> 180625-11:26:56 INFO  Fetching Broadcom information for location Rear Slot 1
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:56 INFO  bnxt_en:212.0.107/1.9.1 pkg 212.0.112.
> 180625-11:26:57 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:57 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:57 INFO  bnxt_en:212.0.107/1.9.1 pkg 212.0.112.
> 180625-11:26:57 INFO  pattern:\.|-v|-,version:212.0.112.
> 180625-11:26:57 ERR*  Unhandled Exception has been thrown
> 180625-11:26:57 EXC** Traceback (most recent call last):
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/platform/modules/Run.py", line 384, in runmain
> 180625-11:26:57 EXC**     result = func(*bares, **keywords)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/tests/broadcom_code_test.py", line 37, in main
> 180625-11:26:57 EXC**     broadcom.verify_firmware_level(location)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 180, in verify_firmware_level
> 180625-11:26:57 EXC**     result, expected, actual = self._verify_firmware_level(location)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 193, in _verify_firmware_level
> 180625-11:26:57 EXC**     actual_parts = version_tuple(actual)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 59, in version_tuple
> 180625-11:26:57 EXC**     return tuple(int(v, base) for v in re.split(pattern, version))
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 59, in <genexpr>
> 180625-11:26:57 EXC**     return tuple(int(v, base) for v in re.split(pattern, version))
> 180625-11:26:57 EXC** ValueError: invalid literal for int() with base 16: ''
> 180625-11:26:57 FAIL  FAIL
> 180625-11:26:57 TESTE FAIL broadcom_code_test.py flash
> 
> 
> From: Qinwei QW1 Yu
> Sent: Monday, June 25, 2018 6:50 PM
> To: Yuhong YH6 Wu <[email-masked]<mailto:[email-masked]>>; Vincent HY1 Long <[email-masked]<mailto:[email-masked]>>; -Product GTE <[email-masked]<mailto:[email-masked]>>
> Cc: Frank Y Wu <[email-masked]<mailto:[email-masked]>>
> Subject: RE: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Hi Yuhong
> 
> The version in adapter VPD is correct.
> I suppose it is caused by ethtool.
> Different ethtool version has different display. See attachment.
> I believe it has same problem for other vendor adapters when the last number of FW version is 0.
> 
> Best Regards!
> 
> -Qinwei
> NIC Engineer
> 
> From: Yuhong YH6 Wu
> Sent: Monday, June 25, 2018 1:29 PM
> To: Qinwei QW1 Yu <[email-masked]<mailto:[email-masked]>>; Vincent HY1 Long <[email-masked]<mailto:[email-masked]>>; -Product GTE <[email-masked]<mailto:[email-masked]>>
> Cc: Frank Y Wu <[email-masked]<mailto:[email-masked]>>
> Subject: common fw brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64 issue
> 
> Hi Qinwei,
> Per talk in lync bnxt_en fw show at ‘212.0.112.’  but actually need is ‘212.0.112.0’ from 18b bin file ‘brcm-lnvgy_fw_nic_nxe-212.0.112.0-a_linux_x86-64.bin’
> Pls help to confirm this.
> 
> [root@localhost ~]# ethtool -i eth5
> driver: bnxt_en
> version: 1.7.25
> firmware-version: 212.0.107/1.9.1 pkg 212.0.112.
> expansion-rom-version:
> bus-info: 0000:30:00.0
> supports-statistics: yes
> supports-test: yes
> supports-eeprom-access: yes
> supports-register-dump: no
> supports-priv-flags: no
> 
> failed in test process as below info:
> 
> 
> 180625-11:26:32 INFO  ----------------------------------------------------------------------------------------------------
> 180625-11:26:32 INFO  |                                        Broadcom FW Flash                                         |
> 180625-11:26:32 INFO  ----------------------------------------------------------------------------------------------------
> 180625-11:26:32 INFO  Fetching Broadcom information for location Rear Slot 2
> 180625-11:26:36 INFO  Configuring <eth0>...
> 180625-11:26:36 INFO  Configuring <eth1>...
> 180625-11:26:38 INFO  Configuring <eth2>...
> 180625-11:26:40 INFO  Configuring <eth3>...
> 180625-11:26:42 INFO  Configuring <eth4>...
> 180625-11:26:44 INFO  Configuring <eth5>...
> 180625-11:26:46 INFO  Configuring <eth6>...
> 180625-11:26:46 INFO  Configuring <eth7>...
> 180625-11:26:48 INFO  Configuring <eth8>...
> 180625-11:26:50 INFO  Configuring <eth9>...
> 180625-11:26:52 INFO  Configuring <eth10>...
> 180625-11:26:54 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:54 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5bdef98>
> 180625-11:26:56 INFO  pattern:\.|-v|-,version:5719-v1.47
> 180625-11:26:56 INFO  pattern:\.|-v|-,version:5719-v1.47
> 180625-11:26:56 INFO  Verified Broadcom [Slot 2] firmware level actual(=5719-v1.47) == expected(=5719-v1.47)
> 180625-11:26:56 INFO  Fetching Broadcom information for location Rear Slot 1
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:56 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:56 INFO  bnxt_en:212.0.107/1.9.1 pkg 212.0.112.
> 180625-11:26:57 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:57 INFO  <LANTools.NETIF object at 0x7f18b5be2dd8>
> 180625-11:26:57 INFO  bnxt_en:212.0.107/1.9.1 pkg 212.0.112.
> 180625-11:26:57 INFO  pattern:\.|-v|-,version:212.0.112.
> 180625-11:26:57 ERR*  Unhandled Exception has been thrown
> 180625-11:26:57 EXC** Traceback (most recent call last):
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/platform/modules/Run.py", line 384, in runmain
> 180625-11:26:57 EXC**     result = func(*bares, **keywords)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/tests/broadcom_code_test.py", line 37, in main
> 180625-11:26:57 EXC**     broadcom.verify_firmware_level(location)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 180, in verify_firmware_level
> 180625-11:26:57 EXC**     result, expected, actual = self._verify_firmware_level(location)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 193, in _verify_firmware_level
> 180625-11:26:57 EXC**     actual_parts = version_tuple(actual)
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 59, in version_tuple
> 180625-11:26:57 EXC**     return tuple(int(v, base) for v in re.split(pattern, version))
> 180625-11:26:57 EXC**   File "/dfcxact/mtsn/J3002240/debug_yuhongw_18b_brcm/repos/common/modules/Broadcom.py", line 59, in <genexpr>
> 180625-11:26:57 EXC**     return tuple(int(v, base) for v in re.split(pattern, version))
> 180625-11:26:57 EXC** ValueError: invalid literal for int() with base 16: ''
> 180625-11:26:57 FAIL  FAIL
> 180625-11:26:57 TESTE FAIL broadcom_code_test.py flash
> 
> Globa Test Engineer
> Email: [email-masked]<mailto:[email-masked]>
> 

-- 
John W. Linville		Someday the world will need a hero, and you
[email-masked]			might be all we have.  Be ready.