Skip to content

Commit ddbe1ce

Browse files
authored
Merge pull request #203 from intel-innersource/202-remap-iio-stacks-on-icx-d
remap ICX-D IIO stacks
2 parents 6aece97 + 8477815 commit ddbe1ce

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

src/pcm-iio.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ static const std::string icx_iio_stack_names[6] = {
8282
"IIO Stack 5 - CBDMA/DMI "
8383
};
8484

85+
static const std::string icx_d_iio_stack_names[6] = {
86+
"IIO Stack 0 - MCP ",
87+
"IIO Stack 1 - PCIe0 ",
88+
"IIO Stack 2 - CBDMA/DMI ",
89+
"IIO Stack 3 - PCIe2 ",
90+
"IIO Stack 4 - PCIe3 ",
91+
"IIO Stack 5 - PCIe1 "
92+
};
93+
8594
static const std::string snr_iio_stack_names[5] = {
8695
"IIO Stack 0 - QAT ",
8796
"IIO Stack 1 - CBDMA/DMI ",
@@ -111,6 +120,15 @@ static const std::map<int, int> icx_sad_to_pmu_id_mapping = {
111120
{ 5, 4 }
112121
};
113122

123+
static const std::map<int, int> icx_d_sad_to_pmu_id_mapping = {
124+
{ ICX_CBDMA_DMI_SAD_ID, 2 },
125+
{ 1, 5 },
126+
{ 2, 1 },
127+
{ ICX_MCP_SAD_ID, 0 },
128+
{ 4, 3 },
129+
{ 5, 4 }
130+
};
131+
114132
#define SNR_ACCELERATOR_PART_ID 4
115133

116134
#define SNR_ROOT_PORT_A_DID 0x334A
@@ -545,8 +563,16 @@ bool IPlatformMapping10Nm::getSadIdRootBusMap(uint32_t socket_id, std::map<uint8
545563
// Mapping for IceLake Server.
546564
class WhitleyPlatformMapping: public IPlatformMapping10Nm {
547565
private:
566+
const bool icx_d;
567+
const std::map<int, int>& sad_to_pmu_id_mapping;
568+
const std::string * iio_stack_names;
548569
public:
549-
WhitleyPlatformMapping() = default;
570+
WhitleyPlatformMapping() :
571+
icx_d(PCM::getInstance()->getCPUModelFromCPUID() == PCM::ICX_D),
572+
sad_to_pmu_id_mapping(icx_d ? icx_d_sad_to_pmu_id_mapping : icx_sad_to_pmu_id_mapping),
573+
iio_stack_names(icx_d ? icx_d_iio_stack_names : icx_iio_stack_names)
574+
{
575+
}
550576
~WhitleyPlatformMapping() = default;
551577
bool pciTreeDiscover(std::vector<struct iio_stacks_on_socket>& iios, uint32_t sockets_count) override;
552578
};
@@ -563,15 +589,15 @@ bool WhitleyPlatformMapping::pciTreeDiscover(std::vector<struct iio_stacks_on_so
563589

564590
{
565591
struct iio_stack stack;
566-
stack.iio_unit_id = icx_sad_to_pmu_id_mapping.at(ICX_MCP_SAD_ID);
567-
stack.stack_name = icx_iio_stack_names[stack.iio_unit_id];
592+
stack.iio_unit_id = sad_to_pmu_id_mapping.at(ICX_MCP_SAD_ID);
593+
stack.stack_name = iio_stack_names[stack.iio_unit_id];
568594
iio_on_socket.stacks.push_back(stack);
569595
}
570596

571597
for (auto sad_id_bus_pair = sad_id_bus_map.cbegin(); sad_id_bus_pair != sad_id_bus_map.cend(); ++sad_id_bus_pair) {
572598
int sad_id = sad_id_bus_pair->first;
573-
if (icx_sad_to_pmu_id_mapping.find(sad_id) ==
574-
icx_sad_to_pmu_id_mapping.end()) {
599+
if (sad_to_pmu_id_mapping.find(sad_id) ==
600+
sad_to_pmu_id_mapping.end()) {
575601
cerr << "Unknown SAD ID: " << sad_id << endl;
576602
return false;
577603
}
@@ -584,9 +610,9 @@ bool WhitleyPlatformMapping::pciTreeDiscover(std::vector<struct iio_stacks_on_so
584610
int root_bus = sad_id_bus_pair->second;
585611
if (sad_id == ICX_CBDMA_DMI_SAD_ID) {
586612
// There is one DMA Controller on each socket
587-
stack.iio_unit_id = icx_sad_to_pmu_id_mapping.at(sad_id);
613+
stack.iio_unit_id = sad_to_pmu_id_mapping.at(sad_id);
588614
stack.busno = root_bus;
589-
stack.stack_name = icx_iio_stack_names[stack.iio_unit_id];
615+
stack.stack_name = iio_stack_names[stack.iio_unit_id];
590616

591617
// PCH is on socket 0 only
592618
if (socket == 0) {
@@ -629,8 +655,8 @@ bool WhitleyPlatformMapping::pciTreeDiscover(std::vector<struct iio_stacks_on_so
629655
continue;
630656
}
631657
stack.busno = root_bus;
632-
stack.iio_unit_id = icx_sad_to_pmu_id_mapping.at(sad_id);
633-
stack.stack_name = icx_iio_stack_names[stack.iio_unit_id];
658+
stack.iio_unit_id = sad_to_pmu_id_mapping.at(sad_id);
659+
stack.stack_name = iio_stack_names[stack.iio_unit_id];
634660
for (int slot = 2; slot < 6; slot++) {
635661
struct pci pci;
636662
pci.bdf.busno = root_bus;
@@ -1009,7 +1035,7 @@ result_content get_IIO_Samples(PCM *m, const std::vector<struct iio_stacks_on_so
10091035
uint64 rawEvents[4] = {0};
10101036
std::unique_ptr<ccr> pccr(get_ccr(m, ctr.ccr));
10111037
rawEvents[ctr.idx] = pccr->get_ccr_value();
1012-
int stacks_count = (int)iios[0].stacks.size();
1038+
const int stacks_count = (int)m->getMaxNumOfIIOStacks();
10131039
before = new IIOCounterState[iios.size() * stacks_count];
10141040
after = new IIOCounterState[iios.size() * stacks_count];
10151041

0 commit comments

Comments
 (0)