]> git.openfabrics.org - ~adrianc/mstflint.git/commitdiff
-mtcr_ul.c : ported changes from mft-3.6.0 branch
authorAdrian Chiris <adrianc@mellanox.com>
Thu, 10 Apr 2014 13:36:02 +0000 (16:36 +0300)
committerAdrian Chiris <adrianc@mellanox.com>
Thu, 10 Apr 2014 13:36:02 +0000 (16:36 +0300)
- mxfwops/flint : modifed GetMaxImageSize due to firmware limitations
- mlxconfig: removed bar size configuration as its not supported yet

12 files changed:
flint/subcommands.cpp
mlxconfig/mlxcfg_lib.cpp
mlxconfig/mlxcfg_lib.h
mlxconfig/mlxcfg_parser.cpp
mlxconfig/mlxcfg_ui.cpp
mlxconfig/mlxcfg_ui.h
mlxfwops/lib/fs2_ops.cpp
mlxfwops/lib/fs2_ops.h
mlxfwops/lib/fs3_ops.cpp
mlxfwops/lib/fs3_ops.h
mlxfwops/lib/fw_ops.h
mtcr_ul/mtcr_ul.c

index e3698d5719f5ad78b91233bb50d4089c4a1c90c7..c753a6005ecc5498b156be10717ee12a0118f9e6 100644 (file)
@@ -3761,13 +3761,15 @@ FlintStatus ResetCfgSubCommand::executeCommand()
     if (preFwOps() == FLINT_FAILED) {
         return FLINT_FAILED;
     }
-
-    if (!askUser("reset non-volatile configuration?")) {
+    printf("-W- Resetting device configuration using Flint should be done as a last resort.\n");
+    printf("-W- Please attempt to reset configuration via mlxconfig tool if possible.\n");
+    printf("-W- Only proceed if you know what you are doing.\n");
+    if (!askUser("reset non-volatile configuration")) {
        return FLINT_FAILED;
     }
 
     printf("Resetting...");
-    if (!_fwOps->FwResetNvData(resetCfgCbFunc)){
+    if (!_fwOps->FwResetNvData()){
        printf(" Failed!\n");
         reportErr(true, FLINT_RESET_CFG_ERROR, _fwOps->err());
         return FLINT_FAILED;
index 6e20ddb20e0557bfbe212916114221f68a0cae0f..88adadee05e16684fadea6ad5f724898d29eec58 100644 (file)
 #define WOL_P2_MASK 0x4
 #define VPI_P1_MASK 0x8
 #define VPI_P2_MASK 0x10
-#define BAR_SZ_MASK 0x20
 
 #define TOOL_CAP_BITS_ADDR 0xc0
 #define MAX_VFS_ADDR 0x38
-#define MAX_BAR_SZ_ADDR 0xc8
 #define DEFAULT_BAR_SZ_ADDR 0x48
 
 // for debug:
@@ -282,112 +280,10 @@ bool MlxCfgOps::WolParams::isLegal(mfile* mf)
     return (_wolMagicEn == 0 || _wolMagicEn == 1 );
 }
 
-/*
- *  BarSzParams Implementation
- */
-
-void MlxCfgOps::BarSzParams::setParam(mlxCfgParam paramType, u_int32_t val)
-{
-    if ((paramType == Mcp_Log_Bar_Size) ) {
-        _logBarSz = val;
-    }
-}
-
-u_int32_t MlxCfgOps::BarSzParams::getParam(mlxCfgParam paramType)
-{
-    if (paramType == Mcp_Log_Bar_Size) {
-        return _logBarSz;
-    }
-    return MLXCFG_UNKNOWN;
-}
-
-McStatus MlxCfgOps::BarSzParams::getFromDev(mfile* mf)
-{
-    if (_updated) {
-        return MCE_SUCCESS;
-    }
-    McStatus rc;
-    // prep tlv
-    u_int8_t buff[tools_bar_size_size()];
-    struct tools_bar_size barSzTlv;
-    memset(buff, 0, tools_bar_size_size());
-    memset(&barSzTlv, 0, sizeof(struct tools_bar_size));
-    // pack it
-    tools_bar_size_pack(&barSzTlv, buff);
-    // send it
-    rc = mnvaCom(mf, buff, tools_bar_size_size(), tlvType, REG_ACCESS_METHOD_GET, 0);
-    // check rc
-    if (rc) {
-        return rc;
-    }
-    // unpack and update
-    tools_bar_size_unpack(&barSzTlv, buff);
-    _logBarSz = _logBarSz == MLXCFG_UNKNOWN ? barSzTlv.log_uar_bar_size : _logBarSz ;
-    _updated = true;
-
-    return MCE_SUCCESS;
-}
-
-McStatus MlxCfgOps::BarSzParams::setOnDev(mfile* mf)
-{
-    McStatus rc;
-    if (_logBarSz == MLXCFG_UNKNOWN) {
-        rc = getFromDev(mf);
-        if (rc) {
-            if (rc == MCE_RES_NOT_AVAIL) {
-                return MCE_INCOMPLETE_PARAMS;
-            }
-            return rc;
-        }
-    }
-    if (!isLegal()) {
-        return MCE_BAD_PARAM_VAL;
-    }
-
-    // prep tlv
-    u_int8_t buff[tools_bar_size_size()];
-    struct tools_bar_size barSzTlv;
-
-    memset(buff, 0, tools_bar_size_size());
-    memset(&barSzTlv, 0, sizeof(struct tools_bar_size));
-
-    barSzTlv.log_uar_bar_size= _logBarSz;
-    // pack it
-    tools_bar_size_pack(&barSzTlv, buff);
-    // send it
-    rc = mnvaCom(mf, buff, tools_bar_size_size(), tlvType, REG_ACCESS_METHOD_SET, 0);
-    // check rc
-    if (rc) {
-        return rc;
-    }
-    _updated = false;
-    return MCE_SUCCESS;
-}
-
-McStatus MlxCfgOps::BarSzParams::updateBarSzInfo(mfile* mf)
-{
-    u_int64_t data = 0;
-    int rc = tools_cmdif_query_dev_cap(mf, MAX_BAR_SZ_ADDR, &data);
-    if (rc) {
-        return translateRc((MError)rc);
-    }
-    _maxLogBarSz = (u_int32_t)(data & 0xffffffff);
-    _currLogBarSz = (u_int32_t)(data >> 32);
-    //printf("-D- vec 0x%lx  max %d  curr %d\n", data, maxBarSz, currBarSz);
-    return MCE_SUCCESS;
-}
-
-bool MlxCfgOps::BarSzParams::isLegal(mfile* mf)
-{
-    (void)mf;
-    return (_logBarSz < _maxLogBarSz );
-}
-
 /*
  *  VpiParams Implementation
  */
 
-
 void MlxCfgOps::VpiParams::setParam(mlxCfgParam paramType, u_int32_t val)
 {
     if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2) ) {
@@ -486,7 +382,6 @@ MlxCfgOps::MlxCfgOps()
     _cfgList[Mct_Wol_P2] = new WolParams(2);
     _cfgList[Mct_Vpi_P1] = new VpiParams(1);
     _cfgList[Mct_Vpi_P2] = new VpiParams(2);
-    _cfgList[Mct_Bar_Size] = new BarSzParams();
     return;
 }
 
@@ -564,14 +459,6 @@ McStatus MlxCfgOps::openComChk()
             return rc;
         }
     }
-
-    // get max/current bar size
-    if (supportsCfg(Mct_Bar_Size)) {
-        McStatus rc = static_cast<BarSzParams*>(_cfgList[Mct_Bar_Size])->updateBarSzInfo(_mf);
-        if (rc) {
-            return rc;
-        }
-    }
     return MCE_SUCCESS;
 }
 
@@ -600,9 +487,6 @@ bool MlxCfgOps::supportsCfg(mlxCfgType cfg)
     if (!isLegal(cfg)) {
         return false;
     }
-    if (cfg == Mct_Bar_Size || cfg == Mct_Vpi_P1  || cfg == Mct_Vpi_P2) { // dont enable these just yet, no FW support
-        return false;
-    }
     return _suppVec & cfgSuppMask[cfg];
 }
 
@@ -703,7 +587,7 @@ bool MlxCfgOps::isLegal(mlxCfgParam cfg)
     return (cfg >= Mcp_Sriov_En && cfg < Mcp_Last) ;
 }
 
-u_int64_t MlxCfgOps::cfgSuppMask[Mct_Last] = {SRIOV_MASK, WOL_P1_MASK, WOL_P2_MASK , VPI_P1_MASK, VPI_P2_MASK, BAR_SZ_MASK};
+u_int64_t MlxCfgOps::cfgSuppMask[Mct_Last] = {SRIOV_MASK, WOL_P1_MASK, WOL_P2_MASK , VPI_P1_MASK, VPI_P2_MASK};
 
 mlxCfgType MlxCfgOps::cfgParam2Type(mlxCfgParam param)
 {
@@ -720,8 +604,6 @@ mlxCfgType MlxCfgOps::cfgParam2Type(mlxCfgParam param)
         return Mct_Vpi_P1;
     case Mcp_Link_Type_P2 :
         return Mct_Vpi_P2;
-    case Mcp_Log_Bar_Size :
-        return Mct_Bar_Size;
     default :
             return Mct_Last;
     }
index 8f2efcb3de78cb27dbc7368fea5ac0e2369b5e64..fe53e0dab0e24a189e6d7dc87f4a4f554ed4352b 100644 (file)
@@ -45,7 +45,6 @@
 #define WOL_TYPE 0x10
 #define SRIOV_TYPE 0x11
 #define VPI_TYPE 0x12
-#define BAR_SIZE_TYPE 0x13
 
 
 
@@ -89,7 +88,6 @@ typedef enum {
     Mct_Wol_P2,
     Mct_Vpi_P1,
     Mct_Vpi_P2,
-    Mct_Bar_Size,
     Mct_Last
 } mlxCfgType;
 
@@ -100,7 +98,6 @@ typedef enum {
     Mcp_Wol_Magic_En_P2,
     Mcp_Link_Type_P1,
     Mcp_Link_Type_P2,
-    Mcp_Log_Bar_Size,
     Mcp_Last
 } mlxCfgParam;
 
@@ -210,29 +207,6 @@ private:
         u_int32_t _linkType;
     };
 
-    class BarSzParams : public CfgParams
-    {
-    public:
-        BarSzParams() : CfgParams(Mct_Bar_Size, BAR_SIZE_TYPE) ,_maxLogBarSz(1), _currLogBarSz(1), _logBarSz(MLXCFG_UNKNOWN) {}
-        ~BarSzParams() {};
-
-        virtual void setParam(mlxCfgParam paramType, u_int32_t val);
-        virtual u_int32_t getParam(mlxCfgParam paramType);
-
-        virtual McStatus getFromDev(mfile* mf);
-        virtual McStatus setOnDev(mfile* mf);
-
-        McStatus updateBarSzInfo(mfile* mf);
-
-    private:
-        virtual bool isLegal(mfile* mf=NULL);
-        u_int32_t _maxLogBarSz;
-        u_int32_t _currLogBarSz;
-        u_int32_t _logBarSz;
-
-    };
-
-
     McStatus openComChk();
     McStatus supportsToolsHCR();
     bool isLegal(mlxCfgType cfg);
index 0fa9f9c9d07c6ed5273bf33a4ab4f7730213dbad..ae2f559b0426d7978f39d084121b3398b5e8734d 100644 (file)
@@ -30,7 +30,6 @@
  * SOFTWARE.
  */
 
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <algorithm>
@@ -92,7 +91,6 @@ void MlxCfg::printHelp()
     printf(IDENT2"WOL_PORT2\t\t: WOL_MAGIC_EN_P2=<1|0>\n");
     printf(IDENT2"VPI_SETTINGS_PORT1\t: LINK_TYPE_P1=<1|2|3> , 1=Infiniband 2=Ethernet 3=VPI(auto-sense).\n");
     printf(IDENT2"VPI_SETTINGS_PORT2\t: LINK_TYPE_P2=<1|2|3>\n");
-    printf(IDENT2"BAR_SIZE\t\t: LOG_BAR_SIZE=<Base_2_log_in_mb> , example: for 8Mb bar size set LOG_BAR_SIZE=3\n");
     printf("\n");
     printf(IDENT"Examples:\n");
     printf(IDENT2"%-35s: %s\n", "To query current Configuration", MLXCFG_NAME" -d "MST_DEV_EXAMPLE" query");
index 5ff5deb1f39ac9ba84b4df9411d44727823c6113..aa3e8582d765f0ef91965ca6cd776b1318f616f0 100644 (file)
@@ -30,7 +30,6 @@
  * SOFTWARE.
  */
 
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -79,8 +78,9 @@ void TerminationHandler(int signum)
     fatal_error_in_progress = 1;
 
     signal (signum, SIG_DFL);
-    printf("\n Received signal %d.\n", signum);
+    printf("\n Received signal %d. \n", signum);
     fflush(stdout);
+
     raise(signum);
 }
 
@@ -121,7 +121,7 @@ void initHandler()
 #endif
 
 std::string MlxCfgParams::param2str[Mcp_Last]= {"SRIOV_EN", "NUM_OF_VFS", "WOL_MAGIC_EN_P1", "WOL_MAGIC_EN_P2",\
-                                                "LINK_TYPE_P1", "LINK_TYPE_P2", "LOG_BAR_SIZE"};
+                                                "LINK_TYPE_P1", "LINK_TYPE_P2"};
 
 u_int32_t MlxCfgParams::getParamVal(mlxCfgParam p)
 {
@@ -171,9 +171,8 @@ if (question == NULL) {
      ansbuff[0] = '\0';
      fflush(stdout);
      //fgets(ansbuff, 30, stdin);
-     int cnt = fscanf(stdin, "%30s", ansbuff);
-     (void)cnt; // avoid errors
-
+     int rc=fscanf(stdin, "%30s", ansbuff);
+     (void)rc; // avoid warnings
      if (  strcasecmp(ansbuff, "y") &&
            strcasecmp(ansbuff, "yes"))  {
 
index f750a7edc1aa3c34de6fc23519804cf45955eb36..b9798f8d810886eb5a8bc454275e111476f9118f 100644 (file)
@@ -30,7 +30,6 @@
  * SOFTWARE.
  */
 
-
 #ifndef MLXCFG_UI_H_
 #define MLXCFG_UI_H_
 
index 8db0f5c7b5446180aaf2754182a37bf003fce38d..cda498bfd61f76aa11a33321ed2bbff2a8c105cc 100644 (file)
@@ -211,8 +211,11 @@ bool Fs2Operations::ParseInfoSect(u_int8_t* buff, u_int32_t byteSize) {
 
         case II_ConfigArea: {
             // configuration area should always exsist
-            _fs2ImgInfo.ext_info.config_sectors = __be32_to_cpu(*(p + 1));;
-            _fs2ImgInfo.ext_info.config_pad = __be32_to_cpu(*(p + 2));;
+            _fs2ImgInfo.ext_info.config_sectors = __be32_to_cpu(*(p + 1));
+            _fs2ImgInfo.ext_info.config_pad = __be32_to_cpu(*(p + 2));
+            if (tagSize > 0x8){//fw_log_sector_size is also found
+                _fs2ImgInfo.fw_sector_size = (1 << __be32_to_cpu(*(p + 3))) * 1024;// the base value is 1kb i.e 1024
+            }
         }
             break;
 
@@ -743,30 +746,34 @@ bool Fs2Operations::FwQuery(fw_info_t *fwInfo, bool readRom, bool isStripedImage
 }
 
 #define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define CX_DFLT_SECTOR_SIZE 0x10000
+#define SX_DFLT_SECTOR_SIZE 0x1000
+#define MAX_CONFIG_AREA_SIZE 0x10000
 
-bool Fs2Operations::GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t imgConfigSectors,\
-        u_int32_t &max_image_size)
+u_int32_t Fs2Operations::getDefaultSectorSz()
 {
-    //printf("-D- flash_info->configAddr1 = %#x, image_info->configAddr1 = %#x\n", flash_info->configAddr1, image_info->configAddr1);
-    //printf("-D- flash_info->configSize = %#x, _ignore_config_section = %#x, image_info->configExists = %#x\n", flash_info->configSize, _ignore_config_section,
-    //        image_info->configExists);
-    // max_image_size = (image_is_fs) ? flash_size / 2 : flash_size;
-/*
-    if (!ignore_config_section && flash_info->imageOk && (image_info->isConfigurable || flash_info->isConfigurable)) {
-        // Configurable image and there is a configuration burnt in the flash
-        if (image_info->isFailsafe) { // failsafe image
-            max_image_size = (flash_size / 2) - flash_info->configSize;
-        } else { // non-faislafe image
-            // Get the minimum config addr
-            max_image_size = flash_info->configAddr2;
-        }
-    } else {
-        // Non-configurable image or the user asked to ignore the configuration section
-    }
-*/
-
+    // for ConnectX family  default sector size is 64kb else 4kb
+    // all of this mess is because the sector_size written in the INI doesnt always correspond to the actual flash sector_size
+    // and as for the calculation of the maximal image size we want to be synced with the FW or take worst case scenario.
+    // we need this method as we only started collecting the fw_sector_size from MFT-3.6.0 so if the image was generated with
+    // an older mlxburn the fw_sector_size wount be available
+    u_int32_t devid = _ioAccess->get_dev_id();
+    switch (devid) {
+    case CX_HW_ID:
+    case CX3_HW_ID:
+    case CX3_PRO_HW_ID:
+        return CX_DFLT_SECTOR_SIZE;
+    default:
+        return SX_DFLT_SECTOR_SIZE;
+    }
+    // we shouldnt reach here
+    return 0;
+}
 
-    // Non-configurable image or the user asked to ignore the configuration section
+bool Fs2Operations::GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t imgConfigSectors, u_int32_t imgFwSectorSz,\
+        u_int32_t &max_image_size)
+{
+    /*
         u_int32_t sector_size = _ioAccess->get_sector_size();
         u_int32_t config_sectors = MY_MAX(imgConfigSectors, _fs2ImgInfo.ext_info.config_sectors);
         if (image_is_fs) {
@@ -775,7 +782,31 @@ bool Fs2Operations::GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_in
             // For non FS image, there's an optional offset + 2 consecutive config areas
             max_image_size = flash_size - (config_sectors * 2 + _fs2ImgInfo.ext_info.config_pad) * sector_size;
         }
-
+        */
+    /* new methodology:
+     * a.  for CX2/CX3/PRO: in case fw_sector_size is present  reserve : num_of_config_sectors * fw_sector_size
+     * b.  for CX2/CX3/PRO: in case sector_size isnt present assume sector size is 64kb and reserve: num_of_config_sectors * 64k
+     * c.  for SwitchX: in case fw_sector_size is present reserve : ( num_of_config_sectors + config_padd) * fw_sector_size
+     * d.  for SwitchX: in case sector_size isnt present assume sector size is 4kb and reserve: ( num_of_config_sectors + config_padd) *4k
+     *   ** on ALL cases we will impose the limitation of reserving at most 64kb to the NV configuration.
+     *   ** config_pad might be != 0 on SwitchX only.
+     *   ** To Orenks knowledge there arent any SwitchX with flashes that dont support 4kb.
+     */
+    u_int32_t sector_size = (imgFwSectorSz != 0 || _fs2ImgInfo.fw_sector_size != 0) ?\
+            MY_MAX(imgFwSectorSz, _fs2ImgInfo.fw_sector_size) : getDefaultSectorSz();
+    u_int32_t config_sectors = MY_MAX(imgConfigSectors, _fs2ImgInfo.ext_info.config_sectors);
+    u_int32_t areaToReserve = config_sectors * sector_size;
+    // we dont want to exceed 64kb of reserved space
+    areaToReserve = areaToReserve > MAX_CONFIG_AREA_SIZE ? MAX_CONFIG_AREA_SIZE : areaToReserve;
+    //printf("-D- sector_size: 0x%x, config_sectors: %d, areaToReserve: 0x%x, config_pad: %d\n"
+            //, sector_size, config_sectors, areaToReserve, _fs2ImgInfo.ext_info.config_pad);
+    if (image_is_fs) {
+        // why do we take config padding of the image info of the device and not the image to be burnt or the maximum between them??
+        max_image_size = (flash_size / 2) - (areaToReserve + (_fs2ImgInfo.ext_info.config_pad * sector_size));
+    } else {
+        // For non FS image, there's an optional offset + 2 consecutive config areas
+        max_image_size = flash_size - (areaToReserve * 2 + _fs2ImgInfo.ext_info.config_pad*sector_size);
+    }
     return true;
 }
 
@@ -842,7 +873,7 @@ bool Fs2Operations::Fs2FailSafeBurn(Fs2Operations &imageOps,
 
     u_int32_t max_image_size;
     if (!GetMaxImageSize(f->get_size(), imageOps._fwImgInfo.ext_info.is_failsafe,\
-            imageOps._fs2ImgInfo.ext_info.config_sectors, max_image_size)) {
+            imageOps._fs2ImgInfo.ext_info.config_sectors, imageOps._fs2ImgInfo.fw_sector_size, max_image_size)) {
         return false;
     }
     //printf("-D- max image size : %d, image_size : %d\n",max_image_size, imageOps._fwImgInfo.ext_info.image_size);
@@ -1936,9 +1967,8 @@ bool Fs2Operations::FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFu
 
 }
 
-bool Fs2Operations::FwResetNvData(ProgressCallBack progressFunc)
+bool Fs2Operations::FwResetNvData()
 {
-       (void)progressFunc;
 
     if (!_ioAccess->is_flash()) {
        return errmsg("Cannot perform operation on Image");
@@ -1950,26 +1980,34 @@ bool Fs2Operations::FwResetNvData(ProgressCallBack progressFunc)
     u_int32_t devId = _ioAccess->get_dev_id();
     if ( devId != CX3_HW_ID && devId != CX3_PRO_HW_ID ) {
         // TODO: Indicate the device name.
-        return errmsg("Unsupported device type %d", _fwImgInfo.ext_info.dev_type);
+        return errmsg("Unsupported device type(%d). Can only perform operation on CX3/CX3-PRO ", _fwImgInfo.ext_info.dev_type);
     }
 
-    // find configuration section base addr = (flash size - (config_sectors + config_pad)*sector_size)
+    if (_fs2ImgInfo.fw_sector_size == 0) {// if fw was generated with old mft i.e without the fw_sector_size than we dont allow this operation
+        return errmsg("Firmware was generated with old MFT, please use MFT-3.6.0 or above");
+    }
 
-    u_int32_t sectorSize = _ioAccess->get_sector_size();
-    u_int32_t AvailFlashSize = _fwImgInfo.actuallyFailsafe ? (_ioAccess->get_size()/2) : _ioAccess->get_size();
+    // find configuration section base addr = (flash size - (config_sectors + config_pad)*64k)
+
+    u_int32_t availFlashSize = _fwImgInfo.actuallyFailsafe ? (_ioAccess->get_size()/2) : _ioAccess->get_size();
+    u_int32_t fwSectorSz = _fs2ImgInfo.fw_sector_size != 0 ? _fs2ImgInfo.fw_sector_size : getDefaultSectorSz();
+    u_int32_t reservedArea = _fs2ImgInfo.ext_info.config_sectors * fwSectorSz;
+    reservedArea = reservedArea > MAX_CONFIG_AREA_SIZE ? MAX_CONFIG_AREA_SIZE : reservedArea;
     u_int32_t configBaseAddr;
        if (_fwImgInfo.actuallyFailsafe) {
-               configBaseAddr = AvailFlashSize  - ((_fs2ImgInfo.ext_info.config_sectors + _fs2ImgInfo.ext_info.config_pad) * sectorSize);
+               configBaseAddr = availFlashSize  - (reservedArea + _fs2ImgInfo.ext_info.config_pad * fwSectorSz) ;
        } else {
                // For non FS image, there's an optional offset + 2 consecutive config areas
-        configBaseAddr = AvailFlashSize - (_fs2ImgInfo.ext_info.config_sectors * 2 + _fs2ImgInfo.ext_info.config_pad) * sectorSize;
+        configBaseAddr = availFlashSize - (reservedArea* 2 + (_fs2ImgInfo.ext_info.config_pad * fwSectorSz));
        }
 
     //printf("-D- config_sectors:0x%x config_pads: 0x%x , sector_size:0x%x, configBaseAddr:0x%x, flashSize:0x%x\n",
-       //              _fs2ImgInfo.ext_info.config_sectors, _fs2ImgInfo.ext_info.config_pad, _ioAccess->get_sector_size(),configBaseAddr, AvailFlashSize);
+                       //_fs2ImgInfo.ext_info.config_sectors, _fs2ImgInfo.ext_info.config_pad, fwSectorSz,configBaseAddr, availFlashSize);
 
-       //erase addresses : configBaseAddr-AvailFlashSize
-       for (u_int32_t eraseAddr=configBaseAddr; eraseAddr<AvailFlashSize; eraseAddr+=sectorSize ) {
+       //erase addresses : [configBaseAddr..AvailFlashSize]
+    u_int32_t sectorSize = _ioAccess->get_sector_size();
+    u_int32_t configEndAddr = availFlashSize - (_fs2ImgInfo.ext_info.config_pad * fwSectorSz);
+       for (u_int32_t eraseAddr=configBaseAddr; eraseAddr < configEndAddr; eraseAddr+=sectorSize ) {
                if (!((Flash*)_ioAccess)->erase_sector(eraseAddr)) {
                        return errmsg("failed to erase configuration address: 0x%x. %s", eraseAddr, _ioAccess->err());
                }
index 203869c148ec354d5861b2da9e9c2b6132e8f3b8..0fc63dba6b223ca18c507153de9a307dd585be2c 100644 (file)
@@ -64,7 +64,7 @@ public:
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL);
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL);
     virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL);
-    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL);
+    virtual bool FwResetNvData();
 
     virtual bool FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sectInfo);
 
@@ -118,6 +118,7 @@ private:
         bool      isConfigurable;
         u_int32_t    infoSectPtr;
         u_int32_t    guidPtr;
+        u_int32_t   fw_sector_size;
 
     };
 
@@ -133,7 +134,8 @@ private:
     bool checkGen(u_int32_t beg,u_int32_t offs, u_int32_t& next, const char *pref, VerifyCallBack verifyCallBackFunc = (VerifyCallBack)NULL);
     bool ParseInfoSect(u_int8_t* buff, u_int32_t byteSize);
     bool Fs2IntQuery(bool readRom = true, bool isStripedImage=false);
-    bool GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t imgConfigSectors, u_int32_t &max_image_size);
+    u_int32_t getDefaultSectorSz();
+    bool GetMaxImageSize(u_int32_t flash_size, bool image_is_fs, u_int32_t imgConfigSectors, u_int32_t imgFwSectorSz, u_int32_t &max_image_size);
     bool UpdateFullImageCRC(u_int32_t* buff, u_int32_t size, bool blank_guids);
     bool Fs2FailSafeBurn(Fs2Operations &imageOps, bool allow_nofs, const char* pre_message,
             ProgressCallBack progressFunc);
index 050db3ebd8aa6987fddd06d210f7dcb0df5da315..f5461f40b6562af99a843e893f5de6152c051136 100644 (file)
@@ -1390,9 +1390,8 @@ bool Fs3Operations::FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFu
     return errmsg("Set access key not supported.");
 }
 
-bool Fs3Operations::FwResetNvData(ProgressCallBack progressFunc)
+bool Fs3Operations::FwResetNvData()
 {
-       (void)progressFunc;
        return errmsg("Unsupported Device, can only reset configuration on a CX3/3-PRO device.");
        /*
        // future support for cx4
index 236cd6d5d614f95222bbb5fd3137f4d71b604a14..d845a48e64ce64ed5f200a9755fb665846e1b4f0 100644 (file)
@@ -72,7 +72,7 @@ public:
     virtual bool FwSetVSD(char* vsdStr, ProgressCallBack progressFunc=(ProgressCallBack)NULL, PrintCallBack printFunc=(PrintCallBack)NULL);
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL);
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL);
-    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL);
+    virtual bool FwResetNvData();
     virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL);
 
 
index df767e9dbdb62856e595269a9baeb43bbd0c32ae..af107cb0365722ea82b95bd4ec875fcbe70a8580 100644 (file)
@@ -100,7 +100,7 @@ public:
     virtual bool FwSetVPD(char* vpdFileStr, PrintCallBack callBackFunc=(PrintCallBack)NULL) = 0;
     virtual bool FwSetAccessKey(hw_key_t userKey, ProgressCallBack progressFunc=(ProgressCallBack)NULL) = 0;
     virtual bool FwGetSection (u_int32_t sectType, std::vector<u_int8_t>& sectInfo)= 0;
-    virtual bool FwResetNvData(ProgressCallBack progressFunc=(ProgressCallBack)NULL) = 0;
+    virtual bool FwResetNvData() = 0;
     virtual bool FwShiftDevData(PrintCallBack progressFunc=(PrintCallBack)NULL) = 0;
 
     void FwCleanUp();
index af454fd6ffa41996a81f7f40bcf9de80c416cfc4..3670362c4354c0e3214b319de8e32224e71c75ba 100644 (file)
@@ -797,8 +797,12 @@ int mdevices(char *buf, int len, int mask)
         if (dir->d_name[0] == '.') {
             continue;
         }
-        sprintf(fname, "/sys/bus/pci/devices/%s/vendor", dir->d_name);
         sz = strlen(dir->d_name);
+        if (sz > 4 && strcmp(dir->d_name + sz - 4, "00.0")) {
+        // Skip virtual functions
+            continue;
+        }
+        sprintf(fname, "/sys/bus/pci/devices/%s/vendor", dir->d_name);
         f = fopen(fname, "r");
         if (f == NULL) {
             ndevs = -2;