1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739
|
/*
* Copyright (C) Jan 2013 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.
*
* mlxcfg_param_lib.cpp
*
* Created on: Mar 22, 2015
* Author: adrianc
*/
#include <signal.h>
#include <math.h>
#include <sstream>
#include <string>
#include <mft_sig_handler.h>
#include <reg_access/reg_access.h>
#include <bit_slice.h>
#include <cmdif/tools_cif.h>
#include <mtcr.h>
#include <compatibility.h>
#include "mlxcfg_param_lib.h"
#include "mlxcfg_status.h"
#include "mlxcfg_utils.h"
enum {
SRIOV_MASK = 0x1,
WOL_P1_MASK = 0x2,
WOL_P2_MASK = 0x4,
VPI_P1_MASK = 0x8,
VPI_P2_MASK = 0x10,
BAR_SZ_MASK = 0x20
};
// tlv classes:
enum {
CLASS_GLOBAL = 0x0,
CLASS_PHYS_PORT = 0x1,
CLASS_BMC = 0x2,
CLASS_PER_HOST = 0x3,
CLASS_ESWITCH = 0x4
};
#define MAX_VFS_ADDR 0x38
#define MAX_BAR_SZ_ADDR 0xc8
#define DEFAULT_BAR_SZ_ADDR 0x48
/*
* Macros for getting and settings a TLV
*/
// TODO: adrianc: add macro for nvqc tlv and use it in cfgSupported for 5th gen Tlvs
/*
* Macros Below rely on the fact that the user has implemented within the parameter class:
* void updateClassAttrFromTlv(void*);
* void updateTLVFromClassAttr(void*);
*
* those method do what they imply: update the class internal memeber from TLV and via versa.
*/
#define SET_ON_DEV_5TH_GEN(mf, ignoreCheck, tlvStructName, tlvNameStr) \
MError __mRc; \
if (!(ignoreCheck) && !checkCfg()) { \
return MCE_BAD_PARAMS; \
} \
int __tlvBuffSize = tlvStructName##_size(); \
u_int8_t *__tlvBuff = new u_int8_t[__tlvBuffSize];\
memset(__tlvBuff, 0, __tlvBuffSize); \
struct tlvStructName __tlvStruct; \
memset(&__tlvStruct, 0, sizeof(__tlvStruct)); \
__mRc = mnvaCom5thGen(mf, __tlvBuff, __tlvBuffSize, getTlvTypeBe(), REG_ACCESS_METHOD_GET); \
if (__mRc && __mRc != ME_REG_ACCESS_RES_NOT_AVLBL) { \
delete[] __tlvBuff; \
return errmsg("failed to set %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
tlvStructName##_unpack(&__tlvStruct, __tlvBuff); \
updateTlvFromClassAttr((void*)&__tlvStruct); \
tlvStructName##_pack(&__tlvStruct, __tlvBuff); \
__mRc = mnvaCom5thGen(mf, __tlvBuff, __tlvBuffSize, getTlvTypeBe(), REG_ACCESS_METHOD_SET); \
delete[] __tlvBuff; \
if (__mRc) { \
return errmsg("failed to set %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
_updated = false; \
return MCE_SUCCESS
#define GET_DEFAULT_5TH_GEN(mf, tlvStructName, tlvNameStr) \
MError __mRc; \
int __tlvBuffSize = tlvStructName##_size(); \
u_int8_t *__tlvBuff = new u_int8_t[__tlvBuffSize]; \
memset(__tlvBuff, 0, __tlvBuffSize); \
struct tlvStructName __tlvStruct; \
memset(&__tlvStruct, 0, sizeof(__tlvStruct)); \
__mRc = mnvaCom5thGen(mf, &__tlvBuff[0], __tlvBuffSize, getTlvTypeBe(), REG_ACCESS_METHOD_GET, true); \
if (__mRc) { \
delete[] __tlvBuff; \
if (__mRc == ME_REG_ACCESS_RES_NOT_AVLBL) { \
return MCE_SUCCESS; \
} \
return errmsg("Failed to get %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
tlvStructName##_unpack(&__tlvStruct, &__tlvBuff[0]); \
updateClassDefaultAttrFromTlv((void*)&__tlvStruct); \
updateClassAttrFromDefaultParams(); \
delete[] __tlvBuff; \
return MCE_SUCCESS
#define GET_FROM_DEV_5TH_GEN(mf, tlvStructName, tlvNameStr) \
MError __mRc; \
int __tlvBuffSize = tlvStructName##_size(); \
u_int8_t *__tlvBuff = new u_int8_t[__tlvBuffSize]; \
memset(__tlvBuff, 0, __tlvBuffSize); \
struct tlvStructName __tlvStruct; \
memset(&__tlvStruct, 0, sizeof(__tlvStruct)); \
if (_updated) { \
delete[] __tlvBuff; \
return MCE_SUCCESS; \
} \
__mRc = mnvaCom5thGen(mf, &__tlvBuff[0], __tlvBuffSize, getTlvTypeBe(), REG_ACCESS_METHOD_GET); \
if (__mRc) { \
delete[] __tlvBuff; \
if (__mRc == ME_REG_ACCESS_RES_NOT_AVLBL) { \
return MCE_SUCCESS; \
} \
return errmsg("Failed to get %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
tlvStructName##_unpack(&__tlvStruct, &__tlvBuff[0]); \
updateClassAttrFromTlv((void*)&__tlvStruct); \
_updated = true; \
delete[] __tlvBuff; \
return MCE_SUCCESS
#define SET_ON_DEV_4TH_GEN(mf, ignoreCheck, tlvStructName, tlvNameStr, typeMod) \
MError __mRc; \
if (!(ignoreCheck) && !checkCfg()) { \
return MCE_BAD_PARAMS; \
} \
int __tlvBuffSize = tlvStructName##_size(); \
u_int8_t *__tlvBuff = new u_int8_t[__tlvBuffSize]; \
memset(__tlvBuff, 0, __tlvBuffSize); \
struct tlvStructName __tlvStruct; \
memset(&__tlvStruct, 0, sizeof(__tlvStruct)); \
__mRc = mnvaCom4thGen(mf, __tlvBuff, __tlvBuffSize, tlvTypeIdx, REG_ACCESS_METHOD_GET, typeMod); \
if (__mRc && __mRc != ME_REG_ACCESS_RES_NOT_AVLBL) { \
delete[] __tlvBuff; \
return errmsg("failed to set %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
tlvStructName##_unpack(&__tlvStruct, __tlvBuff); \
updateTlvFromClassAttr((void*)&__tlvStruct); \
tlvStructName##_pack(&__tlvStruct, __tlvBuff); \
__mRc = mnvaCom4thGen(mf, __tlvBuff, __tlvBuffSize, tlvTypeIdx, REG_ACCESS_METHOD_SET, typeMod); \
delete[] __tlvBuff; \
if (__mRc) { \
return errmsg("failed to set %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
_updated = false; \
return MCE_SUCCESS
#define GET_FROM_DEV_4TH_GEN(mf, tlvStructName, tlvNameStr, typeMod) \
MError __mRc; \
int __tlvBuffSize = tlvStructName##_size(); \
u_int8_t *__tlvBuff = new u_int8_t[__tlvBuffSize]; \
memset(__tlvBuff, 0, __tlvBuffSize); \
struct tlvStructName __tlvStruct; \
memset(&__tlvStruct, 0, sizeof(__tlvStruct)); \
if (_updated) { \
delete[] __tlvBuff; \
return MCE_SUCCESS; \
} \
__mRc = mnvaCom4thGen(mf, &__tlvBuff[0], __tlvBuffSize, tlvTypeIdx, REG_ACCESS_METHOD_GET, typeMod); \
if (__mRc) { \
delete[] __tlvBuff; \
if (__mRc == ME_REG_ACCESS_RES_NOT_AVLBL) { \
return MCE_SUCCESS; \
} \
return errmsg("Failed to get %s settings: %s", tlvNameStr, m_err2str(__mRc)); \
} \
tlvStructName##_unpack(&__tlvStruct, &__tlvBuff[0]); \
updateClassAttrFromTlv((void*)&__tlvStruct); \
_updated = true; \
delete[] __tlvBuff; \
return MCE_SUCCESS
/*static void dealWithSignal()
{
int sig;
sig = mft_signal_is_fired();
if (sig) {
// reset received signal
mft_signal_set_fired(0);
// retore prev handler
mft_signal_set_handling(0);
//raise signal to let the previous handle deal with it.
raise(sig);
}
mft_signal_set_handling(0);
return;
}*/
/*
* Adrianc: TODO: create a SetTlv class and two child classess , for 4th/5th gen.
* each param class will have an instance of SetTlv class
*/
MError mnvaCom4thGen(mfile *mf, u_int8_t *buff, u_int16_t len, u_int16_t tlvTypeIdx, reg_access_method_t method, u_int16_t typeMod)
{
struct tools_open_mnva mnvaTlv;
memset(&mnvaTlv, 0, sizeof(struct tools_open_mnva));
mnvaTlv.nv_hdr.length = len >> 2; // length is in dwords
mnvaTlv.nv_hdr.type = tlvTypeIdx;
mnvaTlv.nv_hdr.type_mod = typeMod;
memcpy(mnvaTlv.data, buff, len);
MError rc;
// "suspend" signals as we are going to take semaphores
mft_signal_set_handling(1);
rc = reg_access_mnva(mf, method, &mnvaTlv);
dealWithSignal();
if (rc) {
return rc;
}
memcpy(buff, mnvaTlv.data, len);
return ME_OK;
}
/*MError mnvaCom5thGen(mfile* mf, u_int8_t* buff, u_int16_t len, u_int32_t tlvType, reg_access_method_t method, bool getDefault=false)
{
struct tools_open_nvda mnvaTlv;
memset(&mnvaTlv, 0, sizeof(struct tools_open_nvda));
mnvaTlv.nv_hdr.length = len;
mnvaTlv.nv_hdr.rd_en = 0;
mnvaTlv.nv_hdr.over_en = 1;
if (getDefault) {
mnvaTlv.nv_hdr.default_ = 1;
}
// tlvType should be in the correct endianess
mnvaTlv.nv_hdr.type.tlv_type_dw.tlv_type_dw = __be32_to_cpu(tlvType);
memcpy(mnvaTlv.data, buff, len);
MError rc;
// "suspend" signals as we are going to take semaphores
mft_signal_set_handling(1);
DEBUG_PRINT_SEND(&mnvaTlv, nvda);
rc = reg_access_nvda(mf, method, &mnvaTlv);
DEBUG_PRINT_RECEIVE(&mnvaTlv, nvda);
dealWithSignal();
if (rc) {
return rc;
}
memcpy(buff, mnvaTlv.data, len);
return ME_OK;
}
MError nvqcCom5thGen(mfile* mf, u_int32_t tlvType, bool& suppRead, bool& suppWrite)
{
struct tools_open_nvqc nvqcTlv;
memset(&nvqcTlv, 0, sizeof(struct tools_open_nvqc));
// tlvType should be in the correct endianess
nvqcTlv.type.tlv_type_dw.tlv_type_dw = __be32_to_cpu(tlvType);
MError rc;
// "suspend" signals as we are going to take semaphores
mft_signal_set_handling(1);
rc = reg_access_nvqc(mf, REG_ACCESS_METHOD_GET, &nvqcTlv);
dealWithSignal();
if (rc) {
return rc;
}
suppRead = nvqcTlv.support_rd;
suppWrite = nvqcTlv.support_wr;
return ME_OK;
}*/
/***************************
* Class implementations :
***************************/
/*
* CfgParams Class implementation :
*/
CfgParams::CfgParams(mlxCfgType t, u_int32_t tlvT)
{
// init the ErrMsg Class
std::map<int, std::string> errmap;
errmap[MCE_SUCCESS] = "Success";
errmap[MCE_FAILED] = "General Failure";
errmap[MCE_BAD_PARAMS] = "Bad parameters";
errmap[MCE_BAD_PARAM_VAL] = "Bad parameter value";
errmap[MCE_BAD_STATUS] = "General Failure";
errmap[MCE_GET_DEFAULT_PARAMS] = "Failed to get default params";
updateErrCodes(errmap);
type = t;
tlvTypeIdx = tlvT;
_updated = false;
_ignoreHardLimits = false;
_ignoreSoftLimits = false;
_devCapVec = 0;
}
int CfgParams::getDefaultParams4thGen(mfile *mf, struct tools_open_query_def_params_global *global_params)
{
mft_signal_set_handling(1);
MError rc = tcif_query_global_def_params(mf, global_params);
dealWithSignal();
if (rc) {
return errmsg(MCE_BAD_STATUS, "Failed to get default parameters: %s", tcif_err2str(rc));
}
return MCE_SUCCESS;
}
int CfgParams::getDefaultParams4thGen(mfile *mf, int port, struct tools_open_query_def_params_per_port *port_params)
{
mft_signal_set_handling(1);
MError rc = tcif_query_per_port_def_params(mf, port, port_params);
dealWithSignal();
if (rc) {
return errmsg(MCE_BAD_STATUS, "Failed to get default parameters: %s", tcif_err2str(rc));
}
return MCE_SUCCESS;
}
int CfgParams::getDefaultAndFromDev(mfile *mf)
{
int rc;
rc = getDefaultParams(mf); CHECK_RC(rc);
rc = getFromDev(mf); CHECK_RC(rc);
return MCE_SUCCESS;
}
bool CfgParams::checkCfg(mfile *mf)
{
if (!_ignoreHardLimits && !hardLimitCheck()) {
return false;
}
if (!_ignoreSoftLimits && !softLimitCheck(mf)) {
return false;
}
return true;
}
bool CfgParams::softLimitCheck(mfile *mf)
{
// by default not implemented
(void)mf;
return true;
}
void CfgParams::setIgnoreSoftLimits(bool val)
{
_ignoreSoftLimits = val;
}
void CfgParams::setIgnoreHardLimits(bool val)
{
_ignoreHardLimits = val;
}
/*
* BootSettingsExtParams Class implementation:
*/
bool BootSettingsExtParams::hardLimitCheck()
{
if (_ipVer > 3) {
errmsg("illegal IP Ver parameter value. can be 0..3");
return false;
}
return true;
}
void BootSettingsExtParams::setParams(u_int32_t ipVer)
{
_ipVer = ipVer;
}
/*
* BootSettingsExtParams4thGen Class implementation:
*/
u_int32_t BootSettingsExtParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Boot_Settings_Ext_IP_Ver_P1 ||
paramType == Mcp_Boot_Settings_Ext_IP_Ver_P2) {
return _ipVerDefault;
}
return MLXCFG_UNKNOWN;
}
void BootSettingsExtParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if (paramType == Mcp_Boot_Settings_Ext_IP_Ver_P1 ||
paramType == Mcp_Boot_Settings_Ext_IP_Ver_P2) {
_ipVer = val;
}
}
u_int32_t BootSettingsExtParams4thGen::getParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Boot_Settings_Ext_IP_Ver_P1 ||
paramType == Mcp_Boot_Settings_Ext_IP_Ver_P2) {
return _ipVer;
}
return MLXCFG_UNKNOWN;
}
bool BootSettingsExtParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)param;
struct tools_open_query_def_params_global params;
int rc;
rc = getDefaultParams4thGen(mf, ¶ms);
if (rc) {
return false;
}
return params.boot_ip_ver;
}
int BootSettingsExtParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_per_port params;
int rc;
rc = getDefaultParams4thGen(mf, _port, ¶ms);
if (rc) {
return false;
}
_ipVerDefault = params.boot_ip_ver;
setParams(_ipVerDefault);
return MCE_SUCCESS;
}
int BootSettingsExtParams4thGen::getFromDev(mfile *mf)
{
if (_updated) {
return MCE_SUCCESS;
}
MError rc;
// prep tlv
u_int8_t buff[TOOLS_OPEN_SRIOV_SIZE];
struct tools_open_boot_settings_ext bootSettingsExtTlv;
memset(buff, 0, tools_open_boot_settings_ext_size());
memset(&bootSettingsExtTlv, 0, sizeof(struct tools_open_boot_settings_ext));
// pack it
tools_open_boot_settings_ext_pack(&bootSettingsExtTlv, buff);
// send it
DEBUG_PRINT_SEND(&bootSettingsExtTlv, boot_settings_ext);
rc = mnvaCom4thGen(mf, buff, tools_open_boot_settings_ext_size(), tlvTypeIdx, REG_ACCESS_METHOD_GET, _port);
// check rc
DEBUG_PRINT_RECEIVE(&bootSettingsExtTlv, boot_settings_ext);
if (rc) {// when attempting to get a nv_cfg tlv from device ME_REG_ACCESS_RES_NOT_AVLBL means - no valid
// tlv found. i.e default configuration are on.
if (rc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg(MCE_BAD_STATUS, "Failed to get Boot Settings Extras configuration: %s", m_err2str(rc));
}
// unpack and update
tools_open_boot_settings_ext_unpack(&bootSettingsExtTlv, buff);
setParams(bootSettingsExtTlv.ip_ver);
_updated = true;
return MCE_SUCCESS;
}
int BootSettingsExtParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
if (_ipVer == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all parameters for Boot Settings Extras.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg(mf)) {
return MCE_BAD_PARAMS;
}
// prep tlv
MError ret;
u_int8_t buff[TOOLS_OPEN_BOOT_SETTINGS_EXT_SIZE];
struct tools_open_boot_settings_ext bootSettingsExtTlv;
memset(buff, 0, tools_open_boot_settings_ext_size());
memset(&bootSettingsExtTlv, 0, sizeof(struct tools_open_boot_settings_ext));
bootSettingsExtTlv.ip_ver = _ipVer;
// pack it
tools_open_boot_settings_ext_pack(&bootSettingsExtTlv, buff);
// send it
ret = mnvaCom4thGen(mf, buff, tools_open_boot_settings_ext_size(), tlvTypeIdx, REG_ACCESS_METHOD_SET, _port);
// check rc
if (ret) {
return errmsg("failed to set Boot Settings Extras params: %s", m_err2str(ret));
}
_updated = false;
return MCE_SUCCESS;
}
/*
* SriovParams4thGen Class implementation:
*/
void SriovParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if (paramType == Mcp_Sriov_En) {
_sriovEn = val;
} else if (paramType == Mcp_Num_Of_Vfs) {
_numOfVfs = val;
}
}
u_int32_t SriovParams4thGen::getParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Sriov_En) {
return _sriovEn;
} else if (paramType == Mcp_Num_Of_Vfs) {
return _numOfVfs;
}
return MLXCFG_UNKNOWN;
}
u_int32_t SriovParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Sriov_En) {
return _sriovEnDefault;
} else if (paramType == Mcp_Num_Of_Vfs) {
return _numOfVfsDefault;
}
return MLXCFG_UNKNOWN;
}
bool SriovParams4thGen::hardLimitCheck()
{
if ((_numOfVfs > _maxVfs)) {
errmsg("Number of VFs exceeds limit (%d).", _maxVfs);
return false;
}
if (_sriovEn != 0 && _sriovEn != 1) {
errmsg("illegal SRIOV_EN parameter value. (should be 0 or 1)");
return false;
}
return true;
}
/*
* SriovParam4thGen Class implementation
*/
bool SriovParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)mf;
(void)param;
return _devCapVec & SRIOV_MASK;
}
int SriovParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_global global_params;
int rc;
rc = updateMaxVfs(mf); CHECK_RC(rc);
rc = getDefaultParams4thGen(mf, &global_params);
if (rc == MCE_SUCCESS) {
_sriovEnDefault = global_params.sriov_en;
_numOfVfsDefault = global_params.num_vfs;
setParams(_sriovEnDefault, _numOfVfsDefault);
} else {
rc = MCE_GET_DEFAULT_PARAMS;
}
return rc;
}
void SriovParams4thGen::setParams(u_int32_t sriovEn, u_int32_t numOfVfs)
{
_sriovEn = sriovEn;
_numOfVfs = numOfVfs;
}
int SriovParams4thGen::getFromDev(mfile *mf)
{
if (_updated) {
return MCE_SUCCESS;
}
MError rc;
// prep tlv
u_int8_t buff[TOOLS_OPEN_SRIOV_SIZE];
struct tools_open_sriov sriovTlv;
memset(buff, 0, tools_open_sriov_size());
memset(&sriovTlv, 0, sizeof(struct tools_open_sriov));
// pack it
tools_open_sriov_pack(&sriovTlv, buff);
// send it
DEBUG_PRINT_SEND(&sriovTlv, sriov);
rc = mnvaCom4thGen(mf, buff, tools_open_sriov_size(), tlvTypeIdx, REG_ACCESS_METHOD_GET, 0);
// check rc
DEBUG_PRINT_RECEIVE(&sriovTlv, sriov);
if (rc) {// when attempting to get a nv_cfg tlv from device ME_REG_ACCESS_RES_NOT_AVLBL means - no valid
// tlv found. i.e default configuration are on.
if (rc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg(MCE_BAD_STATUS, "Failed to get SRIOV configuration: %s", m_err2str(rc));
}
// unpack and update
tools_open_sriov_unpack(&sriovTlv, buff);
setParams(sriovTlv.sriov_en, sriovTlv.total_vfs);
_updated = true;
return MCE_SUCCESS;
}
int SriovParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
if (_sriovEn == MLXCFG_UNKNOWN || _numOfVfs == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all parameters for SRIOV.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg(mf)) {
return MCE_BAD_PARAMS;
}
// prep tlv
MError ret;
u_int8_t buff[TOOLS_OPEN_SRIOV_SIZE];
struct tools_open_sriov sriovTlv;
memset(buff, 0, tools_open_sriov_size());
memset(&sriovTlv, 0, sizeof(struct tools_open_sriov));
sriovTlv.sriov_en = _sriovEn;
sriovTlv.total_vfs = _numOfVfs;
// pack it
tools_open_sriov_pack(&sriovTlv, buff);
// send it
ret = mnvaCom4thGen(mf, buff, tools_open_sriov_size(), tlvTypeIdx, REG_ACCESS_METHOD_SET, 0);
// check rc
if (ret) {
return errmsg("failed to set SRIOV params: %s", m_err2str(ret));
}
_updated = false;
return MCE_SUCCESS;
}
int SriovParams4thGen::updateMaxVfs(mfile *mf)
{
u_int64_t data = 0;
int rc = tcif_query_dev_cap(mf, MAX_VFS_ADDR, &data);
if (rc) {
return errmsg("failed to query device capabilities: %s", m_err2str((MError)rc));
}
_maxVfs = (u_int32_t)(data & 0xff);
if (_maxVfs == 0) { // defined in CX PRM , if max_func_idx=0 then all functions(128) are operational
_maxVfs = 128;
}
_maxVfs--; // remove 1 physical function
return MCE_SUCCESS;
}
bool SriovParams4thGen::softLimitCheck(mfile *mf)
{
u_int32_t barSz = 0;
BarSzParams4thGen barParams;
if (!mf) {
return false;
}
if (barParams.getDefaultAndFromDev(mf)) {
return false;
}
if (_sriovEn == 0) {
return true;
}
barSz = barParams.getParam(Mcp_Log_Bar_Size);
if (barSz == MLXCFG_UNKNOWN) {
return errmsg("Failed to get the bar size from device");
}
// this is the default log2 bar size , we require (numOfVfs+1)*(2^log_uar_bar) <= 512 or else the node might not boot
double TotalMem = (_numOfVfs + 1) * (1 << barSz); // 1 for physical func
if ((TotalMem > 512)) {
unsigned int maxAlowedVfs = static_cast<unsigned int>(512 / (1 << barSz)) - 1;
errmsg("illegal SRIOV parameter value. Maximal number of VFs: %d", maxAlowedVfs < _maxVfs ? maxAlowedVfs : _maxVfs);
return false;
}
return true;
}
/*
* CX3GlobalConfParams Class implementation:
*/
bool CX3GlobalConfParams::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)param;
struct tools_open_query_def_params_global params;
int rc;
rc = getDefaultParams4thGen(mf, ¶ms);
if (rc) {
return false;
}
return (param == Mcp_CQ_Timestamp && params.nv_cq_timestamp_supported)
|| (param == Mcp_Steer_ForceVlan && params.nv_steer_force_vlan_supported)
|| (param == Mcp_Last &&
(params.nv_cq_timestamp_supported || params.nv_steer_force_vlan_supported));
}
void CX3GlobalConfParams::setParam(mlxCfgParam paramType, u_int32_t val)
{
if (paramType == Mcp_CQ_Timestamp) {
_timestamp = val;
}
if (paramType == Mcp_Steer_ForceVlan) {
_steerForceVlan = val;
}
}
u_int32_t CX3GlobalConfParams::getParam(mlxCfgParam paramType)
{
if (paramType == Mcp_CQ_Timestamp) {
return _timestamp;
}
if (paramType == Mcp_Steer_ForceVlan) {
return _steerForceVlan;
}
return MLXCFG_UNKNOWN;
}
u_int32_t CX3GlobalConfParams::getDefaultParam(mlxCfgParam paramType)
{
if (paramType == Mcp_CQ_Timestamp) {
return _timestampDefault;
}
if (paramType == Mcp_Steer_ForceVlan) {
return _steerForceVlanDefault;
}
return MLXCFG_UNKNOWN;
}
int CX3GlobalConfParams::getFromDev(mfile *mf)
{
if (_updated) {
return MCE_SUCCESS;
}
MError rc;
// prep tlv
u_int8_t buff[TOOLS_OPEN_NV_CX3_GLOBAL_CONF_SIZE];
struct tools_open_nv_cx3_global_conf globalConfTlv;
memset(buff, 0, tools_open_nv_cx3_global_conf_size());
memset(&globalConfTlv, 0, sizeof(struct tools_open_nv_cx3_global_conf));
// pack it
tools_open_nv_cx3_global_conf_pack(&globalConfTlv, buff);
// send it
DEBUG_PRINT_SEND(&globalConfTlv, nv_cx3_global_conf);
rc = mnvaCom4thGen(mf, buff, tools_open_nv_cx3_global_conf_size(), tlvTypeIdx, REG_ACCESS_METHOD_GET, 0);
// check rc
DEBUG_PRINT_RECEIVE(&globalConfTlv, nv_cx3_global_conf);
if (rc) {// when attempting to get a nv_cfg tlv from device ME_REG_ACCESS_RES_NOT_AVLBL means - no valid
// tlv found. i.e default configuration are on.
if (rc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg(MCE_BAD_STATUS, "Failed to get CX3_GLOBAL_CONF configuration: %s", m_err2str(rc));
}
// unpack and update
tools_open_nv_cx3_global_conf_unpack(&globalConfTlv, buff);
setParams(globalConfTlv.cq_timestamp, globalConfTlv.steer_force_vlan);
_updated = true;
return MCE_SUCCESS;
}
int CX3GlobalConfParams::setOnDev(mfile *mf, bool ignoreCheck)
{
if (_timestamp == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all parameters for CX3_GLOBAL_CONF.", err() ? err() : "");
}
if (_steerForceVlan == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all parameters for CX3_GLOBAL_CONF.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg(mf)) {
return MCE_BAD_PARAMS;
}
// prep tlv
MError ret;
u_int8_t buff[TOOLS_OPEN_NV_CX3_GLOBAL_CONF_SIZE];
struct tools_open_nv_cx3_global_conf globalConfTlv;
memset(buff, 0, tools_open_nv_cx3_global_conf_size());
memset(&globalConfTlv, 0, sizeof(struct tools_open_nv_cx3_global_conf));
globalConfTlv.cq_timestamp = _timestamp;
globalConfTlv.steer_force_vlan = _steerForceVlan;
// pack it
tools_open_nv_cx3_global_conf_pack(&globalConfTlv, buff);
// send it
ret = mnvaCom4thGen(mf, buff, tools_open_nv_cx3_global_conf_size(), tlvTypeIdx, REG_ACCESS_METHOD_SET, 0);
// check rc
if (ret) {
return errmsg("failed to set CX3_GLOBAL_CONF params: %s", m_err2str(ret));
}
_updated = false;
return MCE_SUCCESS;
}
int CX3GlobalConfParams::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_global global_params;
int rc;
rc = getDefaultParams4thGen(mf, &global_params);
if (rc) {
return MCE_GET_DEFAULT_PARAMS;
}
_timestampDefault = global_params.default_cq_timestamp;
_steerForceVlanDefault = global_params.default_steer_force_vlan;
setParams(_timestampDefault, _steerForceVlanDefault);
return MCE_SUCCESS;
}
bool CX3GlobalConfParams::hardLimitCheck()
{
if (_timestamp != 0 && _timestamp != 1) {
errmsg("illegal CQ_TIMESTAMP parameter value. (should be 0 or 1)");
return false;
}
if (_steerForceVlan != 0 && _steerForceVlan != 1) {
errmsg("illegal STEER_FORCE_VLAN parameter value. (should be 0 or 1)");
return false;
}
return true;
}
void CX3GlobalConfParams::setParams(u_int32_t timestamp, u_int32_t steer_force_vlan)
{
_timestamp = timestamp;
_steerForceVlan = steer_force_vlan;
}
/*
* WolParams Class implementation :
*/
bool WolParams::hardLimitCheck()
{
if (_wolMagicEn == 0 || _wolMagicEn == 1) {
return true;
}
errmsg("illegal WOL parameter value. can be either 0 or 1.");
return false;
}
void WolParams::setParams(u_int32_t wolMagicEn)
{
_wolMagicEn = wolMagicEn;
}
/*
* WolParams4thGen Class implementation :
*/
void WolParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if ((paramType == Mcp_Wol_Magic_En_P1 && _port == 1) || (paramType == Mcp_Wol_Magic_En_P2 && _port == 2) ) {
_wolMagicEn = val;
}
}
u_int32_t WolParams4thGen::getParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Wol_Magic_En_P1 && _port == 1) || (paramType == Mcp_Wol_Magic_En_P2 && _port == 2)) {
return _wolMagicEn;
}
return MLXCFG_UNKNOWN;
}
u_int32_t WolParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Wol_Magic_En_P1 && _port == 1) || (paramType == Mcp_Wol_Magic_En_P2 && _port == 2)) {
return _wolMagicEnDefault;
}
return MLXCFG_UNKNOWN;
}
bool WolParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)mf;
(void)param;
return ((_devCapVec & WOL_P1_MASK) && _port == 1) || ((_devCapVec & WOL_P2_MASK) && _port == 2 );
}
int WolParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_per_port port_params;
int rc = getDefaultParams4thGen(mf, _port, &port_params);
if (rc == MCE_SUCCESS) {
_wolMagicEnDefault = port_params.default_en_wol_magic;
setParams(_wolMagicEnDefault);
} else {
rc = MCE_GET_DEFAULT_PARAMS;
}
return rc;
}
int WolParams4thGen::getFromDev(mfile *mf)
{
if (_updated) {
return MCE_SUCCESS;
}
MError rc;
// prep tlv
u_int8_t buff[TOOLS_OPEN_WOL_SIZE];
struct tools_open_wol wolTlv;
memset(buff, 0, tools_open_wol_size());
memset(&wolTlv, 0, sizeof(struct tools_open_wol));
// pack it
tools_open_wol_pack(&wolTlv, buff);
// send it
rc = mnvaCom4thGen(mf, buff, tools_open_wol_size(), tlvTypeIdx, REG_ACCESS_METHOD_GET, _port);
// check rc
if (rc) {
if (rc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg("Failed to get WOL port%d configuration: %s", _port, m_err2str(rc));
}
// unpack and update
tools_open_wol_unpack(&wolTlv, buff);
setParams(wolTlv.en_wol_magic);
_updated = true;
return MCE_SUCCESS;
}
int WolParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
if (_wolMagicEn == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all the parameters for WOL.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg()) {
return MCE_BAD_PARAMS;
}
// prep tlv
MError ret;
u_int8_t buff[TOOLS_OPEN_WOL_SIZE];
struct tools_open_wol wolTlv;
memset(buff, 0, tools_open_wol_size());
memset(&wolTlv, 0, sizeof(struct tools_open_wol));
wolTlv.en_wol_magic = _wolMagicEn;
// pack it
tools_open_wol_pack(&wolTlv, buff);
// send it
ret = mnvaCom4thGen(mf, buff, tools_open_wol_size(), tlvTypeIdx, REG_ACCESS_METHOD_SET, _port);
// check rc
if (ret) {
return errmsg("failed to set WOL params for port%d: %s", _port, m_err2str(ret));
}
_updated = false;
return MCE_SUCCESS;
}
/*
* BarSzParams Class implementation :
*/
void BarSzParams::setParam(mlxCfgParam paramType, u_int32_t val)
{
if (paramType == Mcp_Log_Bar_Size) {
_logBarSz = val;
}
}
u_int32_t BarSzParams::getParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Log_Bar_Size) {
return _logBarSz;
}
return MLXCFG_UNKNOWN;
}
u_int32_t BarSzParams::getDefaultParam(mlxCfgParam paramType)
{
if (paramType == Mcp_Log_Bar_Size) {
return _logBarSzDefault;
}
return MLXCFG_UNKNOWN;
}
bool BarSzParams::hardLimitCheck()
{
if (_logBarSz > _maxLogBarSz) {
errmsg("given bar size is too large, max allowed log2 bar size: 0x%x", _maxLogBarSz);
return false;
}
return true;
}
void BarSzParams::setParams(u_int32_t logBarSz)
{
_logBarSz = logBarSz;
}
/*
* BarSzParams4thGen Class implementation :
*/
bool BarSzParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)mf;
(void)param;
return _devCapVec & BAR_SZ_MASK;
}
int BarSzParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_global global_params;
int rc = getDefaultParams4thGen(mf, &global_params);
if ((rc == MCE_SUCCESS) & 0) { //TODO: adrianc: remove the & 0 when FW displays thesee parameters correctly in QUERY_DEF_PARAMS command
_logBarSzDefault = global_params.uar_bar_size;
_maxLogBarSz = global_params.max_uar_bar_size;
setParams(_logBarSzDefault);
} else {
// attempt to take from query_dev_cap
rc = getDefaultBarSz(mf);
}
return rc;
}
int BarSzParams4thGen::getDefaultBarSz(mfile *mf)
{
u_int64_t data = 0;
MError rc = tcif_query_dev_cap(mf, MAX_BAR_SZ_ADDR, &data);
if (rc) {
return errmsg(MCE_BAD_STATUS, "Failed to query device capabilities. %s", tcif_err2str(rc));
}
_maxLogBarSz = EXTRACT64(data, 3, 6);
rc = tcif_query_dev_cap(mf, DEFAULT_BAR_SZ_ADDR, &data);
if (rc) {
return errmsg(MCE_BAD_STATUS, "Failed to query device capabilities. %s", tcif_err2str(rc));
}
_logBarSzDefault = EXTRACT64(data, 16, 6) + 1; //adrianc: this field reports only half of the bar size (i.e without the blue flame)
setParams(_logBarSzDefault);
return MCE_SUCCESS;
}
int BarSzParams4thGen::getFromDev(mfile *mf)
{
if (_updated) {
return MCE_SUCCESS;
}
MError rc;
// prep tlv
u_int8_t buff[TOOLS_OPEN_BAR_SIZE_SIZE];
struct tools_open_bar_size barSzTlv;
memset(buff, 0, tools_open_bar_size_size());
memset(&barSzTlv, 0, sizeof(struct tools_open_bar_size));
// pack it
tools_open_bar_size_pack(&barSzTlv, buff);
// send it
rc = mnvaCom4thGen(mf, buff, tools_open_bar_size_size(), tlvTypeIdx, REG_ACCESS_METHOD_GET, 0);
// check rc
if (rc) {
if (rc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg("Failed to get BAR size configuration: %s", m_err2str(rc));
}
// unpack and update
tools_open_bar_size_unpack(&barSzTlv, buff);
setParams(barSzTlv.log_uar_bar_size);
_updated = true;
return MCE_SUCCESS;
}
int BarSzParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
if (_logBarSz == MLXCFG_UNKNOWN) {
return errmsg("%s please specify all the parameters for BAR size.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg(mf)) {
return MCE_BAD_PARAMS;
}
// prep tlv
MError ret;
u_int8_t buff[TOOLS_OPEN_BAR_SIZE_SIZE];
struct tools_open_bar_size barSzTlv;
memset(buff, 0, tools_open_bar_size_size());
memset(&barSzTlv, 0, sizeof(struct tools_open_bar_size));
barSzTlv.log_uar_bar_size = _logBarSz;
// pack it
tools_open_bar_size_pack(&barSzTlv, buff);
// send it
ret = mnvaCom4thGen(mf, buff, tools_open_bar_size_size(), tlvTypeIdx, REG_ACCESS_METHOD_SET, 0);
// check rc
if (ret) {
return errmsg("failed to set BAR size params: %s", m_err2str(ret));
}
_updated = false;
return MCE_SUCCESS;
}
bool BarSzParams4thGen::softLimitCheck(mfile *mf)
{
u_int32_t numOfVfs = 0;
int sriovEn;
SriovParams4thGen sriovParams;
if (!mf) {
return false;
}
if (sriovParams.getDefaultAndFromDev(mf)) {
errmsg("Failed to get SRIOV parameters from device: %s", sriovParams.err());
return false;
}
numOfVfs = sriovParams.getParam(Mcp_Num_Of_Vfs);
sriovEn = sriovParams.getParam(Mcp_Sriov_En);
if (numOfVfs == MLXCFG_UNKNOWN || numOfVfs == MLXCFG_UNKNOWN) {
errmsg("Illegal SRIOV parameters values");
return false;
}
if (sriovEn == 0) {
return true;
}
// this is the default log2 bar size , we require numOfVfs*(2^log_uar_bar) <= 512 or else the node might not boot
double TotalMem = (numOfVfs + 1) * (1 << _logBarSz);
//printf("-D- num_of_vfs*2^(bar_sz+1) = %d*2^%ld = %d\n", _numOfVfs, data, (int)(_numOfVfs*(std::pow((double)2, (int)data))));
//printf("-D- maxVfs(default set by fw) : %d\n", _maxVfs);
if (TotalMem > 512) {
unsigned int maxAlowedLogBarSz = static_cast<unsigned int>(log2((512 / (numOfVfs + 1 ))));
errmsg("illegal Bar Size parameter value. Maximal allowed bar size: %d", maxAlowedLogBarSz < _maxLogBarSz ? maxAlowedLogBarSz : _maxLogBarSz);
return false;
}
return true;
}
/*
* VpiParams Class implementation :
*/
int VpiParams::getFromDevComPre()
{
// prep tlv
_tlvBuff.resize(TOOLS_OPEN_VPI_SETTINGS_SIZE);
memset(&_tlvBuff[0], 0, TOOLS_OPEN_VPI_SETTINGS_SIZE);
memset(&_vpiTlv, 0, sizeof(struct tools_open_vpi_settings));
// pack it
tools_open_vpi_settings_pack(&_vpiTlv, &_tlvBuff[0]);
return MCE_SUCCESS;
}
int VpiParams::getFromDevComPost(MError mnvaComRC)
{
if (mnvaComRC) {
if (mnvaComRC == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg("Failed to get VPI port%d configuration: %s", _port, m_err2str(mnvaComRC));
}
// unpack and update
tools_open_vpi_settings_unpack(&_vpiTlv, &_tlvBuff[0]);
setParams(_vpiTlv.network_link_type, _vpiTlv.default_link_type,
_vpiTlv.phy_type, _vpiTlv.xfi_mode, _vpiTlv.force_mode);
_updated = true;
return MCE_SUCCESS;
}
void VpiParams::setParams(u_int32_t linkType, u_int32_t defaultLinkType,
u_int32_t phyType, u_int32_t xfiMode, u_int32_t forceMode)
{
_linkType = linkType;
_defaultLinkType = defaultLinkType;
_phyType = phyType;
_xfiMode = xfiMode;
_forceMode = forceMode;
}
int VpiParams::setOnDevComPre(bool ignoreCheck)
{
if (_isVPISupported && (_linkType == MLXCFG_UNKNOWN || _defaultLinkType == MLXCFG_UNKNOWN)) {
return errmsg("%s please specify all the parameters for VPI settings.", err() ? err() : "");
}
if (_isForceModeSupported && (_phyType == MLXCFG_UNKNOWN || _xfiMode == MLXCFG_UNKNOWN || _forceMode == MLXCFG_UNKNOWN)) {
return errmsg("%s please specify all the parameters for VPI Force Mode settings.", err() ? err() : "");
}
if (!ignoreCheck && !checkCfg()) {
return MCE_BAD_PARAMS;
}
_tlvBuff.resize(TOOLS_OPEN_VPI_SETTINGS_SIZE);
memset(&_tlvBuff[0], 0, _tlvBuff.size());
memset(&_vpiTlv, 0, sizeof(struct tools_open_vpi_settings));
_vpiTlv.network_link_type = _linkType;
_vpiTlv.default_link_type = _defaultLinkType;
_vpiTlv.phy_type = _phyType;
_vpiTlv.xfi_mode = _xfiMode;
_vpiTlv.force_mode = _forceMode;
// pack it
tools_open_vpi_settings_pack(&_vpiTlv, &_tlvBuff[0]);
return MCE_SUCCESS;
}
int VpiParams::setOnDevComPost(MError mnvaComRC)
{
if (mnvaComRC) {
return errmsg("failed to set VPI port%d params: %s", _port, m_err2str(mnvaComRC));
}
_updated = false;
return MCE_SUCCESS;
}
/*
* VpiParams4thGen Class implementation :
*/
void VpiParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2)) {
_linkType = val;
} else if ((paramType == Mcp_Phy_Type_P1 && _port == 1) || (paramType == Mcp_Phy_Type_P2 && _port == 2)) {
_phyType = val;
} else if ((paramType == Mcp_Xfi_Mode_P1 && _port == 1) || (paramType == Mcp_Xfi_Mode_P2 && _port == 2)) {
_xfiMode = val;
} else if ((paramType == Mcp_Force_Mode_P1 && _port == 1) || (paramType == Mcp_Force_Mode_P2 && _port == 2)) {
_forceMode = val;
}
}
u_int32_t VpiParams4thGen::getParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2) ) {
return _linkType;
} else if ((paramType == Mcp_Phy_Type_P1 && _port == 1) || (paramType == Mcp_Phy_Type_P2 && _port == 2)) {
return _phyType;
} else if ((paramType == Mcp_Xfi_Mode_P1 && _port == 1) || (paramType == Mcp_Xfi_Mode_P2 && _port == 2)) {
return _xfiMode;
} else if ((paramType == Mcp_Force_Mode_P1 && _port == 1) || (paramType == Mcp_Force_Mode_P2 && _port == 2)) {
return _forceMode;
}
return MLXCFG_UNKNOWN;
}
u_int32_t VpiParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Link_Type_P1 && _port == 1 ) || (paramType == Mcp_Link_Type_P2 && _port == 2) ) {
return _linkTypeDefault;
} else if ((paramType == Mcp_Phy_Type_P1 && _port == 1) || (paramType == Mcp_Phy_Type_P2 && _port == 2)) {
return _phyTypeDefault;
} else if ((paramType == Mcp_Xfi_Mode_P1 && _port == 1) || (paramType == Mcp_Xfi_Mode_P2 && _port == 2)) {
return _xfiModeDefault;
} else if ((paramType == Mcp_Force_Mode_P1 && _port == 1) || (paramType == Mcp_Force_Mode_P2 && _port == 2)) {
return _forceModeDefault;
}
return MLXCFG_UNKNOWN;
}
int VpiParams4thGen::getDefaultParamsAux(mfile *mf)
{
struct tools_open_query_def_params_per_port port_params;
memset(&port_params, 0, sizeof(port_params));
_defaultLinkTypeDefault = 0; // not used for 4th gen devices , we give it a default value
int rc = getDefaultParams4thGen(mf, _port, &port_params);
if (rc) {
return MCE_GET_DEFAULT_PARAMS;
}
if (port_params.default_network_link_type) {
_linkTypeDefault = port_params.default_network_link_type;
}
_isForceModeSupported = port_params.nv_config_vpi_force_mode;
_phyTypeDefault = port_params.default_vpi_phy_type;
_xfiModeDefault = port_params.default_vpi_xfi_mode;
_forceModeDefault = port_params.default_vpi_force_mode;
return MCE_SUCCESS;
}
bool VpiParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)mf;
(void)param;
int rc;
if (((param == Mcp_Phy_Type_P1 || param == Mcp_Xfi_Mode_P1 || param == Mcp_Force_Mode_P1) && (_port == 1))
||
((param == Mcp_Phy_Type_P2 || param == Mcp_Xfi_Mode_P2 || param == Mcp_Force_Mode_P2) && (_port == 2))) {
rc = getDefaultParamsAux(mf);
bool x = ((!rc) && _isForceModeSupported);
return x;
}
_isVPISupported = ((_devCapVec & VPI_P1_MASK) && _port == 1) || ((_devCapVec & VPI_P2_MASK) && _port == 2);
if (param == Mcp_Last) {
rc = getDefaultParamsAux(mf);
bool x = ((!rc) && _isForceModeSupported);
return (x || _isVPISupported);
}
return _isVPISupported;
}
int VpiParams4thGen::getDefaultParams(mfile *mf)
{
int rc = getDefaultParamsAux(mf);
if (rc) {
return rc;
}
_linkType = _linkTypeDefault;
_defaultLinkType = _defaultLinkTypeDefault;
_phyType = _phyTypeDefault;
_xfiMode = _xfiModeDefault;
_forceMode = _forceModeDefault;
return MCE_SUCCESS;
}
int VpiParams4thGen::getFromDev(mfile *mf)
{
MError mRc;
int rc;
if (_updated) {
return MCE_SUCCESS;
}
if ((rc = getFromDevComPre())) {
return rc;
}
mRc = mnvaCom4thGen(mf, &_tlvBuff[0], TOOLS_OPEN_VPI_SETTINGS_SIZE, tlvTypeIdx, REG_ACCESS_METHOD_GET, _port);
return getFromDevComPost(mRc);
}
int VpiParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
MError mRc;
int rc;
if ((rc = setOnDevComPre(ignoreCheck))) {
return rc;
}
mRc = mnvaCom4thGen(mf, &_tlvBuff[0], TOOLS_OPEN_VPI_SETTINGS_SIZE, tlvTypeIdx, REG_ACCESS_METHOD_SET, _port);
return setOnDevComPost(mRc);
}
bool VpiParams4thGen::hardLimitCheck()
{
if (_isVPISupported) {
if (_linkType < 1 || _linkType > 3) {
errmsg("illegal VPI link type (should be 1|2|3).");
return false;
}
}
if (_isForceModeSupported) {
if (_phyType < 1 || _phyType > 3) {
errmsg("illegal Phy Type value (shold be 1|2|3)");
return false;
}
if (_xfiMode > 2) {
errmsg("illegal Xfi Mode value (should be 0|1|2)");
return false;
}
if (_forceMode > 1) {
errmsg("illegal Force Mode value (should be 0|1)");
return false;
}
}
return true;
}
/*
* InfinibandBootSettingsParams4thGen Class implementation:
*/
bool InfinibandBootSettingsParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)param;
struct tools_open_query_def_params_per_port portParams;
int rc;
rc = getDefaultParams4thGen(mf, _port, &portParams);
if (rc) {
return false;
}
return portParams.nv_config_infiniband_boot_settings;
}
void InfinibandBootSettingsParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if ((paramType == Mcp_Boot_Pkey_P1 && _port == 1) || (paramType == Mcp_Boot_Pkey_P2 && _port == 2)) {
_bootPkey = val;
}
}
u_int32_t InfinibandBootSettingsParams4thGen::getParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Boot_Pkey_P1 && _port == 1) || (paramType == Mcp_Boot_Pkey_P2 && _port == 2)) {
return _bootPkey;
}
return MLXCFG_UNKNOWN;
}
u_int32_t InfinibandBootSettingsParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Boot_Pkey_P1 && _port == 1) || (paramType == Mcp_Boot_Pkey_P2 && _port == 2)) {
return _bootPkeyDefault;
}
return MLXCFG_UNKNOWN;
}
int InfinibandBootSettingsParams4thGen::getFromDev(mfile *mf)
{
MError mRc;
u_int8_t tlvBuff[TOOLS_OPEN_INFINIBAND_BOOT_SETTINGS_SIZE] = {0};
struct tools_open_infiniband_boot_settings bootSettingsTlv;
memset(&bootSettingsTlv, 0, sizeof(bootSettingsTlv));
if (_updated) {
return MCE_SUCCESS;
}
mRc = mnvaCom4thGen(mf, &tlvBuff[0], TOOLS_OPEN_INFINIBAND_BOOT_SETTINGS_SIZE, tlvTypeIdx, REG_ACCESS_METHOD_GET, _port);
if (mRc) {
if (mRc == ME_REG_ACCESS_RES_NOT_AVLBL) {
return MCE_SUCCESS;
}
return errmsg("Failed to get Infiniband Boot Settings: %s", m_err2str(mRc));
}
// unpack and update
tools_open_infiniband_boot_settings_unpack(&bootSettingsTlv, &tlvBuff[0]);
_bootPkey = bootSettingsTlv.boot_pkey;
_updated = true;
return MCE_SUCCESS;
}
int InfinibandBootSettingsParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
MError mRc;
if (!ignoreCheck && !checkCfg()) {
return MCE_BAD_PARAMS;
}
// get Tlv modify it and set it
u_int8_t tlvBuff[TOOLS_OPEN_INFINIBAND_BOOT_SETTINGS_SIZE] = {0};
struct tools_open_infiniband_boot_settings bootSettingsTlv;
memset(&bootSettingsTlv, 0, sizeof(bootSettingsTlv));
bootSettingsTlv.boot_pkey = _bootPkey;
// pack it
tools_open_infiniband_boot_settings_pack(&bootSettingsTlv, tlvBuff);
mRc = mnvaCom4thGen(mf, tlvBuff, TOOLS_OPEN_TPT_CONFIGURATION_SIZE, tlvTypeIdx, REG_ACCESS_METHOD_SET, _port);
if (mRc) {
return errmsg("failed to set Infiniband Boot Settings: %s", m_err2str(mRc));
}
_updated = false;
return MCE_SUCCESS;
}
int InfinibandBootSettingsParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_per_port portParams;
int rc;
rc = getDefaultParams4thGen(mf, _port, &portParams);
if (rc == MCE_SUCCESS) {
_bootPkeyDefault = portParams.default_boot_pkey;
setParams(_bootPkeyDefault);
} else {
rc = MCE_GET_DEFAULT_PARAMS;
}
return rc;
}
void InfinibandBootSettingsParams4thGen::setParams(u_int32_t bootPkey)
{
_bootPkey = bootPkey;
}
bool InfinibandBootSettingsParams4thGen::hardLimitCheck()
{
if (_bootPkey >= (1 << 16)) {
errmsg("Illegal BOOT_PKEY_P%d parameter value, valid values: [0..65535]", ((_port == 1) ? 1 : 2));
return false;
}
return true;
}
/*
* PrebootBootSettingsParams4thGen Class implementation:
*/
bool PrebootBootSettingsParams4thGen::cfgSupported(mfile *mf, mlxCfgParam param)
{
(void)param;
struct tools_open_query_def_params_per_port portParams;
int rc;
rc = getDefaultParams4thGen(mf, _port, &portParams);
if (rc) {
return false;
}
return true; //portParams.nv_config_boot_parameters; <--BUG fw is not updating this bit, assume supported if query_def_params command passess
}
void PrebootBootSettingsParams4thGen::setParam(mlxCfgParam paramType, u_int32_t val)
{
if ((paramType == Mcp_Boot_Option_Rom_En_P1 && _port == 1) || (paramType == Mcp_Boot_Option_Rom_En_P2 && _port == 2)) {
_bootOptionRomEn = val;
}
if ((paramType == Mcp_Boot_Vlan_En_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_En_P2 && _port == 2)) {
_bootVlanEn = val;
}
if ((paramType == Mcp_Boot_Retry_Cnt_P1 && _port == 1) || (paramType == Mcp_Boot_Retry_Cnt_P2 && _port == 2)) {
_bootRetryCnt = val;
}
if ((paramType == Mcp_Legacy_Boot_Protocol_P1 && _port == 1) || (paramType == Mcp_Legacy_Boot_Protocol_P2 && _port == 2)) {
_legacyBootProtocol = val;
}
if ((paramType == Mcp_Boot_Vlan_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_P2 && _port == 2)) {
_bootVlan = val;
}
}
u_int32_t PrebootBootSettingsParams4thGen::getParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Boot_Option_Rom_En_P1 && _port == 1) || (paramType == Mcp_Boot_Option_Rom_En_P2 && _port == 2)) {
return _bootOptionRomEn;
}
if ((paramType == Mcp_Boot_Vlan_En_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_En_P2 && _port == 2)) {
return _bootVlanEn;
}
if ((paramType == Mcp_Boot_Retry_Cnt_P1 && _port == 1) || (paramType == Mcp_Boot_Retry_Cnt_P2 && _port == 2)) {
return _bootRetryCnt;
}
if ((paramType == Mcp_Legacy_Boot_Protocol_P1 && _port == 1) || (paramType == Mcp_Legacy_Boot_Protocol_P2 && _port == 2)) {
return _legacyBootProtocol;
}
if ((paramType == Mcp_Boot_Vlan_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_P2 && _port == 2)) {
return _bootVlan;
}
return MLXCFG_UNKNOWN;
}
u_int32_t PrebootBootSettingsParams4thGen::getDefaultParam(mlxCfgParam paramType)
{
if ((paramType == Mcp_Boot_Option_Rom_En_P1 && _port == 1) || (paramType == Mcp_Boot_Option_Rom_En_P2 && _port == 2)) {
return _bootOptionRomEnDefault;
}
if ((paramType == Mcp_Boot_Vlan_En_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_En_P2 && _port == 2)) {
return _bootVlanEnDefault;
}
if ((paramType == Mcp_Boot_Retry_Cnt_P1 && _port == 1) || (paramType == Mcp_Boot_Retry_Cnt_P2 && _port == 2)) {
return _bootRetryCntDefault;
}
if ((paramType == Mcp_Legacy_Boot_Protocol_P1 && _port == 1) || (paramType == Mcp_Legacy_Boot_Protocol_P2 && _port == 2)) {
return _legacyBootProtocolDefault;
}
if ((paramType == Mcp_Boot_Vlan_P1 && _port == 1) || (paramType == Mcp_Boot_Vlan_P2 && _port == 2)) {
return _bootVlanDefault;
}
return MLXCFG_UNKNOWN;
}
void PrebootBootSettingsParams4thGen::setParams(u_int32_t bootOptionRomEn, u_int32_t bootVlanEn, u_int32_t bootRetryCnt,
u_int32_t legacyBootProtocol, u_int32_t bootVlan)
{
_bootOptionRomEn = bootOptionRomEn;
_bootVlanEn = bootVlanEn;
_bootRetryCnt = bootRetryCnt;
_legacyBootProtocol = legacyBootProtocol;
_bootVlan = bootVlan;
}
void PrebootBootSettingsParams4thGen::updateClassAttrFromDefaultParams()
{
setParams(_bootOptionRomEnDefault, _bootVlanEnDefault, _bootRetryCntDefault,
_legacyBootProtocolDefault, _bootVlanDefault);
}
int PrebootBootSettingsParams4thGen::getFromDev(mfile *mf)
{
GET_FROM_DEV_4TH_GEN(mf, tools_open_preboot_boot_settings, "Preboot Boot Settings", _port);
}
int PrebootBootSettingsParams4thGen::setOnDev(mfile *mf, bool ignoreCheck)
{
SET_ON_DEV_4TH_GEN(mf, ignoreCheck, tools_open_preboot_boot_settings, "Preboot Boot Settings", _port);
}
void PrebootBootSettingsParams4thGen::updateTlvFromClassAttr(void *tlv)
{
struct tools_open_preboot_boot_settings *prebootTlv = (struct tools_open_preboot_boot_settings*)tlv;
prebootTlv->boot_option_rom_en = _bootOptionRomEn;
prebootTlv->boot_vlan_en = _bootVlanEn;
prebootTlv->boot_retry_count = _bootRetryCnt;
prebootTlv->legacy_boot_protocol = _legacyBootProtocol;
prebootTlv->boot_vlan = _bootVlan;
}
void PrebootBootSettingsParams4thGen::updateClassAttrFromTlv(void *tlv)
{
struct tools_open_preboot_boot_settings *prebootTlv = (struct tools_open_preboot_boot_settings*)tlv;
_bootOptionRomEn = prebootTlv->boot_option_rom_en;
_bootVlanEn = prebootTlv->boot_vlan_en;
_bootRetryCnt = prebootTlv->boot_retry_count;
_legacyBootProtocol = prebootTlv->legacy_boot_protocol;
_bootVlan = prebootTlv->boot_vlan;
}
void PrebootBootSettingsParams4thGen::updateClassDefaultAttrFromTlv(void *tlv)
{
struct tools_open_preboot_boot_settings *prebootTlv = (struct tools_open_preboot_boot_settings*)tlv;
_bootOptionRomEnDefault = prebootTlv->boot_option_rom_en;
_bootVlanEnDefault = prebootTlv->boot_vlan_en;
_bootRetryCntDefault = prebootTlv->boot_retry_count;
_legacyBootProtocolDefault = prebootTlv->legacy_boot_protocol;
_bootVlanDefault = prebootTlv->boot_vlan;
}
int PrebootBootSettingsParams4thGen::getDefaultParams(mfile *mf)
{
struct tools_open_query_def_params_per_port portParams;
int rc;
rc = getDefaultParams4thGen(mf, _port, &portParams);
if (rc == MCE_SUCCESS) {
_bootOptionRomEnDefault = portParams.default_boot_option_rom_en;
_bootVlanEnDefault = portParams.default_boot_vlan_en;
_bootRetryCntDefault = portParams.default_boot_retry_cnt;
_legacyBootProtocolDefault = portParams.default_boot_protocol;
_bootVlanDefault = portParams.default_boot_vlan;
updateClassAttrFromDefaultParams();
} else {
rc = MCE_GET_DEFAULT_PARAMS;
}
return rc;
}
bool PrebootBootSettingsParams4thGen::hardLimitCheck()
{
if (_bootOptionRomEn > 1) {
errmsg("Illegal BOOT_OPTION_ROM_EN_P%d parameter value, valid values: 0 or 1", ((_port == 1) ? 1 : 2));
return false;
}
if (_bootVlanEn > 1) {
errmsg("Illegal BOOT_VLAN_EN_P%d parameter value, valid values: 0 or 1", ((_port == 1) ? 1 : 2));
return false;
}
if (_bootRetryCnt > 7) {
errmsg("Illegal BOOT_RETRY_CNT_P%d parameter value, valid values: [0..7]", ((_port == 1) ? 1 : 2));
return false;
}
if (_legacyBootProtocol > 3) {
errmsg("Illegal LEGACY_BOOT_PROTOCOL_P%d parameter value, valid values: [0..3]", ((_port == 1) ? 1 : 2));
return false;
}
if (_bootVlan >= (1 << 12)) {
errmsg("Illegal BOOT_VLAN_P%d parameter value, valid values: [0..4095]", ((_port == 1) ? 1 : 2));
return false;
}
return true;
}
|