Skip to content

Commit

Permalink
Merge branch 'master_devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGoldbergMellanox committed Jan 20, 2019
2 parents 2171795 + 7366c7f commit 305da35
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 96 deletions.
12 changes: 11 additions & 1 deletion common/python_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ export MSTFLINT_LIB_DIR=$mlibdir
export LD_LIBRARY_PATH=$mlibdir
export MSTFLINT_BIN_DIR=$mbindir
EXEC_NAME=`basename $(readlink -f $0)`
exec /usr/bin/env python $MSTFLINT_PYTHON_TOOLS/$EXEC_NAME/${EXEC_NAME}.py "$@"
which python3 >/dev/null 2>&1
if test $? -eq 0 ; then
PYTHON_EXEC='/usr/bin/env python3'
else
which python2 >/dev/null 2>&1
if test $? -eq 0 ; then
PYTHON_EXEC='/usr/bin/env python2'
fi
fi

exec $PYTHON_EXEC $MSTFLINT_PYTHON_TOOLS/$EXEC_NAME/${EXEC_NAME}.py "$@"
7 changes: 0 additions & 7 deletions dev_mgt/dev_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,3 @@ def isLivefishMode(self):
return not (rc == 0)
else:
raise DevMgtException("Failed to load c_dev_mgt.so/libdev_mgt.dll")


if __name__ == "__main__":
mstdev = "/dev/mst/mt523_pciconf0"
#mstdev = "/dev/mst/mt4113_pciconf0"
devMgt = DevMgt(mstdev)
print(devMgt.isLivefishMode())
9 changes: 9 additions & 0 deletions flint/cmd_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ FlagMetaData::FlagMetaData()
_flags.push_back(new Flag("", "hh", 0));
_flags.push_back(new Flag("i", "image", 1));
_flags.push_back(new Flag("", "qq", 0));
_flags.push_back(new Flag("", "low_cpu", 0));
_flags.push_back(new Flag("", "nofs", 0));
_flags.push_back(new Flag("", "allow_psid_change", 0));
_flags.push_back(new Flag("", "allow_rom_change", 0));
Expand Down Expand Up @@ -501,6 +502,12 @@ void Flint::initCmdParser()
" operation. This may shorten execution time when running over slow interfaces (e.g., I2C, MTUSB-1).\n"
"Commands affected: query");

AddOptions("low_cpu",
' ',
"",
"When specified, cpu usage will be reduced. Run time might be increased\n"
"Commands affected: query");

AddOptions("nofs",
' ',
"",
Expand Down Expand Up @@ -809,6 +816,8 @@ ParseStatus Flint::HandleOption(string name, string value)
} else if (name == "qq") {
_flintParams.quick_query = true;
_flintParams.skip_rom_query = true;
} else if (name == "low_cpu") {
_flintParams.low_cpu = true;
} else if (name == "nofs") {
_flintParams.nofs = true;
} else if (name == "allow_psid_change") {
Expand Down
1 change: 1 addition & 0 deletions flint/flint_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class FlintParams {
bool blank_guids;
bool clear_semaphore;
bool quick_query;
bool low_cpu;
bool skip_rom_query;
bool image_specified;
string image;
Expand Down
3 changes: 3 additions & 0 deletions flint/subcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,9 @@ QuerySubCommand:: ~QuerySubCommand()

FlintStatus QuerySubCommand::executeCommand()
{
if (_flintParams.low_cpu) {
increase_poll_time = 1;
}
if (preFwOps() == FLINT_FAILED) {
return FLINT_FAILED;
}
Expand Down
2 changes: 2 additions & 0 deletions include/mtcr_ul/mtcr_com_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ typedef long long int64_t;

#endif

extern int increase_poll_time;

/*
* MST <--> MTCR API defines
*/
Expand Down
8 changes: 8 additions & 0 deletions mlxsign_lib/mlxsign_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,12 @@ int MlxSignRSA::createRSAFromPEMKeyString(const std::string& pemKey, bool isPri

MlxSignHMAC::MlxSignHMAC()
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
ctx = malloc(sizeof(HMAC_CTX));
HMAC_CTX_init((HMAC_CTX*)ctx);
#else
ctx = HMAC_CTX_new();
#endif
}

int MlxSignHMAC::setKey(const std::vector<u_int8_t>& key)
Expand Down Expand Up @@ -415,8 +419,12 @@ int MlxSignHMAC::getDigest(std::vector<u_int8_t>& digest)

MlxSignHMAC::~MlxSignHMAC()
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX_cleanup((HMAC_CTX*)ctx);
free(ctx);
#else
HMAC_CTX_free((HMAC_CTX*)ctx);
#endif
}

#endif //ENABLE_OPENSSL
2 changes: 1 addition & 1 deletion mtcr_py/mtcr.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MtcrException(Exception):
class MstDevice:
##########################
def __init__(self, dev):
self.mdev = dev
self.mdev = dev.encode('ascii')
self.mf = 0
self.mopenFunc = CMTCR.mopen
self.mopenFunc.restype = c_void_p
Expand Down
12 changes: 11 additions & 1 deletion mtcr_ul/mtcr_ul_icmd_cif.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ enum {
#define QUANTUM_HW_ID 589
#define SPECTRUM2_HW_ID 590

/***** GLOBALS *****/
int increase_poll_time = 0;
/***** GLOBALS *****/

/*************************************************************************************/
/*
* get_version
Expand Down Expand Up @@ -268,7 +272,13 @@ static int go(mfile *mf)
MWRITE4_ICMD(mf, mf->icmd.ctrl_addr, reg, return ME_ICMD_STATUS_CR_FAIL);

DBG_PRINTF("Busy-bit raised. Waiting for command to exec...\n");
char *icmd_sleep_env = getenv("MFT_CMD_SLEEP");
char *icmd_sleep_env;
if (increase_poll_time) {
icmd_sleep_env = "70\0";
}
else {
icmd_sleep_env = getenv("MFT_CMD_SLEEP");
}
int icmd_sleep = -1;
if (icmd_sleep_env) {
char *endptr;
Expand Down
40 changes: 0 additions & 40 deletions reg_access/regaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,43 +275,3 @@ def getSecureFWStatus(self):


####################################################################################
if __name__ == "__main__":

# mstdev = mtcr.MstDevice("/dev/mst/mt4119_pciconf1")
# regAc = RegAccess(mstdev)
#
# reset_level = regAc.sendMFRL(0, REG_ACCESS_METHOD_GET)
# print "reset level is 0x{0:x}".format(reset_level)
#
# uptime = regAc.getFWUptime()
# print "uptime is {0}".format(uptime)
#
# manufacturing_base_mac = regAc.getManufacturingBaseMac()
# print 'manufacturing_base_mac : 0x{0:x}'.format(manufacturing_base_mac)

pci_devices = ['0e:00.1', '08:00.1', '0e:00.0', '08:00.0', '0000:05:00.0']

pci_devices = ['81:00.0', '02:00.0', '82:00.0']

pci_devices = ['05:00.0']
for pci_device in pci_devices:

print("pci device {0}".format(pci_device))
mstdev = mtcr.MstDevice(pci_device)
regAc = RegAccess(mstdev)

regAc.sendMtrcCapTakeOwnership()

reset_level = regAc.sendMFRL(0, REG_ACCESS_METHOD_GET)
print("reset level is 0x{0:x}".format(reset_level))
if mstdev != None:
mstdev.close()

uptime = regAc.getFWUptime()
print("uptime is {0}".format(uptime))

manufacturing_base_mac = regAc.getManufacturingBaseMac()
print('manufacturing_base_mac : 0x{0:x}'.format(manufacturing_base_mac))

secure_fw = RegAccess(pci_device=pci_device).getSecureFWStatus()
print('secure_fw : {0}'.format(secure_fw))
37 changes: 0 additions & 37 deletions small_utils/mlxfwresetlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,38 +1 @@
# Copyright (c) 2004-2010 Mellanox Technologies LTD. All rights reserved.
#
# This software is available to you under a choice of one of two
# licenses. You may choose to be licensed under the terms of the GNU
# General Public License (GPL) Version 2, available from the file
# COPYING in the main directory of this source tree, or the
# OpenIB.org BSD license below:
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# - Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# - Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#--

from mlxfwreset_mlnxdriver import *
from mlxfwreset_status_checker import *
from mlxfwreset_utils import *
from logger import *
from mcra import *
from mlnx_peripheral_components import *
from pci_device import *
3 changes: 2 additions & 1 deletion small_utils/mlxfwresetlib/mlnx_peripheral_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* $Id : mlnx_peripheral_components.py 2017-11-28
* $Authors : Roei Yitzhak (roei@mellanox.com)
"""
from __future__ import print_function

from __future__ import print_function
import platform
Expand Down Expand Up @@ -70,7 +71,7 @@ def discover_pci_devices(self):
raise RuntimeError("Failed to get device PCI address")

for line in out.split('\n'):
# print line
# print(line)
try:
result = re.match(pattern, line)
if result:
Expand Down
8 changes: 1 addition & 7 deletions small_utils/mlxfwresetlib/mlxfwreset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def cmdExec(cmd):
shell=True)
output = p.communicate()
stat = p.wait()
return (stat, output[0], output[1]) # RC, Stdout, Stderr
return (stat, output[0].decode('utf-8'), output[1].decode('utf-8')) # RC, Stdout, Stderr

######################################################################
# Description: Run cmd in loops
Expand Down Expand Up @@ -153,9 +153,3 @@ def getDevDBDF(device,logger=None):
raise RuntimeError("Unsupported OS")




if __name__ == '__main__':
#device = '/dev/mst/mt4119_pciconf1.1'
device = '0:136:0:0'
print(getDevDBDF(device,None))
2 changes: 1 addition & 1 deletion small_utils/mstfwreset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ def check_positive_float(val):
global MstDevObjsSD
global RegAccessObjsSD

# Roei

devicesSD = []
if command == "reset" and not args.skip_socket_direct:

Expand Down

0 comments on commit 305da35

Please sign in to comment.