Skip to content

Commit 80801ee

Browse files
committed
debugging
1 parent b384a4e commit 80801ee

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

software/include/enso/helpers.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include <iostream>
5555
#include <string>
5656
#include <thread>
57+
#include <tuple>
58+
#include <unordered_map>
5759
#include <vector>
5860

5961
namespace enso {
@@ -79,6 +81,23 @@ struct stats_t {
7981
uint64_t nb_pkts;
8082
} __attribute__((aligned(64)));
8183

84+
// RSS 5-tuple containing dst port, src port, dst ip, src ip, protocol
85+
typedef std::tuple<uint16_t, uint16_t, uint32_t, uint32_t, uint32_t>
86+
config_tuple;
87+
88+
// A hash function used to hash the config tuple
89+
struct hash_config_tuple {
90+
template <class T1, class T2, class T3, class T4, class T5>
91+
92+
size_t operator()(const std::tuple<T1, T2, T3, T4, T5>& x) const {
93+
return std::get<0>(x) ^ std::get<1>(x) ^ std::get<2>(x) ^ std::get<3>(x) ^
94+
std::get<4>(x);
95+
}
96+
};
97+
98+
// Hash map containing bindings of configurations to enso pipe IDs
99+
extern std::unordered_map<config_tuple, int, hash_config_tuple> config_hashmap;
100+
82101
/**
83102
* @brief Returns RTT, in number of cycles, for a given packet.
84103
*

software/src/enso/config.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <enso/helpers.h>
4343
#include <enso/internals.h>
4444
#include <immintrin.h>
45-
#include <mock_pcie.h>
4645

4746
#include <cstdio>
4847

software/src/enso/helpers.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@
3838
*/
3939

4040
#include <enso/helpers.h>
41-
#include <mock_pcie.h>
4241

4342
#include <cstdio>
4443
#include <iostream>
4544
#include <thread>
4645
#include <vector>
46+
4747
namespace enso {
4848

49+
std::unordered_map<config_tuple, int, hash_config_tuple> config_hashmap;
50+
4951
uint16_t get_bdf_from_pcie_addr(const std::string& pcie_addr) {
5052
uint32_t domain, bus, dev, func;
5153
uint16_t bdf = 0;
@@ -168,8 +170,8 @@ int rss_hash_packet(uint8_t* pkt_buf, int mod) {
168170

169171
// check if this configuration has already been bound
170172
config_tuple tup(dst_port, src_port, dst_ip, src_ip, protocol);
171-
if (config_hashmap.contains(tup)) {
172-
return config_hahsmap[tup];
173+
if (config_hashmap.find(tup) != config_hashmap.end()) {
174+
return config_hashmap[tup];
173175
}
174176

175177
return (src_ip ^ dst_ip ^ protocol ^ src_port ^ dst_port) % mod;

software/src/mock_pcie.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <iostream>
1919
#include <limits>
2020
#include <stdexcept>
21-
#include <tuple>
22-
#include <unordered_map>
2321
#include <vector>
2422

2523
#include "pcie.h"
@@ -49,10 +47,4 @@ typedef struct enso_pipe {
4947
* @brief Vector of all enso pipes in mock
5048
*
5149
*/
52-
std::vector<enso_pipe_t*> enso_pipes_vector;
53-
54-
// RSS 5-tuple containing dst port, src port, dst ip, src ip, protocol
55-
typedef tuple<uint16_t, uint16_t, uint32_t, uint32_t, uint32_t> config_tuple;
56-
57-
// Hash map containing bindings of configurations to enso pipe IDs
58-
unordered_map<config_tuple, int> config_hashmap;
50+
std::vector<enso_pipe_t*> enso_pipes_vector;

0 commit comments

Comments
 (0)