Giter Club home page Giter Club logo

mstflint's Introduction

Mellanox Technologies - www.mellanox.com
****************************************

MSTFLINT Package - Firmware Burning and Diagnostics Tools

1) Overview
    This package contains a burning tool and diagnostic tools for Mellanox
    manufactured HCA/NIC cards. It also provides access to the relevant source
    code. Please see the file LICENSE for licensing details.
	This package is based on a subset of the Mellanox Firmware Tools (MFT) package.
	For a full documentation of the MFT package, please refer to the downloads page
	in Mellanox web site.

    ----------------------------------------------------------------------------
    NOTES:
    As of mstflint-4.8.0 ./configure --enable-cs will be deprecated, instead need to use
    ./configure --enable-openssl which will enable all open SSL features including CS.

    As of mstflint-4.6.0 hca_self_test.ofed will not be a part of msflint package,
    it will be found in ofed-scripts  provided by mellanox OFED package.

    This burning tool should be used only with Mellanox-manufactured
    HCA/NIC cards. Using it with cards manufactured by other vendors
    may be harmful  to  the cards (due to different configurations).
    Using the diagnostic tools is normally safe for all HCAs/NICs.
    ----------------------------------------------------------------------------

2) Package Contents
    a) mstflint source code
    b) mflash lib
       This lib provides low level Flash access through Mellanox HCAs.
    c) mtcr lib (implemented in mtcr.h file)
       This lib enables access to HCA hardware registers.
    d) mstregdump utility
       This utility dumps hardware registers from Mellanox hardware
       for later analysis by Mellanox.
    e) mstvpd
       This utility dumps the on-card VPD.
    f) mstmcra
       This debug utility reads/writes a to/from the device configuration register space.
    g) mstconfig
       This tool sets or queries non-volatile configurable options for Mellanox HCAs.
    h) mstfwmanager
       Mellanox firmware update and query utility which scans the system for available Mellanox devices (only mst
       PCI devices) and performs the necessary firmware updates.
    i) mstreg
       The mlxreg utility allows users to obtain information regarding supported access registers, such as their fields and
       attributes.
    j) mstfwtrace
       The mstfwtrace utility extracts and prints trace messages generated by the firmware running on 5th generation
       devices iRISCs. This tool supports secure FW flow only.
    k) mstlink
       The mstlink tool is used to check and debug link status and issues related to them.

3) Installation
    a) Build the mstflint utility. This package is built using a standard
       autotools method.

	   NOTE: if you are trying to build from the GitHub repository, need to run ./autogen.sh first.

       Example:
       > ./autogen.sh
       > mkdir build
       > cd build
       > ../configure
       > make
       > make install

       - Run "configure --help" for custom configuration options.
       - Typically, root privileges are required to run "make install"

    b) Installation on DEB based OS. This package is using Debian package development tools.

       Example:
       > dpkg-buildpackage -uc -us
       > dpkg -i ../mstflint_<version>_<arch>.deb
       > dpkg -i ../mstflint-dkms_<version>_all.deb

4) Hardware Access Device Names
   The tools in this package require a device name in the command
   line. The device name is the identifier of the target CA.
   This section describes the device name formats and the HW access flow.

   a) The devices can be accessed by their PCI ID as displayed by lspci
      (bus:dev.fn).
      Example:
      # List all Mellanox devices
      > /sbin/lspci -d 15b3:
        02:00.0 Ethernet controller: Mellanox Technologies MT25448 [ConnectX EN 10GigE, PCIe 2.0 2.5GT/s] (rev a0)

      # Use mstflint tool to query the firmware on this device
      > mstflint -d 02:00.0 q

    b) When the IB driver (mlx4 or mthca) is loaded, the devices can be accessed
       by their IB device name.
       Example:
       # List the IB devices
       > ibv_devinfo | grep hca_id
         hca_id: mlx4_0

       # Use mstvpd tool to dump the VPD of this device
       > mstvpd mlx4_0

    c) PCI configuration access
       In examples a and b above, the device is accessed via PCI Memory Mapping.
       The device can also be accessed by PCI configuration cycles.
       PCI configuration access is slower and less safe than memory access --
       use it only if methods a and b above do not work.

       To force configuration access, use device names in the following format:
       /proc/bus/pci/<bus>/<dev.fn>

       Example:
       # List all Mellanox devices
       > /sbin/lspci -d 15b3:
         02:00.0 Ethernet controller: Mellanox Technologies MT25448 [ConnectX EN 10GigE, PCIe 2.0 2.5GT/s] (rev a0)

       # Use mstregdump to dump HW registers, using PCI config cycles
       > mstregdump /proc/bus/pci/02/00.0 > crdump.log

       Note: Typically, you will need root privileges for hardware access

	d) Accessing a multi-function device:

	   In some configuration, the CA device identifies as a multi-function device on PCI. E.G.:
	   > /sbin/lspci -d 15b3:
	   07:00.0 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.1 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.2 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.3 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.4 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.5 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.6 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
	   07:00.7 Ethernet controller: Mellanox Technologies MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)

	   These multiple "logical" devices are actually a single physical device, so firmware update or "physical"
	   diagnostics should be run only on one of the functions.

	   When the device driver is loaded, only the primary physical function of the device can be accessed.
	   In Linux that would typically be function 0. This function can be accessed using memory mapping, as
	   described in sub section a) above. E.G.:
	   > mstflint -d 07:00.0 q

	   When the device driver is not loaded, all the functions can be accessed using configuration cycles, as
	   described in sub section c) above. It is recommended to use function 0 for FW update or diagnostics, E.G.:
	   > mstflint -d /proc/bus/pci/07/00.0 q

5) Usage (mstflint):
       Read mstflint usage. Enter "./mstflint -h" for a short help message, or
       "./mstflint -hh" for a detailed help message.

       Obtaining firmware files:
       If you purchased your card from Mellanox Technologies, please use the
       Mellanox website (www.mellanox.com, under 'Firmware' downloads) to
       download the firmware for your card.
       If you purchased your card from a vendor other than Mellanox, get a
       specific firmware configuration (INI) file from your HCA card vendor and
       generate the binary image.

       Use mstflint to burn a device according to the burning instructions in
       "mstflint -hh" and in Mellanox web site firmware page.

6) Usage (mstregdump):
       An internal register dump is displayed to the standard output.
       Please store it in a file for analysis by Mellanox.

       Example:
       > mstregdump mthca0 > dumpfile

7) Usage (mstvpd):
    A VPD dump is displayed to the standard output.
	A list of keywords to dump can be supplied after the -- flag
	to apply an output filter.

	Examples:
	> mstvpd mlx4_0
	ID: Hawk Dual Port
	PN: MNPH29C-XTR
	EC: X2
	SN: MT1001X00749
	V0: PCIe Gen2 x8
	V1: N/A
	YA: N/A
	RW:

    > mstvpd mlx4_0 -- PN ID
	PN: MNPH29C-XTR
	ID: Hawk Dual Port

8)  Usage (mstconfig):
    Read mstconfig usage. Enter "mstconfig -h" for a help message.

9)  Usage (mstreg):
    Read mstconfig usage. Enter "mstreg -h" for a help message.

10) Usage (mstfwtrace):
    Read mstconfig usage. Enter "mstfwtrace -h" for a help message.

11) Usage (mstlink):
    Read mstconfig usage. Enter "mstlink -h" for a help message.

12) Problem Reporting:
	Please collect the following information when reporting issues:

	uname -a
	cat /etc/issue
	cat /proc/bus/pci/devices
	mstflint -vv
	lspci
        mstflint -d 02:00.0 v
        mstflint -d 02:00.0 q
        mstvpd 02:00.0

mstflint's People

Contributors

adham-mellanox avatar adrianchiris avatar ahmadawwad avatar ahmadsoboh-mellanox avatar alonstr avatar aron-silverton avatar ashargorodsk avatar bdrung avatar boded avatar chrismoorenvidia avatar dangoldbergmellanox avatar diaedinrim avatar edwardgelzin avatar harelkarni avatar idanmeh avatar itayav17 avatar kstntnm avatar lgofman avatar mahmodh avatar mataneli94 avatar mustafadall avatar ogalbxela avatar roei-mlnx avatar romanyano avatar samerd avatar shellysela219 avatar talventura avatar thillux avatar tomer540 avatar tzafrir-mellanox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mstflint's Issues

Fails on ppc64el (POWER9)

On our POWER9 boxes, mstflint fails with:

mstflint -d 0031:01:00.0 q
-E- Cannot open Device: 0031:01:00.0. Operation not supported. MFE_CR_ERROR

lspci -s on the affected card:

0031:01:00.0 InfiniBand: Mellanox Technologies MT25208 [InfiniHost III Ex] (rev a0)

Tail of strace:

openat(AT_FDCWD, "/sys/bus/pci/devices/0031:01:00.0/config", O_RDONLY) = 3
read(3, "\263\25\202bB\1\20\0\240\0\6\f\0\0\0\0\4\0\0\200\0\0\0\0\f\0\0\0@ \6\0"..., 64) = 64
close(3)                                = 0
access("/dev/0031:01:00.0_mstcr", F_OK) = -1 ENOENT (No such file or directory)
access("/dev/0031:01:00.0_mstconf", F_OK) = -1 ENOENT (No such file or directory)
mkdir("/tmp", 0777)                     = -1 EEXIST (File exists)
mkdir("/tmp/mstflint_lockfiles", 0777)  = -1 EEXIST (File exists)
openat(AT_FDCWD, "/tmp/mstflint_lockfiles/0031:01:00.0_config", O_RDONLY|O_CREAT, 0777) = 3
openat(AT_FDCWD, "/sys/bus/pci/devices/0031:01:00.0/device", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=65536, ...}) = 0
read(4, "0x6282\n", 8192)               = 7
close(4)                                = 0
close(3)                                = 0
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
write(1, "-E- Cannot open Device: 0031:01:"..., 76-E- Cannot open Device: 0031:01:00.0. Operation not supported. MFE_CR_ERROR
) = 76
exit_group(1)                           = ?
+++ exited with 1 +++

32bit platforms fail building: mlxlink_cables_commander.cpp:96:37: error: ‘]’ directive writing 1 byte into a region of size between 0 and 9 [-Werror=format-overflow=]

Build log: https://buildd.debian.org/status/fetch.php?pkg=mstflint&arch=armhf&ver=4.16.0%2B1-1&stamp=1612359698&raw=0
Error:
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -I. -I../.. -I../../mtcr_ul -I -I../../mft_utils -I../../mlxreg -I../../mlxlink -I../../include/mtcr_ul -I/usr/include/jsoncpp -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -W -g -MP -MD -pipe -Werror -g -O2 -ffile-prefix-map=/<>=. -fstack-protector-strong -Wformat -Werror=format-security -isystem /usr/local/include -DHAVE_TERMIOS_H -DMST_UL -c mlxlink_reg_parser.cpp -o mlxlink_reg_parser.o >/dev/null 2>&1
mlxlink_cables_commander.cpp: In member function ‘void MlxlinkCablesCommander::writeMCIA(u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int8_t*, u_int32_t)’:
mlxlink_cables_commander.cpp:96:37: error: ‘]’ directive writing 1 byte into a region of size between 0 and 9 [-Werror=format-overflow=]
96 | sprintf(fieldName, "dword[%d]", i);
| ^
In file included from /usr/include/stdio.h:867,
from /usr/include/c++/10/cstdio:42,
from /usr/include/c++/10/ext/string_conversions.h:43,
from /usr/include/c++/10/bits/basic_string.h:6545,
from /usr/include/c++/10/string:55,
from mlxlink_logger.h:38,
from mlxlink_utils.h:38,
from mlxlink_reg_parser.h:37,
from mlxlink_cables_commander.h:37,
from mlxlink_cables_commander.cpp:33:
/usr/include/arm-linux-gnueabihf/bits/stdio2.h:36:34: note: ‘__builtin___sprintf_chk’ output between 9 and 18 bytes into a destination of size 16
36 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are similar errors on other platforms:
See logs here: https://buildd.debian.org/status/logs.php?pkg=mstflint&ver=4.16.0%2B1-1
The following 32 bit platforms failed in the same way:
armel, armhf, i386, powerpc.
All successful builds were 64 bit platforms.

(Some other platforms failed because they are not supported: m68k, hppa and riscv64)

4.11.0-1 compilation failure on gcc 8.2.1

Using gcc 8.2.1, mstflint 4.11.0-1 fails to compile.

Making all in tools_crypto
make[2]: Entering directory '/build/mstflint/src/mstflint/tools_crypto'
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../common -fPIC -D_FORTIFY_SOURCE=2 -MD -pipe -Wall -W -DMST_UL -g -fPIC -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -DMST_UL -MT tools_md5.o -MD -MP -MF .deps/tools_md5.Tpo -c -o tools_md5.o tools_md5.c                        
mv -f .deps/tools_md5.Tpo .deps/tools_md5.Po
rm -f libtools_crypto.a
ar cru libtools_crypto.a tools_md5.o
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib libtools_crypto.a
make[2]: Leaving directory '/build/mstflint/src/mstflint/tools_crypto'
Making all in mlxsign_lib
make[2]: Entering directory '/build/mstflint/src/mstflint/mlxsign_lib'
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../common  -D_FORTIFY_SOURCE=2 -Wall -W -Werror -g -MP -MD -pipe -fPIC -DTOOLS_CRYPTO_KEY='' -DTOOLS_CRYPTO_IV='' -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -DHAVE_TERMIOS_H -DMST_UL -MT mlxsign_lib.o -MD -MP -MF .deps/mlxsign_lib.Tpo -c -o mlxsign_lib.o mlxsign_lib.cpp
mlxsign_lib.cpp: In constructor ‘MlxSignHMAC::MlxSignHMAC()’:
mlxsign_lib.cpp:363:33: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX’ {aka ‘hmac_ctx_st’}                                  
     ctx = malloc(sizeof(HMAC_CTX));
                                 ^
mlxsign_lib.cpp:364:5: error: ‘HMAC_CTX_init’ was not declared in this scope                                                                      
     HMAC_CTX_init((HMAC_CTX*)ctx);
     ^~~~~~~~~~~~~
mlxsign_lib.cpp:364:5: note: suggested alternative: ‘HMAC_CTX_new’
     HMAC_CTX_init((HMAC_CTX*)ctx);
     ^~~~~~~~~~~~~
     HMAC_CTX_new
mlxsign_lib.cpp: In destructor ‘MlxSignHMAC::~MlxSignHMAC()’:
mlxsign_lib.cpp:418:5: error: ‘HMAC_CTX_cleanup’ was not declared in this scope                                                                   
     HMAC_CTX_cleanup((HMAC_CTX*)ctx);
     ^~~~~~~~~~~~~~~~
mlxsign_lib.cpp:418:5: note: suggested alternative: ‘HMAC_CTX_get_md’
     HMAC_CTX_cleanup((HMAC_CTX*)ctx);
     ^~~~~~~~~~~~~~~~
     HMAC_CTX_get_md
make[2]: *** [Makefile:432: mlxsign_lib.o] Error 1
make[2]: Leaving directory '/build/mstflint/src/mstflint/mlxsign_lib'
make[1]: *** [Makefile:533: all-recursive] Error 1
make[1]: Leaving directory '/build/mstflint/src/mstflint'
make: *** [Makefile:420: all] Error 2

license issue

./mtcr_freebsd/mtcr_ul.c

1 /*
2 * - Mellanox Confidential and Proprietary -
3 *
4 * Copyright (C) Jan 2013, Mellanox Technologies Ltd. ALL RIGHTS RESERVED.
5 *
6 * Except as specifically permitted herein, no portion of the information,
7 * including but not limited to object code and source code, may be reproduced,
8 * modified, distributed, republished or otherwise exploited in any form or by
9 * any means for any purpose without the prior written permission of Mellanox
10 * Technologies Ltd. Use of software subject to the terms and conditions
11 * detailed in the file "LICENSE.txt".
12 */

Please release this file with a open-source license such as GPL or BSD.

./configure.sh fails when openssl-devel is not installed

Despite having openssl installed, ./configure failed with error:

...
checking for openssl/sha.h... no
configure: error: cannot find openssl/sha.h . remove --enable-openssl to remove this dependaency or install openssl

Installing openssl-devel as well fixed the error.

rpmlint: Bogus dates in changelog

$ rpmlint mstflint.spec

mstflint.spec: E: specfile-error warning: bogus date in %changelog: Mon Jan 10 2017 Adham Masarwah
mstflint.spec: E: specfile-error warning: bogus date in %changelog: Wed May 17 2016 Adrian Chiris
mstflint.spec: E: specfile-error warning: bogus date in %changelog: Wed Jun 05 2015 Adrian Chiris
mstflint.spec: E: specfile-error warning: bogus date in %changelog: Mon Oct 12 2014 Oren Kladnitsky
mstflint.spec: E: specfile-error warning: bogus date in %changelog: Mon Jul 31 2014 Oren Kladnitsky
mstflint.spec: E: specfile-error warning: bogus date in %changelog: Fri Dec 23 2007 Oren Kladnitsky
0 packages and 1 specfiles checked; 6 errors, 0 warnings.

Spectrum2.csv is missing from mstdump

Hi,

Spectrum2.csv is missing from mstdump, resulting in the following error when mstregdump is invoked on a Spectrum-2 system:

# mstregdump -v
mstregdump, mstflint 4.16.0, built on Apr  7 2021, 00:00:00. Git SHA Hash: N/A

# mstregdump 06:00.0
-E- Failed to open csv file : '/usr/share/mstflint/Spectrum2.csv'

Files for other Spectrum ASICs do exist:

# ls /usr/share/mstflint/Spectrum*.csv
/usr/share/mstflint/Spectrum3.csv  /usr/share/mstflint/Spectrum.csv

Thanks

[regression issue] mstvpd does not work over mlx5 device

Hi,

I built and installed latest mstflint. It seems there is a regression issue for mstvpd. I ran
'git bisect' to narrow down the bad commit.

mstflint]# lspci | grep -i mellanox
04:00.0 Infiniband controller: Mellanox Technologies MT27600 [Connect-IB]

mstflint]# /opt/mstflint-v4.7.0-1/bin/mstvpd 04:00.0
ID: CB194A - Connect-IB QSFP
PN: MCB194A-FCAT
EC: A9
SN: MT1340X00409
V0: PCIe Gen3 x16

mstflint]# /opt/mstflint-v4.8.0-2/bin/mstvpd 04:00.0
-E- Failed to read VPD from 04:00.0!

mstflint]# git bisect good
4201e56 is the first bad commit
commit 4201e56
Author: Idan Mehalel [email protected]
Date: Wed Oct 18 16:51:34 2017 +0300

Title: use mvpd in mstvpd

Description:
Issue: 1081769

Document FreeBSD device naming

There's no clear way to actually select a device for usage with these tools on FreeBSD. It doesn't have 'lspci', it has 'pciconf'--but no permutation that I tried of the card name listed there was usable for the -d parameter.

Here's the example output with an installed card (MNPA19-XTR) on FreeBSD 12.0-RELEASE:

# pciconf -l | grep mlx
mlx4_core0@pci0:129:0:0:        class=0x020000 card=0x002115b3 chip=0x675015b3 rev=0xb0 hdr=0x00

Check RPM spec file for missing BuildRequires and Requires

PR #177 includes some fixes to conditionally add BuildRequires and/or Requires to the RPM spec file depending on which options are enabled. I only tested some options (e.g., enableadbgenerictools) and not others (e.g., enablecsi, enablefwmgr, etc.) and it is possible that if those or other options are enabled that additional BuildRequires and/or Requires would also be needed.

C++ errors in jsoncpp-headers

Trying to build the tool on FreeBSD (both 11.3 and 12.2) with jsoncpp-1.9.4 installed, I get these compilation errors:

mlxarchive_mfa2_builder.cpp:124:38: error: no viable conversion from 'Json::Value::const_iterator' (aka 'Json::ValueConstIterator') to 'Json::ValueIterator'
            for (Json::ValueIterator itr = _componentsJSON.begin();
                                     ^     ~~~~~~~~~~~~~~~~~~~~~~~
/opt/include/json/value.h:884:3: note: candidate constructor not viable: no known conversion from 'Json::Value::const_iterator' (aka 'Json::ValueConstIterator') to 'const Json::ValueIterator &' for 1st argument
  ValueIterator(const ValueIterator& other);
  ^
/opt/include/json/value.h:883:12: note: explicit constructor is not a candidate
  explicit ValueIterator(const ValueConstIterator& other);
           ^
/opt/include/json/value.h:889:12: note: explicit constructor is not a candidate
  explicit ValueIterator(const Value::ObjectValues::iterator& current);
           ^
mlxarchive_mfa2_builder.cpp:159:30: error: no viable conversion from 'Json::Value::const_iterator' (aka 'Json::ValueConstIterator') to 'Json::ValueIterator'
    for (Json::ValueIterator itr = _componentsJSON.begin();
                             ^     ~~~~~~~~~~~~~~~~~~~~~~~
/opt/include/json/value.h:884:3: note: candidate constructor not viable: no known conversion from 'Json::Value::const_iterator' (aka 'Json::ValueConstIterator') to 'const Json::ValueIterator &' for 1st argument
  ValueIterator(const ValueIterator& other);
  ^
/opt/include/json/value.h:883:12: note: explicit constructor is not a candidate
  explicit ValueIterator(const ValueConstIterator& other);
           ^
/opt/include/json/value.h:889:12: note: explicit constructor is not a candidate
  explicit ValueIterator(const Value::ObjectValues::iterator& current);
           ^
3 warnings and 2 errors generated.

Questions about mstflint release versions

Questions about the 4.9 release numbering.

At the URL : https://github.com/Mellanox/mstflint/releases
There are three 4.9.0 releases listed. They are
4.9.0-3
4.9.0-2
4.9.0

The two versions named 4.9.0-3 and 4.9.0-2 download a file named mstflint-4.9.0-1.tar.gz.

  • Is this correct?
  • I would have expected each release to have to use the "-3" and "-2" as part of the file name to differentiate between the release versions.

In the 4.9.0-3 version .tar.gz file. The file named mstflint.spec.in at the top level directory.
It has a line :
%{!?release: %define release 2}

If the latest .tar.gz file is 4.9.0-3, then should the number value be 3 instead of 2?

Thank you for your help.

mstlink doesn't build if system libjson-c-dev installed

mstlink builds fine when using the internal libjson - but if a system one is installed, it fails. As seen on Debian/unstable:

$ ./autogen.sh && ./configure --enable-adb-generic-tools && make -j$(nproc)

[...]

Making all in mlxlink
make[2]: Entering directory '/tmp/mstflint/mlxlink'
 cd .. && /bin/bash /tmp/mstflint/config/missing automake-1.16 --foreign mlxlink/Makefile
mlxlink/Makefile.am:49: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
 cd .. && /bin/bash ./config.status mlxlink/Makefile depfiles
config.status: creating mlxlink/Makefile
config.status: executing depfiles commands
Making all in modules
make[3]: Entering directory '/tmp/mstflint/mlxlink/modules'
Making all in printutil
make[4]: Entering directory '/tmp/mstflint/mlxlink/modules/printutil'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/tmp/mstflint/mlxlink/modules/printutil'
make[4]: Entering directory '/tmp/mstflint/mlxlink/modules'
make[4]: *** No rule to make target '../../ext_libs/json/libjson.a', needed by 'libmodules_lib.a'.  Stop.
make[4]: Leaving directory '/tmp/mstflint/mlxlink/modules'
make[3]: *** [Makefile:603: all-recursive] Error 1
make[3]: Leaving directory '/tmp/mstflint/mlxlink/modules'
make[2]: *** [Makefile:599: all-recursive] Error 1
make[2]: Leaving directory '/tmp/mstflint/mlxlink'
make[1]: *** [Makefile:545: all-recursive] Error 1
make[1]: Leaving directory '/tmp/mstflint'
make: *** [Makefile:432: all] Error 2

default generated configuration script ./configure.sh script fails, missing infiniband/mad.h

The .configure script generated by ./autogen.sh fails in t he default mode (build with inifiband).

checking infiniband/mad.h usability... no
checking infiniband/mad.h presence... no
checking for infiniband/mad.h... no
configure: error: cannot find infiniband/mad.h . Use --disable-inband to remove this dependaency

This will build successfully when the --disable-inband is used.

But default setup should build without errors.

old program names used in the help messages

mstfwmanager/mstfwreset help text mentions the mlx* utilities (mlxfwmanager/mlxfwreset). These should be updated to use the mst* utility names instead.

mstflint]# /usr/bin/mstfwreset --help
usage: mlxfwreset -d|--device DEVICE [-l|--level {0,1,2,3,4,5}] [--yes] q|query|r|reset
[--help]
[--version]

Mlxfwreset : Tool which provides the following functionality:
1. Query device for reset level required in order to load new firmware
2. Perform reset operation in order to load new firmware

Options:
--device DEVICE, -d DEVICE
Device to work with.
--level {0,1,2,3,4,5}, -l {0,1,2,3,4,5}
Run reset with the specified reset level.
--yes, -y answer "yes" on prompt.
--skip_driver, -s Skip driver start/stop stage (driver must be stopped
manually).
--mst_flags MST_FLAGS, -m MST_FLAGS
Provide mst flags to be used when invoking mst restart
step. For example: --mst_flags="--with_fpga"
--version, -v Print tool version.
--help, -h show this help message and exit.
--skip_fsm_sync Skip fsm syncing

Commands:
{q,query,r,reset,reset_fsm_register}
query: Query reset Level. reset: Execute reset.
reset_fsm_register: Reset the fsm register.

Reset levels:
0: Full ISFU.
1: Driver restart (link/managment will remain up).
2: Driver restart (link/managment will be down).
3: Driver restart and PCI reset.
4: Warm reboot.
5: Cold reboot (performed by the user).

Supported Devices:
ConnectIB, ConnectX4, ConnectX4LX, ConnectX5, BlueField.

mstflint]# /usr/bin/mstfwmanager --help
NAME
mlxfwmanager

SYNOPSIS
mlxfwmanager
[-d|--dev DeviceName] [-h|--help] [-v|--version] [--query] [--query-format Format]
[-u|--update] [-i|--image-file FileName] [-D|--image-dir DirectoryName] [-f|--force]
[--no_fw_ctrl] [-y|--yes] [--no] [--clear-semaphore] [--exe-rel-path]
[-l|--list-content] [--archive-names] [--nofs] [--log] [-L|--log-file LogFileName]
[--no-progress] [-o|--outfile OutputFileName] [--online] [--online-query-psid PSIDs]
[--key key] [--download DirectoryName] [--download-default] [--get-download-opt OPT]
[--download-device Device] [--download-os OS] [--download-type Type]
[--ssl-certificate Certificate]

DESCRIPTION
Mellanox Firmware Manager

OPTIONS
mlxfwmanager
-d|--dev DeviceName : Perform operation for specified mst
device(s). Run 'mst status' command to list
the available devices. Multiple devices can
be specified delimited by semicolons. A
device list containing semicolons must be
quoted.
-h|--help : Show this message and exit
-v|--version : Show the executable version and exit
--query : Query device(s) info
--query-format Format : (Query | Online query) output format, XML |
Text - default Text
-u|--update : Update firmware image(s) on the device(s)
-i|--image-file FileName : Specified image file to use
-D|--image-dir DirectoryName : Specified directory instead of default to
locate image files
-f|--force : Force image update
--no_fw_ctrl : Don't use FW Ctrl update
-y|--yes : Answer is yes in prompts
--no : Answer is no in prompts
--clear-semaphore : Force clear the flash semaphore on the
device, No command is allowed when this flag
is used. NOTE: May result in system
instability or flash corruption if the
device or another application is currently
using the flash. Exercise caution.
--exe-rel-path : Use paths relative to the location of the
executable
-l|--list-content : List file/Directory content, used with
--image-dir and --image-file flags
--archive-names : Display archive names in listing
--nofs : Burn image in a non failsafe manner
--log : Create log file
-L|--log-file LogFileName : Use specified log file
--no-progress : Do not show progress
-o|--outfile OutputFileName : Write to specified output file
--online : Fetch required FW images online from Mellanox
server
--online-query-psid PSIDs : Query FW info, PSID(s) are comma separated
--key key : Key for custom download/update
--download DirectoryName : Download files from server to a specified
directory
--download-default : Use Default values for download
--get-download-opt OPT : Get download options for OS or Device
Options are: OS, Device
--download-device Device : Use '--get-download-opt Device' option to
view available devices for device specific
downloads
--download-os OS : Only for self_extractor download: Use
'--get-download-opt OS' option to view
available OS for sfx download
--download-type Type : MFA | self_extractor - default All
--ssl-certificate Certificate : SSL certificate For secure connection

Examples:
1. Query specific device or all devices (if no device were supplied)
>> mlxfwmanager [-d ] [--query]
2. Burn device with specific image / MFA / images directory
>> mlxfwmanager -d [-i <image file/MFA file> | -D ]
3. Update the card's firmware
>> mlxfwmanager -u
4. Update the card's firmware from latest version on the web
>> mlxfwmanager --online -u
5. Download latest FW package from the web
>> mlxfwmanager --download-default --download-os Linux_x64 --download-type self_extractor

mstconfig Fails to query device configuration on Connectx-3 EN cards

I have two Connectx-3 EN single SFP+ port cards that I am trying to change the config. FW 2.42.5000 / FlexBoot 3.4.752

I have used multiple versions of the OFED driver as well as the EN driver with multiple versions of mstflint.

I have tried Centos 7.6, Fedora 29 and Ubuntu 16.04.

I have reflashed the cards multiple times as well as reset the config. I even flashed them from livefish mode.

Nothing seems to work, I can't query the config of the cards with either mstflint or MFT.

Edit: Others have the same problem as well:

https://community.mellanox.com/s/question/0D51T00006RVv0vSAD/unable-to-set-mellanox-connectx3-to-ethernet-failed-to-query-device-current-configuration

https://community.mellanox.com/s/question/0D51T00006RVujaSAD/issue-with-connectx3-failed-to-query-device-current-configuration?t=1549276511711

Build instructions are incorrect

The build instructions are:

  1. Installation
    a) Build the mstflint utility. This package is built using a standard
    autotools method.

    Example: 
    > ./configure
    > make
    > make install
    
    - Run "configure --help" for custom configuration options.
    - Typically, root privileges are required to run "make install"
    

However, "configure" is not provided and it appears that running autogen.sh first is required.

compilation failed for fedora 33

g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I. -I../mtcr_ul -I../mflash -I../common -I../tools_layouts -I../mft_utils -I../include/mtcr_ul -Wall -W -g -MP -MD -pipe -DEXTERNAL -fPIC -DFLINT_NAME="mstflint" -DFLINT_DISPLAY_NAME="MstFlint" -DMST_DEV_EXAMPLE1="03:00.0" -DMST_DEV_EXAMPLE2="mlx4_0" -DMST_DEV_EXAMPLE3="03:00.0" -DMST_DEV_EXAMPLE4="04:00.0" -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -isystem /usr/local/include -DHAVE_TERMIOS_H -isystem /usr/include/libxml2 -DMST_UL -c -o mstflint-subcommands.o test -f 'subcommands.cpp' || echo './'subcommands.cpp
subcommands.cpp: In member function 'bool BurnSubCommand::checkFwVersion(bool, u_int16_t, u_int16_t, u_int16_t)':
subcommands.cpp: In member function 'bool BurnSubCommand::checkFwVersion(bool, u_int16_t, u_int16_t, u_int16_t)':
subcommands.cpp:1852:42: error: format not a string literal and no format arguments [-Werror=format-security]
subcommands.cpp:1852:42: error: format not a string literal and no format arguments [-Werror=format-security]
1852 | false, "N/A").c_str());
1852 | false, "N/A").c_str());
| ^
| ^
subcommands.cpp:1862:39: error: format not a string literal and no format arguments [-Werror=format-security]
subcommands.cpp:1862:39: error: format not a string literal and no format arguments [-Werror=format-security]
1862 | "N/A").c_str());
1862 | "N/A").c_str());

python scripts with shebang but installed as not executables

mstflint (master)]$ find -name '*.py' | xargs grep -E '^#!/usr/bin'
./small_utils/mstfwreset.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/mlxfwreset_utils.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/mcra.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/mlxfwreset_status_checker.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/pci_device.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/mlnx_peripheral_components.py:#!/usr/bin/python
./small_utils/mlxfwresetlib/mlxfwreset_mlnxdriver.py:#!/usr/bin/python
./mtcr_py/test.py:#!/usr/bin/env python

https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines

"Files which are not installed as executables SHOULD NOT have shebang lines."

mstflint installed all python scripts as not executables. If those files are not executables, we
should remove the shebang line for them. Or, we should install those files as executables.

need to replace 'mlxfwreset' with 'mstfwreset'

$ mstflint -d 05:00.0 -i ./fw-ConnectIB-rel-10_16_1200-MCB194A-FCA_A1.bin burn

Current FW version on flash:  10.16.1020
New FW version:               10.16.1200

Burning FW image without signatures - OK
Restoring signature - OK
-I- To load new FW run mlxfwreset or reboot machine.
^^^^^^^^^^^

***** minor nitpick: above should state 'mstfwreset' instead of 'mlxfwreset' *****

$ rpm -qpl mstflint-4.11.0-2.el7.x86_64.rpm | grep fwreset | grep bin
/usr/bin/mstfwreset

There is no 'mlxfwreset' in the rpm. Only 'mstfwreset'.

flint truncating long PCI addresses, device file cannot be opened

Hello,

I am trying to upgrade the firmware on some Mellanox ConnectX-5 cards and am running into some issues that I think are related to the flint tool. Here is the system information:

Motherboard: Intel S2600BP
OS: RHEL 7.4
Card: ConnectX-5 VPI (MCX556A-ECAT)
Card FW: 16.20.1010
MFT version: 4.9.0-38
OFED version: 4.3-1.0.1.0-rhel7.4

I can see the cards in the lspci output (see below). Note the longer-than-usual PCI addresses (10002:01:00.0/1). This is the first time I have encountered a PCI address like this, but supposedly, on systems with multiple PCI bridges (which this one has) this can happen.

10002:01:00.0 Infiniband controller: Mellanox Technologies MT27800 Family [ConnectX-5]
	Subsystem: Mellanox Technologies Device 0001
10002:01:00.1 Infiniband controller: Mellanox Technologies MT27800 Family [ConnectX-5]
	Subsystem: Mellanox Technologies Device 0001

I am trying to query the device with flint using the following command:

flint -d 10002:01:00.0 q

And the following error is being thrown:

Failed to open (/sys/bus/pci/devices/0002:01:00.0/config) for reading: No such file or directory

Notice that the file it is looking for has had the leading 1 removed, so that instead of 10002:01:00.0 it is looking for 0002:01:00.0 which is not a real device.

I cloned the git repo and tried to find where in the code this might be happening, but I do not have enough knowledge of C++ to make a worthwhile effort.

Thank you

Please fix important covscan issues

Please note: there are false positive in the covscan report.

  9	BUFFER_SIZE_WARNING
  2	COPY_PASTE_ERROR

mstflint-4.11.0-2.el8/scan-results-imp.err

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:237: buffer_size_warning: Calling strncpy with a maximum size argument of 97 bytes on destination array "this->_fs3ImgInfo.ext_info.orig_prs_name" of size 97 bytes might leave the destination string unterminated.

235| memset(&tools_mfg_info, 0, sizeof(tools_mfg_info));

236| tools_open_mfg_info_unpack(&tools_mfg_info, buff);

237|-> strncpy(_fs3ImgInfo.ext_info.orig_prs_name, tools_mfg_info.orig_prs_name, FS3_PRS_NAME_LEN);

238| }

239| return true;

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:314: buffer_size_warning: Calling strncpy with a maximum size argument of 65 bytes on destination array "this->_fs3ImgInfo.ext_info.name" of size 65 bytes might leave the destination string unterminated.

312| memset(&tools_image_info, 0, sizeof(tools_image_info));

313| tools_open_image_info_unpack(&tools_image_info, buff);

314|-> strncpy(_fs3ImgInfo.ext_info.name, tools_image_info.name, NAME_LEN);

315| strncpy(_fs3ImgInfo.ext_info.description, tools_image_info.description, DESCRIPTION_LEN);

316| strncpy(_fs3ImgInfo.ext_info.prs_name, tools_image_info.prs_name, FS3_PRS_NAME_LEN);

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:315: buffer_size_warning: Calling strncpy with a maximum size argument of 257 bytes on destination array "this->_fs3ImgInfo.ext_info.description" of size 257 bytes might leave the destination string unterminated.

313| tools_open_image_info_unpack(&tools_image_info, buff);

314| strncpy(_fs3ImgInfo.ext_info.name, tools_image_info.name, NAME_LEN);

315|-> strncpy(_fs3ImgInfo.ext_info.description, tools_image_info.description, DESCRIPTION_LEN);

316| strncpy(_fs3ImgInfo.ext_info.prs_name, tools_image_info.prs_name, FS3_PRS_NAME_LEN);

317| }

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:316: buffer_size_warning: Calling strncpy with a maximum size argument of 97 bytes on destination array "this->_fs3ImgInfo.ext_info.prs_name" of size 97 bytes might leave the destination string unterminated.

314| strncpy(_fs3ImgInfo.ext_info.name, tools_image_info.name, NAME_LEN);

315| strncpy(_fs3ImgInfo.ext_info.description, tools_image_info.description, DESCRIPTION_LEN);

316|-> strncpy(_fs3ImgInfo.ext_info.prs_name, tools_image_info.prs_name, FS3_PRS_NAME_LEN);

317| }

318| _fs3ImgInfo.ext_info.mcc_en = image_info.mcc_en;

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:1195: buffer_size_warning: Calling strncpy with a maximum size argument of 17 bytes on destination array "tools_image_info.psid" of size 17 bytes might leave the destination string unterminated.

1193| struct tools_open_image_info tools_image_info;

1194| tools_open_image_info_unpack(&tools_image_info, &imageInfoSect[0]);

1195|-> strncpy(tools_image_info.psid, _fwImgInfo.ext_info.psid, PSID_LEN + 1);

1196| strncpy(tools_image_info.name, _fs3ImgInfo.ext_info.name, NAME_LEN);

1197| strncpy(tools_image_info.description, _fs3ImgInfo.ext_info.description, DESCRIPTION_LEN);

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:1196: buffer_size_warning: Calling strncpy with a maximum size argument of 65 bytes on destination array "tools_image_info.name" of size 65 bytes might leave the destination string unterminated.

1194| tools_open_image_info_unpack(&tools_image_info, &imageInfoSect[0]);

1195| strncpy(tools_image_info.psid, _fwImgInfo.ext_info.psid, PSID_LEN + 1);

1196|-> strncpy(tools_image_info.name, _fs3ImgInfo.ext_info.name, NAME_LEN);

1197| strncpy(tools_image_info.description, _fs3ImgInfo.ext_info.description, DESCRIPTION_LEN);

1198| tools_open_image_info_pack(&tools_image_info, &imageInfoSect[0]);

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fs3_ops.cpp:1197: buffer_size_warning: Calling strncpy with a maximum size argument of 257 bytes on destination array "tools_image_info.description" of size 257 bytes might leave the destination string unterminated.

1195| strncpy(tools_image_info.psid, _fwImgInfo.ext_info.psid, PSID_LEN + 1);

1196| strncpy(tools_image_info.name, _fs3ImgInfo.ext_info.name, NAME_LEN);

1197|-> strncpy(tools_image_info.description, _fs3ImgInfo.ext_info.description, DESCRIPTION_LEN);

1198| tools_open_image_info_pack(&tools_image_info, &imageInfoSect[0]);

1199| }

Error: COPY_PASTE_ERROR (CWE-398):
mstflint-4.11.0/mlxfwops/lib/fs4_ops.cpp:1147: original: "flashObjWithOcr != NULL" looks like the original copy.
mstflint-4.11.0/mlxfwops/lib/fs4_ops.cpp:1067: copy_paste_error: "flashObjWithOcr" in "flashObjWithOcr != NULL" looks like a copy-paste error.
mstflint-4.11.0/mlxfwops/lib/fs4_ops.cpp:1067: remediation: Should it say "origFlashObj" instead?

1065| }

1066|

1067|-> if (flashObjWithOcr != NULL) {

1068| _ioAccess = origFlashObj;

1069| _fwParams.ignoreCacheRep = 0;

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fsctrl_ops.cpp:174: buffer_size_warning: Calling strncpy with a maximum size argument of 65 bytes on destination array "this->_fsCtrlImgInfo.name" of size 65 bytes might leave the destination string unterminated.

172| }

173|

174|-> strncpy(_fsCtrlImgInfo.name, fwQery.name, NAME_LEN);

175| strncpy(_fsCtrlImgInfo.description, fwQery.description, DESCRIPTION_LEN);

176|

Error: BUFFER_SIZE_WARNING (CWE-120):
mstflint-4.11.0/mlxfwops/lib/fsctrl_ops.cpp:175: buffer_size_warning: Calling strncpy with a maximum size argument of 257 bytes on destination array "this->_fsCtrlImgInfo.description" of size 257 bytes might leave the destination string unterminated.

173|

174| strncpy(_fsCtrlImgInfo.name, fwQery.name, NAME_LEN);

175|-> strncpy(_fsCtrlImgInfo.description, fwQery.description, DESCRIPTION_LEN);

176|

177| return true;

Error: COPY_PASTE_ERROR (CWE-398):
mstflint-4.11.0/mtcr_ul/mtcr_ul_icmd_cif.c:579: original: "mtcr_memaccess(mf, 0U, read_data_size, data, 0, MEM_ICMD)" looks like the original copy.
mstflint-4.11.0/mtcr_ul/mtcr_ul_icmd_cif.c:556: copy_paste_error: "read_data_size" in "mtcr_memaccess(mf, 0U, read_data_size, data, 1, MEM_ICMD)" looks like a copy-paste error.
mstflint-4.11.0/mtcr_ul/mtcr_ul_icmd_cif.c:556: remediation: Should it say "write_data_size" instead?

554| DBG_PRINTF("-D- Writing command to mailbox");

555| if (mf->icmd.dma_icmd) {

556|-> if (mtcr_memaccess(mf, 0, read_data_size, data, 1, MEM_ICMD)) {

557| ret = ME_ICMD_STATUS_CR_FAIL;

558| goto cleanup;

v4.9 added libibverbs dependency

Hi @adham-mellanox,

It looks like Porting MFT-4.9.0 changes added a dependency on libibverbs:

#if !defined(__WIN__) && !defined(DISABLE_OFED)
#include <dlfcn.h>
#include <infiniband/verbs.h>
#endif

but there is no BuildRequires in the spec file.

Perhaps:

BuildRequires: libibverbs-devel

which should pull in rdma-core-devel when appropriate since it provides libibverbs-devel in newer distros.

What is the effect of ONE_QP_PER_RECOVERY

Hi,
we are currently testing some proprietary software were ONE_QP_PER_RECOVERY will be set to 1. Can anyone explain to me how this setting affects the performance? I saw that this setting was removed from the .db file , what is the reason for this?

Python scripts with missing or incorrect shebang lines

With Enterprise Linux 8 distros, Python is either /usr/bin/python2 or /usr/bin/python3 (preferred) and there is no un-versioned /usr/bin/python unless one goes out of their way to make it so.

I find these Python files in mstflint:

./cmdif/cmdif.py
./common/mft_logger.py
./common/tools_version.py.in
./dev_mgt/dev_mgt.py
./ext_libs/iniParser/test/twisted-genhuge.py
./mlxconfig/mstprivhost.py
./mtcr_py/mtcr.py
./mtcr_py/test.py
./reg_access/regaccess.py
./small_utils/binary_file.py
./small_utils/mlxfwresetlib/__init__.py
./small_utils/mlxfwresetlib/logger.py
./small_utils/mlxfwresetlib/mcra.py
./small_utils/mlxfwresetlib/mlnx_peripheral_components.py
./small_utils/mlxfwresetlib/mlxfwreset_mlnxdriver.py
./small_utils/mlxfwresetlib/mlxfwreset_status_checker.py
./small_utils/mlxfwresetlib/mlxfwreset_utils.py
./small_utils/mlxfwresetlib/pci_device.py
./small_utils/mlxpci_lib.py
./small_utils/mstfwreset.py
./tracers/fwtrace/fw_trace_utilities.py
./tracers/fwtrace/mstfwtrace.py
./tracers/fwtrace/secure_fw_trace.py

I only check files with "py" in their extension and did not look for files that are actually Python but do not include the extension.

Out of those files, I only find one that has a shebang:

head -n1 ./tracers/fwtrace/mstfwtrace.py
#!/usr/bin/env python

This makes me wonder

  1. Are there other Python files that just happen to be missing a .py extension?
  2. Should any of the other Python files included a shebang?
  3. Are all of the Python files compatible with both python2 and python3 (the ./common/python_wrapper.sh script seems to imply yes...)

If you want to keep a single upstream spec file for both .el7 and .el8 you may want to check "dist" and then modify the Python scripts' shebang lines to be either /usr/bin/python2 or /usr/bin/python3 and conditionally Require and BuildRequires the appropriate Python as needed. If you stick with using GNU autotools, you can probably do this with configure, make, and mstflint.spec.in as well as do the substitution of the shebang lines.

RPM has rpmlint issues

Summarizing email thread...

The RPM produced by the upstream spec file has these rpmlint issues:

mstflint.x86_64: W: devel-file-in-non-devel-package /usr/lib64/mstflint/libmtcr_ul.a
mstflint.x86_64: E: script-without-shebang /usr/lib64/mstflint/python_tools/mstfwreset/mstfwreset.py
mstflint.x86_64: W: devel-file-in-non-devel-package /usr/include/mstflint/mtcr.h
mstflint.x86_64: E: script-without-shebang /usr/lib64/mstflint/python_tools/mstprivhost/mstprivhost.py
mstflint.x86_64: W: devel-file-in-non-devel-package /usr/include/mstflint/mtcr_com_defs.h
mstflint.x86_64: E: non-executable-script /usr/lib64/mstflint/python_tools/mstfwtrace/mstfwtrace.py 0644L /usr/bin/env
mstflint.x86_64: W: no-manual-page-for-binary mstfwreset
mstflint.x86_64: W: no-manual-page-for-binary mstcongestion

@DanGoldbergMellanox: Regarding devel warnings, we will need to decide if we want to create devel package. It looks as the right thing to do, but it should be checked also with other customers.

@DanGoldbergMellanox: Regarding script without shebang, it’s a common practice in py scripts and it solves py compatibility issues. We don’t access those scripts directly but with a wrapper script. We can have a discussion on preferred way to improve the python packaging process.

@DanGoldbergMellanox: Regarding missing man pages, we should add them.

warning: Installed (but unpackaged) file(s) found:
   /usr/bin/mstfwtrace [R] This is the result of the previously mentioned bug (Oracle added the fix for it).
   /usr/include/mstflint/cmdif/icmd_cif_common.h
   /usr/include/mstflint/cmdif/icmd_cif_open.h
   /usr/include/mstflint/common/compatibility.h
   /usr/include/mstflint/mtcr_mf.h
   /usr/include/mstflint/tools_layouts/adb_to_c_utils.h
   /usr/include/mstflint/tools_layouts/icmd_layouts.h
   /usr/lib64/libcmdif.a
   /usr/lib64/libdev_mgt.a
   /usr/lib64/libreg_access.a
   /usr/lib64/libtools_layouts.a
   /usr/lib64/mstflint/python_tools/cmdif.pyc
   /usr/lib64/mstflint/python_tools/cmdif.pyo
   /usr/lib64/mstflint/python_tools/dev_mgt.pyc
   /usr/lib64/mstflint/python_tools/dev_mgt.pyo
   /usr/lib64/mstflint/python_tools/mft_logger.pyc
   /usr/lib64/mstflint/python_tools/mft_logger.pyo
   /usr/lib64/mstflint/python_tools/mlxpci/binary_file.pyc
   /usr/lib64/mstflint/python_tools/mlxpci/binary_file.pyo
   /usr/lib64/mstflint/python_tools/mlxpci/mlxpci_lib.pyc
   /usr/lib64/mstflint/python_tools/mlxpci/mlxpci_lib.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/__init__.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/__init__.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/logger.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/logger.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mcra.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mcra.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlnx_peripheral_components.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlnx_peripheral_components.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_mlnxdriver.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_mlnxdriver.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_status_checker.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_status_checker.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_utils.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/mlxfwreset_utils.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/pci_device.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mlxfwresetlib/pci_device.pyo
   /usr/lib64/mstflint/python_tools/mstfwreset/mstfwreset.pyc
   /usr/lib64/mstflint/python_tools/mstfwreset/mstfwreset.pyo
   /usr/lib64/mstflint/python_tools/mstfwtrace/fw_trace_utilities.pyc
   /usr/lib64/mstflint/python_tools/mstfwtrace/fw_trace_utilities.pyo
   /usr/lib64/mstflint/python_tools/mstfwtrace/mstfwtrace.pyc
   /usr/lib64/mstflint/python_tools/mstfwtrace/mstfwtrace.pyo
   /usr/lib64/mstflint/python_tools/mstfwtrace/secure_fw_trace.pyc
   /usr/lib64/mstflint/python_tools/mstfwtrace/secure_fw_trace.pyo
   /usr/lib64/mstflint/python_tools/mstprivhost/mstprivhost.pyc
   /usr/lib64/mstflint/python_tools/mstprivhost/mstprivhost.pyo
   /usr/lib64/mstflint/python_tools/mtcr.pyc
   /usr/lib64/mstflint/python_tools/mtcr.pyo
   /usr/lib64/mstflint/python_tools/regaccess.pyc
   /usr/lib64/mstflint/python_tools/regaccess.pyo
   /usr/lib64/mstflint/python_tools/tools_version.pyc
   /usr/lib64/mstflint/python_tools/tools_version.pyo

Files should either be packaged and included in the RPM or they should not be installed in the RPM BUILDROOT while the RPM is being built. Some of the files listed above probably belong in the missing -devel package if one is ever provided. The binary python files, if built during rpmbuild (i.e., built for the specific platform) should be fine to include in the binary RPM. Any .pyc or .pyo files committed to the git repo for some reason should not be packaged as the files in the repo may not have been built for the correct platform. I think the binary python files should be built as part of rpmbuild or excluded entirely from the RPM.

Is 4.11.0-4 meant to be tagged pre-release?

Very sorry if 4.11.0-4 is meant to be a pre-release. Not used to seeing that on this project, and without it having a versioning scheme like some projects designating even/odds etc, or a rc in the name, wanted to check. I maintain mstflint in the Arch AUR repository, and don't want to release -4 if it's not meant to be a stable release. Gut feeling is the wrong box was checked.

Autotools "configure" script is missing check for "lzma.h"

I believe that the "configure" script is missing a check for "lzma.h" which is provided by xz-devel on EL systems. It is likely a different package on Debian-based distros. Regardless, the scripts should check that "lzma.h" is present when it is required.

mstflint user tools and kernel module versions are inconsistent

Prior mstflint releases bumped the version of kernel-mstflint to match that of the userspace tools even if the kernel module code was unchanged.

The versions are currently out-of-sync. For now, they should probably be kept in-sync. However, in the long term, some better mechanism for maintaining the user tools and the kernel module and their ABI compatibility should be explored.

kernel denied for mstconfig: lockdown_reason="direct PCI access"

It seams that mstflint has an issue with newer Linux Kernel versions (5.4+), which supports kernel_lockdown

sh-4.4# mstconfig -v
mstconfig, mstflint 4.15.0, built on Nov 16 2020, 18:12:47. Git SHA Hash: N/A
sh-4.4# mstconfig -d af:00.0 q
write counter to semaphore: Permission denied
-E- Failed to open the device
sh-4.4# uname -a
Linux ... 5.13.4-200.fc34.x86_64 #1 SMP Tue Jul 20 20:27:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
sh-4.4# 

journal entry:

kernel: audit: type=1400 audit(1632295980.136:80874): avc:  denied  { integrity } for  pid=423824 comm="mstconfig" lockdown_reason="direct PCI access" scontext=system_u:system_r:spc_t:s0 tcontext=system_u:system_r:spc_t:s0 tclass=lockdown permissive=0

I am not able to test latest mstfint version, but have only 4.15 available at the moment.

Anybody can confirm that latest mstfint has a fix, or it still an open issue? when will mstflint support kernel 5.4+ with kernel lockdown model enabled?

small_utils/mlxfwresetlib/mlxfwreset_status_checker.py format is different from other python scripts

mstflint-4.11.0 (master )]$ find -name '.py' | xargs file
./cmdif/cmdif.py: Python script, ASCII text executable
./dev_mgt/dev_mgt.py: Python script, ASCII text executable
./ext_libs/iniParser/test/twisted-genhuge.py: Python script, ASCII text executable
./mlxconfig/mstprivhost.py: Python script, ASCII text executable
./mtcr_py/mtcr.py: Python script, ASCII text executable
./mtcr_py/test.py: Python script, ASCII text executable
./reg_access/regaccess.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/mcra.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/mlnx_peripheral_components.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/mlxfwreset_mlnxdriver.py: Python script, ASCII text executable

./small_utils/mlxfwresetlib/mlxfwreset_status_checker.py: Python script, ASCII text executable, with CRLF, LF line terminators

./small_utils/mlxfwresetlib/mlxfwreset_utils.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/pci_device.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/init.py: Python script, ASCII text executable
./small_utils/mlxfwresetlib/logger.py: Python script, ASCII text executable
./small_utils/mstfwreset.py: Python script, ASCII text executable

Please convert the format with 'dos2unix'.

configure: EL6 compiler warnings

On a clean install of EL6:

./configure: line 17373: syntax error near unexpected token -Wno-implicit-fallthrough,' ./configure: line 17373: AX_CHECK_COMPILE_FLAG(-Wno-implicit-fallthrough, CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough", , )'

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)

mstreg can't access registers while mlxreg can

Hi!

Trying to use mstreg, which as far as I understand is the mstflint port or MFT's mlxreg, I noticed that it doesn't seem to be working the same way:

For instance, trying to get PAOS registers from a MQM8790 switch fails with mstreg:

# ./mlxreg/mstreg -d /dev/mst/SW_MT54000_sh03-isw-c03_lid-0x0010 --reg_name PAOS --get
-E- FW burnt on device does not support generic access register

while it works fine with the mlxreg version from MFT:

# mlxreg -d /dev/mst/SW_MT54000_sh03-isw-c03_lid-0x0010 --show_reg PAOS
Field Name      | Address (Bytes) | Offset (Bits) | Size (Bits) | Access
=========================================================================
oper_status     | 0x00000000      | 0             | 4           | RO
admin_status    | 0x00000000      | 8             | 4           | RW
local_port      | 0x00000000      | 16            | 8           | INDEX
swid            | 0x00000000      | 24            | 8           | INDEX
e               | 0x00000004      | 0             | 2           | RW
ee              | 0x00000004      | 30            | 1           | WO
ase             | 0x00000004      | 31            | 1           | WO
=========================================================================

This is with mstflint version 4.14.0:

# ./mlxreg/mstreg -v
mstreg, mstflint 4.14.0, built on Apr 16 2020, 10:29:00. Git SHA Hash: N/A

Is this expected?
Thanks!

Please link shared libraries with '-Wl,-z,now'.

annocheck error message:
Hardened: ./usr/lib64/mstflint/python_tools/c_dev_mgt.so: FAIL: Not linked with -Wl,-z,now.
Hardened: ./usr/lib64/mstflint/python_tools/ccmdif.so: FAIL: Not linked with -Wl,-z,now.
Hardened: ./usr/lib64/mstflint/python_tools/cmtcr.so: FAIL: Not linked with -Wl,-z,now.
Hardened: ./usr/lib64/mstflint/python_tools/rreg_access.so: FAIL: Not linked with -Wl,-z,now.

diff --git a/cmdif/Makefile.am b/cmdif/Makefile.am
index d4f89a2..46604f5 100644
--- a/cmdif/Makefile.am
+++ b/cmdif/Makefile.am
@@ -46,7 +46,7 @@ libcmdif_a_SOURCES = tools_cif.c tools_cif.h icmd_cif_common.c icmd_cif_common.h
 cmdif_pylibdir = $(libdir)/mstflint/python_tools/
 cmdif_pylib_DATA = ${CCMDIF_SO} cmdif.py
 ${CCMDIF_SO}: libcmdif.a
-	$(CC) -g -Wall -pthread -shared ${CFLAGS} *.o -o ${CCMDIF_SO} \
+	$(CC) -g -Wall -pthread -shared ${CFLAGS} ${LDFLAGS} *.o -o ${CCMDIF_SO} \
 	-L$(USER_DIR)/tools_layouts -ltools_layouts -L$(USER_DIR)/${MTCR_CONF_DIR} -lmtcr_ul
 
 CLEANFILES = ${CCMDIF_SO}
diff --git a/dev_mgt/Makefile.am b/dev_mgt/Makefile.am
index 907e5ce..a7e2249 100644
--- a/dev_mgt/Makefile.am
+++ b/dev_mgt/Makefile.am
@@ -50,7 +50,7 @@ dev_mgt_pylib_DATA = c_dev_mgt.so dev_mgt.py
 dist_dev_mgt_pylib_DATA = dev_mgt.py
 
 c_dev_mgt.so: libdev_mgt.a
-	$(CC) -g -Wall -pthread -shared ${CFLAGS} tools_dev_types.o -o c_dev_mgt.so \
+	$(CC) -g -Wall -pthread -shared ${CFLAGS} ${LDFLAGS} tools_dev_types.o -o c_dev_mgt.so \
 	-L$(USER_DIR)/reg_access -lreg_access \
 	-L$(USER_DIR)/tools_layouts -ltools_layouts \
 	-L$(USER_DIR)/${MTCR_CONF_DIR} -lmtcr_ul
diff --git a/mtcr_py/Makefile.am b/mtcr_py/Makefile.am
index 5f5677d..566a870 100644
--- a/mtcr_py/Makefile.am
+++ b/mtcr_py/Makefile.am
@@ -39,7 +39,7 @@ MTCR_DIR = $(USER_DIR)/${MTCR_CONF_DIR}
 mtcr_pylib_DATA = cmtcr.so mtcr.py
 dist_mtcr_pylib_DATA = mtcr.py
 cmtcr.so:
-	$(CC) -g -Wall -pthread -shared ${CFLAGS} $(MTCR_DIR)/*.o -o cmtcr.so
+	$(CC) -g -Wall -pthread -shared ${CFLAGS} ${LDFLAGS} $(MTCR_DIR)/*.o -o cmtcr.so
 
 CLEANFILES = cmtcr.so
 
diff --git a/reg_access/Makefile.am b/reg_access/Makefile.am
index 353fe02..7d70fd8 100644
--- a/reg_access/Makefile.am
+++ b/reg_access/Makefile.am
@@ -53,7 +53,7 @@ reg_access_pylib_DATA = ${RREG_ACCESS_SO} regaccess.py
 dist_reg_access_pylib_DATA = regaccess.py
 
 ${RREG_ACCESS_SO}: libreg_access.a
-	$(CC) -g -Wall -pthread -shared ${CFLAGS} *.o -o ${RREG_ACCESS_SO} \
+	$(CC) -g -Wall -pthread -shared ${CFLAGS} ${LDFLAGS} *.o -o ${RREG_ACCESS_SO} \
 	-L$(USER_DIR)/tools_layouts -ltools_layouts -L$(MTCR_DIR) -lmtcr_ul
 
 CLEANFILES = ${RREG_ACCESS_SO}

Can't compile mstflint-4.9 with gcc-8

Failed to compile mstflint-4.9 with Fedora-28 or Fedora-Rawhide (F29). gcc-8 terminated because "-W-error=cast-function-type" and "-W-error=class-memaccess".

export CFLAGS="$RPM_OPT_FLAGS -Wno-error=cast-function-type"
export CXXFLAGS="$RPM_OPT_FLAGS -std=gnu++98 -Wno-c++11-compat -Wno-error=cast-function-type -Wno-error=class-memaccess"

With those two env parameters, compiling works again. But it is just a workaround, please consider to fix those gcc/g++ syntax error.

thanks

Unsupported device error

Card: connectX-2 EN

I know i'm using a device that is past what MFT and I guess mst supports but what version of this software do I need to use that does. I need to turn off pxe booting on this card

mtcr_ul_com.c:2422:62: error: '/device' directive output may be truncated writing 7 bytes into a region of size between 5 and 126 [-Werror=format-truncation=]

gcc -DHAVE_CONFIG_H -I. -I.. -I../include/mtcr_ul -I../common -W -Wall -g -MP -MD -fPIC -DMTCR_API="" -DMST_UL -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -Wno-error=cast-function-type -Werror -DMST_UL -Wno-format-overflow -Wno-implicit-fallthrough -c -o libmtcr_ul_a-mtcr_ul_com.o test -f 'mtcr_ul_com.c' || echo './'mtcr_ul_com.c
mtcr_ul_com.c: In function 'maccess_reg_mad_ul':
mtcr_ul_com.c:2422:62: error: '/device' directive output may be truncated writing 7 bytes into a region of size between 5 and 126 [-Werror=format-truncation=]
snprintf(subdirname, DEV_DIR_MAX_SIZE - 1, "%s/%.100s/device", dirname, dir->d_name);
^~~~~~~
In file included from /usr/include/stdio.h:862,
from mtcr_ul_com.c:59:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 9 and 130 bytes into a destination of size 127
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:564: libmtcr_ul_a-mtcr_ul_com.o] Error 1
make[2]: Leaving directory '/builddir/build/BUILD/mstflint-4.9.0/mtcr_ul'
make[1]: *** [Makefile:522: all-recursive] Error 1
make[1]: Leaving directory '/builddir/build/BUILD/mstflint-4.9.0'
make: *** [Makefile:408: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.FSqZlp (%build)

This dummy patch fixes the issue:
diff --git a/mtcr_ul/mtcr_ul_com.c b/mtcr_ul/mtcr_ul_com.c
index dd4746c..04b807e 100644
--- a/mtcr_ul/mtcr_ul_com.c
+++ b/mtcr_ul/mtcr_ul_com.c
@@ -2391,7 +2391,7 @@ int mclose_ul(mfile *mf)

#define IBDR_MAX_NAME_SIZE 128
#define BDF_NAME_SIZE 12
-#define DEV_DIR_MAX_SIZE 128
+#define DEV_DIR_MAX_SIZE 256
static
int get_inband_dev_from_pci(char* inband_dev, char* pci_dev)
{

Question about 4.12 user manual supported devices

The document mstflint_User_Manual_v4_12_0.pdf

In section 1.5 "Supported Mellanox ICs "
The ConnectX-6 and Quantum are listed in the 5th generation of devices.

In section 2.2 "Access to Hardware Devices"
The ConnectX-6 and Quantum devices are not listed in the table of devices that mstflint can access.

I am not sure if the two sections should be an echo of each other, but should section 2.2 include the ConnectX-6 and Quantum devices in the table and the supported access methods?

Thank you for your help.

MST:: : get_space_support_status 438: At least one SPACE is not supported

It appears that this error message is the result of a test for which address spaces are supported by a device:

$ git grep "At least one SPACE is not supported"
kernel/mst_main.c:      mst_err("At least one SPACE is not supported\n");

    if (_set_addr_space(dev, AS_CR_SPACE) || _set_addr_space(dev, AS_ICMD)
            || _set_addr_space(dev, AS_SEMAPHORE)) {
        mst_err("At least one SPACE is not supported\n");
        dev->spaces_support_status = SS_NOT_ALL_SPACES_SUPPORTED;
    } else {
        dev->spaces_support_status = SS_ALL_SPACES_SUPPORTED;
    }

As a result of the test with our specific devices, a constant (i.e, SS_NOT_ALL_SPACES_SUPPORTED)is set. But, it does not appear that this constant is ever used elsewhere in the code:

$ git grep "SS_NOT_ALL_SPACES_SUPPORTED"
kernel/mst_main.c:  SS_NOT_ALL_SPACES_SUPPORTED = 2
kernel/mst_main.c:      dev->spaces_support_status = SS_NOT_ALL_SPACES_SUPPORTED;

If this test is determining something useful about the device then perhaps is should be displayed with a meaningful message with INFO status and not as an error message. If the message is of no use to an operator/admin then it should be surpressed regardless of how it is worded.

I do not think that we've looked at whether the same message is seen with CX-5 operating in Infiniband mode so, at this time, I do not know if this is a CX-3 vs. CX-5 issue and/or an Infiniband vs. RoCE issue. Either way, any messages printed by the driver should be meaningful to the operator.

mstflint crash when compiled with 'CXXFLAGS='-Wp,-D_GLIBCXX_ASSERTIONS''

/opt/mstflint-assert-debug/bin/mstflint -y -d 01:00.0 -i /root/fw-ConnectX4Lx-rel-14_24_1000-MCX4121A-ACA_Ax-UEFI-14.17.11-FlexBoot-3.5.603.bin burn

Current FW version on flash:  14.24.1000
New FW version:               14.24.1000

Note: The new FW version is the same as the current FW version on flash.

Do you want to continue ? (y/n) [n] : y

/usr/include/c++/8/bits/stl_vector.h:932: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = unsigned char; _Alloc = std::allocator; std::vector<_Tp, _Alloc>::reference = unsigned char&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.

This hack works for me.

diff --git a/mlxfwops/lib/fs3_ops.cpp b/mlxfwops/lib/fs3_ops.cpp
index bfe8adb..8cf3f5e 100644
--- a/mlxfwops/lib/fs3_ops.cpp
+++ b/mlxfwops/lib/fs3_ops.cpp
@@ -525,7 +525,7 @@ bool Fs3Operations::VerifyTOC(u_int32_t dtoc_addr, bool &bad_signature, VerifyCa
                     }
                     // Only when we have full verify or the info of this section should be collected for query
                     std::vector<u_int8_t> buffv(entry_size_in_bytes);
-                    u_int8_t *buff = (u_int8_t *)(&(buffv[0]));
+                    u_int8_t *buff = (u_int8_t *)(buffv.size() ? (&(buffv[0])) : nullptr);
                     if (show_itoc) {
                         cibfw_itoc_entry_dump(&toc_entry, stdout);
                         if (!DumpFs3CRCCheck(toc_entry.type, phys_addr, entry_size_in_bytes, 0, 0, true, verifyCallBackFunc)) {

I also instrument the code to dump some message for debugging purpose.
mstflint (master *)]$ /opt/mstflint-print/bin/mstflint -d 01:00.0 -i /root/fw-ConnectX4Lx-rel-14_24_1000-MCX4121A-ACA_Ax-UEFI-14.17.11-FlexBoot-3.5.603.bin burn
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb8158, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb8158, entry_size_in_bytes = 650792
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb8158, entry_size_in_bytes = 1024
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb8158, entry_size_in_bytes = 512
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb8158, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb92b8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb92b8, entry_size_in_bytes = 650792
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb92b8, entry_size_in_bytes = 1024
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb92b8, entry_size_in_bytes = 512
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb92b8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb6748, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb6748, entry_size_in_bytes = 1024
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb6748, entry_size_in_bytes = 512
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb6748, entry_size_in_bytes = 320

Current FW version on flash:  14.24.1000
New FW version:               14.24.1000

Note: The new FW version is the same as the current FW version on flash.

Do you want to continue ? (y/n) [n] : y

fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66f8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66f8, entry_size_in_bytes = 650792
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66f8, entry_size_in_bytes = 1024
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66f8, entry_size_in_bytes = 512
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66f8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 256
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 3072
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 896
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 5504
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 11392
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 2304
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 144
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 576
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 4352
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 650792
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 65536
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 2560
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 39184
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 162308
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 55848
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 2891232
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 56608
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 3728
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 7460
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 1024
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 1944
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 8
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 65536
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 65536
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 65536
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 512
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 320
fs3_ops.cpp:VerifyTOC:528: buffv = 0xfffff5fb66e8, entry_size_in_bytes = 0
Initializing image partition - OK
Writing Boot image component - OK
-I- To load new FW run mlxfwreset or reboot machine.

mstflint crash when burn firmware for connectX-5 card

#36

This closed issue fixes the segment fault issue for connectX-4 devices. But we need a similar patch for connectX-5 device. mstflint crash when brun firmware for CX-5 devices. mstflint was built with 'CXXFLAGS='-Wp,-D_GLIBCXX_ASSERTIONS''

diff --git a/mlxfwops/lib/fs4_ops.cpp b/mlxfwops/lib/fs4_ops.cpp
index eb0ca29..4b10307 100644
--- a/mlxfwops/lib/fs4_ops.cpp
+++ b/mlxfwops/lib/fs4_ops.cpp
@@ -403,7 +403,7 @@ bool Fs4Operations::verifyTocEntries(u_int32_t tocAddr, bool show_itoc, bool isD
 
                 // Only when we have full verify or the info of this section should be collected for query
                 std::vector<u_int8_t> buffv(entrySizeInBytes);
-                u_int8_t *buff = (u_int8_t *)(&(buffv[0]));
+                u_int8_t *buff = (u_int8_t *)(buffv.size() ? (&(buffv[0])) : NULL);
 
                 if (show_itoc) {
                     cx5fw_itoc_entry_dump(&tocEntry, stdout);

failed to compile with gcc-8.2.1

make[3]: Entering directory '/root/rpmbuild/BUILD/mstflint-4.11.0/ext_libs/iniParser'
/bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I. -I../.. -I../../ -I../../common -W -Werror -g -MP -MD -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DMST_UL -c -o iniparser.lo iniparser.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../.. -I. -I../.. -I../../ -I../../common -W -Werror -g -MP -MD -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DMST_UL -c iniparser.c -fPIC -DPIC -o .libs/iniparser.o
iniparser.c: In function 'iniparser_load':
iniparser.c:639:30: error: '%s' directive writing up to 1024 bytes into a region of size between 0 and 1024 [-Werror=format-overflow=]
sprintf(tmp, "%s:%s", section, key);
^~ ~~~
In file included from /usr/include/stdio.h:873,
from iniparser.h:58,
from iniparser.c:52:
/usr/include/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 2 and 2050 bytes into a destination of size 1025
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:417: iniparser.lo] Error 1
make[3]: Leaving directory '/root/rpmbuild/BUILD/mstflint-4.11.0/ext_libs/iniParser'
make[3]: *** Waiting for unfinished jobs....
make[3]: Entering directory '/root/rpmbuild/BUILD/mstflint-4.11.0/ext_libs/iniParser'

IBM-branded cards rejected

Hello!

I have a pair of FreeBSD-11 servers connected via InfiniBand. The cards work very nicely -- providing 5 times lower latency than the Gigabit Ethernet -- which makes NFS feel like local drive.

The cards are recognized by the ibv_devinfo utility, that comes with the OS, as:

hca_id: mlx4_0
        transport:                      InfiniBand (0)
        fw_ver:                         2.7.700
        node_guid:                      0002:c903:0005:xxxx
        sys_image_guid:                 0002:c903:0005:xxxy
        vendor_id:                      0x02c9
        vendor_part_id:                 26428
        hw_ver:                         0xA0
        board_id:                       IBM0030000009
        phys_port_cnt:                  2
                port:   1
                        state:                  PORT_DOWN (1)
                        max_mtu:                4096 (5)
                        active_mtu:             4096 (5)
                        sm_lid:                 0
                        port_lid:               0
                        port_lmc:               0x00
                        link_layer:             InfiniBand

                port:   2
                        state:                  PORT_ACTIVE (4)
                        max_mtu:                4096 (5)
                        active_mtu:             4096 (5)
                        sm_lid:                 1
                        port_lid:               1
                        port_lmc:               0x00
                        link_layer:             InfiniBand

Unfortunately, the mstflint-utilities refuse to talk to them:

# mstflint -d pci0:4:0:0 q
FATAL - Can't find device id.
-E- Cannot open Device: pci0:4:0:0. File exists. MFE_UNSUPPORTED_DEVICE

mlxreg: can't write large registers

Hi!

I'm trying to use mlxreg --set to update a switch's node description, but it looks like there's an issue with register sizes, that may be larger than the maximum register size that can be sent in-band.

Specifically, I can read the SPZR register just fine:

# mlxreg -d /dev/mst/SW_MT54000_sh03-isw-c03_lid-0x0010 --reg_name SPZR --get --indexes "swid=0x0"
Sending access register...

Field Name              | Data
=====================================
enh_sw_p0               | 0x00000000
ng                      | 0x00000000
sig                     | 0x00000000
mp                      | 0x00000000
vk                      | 0x00000000
cm                      | 0x00000000
enh_sw_p0_mask          | 0x00000000
ndm                     | 0x00000000
cm2                     | 0x00000000
swid                    | 0x00000000
capability_mask         | 0x4450c848
system_image_guid_h     | 0x1c34da03
system_image_guid_l     | 0x004f6244
node_guid_h             | 0x1c34da03
node_guid_l             | 0x004f6244
v_key_h                 | 0x00000000
v_key_l                 | 0x00000000
capability_mask2        | 0x0000003b
max_pkey                | 0x00000008
node_description[0]     | 0x73683033
node_description[1]     | 0x2d697377
node_description[2]     | 0x2d633033
node_description[3]     | 0x00000000
node_description[4]     | 0x00000000
node_description[5]     | 0x00000000
node_description[6]     | 0x00000000
node_description[7]     | 0x00000000
node_description[8]     | 0x00000000
node_description[9]     | 0x00000000
node_description[10]    | 0x00000000
node_description[11]    | 0x00000000
node_description[12]    | 0x00000000
node_description[13]    | 0x00000000
node_description[14]    | 0x00000000
node_description[15]    | 0x00000000
=====================================

But setting a value for node_description[0] fails with -E- Failed to send access register: Register is too large:

# mlxreg -d /dev/mst/SW_MT54000_sh03-isw-c03_lid-0x0010 --reg_name SPZR --set "ndm=0x1,node_description[0]=0x74657374" --indexes "swid=0x0"
You are about to send access register: SPZR with the following data:
Field Name              | Data    
=====================================
enh_sw_p0               | 0x00000000
ng                      | 0x00000000
sig                     | 0x00000000
mp                      | 0x00000000
vk                      | 0x00000000
cm                      | 0x00000000
enh_sw_p0_mask          | 0x00000000
ndm                     | 0x00000001
cm2                     | 0x00000000
swid                    | 0x00000000
capability_mask         | 0x4450c848
system_image_guid_h     | 0x1c34da03
system_image_guid_l     | 0x004f6244
node_guid_h             | 0x1c34da03
node_guid_l             | 0x004f6244
v_key_h                 | 0x00000000
v_key_l                 | 0x00000000
capability_mask2        | 0x0000003b
max_pkey                | 0x00000008
node_description[0]     | 0x74657374
node_description[1]     | 0x2d697377
node_description[2]     | 0x2d633033
node_description[3]     | 0x00000000
node_description[4]     | 0x00000000
node_description[5]     | 0x00000000
node_description[6]     | 0x00000000
node_description[7]     | 0x00000000
node_description[8]     | 0x00000000
node_description[9]     | 0x00000000
node_description[10]    | 0x00000000
node_description[11]    | 0x00000000
node_description[12]    | 0x00000000
node_description[13]    | 0x00000000
node_description[14]    | 0x00000000
node_description[15]    | 0x00000000
=====================================

 Do you want to continue ? (y/n) [n] : y
 Sending access register...
-E- Failed to send access register: Register is too large

This seems to be related to the fact that the SPZR register has a size of 0x70, while the maximum register size authorized to be sent inband is 0x2c (INBAND_MAX_REG_SIZE = 44, as defined here:

#define INBAND_MAX_REG_SIZE 44

There's same issue with both mlxreg from MFT and mstreg from mstflint.

What would be the best way around this?
Thanks!

-Werror=implicit-fallthrough gcc 7.1.1 (Arch Linux)

Error

[admin@MasMac mstflint]$ make -j
make  all-recursive
make[1]: Entering directory '/home/admin/git/mstflint'
Making all in common
make[2]: Entering directory '/home/admin/git/mstflint/common'
sed -e 's,[@]MFT_VERSION_STR[@],mstflint 4.7.0,g' -e 's,[@]TOOLS_BUILD_TIME[@],Sep 06 2017\, 15:43:52,g' -e 's,[@]TOOLS_GIT_SHA[@],N/A,g' < ./tools_version.py.in > tools_version.py
sed -e 's,[@]MST_LIB_DIR[@],/usr/local/lib,g' -e 's,[@]MST_BIN_DIR[@],/usr/local/bin,g' -e 's,[@]MFTCONF_PREFIX[@],/usr/local,g' < ./python_wrapper.sh > python_wrapper
chmod +x python_wrapper
make[2]: Leaving directory '/home/admin/git/mstflint/common'
Making all in mft_utils
make[2]: Entering directory '/home/admin/git/mstflint/mft_utils'
gcc -DHAVE_CONFIG_H -I. -I..  -I. -I../common -fPIC  -MD -pipe -Wall -W -Werror -fPIC -g -O2 -Werror -DMST_UL -MT mft_sig_handler.o -MD -MP -MF .deps/mft_sig_handler.Tpo -c -o mft_sig_handler.o mft_sig_handler.c
g++ -DHAVE_CONFIG_H -I. -I..  -I. -I../common -fPIC   -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT errmsg.o -MD -MP -MF .deps/errmsg.Tpo -c -o errmsg.o errmsg.cpp
gcc -DHAVE_CONFIG_H -I. -I..  -I. -I../common -fPIC  -MD -pipe -Wall -W -Werror -fPIC -g -O2 -Werror -DMST_UL -MT calc_hw_crc.o -MD -MP -MF .deps/calc_hw_crc.Tpo -c -o calc_hw_crc.o calc_hw_crc.c
g++ -DHAVE_CONFIG_H -I. -I..  -I. -I../common -fPIC   -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT mlarge_buffer.o -MD -MP -MF .deps/mlarge_buffer.Tpo -c -o mlarge_buffer.o mlarge_buffer.cpp
mv -f .deps/calc_hw_crc.Tpo .deps/calc_hw_crc.Po
mv -f .deps/mft_sig_handler.Tpo .deps/mft_sig_handler.Po
mv -f .deps/mlarge_buffer.Tpo .deps/mlarge_buffer.Po
mv -f .deps/errmsg.Tpo .deps/errmsg.Po
rm -f libmftutils.a
ar cru libmftutils.a mft_sig_handler.o errmsg.o calc_hw_crc.o mlarge_buffer.o 
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib libmftutils.a
make[2]: Leaving directory '/home/admin/git/mstflint/mft_utils'
Making all in ext_libs
make[2]: Entering directory '/home/admin/git/mstflint/ext_libs'
Making all in muparser
make[3]: Entering directory '/home/admin/git/mstflint/ext_libs/muparser'
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParserBase.o -MD -MP -MF .deps/muParserBase.Tpo -c -o muParserBase.o muParserBase.cpp
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParserBytecode.o -MD -MP -MF .deps/muParserBytecode.Tpo -c -o muParserBytecode.o muParserBytecode.cpp
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParserCallback.o -MD -MP -MF .deps/muParserCallback.Tpo -c -o muParserCallback.o muParserCallback.cpp
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParser.o -MD -MP -MF .deps/muParser.Tpo -c -o muParser.o muParser.cpp
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParserError.o -MD -MP -MF .deps/muParserError.Tpo -c -o muParserError.o muParserError.cpp
g++ -DHAVE_CONFIG_H -I. -I../..    -W -Werror -g -MP -MD -fPIC -Wno-deprecated-declarations -g -O2 -DHAVE_TERMIOS_H -Werror -DMST_UL -MT muParserTokenReader.o -MD -MP -MF .deps/muParserTokenReader.Tpo -c -o muParserTokenReader.o muParserTokenReader.cpp
mv -f .deps/muParserCallback.Tpo .deps/muParserCallback.Po
muParserBase.cpp: In member function ‘void mu::ParserBase::CheckOprt(const string_type&, const mu::ParserCallback&, const string_type&) const’:
muParserBase.cpp:379:33: error: this statement may fall through [-Werror=implicit-fallthrough=]
       case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
muParserBase.cpp:380:7: note: here
       case cmOPRT_INFIX:   Error(ecINVALID_INFIX_IDENT, -1, a_sName);
       ^~~~
muParserBase.cpp:380:33: error: this statement may fall through [-Werror=implicit-fallthrough=]
       case cmOPRT_INFIX:   Error(ecINVALID_INFIX_IDENT, -1, a_sName);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
muParserBase.cpp:381:7: note: here
       default:             Error(ecINVALID_NAME, -1, a_sName);
       ^~~~~~~
muParserBase.cpp: In member function ‘void mu::ParserBase::CreateRPN() const’:
muParserBase.cpp:1230:17: error: this statement may fall through [-Werror=implicit-fallthrough=]
                 ++stArgCount.top();
                 ^~~~~~~~~~~~~~~~~~
muParserBase.cpp:1233:9: note: here
         case cmEND:
         ^~~~
muParserBase.cpp:1288:33: error: this statement may fall through [-Werror=implicit-fallthrough=]
                 m_nIfElseCounter++;
                 ~~~~~~~~~~~~~~~~^~
muParserBase.cpp:1291:9: note: here
         case cmLAND:
         ^~~~
mv -f .deps/muParser.Tpo .deps/muParser.Po
mv -f .deps/muParserError.Tpo .deps/muParserError.Po
mv -f .deps/muParserBytecode.Tpo .deps/muParserBytecode.Po
mv -f .deps/muParserTokenReader.Tpo .deps/muParserTokenReader.Po
cc1plus: all warnings being treated as errors
make[3]: *** [Makefile:427: muParserBase.o] Error 1
make[3]: Leaving directory '/home/admin/git/mstflint/ext_libs/muparser'
make[2]: *** [Makefile:393: all-recursive] Error 1
make[2]: Leaving directory '/home/admin/git/mstflint/ext_libs'
make[1]: *** [Makefile:526: all-recursive] Error 1
make[1]: Leaving directory '/home/admin/git/mstflint'
make: *** [Makefile:413: all] Error 2

Analysis and Possible Fixes

Analysis 1

Looking more closely at case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); it seems like ParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const string_type &a_sTok) const throws an exception. This means we can just add breaks without any changes in functionality.

Fix 1

For example ext_libs/muparser/muParserBase.cpp:379

switch(a_Callback.GetCode())
{
      case cmOPRT_POSTFIX: Error(ecINVALID_POSTFIX_IDENT, -1, a_sName); break;
      case cmOPRT_INFIX:   Error(ecINVALID_INFIX_IDENT, -1, a_sName); break;
      default:             Error(ecINVALID_NAME, -1, a_sName); break;
}

Analysis 2

For the next fall-through, it's actually intentional ext_libs/muparser/muParserBase.cpp:1226

case cmARG_SEP:
    if (stArgCount.empty())
        Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos());

    ++stArgCount.top();
    // fallthrough intentional (no break!)

case cmEND:
    ApplyRemainingOprt(stOpt, stVal);
    break;

Fix 2

I recommend using the comment scheme described in this article: GCC 7 Implicit Fallthrough.

case cmARG_SEP:
    if (stArgCount.empty())
        Error(ecUNEXPECTED_ARG_SEP, m_pTokenReader->GetPos());

    ++stArgCount.top();
    // Falls through
    // fallthrough intentional (no break!)

case cmEND:
    ApplyRemainingOprt(stOpt, stVal);
    break;

and

case cmIF:
    m_nIfElseCounter++;
    // Falls through
    // fallthrough intentional (no break!)

case cmLAND:

Analysis 3

ext_libs/sqlite/sqlite3.c
More fall-through issues. I'd recommend this as the fastest fix is just to disable the check (lots of instances).

Fix 3

Add -Wimplicit-fallthrough=0 to ext_libs/sqlite/Makefile.am

AM_CFLAGS = -W -Werror -g -MP -MD -DSQLITE_THREADSAFE=0 ${COMPILER_FPIC} -Wimplicit-fallthrough=0

Make sure to re-run ./configure.

Analysis 4

mtcr_ul_com.c: In functionmdevices_v_ul’:
mtcr_ul_com.c:1345:51: error: ‘%sdirective writing up to 255 bytes into a region of size 43 [-Werror=format-overflow=]
             sprintf(physfn, "/sys/bus/pci/devices/%s/physfn", dir->d_name);
                                                   ^~
mtcr_ul_com.c:1345:13: note: ‘sprintfoutput between 29 and 284 bytes into a destination of size 64
             sprintf(physfn, "/sys/bus/pci/devices/%s/physfn", dir->d_name);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mtcr_ul_com.c:1351:46: error: ‘%sdirective writing up to 255 bytes into a region of size 43 [-Werror=format-overflow=]
         sprintf(fname, "/sys/bus/pci/devices/%s/vendor", dir->d_name);
                                              ^~
mtcr_ul_com.c:1351:9: note: ‘sprintfoutput between 29 and 284 bytes into a destination of size 64
         sprintf(fname, "/sys/bus/pci/devices/%s/vendor", dir->d_name);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mtcr_ul_com.c: In functionreopen_pci_as_inband’:
mtcr_ul_com.c:2125:33: error: ‘%sdirective writing up to 255 bytes into a region of size 127 [-Werror=format-overflow=]
         sprintf(subdirname, "%s/%s/device", dirname, dir->d_name);
                                 ^~
mtcr_ul_com.c:2125:9: note: ‘sprintfoutput 9 or more bytes (assuming 264) into a destination of size 128
         sprintf(subdirname, "%s/%s/device", dirname, dir->d_name);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mtcr_ul_com.c:2138:41: error: ‘%sdirective writing up to 255 bytes into a region of size 121 [-Werror=format-overflow=]
             sprintf(inband_dev, "ibdr-0,%s,1", dir->d_name);
                                         ^~
mtcr_ul_com.c:2138:13: note: ‘sprintfoutput between 10 and 265 bytes into a destination of size 128
             sprintf(inband_dev, "ibdr-0,%s,1", dir->d_name);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Notes

There are some more problems with gcc 7.1.1, but these are the first bunch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.