Skip to content

Commit a3898b9

Browse files
authored
Merge pull request #1410 from Mellanox/master_devel
Merge master_devel to master branch
2 parents d431e08 + 5f00585 commit a3898b9

File tree

192 files changed

+50008
-4883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+50008
-4883
lines changed

adb_parser/adb_condVar.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include "adb_instance.h"
4040

4141
using namespace std;
42+
43+
u_int64_t pop_from_buf(const u_int8_t* buff, u_int32_t bit_offset, u_int32_t field_size);
44+
4245
template<typename T_OFFSET>
4346
_AdbCondVar_impl<T_OFFSET>::_AdbCondVar_impl(string original_name) : _original_name(original_name)
4447
{
@@ -84,13 +87,13 @@ typename _AdbCondVar_impl<T_OFFSET>::AdbInstance* _AdbCondVar_impl<T_OFFSET>::ge
8487
return this->_instance;
8588
}
8689
template<typename T_OFFSET>
87-
void _AdbCondVar_impl<T_OFFSET>::evaluate(uint8_t* buffer)
90+
void _AdbCondVar_impl<T_OFFSET>::evaluate(uint8_t* buffer, T_OFFSET offset_shift)
8891
{
8992
if (!is_evaluated())
9093
{
9194
if (this->_instance)
9295
{
93-
uint64_t value = this->_instance->popBuf(buffer);
96+
uint64_t value = pop_from_buf(buffer, this->_instance->offset + offset_shift, this->_instance->get_size());
9497
set_value(static_cast<int>(value));
9598
}
9699
else

adb_parser/adb_condVar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _AdbCondVar_impl
5858
int get_value() const;
5959
AdbInstance* get_instance() const;
6060
const string& get_original_name() const;
61-
void evaluate(uint8_t* buffer);
61+
void evaluate(uint8_t* buffer, T_OFFSET offset_shift = 0);
6262

6363
private:
6464
bool _evaluated{false};
@@ -69,4 +69,4 @@ class _AdbCondVar_impl
6969

7070
using AdbCondVarLegacy = _AdbCondVar_impl<uint32_t>;
7171
using AdbCondVar = _AdbCondVar_impl<uint64_t>;
72-
#endif // ADB_CONDVAR_H
72+
#endif // ADB_CONDVAR_H

adb_parser/adb_condition.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,24 @@ void _AdbCondition_impl<T_OFFSET>::update_enum(const string& var_name)
248248
}
249249
}
250250
template<typename T_OFFSET>
251-
uint64_t _AdbCondition_impl<T_OFFSET>::evaluate(uint8_t* buffer)
251+
uint64_t _AdbCondition_impl<T_OFFSET>::evaluate(uint8_t* buffer, T_OFFSET offset_shift)
252252
{
253253
for (auto& pair : _vars_map)
254254
{
255255
const string& var_name = pair.first;
256256
auto& cond_var = pair.second;
257257
try
258258
{
259-
cond_var.evaluate(buffer);
259+
cond_var.evaluate(buffer, offset_shift);
260260
}
261261
catch (const AdbException& e)
262262
{
263263
throw AdbException("Failed to evaluate condition variable '" + var_name + "': " + e.what());
264264
}
265265
}
266266
ConditionExpr<T_OFFSET> expr_evaluator(_vars_map);
267-
char condition_str_cpy[MAX_CONDITION_SIZE];
267+
268+
char condition_str_cpy[MAX_CONDITION_SIZE + 1];
268269
char* condition_str_ptr = condition_str_cpy;
269270
strncpy(condition_str_cpy, _condition_str.c_str(), MAX_CONDITION_SIZE);
270271
uint64_t result = 0;

adb_parser/adb_condition.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class _AdbCondition_impl
5858
map<string, AdbCondVar>& get_vars_map();
5959
const std::string& get_condition() const;
6060
void update_enum(const std::string& var_name);
61-
uint64_t evaluate(uint8_t* buffer);
61+
uint64_t evaluate(uint8_t* buffer, T_OFFSET offset_shift = 0);
6262

6363
private:
6464
void init_variables();
@@ -95,4 +95,4 @@ class ConditionExpr : public Expr
9595
}
9696
void Error(const std::string& msg) override;
9797
};
98-
#endif // ADB_CONDITION_Hs
98+
#endif // ADB_CONDITION_Hs

adb_parser/adb_exceptionHolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ string ExceptionHolder::printAdbExceptionMap()
128128
vector<string> warnings = ExceptionHolder::adbExceptionMap[ExceptionHolder::WARN_EXCEPTION];
129129
for (vector<string>::iterator it = warnings.begin(); it != warnings.end(); ++it)
130130
{
131-
errorStr += "-" + ExceptionHolder::WARN_EXCEPTION + "- " + "- " + *it + ";";
131+
errorStr += "-" + ExceptionHolder::WARN_EXCEPTION + "- " + *it + ";";
132132
}
133133
return errorStr;
134134
}

adb_parser/adb_field.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,22 @@ string AdbField_impl<T_OFFSET>::toXml(const string& addPrefix)
452452
return xml;
453453
}
454454

455+
template<typename T_OFFSET>
456+
bool AdbField_impl<T_OFFSET>::compareFieldsForXmlOutput(AdbField_impl<T_OFFSET>* f1, AdbField_impl<T_OFFSET>* f2)
457+
{
458+
AdbField_impl<T_OFFSET> first = *f1;
459+
AdbField_impl<T_OFFSET> second = *f2;
460+
if (first.offset / 32 < second.offset / 32)
461+
{
462+
return true;
463+
}
464+
else if (first.offset / 32 == second.offset / 32)
465+
{
466+
return first.offset > second.offset;
467+
}
468+
return false;
469+
}
470+
455471
// Explicit instantiations
456472
template class AdbField_impl<u_int32_t>;
457473
template class AdbField_impl<u_int64_t>;

adb_parser/adb_field.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ class AdbField_impl
124124
bool isReserved{false};
125125
string condition; // field's visibility dynamic condition
126126

127+
// FOR USER USAGE
128+
// (BigEndian)
129+
static bool compareFieldsForXmlOutput(AdbField_impl<T_OFFSET>* f1, AdbField_impl<T_OFFSET>* f2);
130+
127131
// FOR USER USAGE
128132
void* userData{nullptr};
129133
};

adb_parser/adb_instance.cpp

Lines changed: 122 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,6 @@
5353
namespace Regex = mstflint::common::regex;
5454
namespace Algorithm = mstflint::common::algorithm;
5555

56-
string addPathSuffixForArraySupport(string path)
57-
{
58-
if (path[path.length() - 1] == ']')
59-
{ // Won't add suffix if leaf is in Array
60-
return "";
61-
}
62-
size_t pos = 0;
63-
string suffix = "";
64-
while ((pos = path.find("[")) != std::string::npos)
65-
{ // Add array index number in path to suffix.
66-
size_t end_pos = path.find("]");
67-
size_t len = end_pos - pos - 1;
68-
suffix = suffix + "_" + path.substr(pos + 1, len);
69-
path.erase(0, end_pos + 1);
70-
}
71-
return suffix;
72-
}
73-
7456
template<bool e, typename T_OFFSET>
7557
_AdbInstance_impl<e, T_OFFSET>::_AdbInstance_impl(AdbField* i_fieldDesc,
7658
AdbNode* i_nodeDesc,
@@ -366,6 +348,28 @@ string _AdbInstance_impl<e, O>::evalExpr(string expr, AttrsMap* vars)
366348
return expr;
367349
}
368350

351+
/**
352+
* Function: _AdbInstance_impl::addPathSuffixForArraySupport
353+
**/
354+
template<bool e, typename O>
355+
string _AdbInstance_impl<e, O>::addPathSuffixForArraySupport(string path)
356+
{
357+
if (path[path.length() - 1] == ']')
358+
{ // Won't add suffix if leaf is in Array
359+
return "";
360+
}
361+
size_t pos = 0;
362+
string suffix = "";
363+
while ((pos = path.find("[")) != std::string::npos)
364+
{ // Add array index number in path to suffix.
365+
size_t end_pos = path.find("]");
366+
size_t len = end_pos - pos - 1;
367+
suffix = suffix + "_" + path.substr(pos + 1, len);
368+
path.erase(0, end_pos + 1);
369+
}
370+
return suffix;
371+
}
372+
369373
/**
370374
* Function: _AdbInstance_impl::_AdbInstance_impl
371375
**/
@@ -541,6 +545,37 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
541545
{
542546
return;
543547
}
548+
549+
if (parent)
550+
{
551+
if (!parent->inst_props.valid_array_index)
552+
{
553+
inst_props.valid_array_index = 0;
554+
}
555+
556+
if (!inst_props.valid_array_index)
557+
{
558+
inst_props.access_r = 1;
559+
inst_props.access_w = 1;
560+
inst_props.is_semaphore = 0;
561+
}
562+
else
563+
{
564+
if (!parent->inst_props.access_w)
565+
{
566+
inst_props.access_w = 0;
567+
}
568+
if (!parent->inst_props.access_r)
569+
{
570+
inst_props.access_r = 0;
571+
}
572+
if (parent->inst_props.is_semaphore)
573+
{
574+
inst_props.is_semaphore = 1;
575+
}
576+
}
577+
}
578+
544579
if (isPartOfArray())
545580
{
546581
string fiVal = getInstanceAttr("valid_first_index");
@@ -579,17 +614,28 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
579614
{
580615
sem = getInstanceAttr("sem");
581616
access_type = getInstanceAttr("rw");
617+
if (access_type.empty())
618+
{
619+
access_type = getInstanceAttr("access");
620+
}
582621
if (!sem.empty())
583622
{
584623
inst_props.is_semaphore = stoi(sem) > 0;
585624
}
586625
if (access_type == "WO")
587626
{
588627
inst_props.access_r = 0;
628+
inst_props.access_w = 1;
589629
}
590630
else if (access_type == "RO")
591631
{
592632
inst_props.access_w = 0;
633+
inst_props.access_r = 1;
634+
}
635+
else if (access_type == "RW")
636+
{
637+
inst_props.access_r = 1;
638+
inst_props.access_w = 1;
593639
}
594640
}
595641

@@ -598,36 +644,6 @@ void _AdbInstance_impl<e, O>::init_props(unsigned char adabe_version) // logic o
598644
{
599645
inst_props.is_semaphore = stoi(sem) > 0;
600646
}
601-
602-
if (parent)
603-
{
604-
if (!parent->inst_props.valid_array_index)
605-
{
606-
inst_props.valid_array_index = 0;
607-
}
608-
609-
if (!inst_props.valid_array_index)
610-
{
611-
inst_props.access_r = 1;
612-
inst_props.access_w = 1;
613-
inst_props.is_semaphore = 0;
614-
}
615-
else
616-
{
617-
// if (parent->inst_ops.access_r && !parent->inst_ops.access_w)
618-
// {
619-
// inst_ops.access_w = 0;
620-
// }
621-
// if (!parent->inst_ops.access_r && parent->inst_ops.access_w)
622-
// {
623-
// inst_ops.access_r = 0;
624-
// }
625-
if (parent->inst_props.is_semaphore)
626-
{
627-
inst_props.is_semaphore = 1;
628-
}
629-
}
630-
}
631647
}
632648

633649
/**
@@ -1046,7 +1062,7 @@ template<bool eval_expr, typename O>
10461062
template<bool U>
10471063
typename enable_if<U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getCondition()
10481064
{
1049-
return &(inst_ops_props.condition);
1065+
return inst_ops_props.condition.get_condition().empty() ? nullptr : &(inst_ops_props.condition);
10501066
}
10511067

10521068
template<bool eval_expr, typename O>
@@ -1056,6 +1072,20 @@ typename enable_if<!U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr
10561072
return nullptr;
10571073
}
10581074

1075+
template<bool eval_expr, typename O>
1076+
template<bool U>
1077+
typename enable_if<U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getArraySizeCondition()
1078+
{
1079+
return inst_ops_props.conditionalSize.get_condition().empty() ? nullptr : &(inst_ops_props.conditionalSize);
1080+
}
1081+
1082+
template<bool eval_expr, typename O>
1083+
template<bool U>
1084+
typename enable_if<!U, _AdbCondition_impl<O>*>::type _AdbInstance_impl<eval_expr, O>::getArraySizeCondition()
1085+
{
1086+
return nullptr;
1087+
}
1088+
10591089
/**
10601090
* Function: _AdbInstance_impl::isEnumExists
10611091
**/
@@ -1290,7 +1320,7 @@ _AdbInstance_impl<e, O>* _AdbInstance_impl<e, O>::getUnionSelectedNodeName(const
12901320
}
12911321

12921322
throw AdbException("Union selector field (" + unionSelector->layout_item_name +
1293-
") doesn't define selector value (" + to_string(selectorVal));
1323+
") doesn't define selector value (" + to_string(selectorVal) + ")");
12941324
}
12951325

12961326
/**
@@ -1347,6 +1377,30 @@ bool _AdbInstance_impl<e, O>::isConditionalNode()
13471377
return false;
13481378
}
13491379

1380+
/**
1381+
* Function: _AdbInstance_impl::containsDynamicArray
1382+
**/
1383+
template<bool e, typename O>
1384+
bool _AdbInstance_impl<e, O>::containsDynamicArray()
1385+
{
1386+
if (!isNode())
1387+
{
1388+
return false;
1389+
}
1390+
1391+
_AdbInstance_impl<e, O>* last = nullptr;
1392+
last = subItems.back();
1393+
while (last)
1394+
{
1395+
if (last->fieldDesc->array_type >= AdbField_impl<O>::ArrayType::unlimited)
1396+
{
1397+
return true;
1398+
}
1399+
last = last->isNode() ? last->subItems.back() : nullptr;
1400+
}
1401+
return false;
1402+
}
1403+
13501404
/**
13511405
* Function: _AdbInstance_impl::isConditionValid
13521406
* Throws exception: AdbException
@@ -1420,7 +1474,8 @@ vector<_AdbInstance_impl<e, O>*> _AdbInstance_impl<e, O>::getLeafFields(bool ext
14201474
}
14211475
else
14221476
{
1423-
subItems[i]->layout_item_name += addPathSuffixForArraySupport(subItems[i]->fullName());
1477+
subItems[i]->layout_item_name +=
1478+
_AdbInstance_impl<e, O>::addPathSuffixForArraySupport(subItems[i]->fullName());
14241479
}
14251480
subItems[i]->inst_props.is_name_extended = true;
14261481
}
@@ -1504,6 +1559,22 @@ template typename enable_if<true, _AdbCondition_impl<uint32_t>*>::type
15041559
_AdbInstance_impl<true, uint32_t>::getCondition<true>();
15051560
template typename enable_if<true, _AdbCondition_impl<uint64_t>*>::type
15061561
_AdbInstance_impl<true, uint64_t>::getCondition<true>();
1562+
1563+
template typename enable_if<!false, _AdbCondition_impl<uint32_t>*>::type
1564+
_AdbInstance_impl<false, uint32_t>::getCondition<false>();
1565+
template typename enable_if<!false, _AdbCondition_impl<uint64_t>*>::type
1566+
_AdbInstance_impl<false, uint64_t>::getCondition<false>();
1567+
1568+
template typename enable_if<true, _AdbCondition_impl<uint32_t>*>::type
1569+
_AdbInstance_impl<true, uint32_t>::getArraySizeCondition<true>();
1570+
template typename enable_if<true, _AdbCondition_impl<uint64_t>*>::type
1571+
_AdbInstance_impl<true, uint64_t>::getArraySizeCondition<true>();
1572+
1573+
template typename enable_if<!false, _AdbCondition_impl<uint32_t>*>::type
1574+
_AdbInstance_impl<false, uint32_t>::getArraySizeCondition<false>();
1575+
template typename enable_if<!false, _AdbCondition_impl<uint64_t>*>::type
1576+
_AdbInstance_impl<false, uint64_t>::getArraySizeCondition<false>();
1577+
15071578
LayoutItemAttrsMap::LayoutItemAttrsMap(AttrsMap& field_desc_attrs) : _field_desc_attrs(field_desc_attrs) {}
15081579

15091580
LayoutItemAttrsMap& LayoutItemAttrsMap::operator=(const LayoutItemAttrsMap& other)

0 commit comments

Comments
 (0)