Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,42 @@ target_link_libraries(benchmark_pktbuf pthread m)
add_executable(benchmark_throughput tests/benchmark_throughput.c src/pktbuf.c src/ring.c src/rule_table.c src/worker.c src/parser.c src/log.c src/arp_table.c src/ndp_table.c src/affinity.c src/benchmark_test.c src/log.c src/latency.c)
target_include_directories(benchmark_throughput PRIVATE include)
target_link_libraries(benchmark_throughput pthread m)


# Router--------–>

find_package(PkgConfig REQUIRED)
pkg_check_modules(DPDK REQUIRED libdpdk)

add_executable(upe-router
router/src/main.c
router/src/mac_table.c
router/src/rx_lcore.c
src/latency.c
src/log.c
)

target_include_directories(upe-router PRIVATE
include
router/include
${DPDK_INCLUDE_DIRS}
)

target_compile_options(upe-router PRIVATE
${DPDK_CFLAGS_OTHER}
-Wall
-Wextra
-Wno-pedantic
)

target_link_libraries(upe-router PRIVATE
${DPDK_LIBRARIES}
pthread
m
dl
numa
)

target_link_options(upe-router PRIVATE
${DPDK_LDFLAGS_OTHER}
)
76 changes: 1 addition & 75 deletions router/include/mac_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,81 +48,7 @@ bool mac_table_insert(mac_table_t *table, const uint8_t mac[MAC_ADDR_LEN],
* @param out_port Output for port_id if found
* @return true if MAC found and not expired, false otherwise
*/
bool mac_table_lookup(mac_table_t *table, const uint8_t, mac[MAC_ADDR_LEN],
uint64_t current_tsc, uint16_t *out_port);

/**
* Check if MAC address is unicast (the first octet's LSB is 0)
* @param mac MAC address to check
* @return true if unicast
*/
static inline bool mac_is_unicast(const uint8_t mac[MAC_ADDR_LEN]) {
return (mac[0] & 0x01) == 0;
}

/**
* Check if MAC address is broadcast (FF:FF:FF:FF:FF:FF)
* @param mac MAC address to check
* @return true if broadcast
*/
static inline bool mac_is_broadcast(const uint8_t mac[MAC_ADDR_LEN]) {
return mac[0] == 0xFF && mac[1] == 0xFF && mac[2] == 0xFF &&
mac[3] == 0xFF && mac[4] == 0xFF && mac[5] == 0xFF;
}

#endif /* MAC_TABLE_H */

#ifndef MAC_TABLE_H
#define MAC_TABLE_H

#include <stdint.h>
#include <stdbool.h>

#define MAC_ADDR_LEN 6
#define MAC_TABLE_CAPACITY 2048
#define MAC_TABLE_MAX_PROBE 16 /* Maximum linear probe distance before giving up */

typedef struct {
uint8_t mac[MAC_ADDR_LEN];
uint16_t port_id;
uint64_t last_seen_tsc;
bool occupied;
} mac_entry_t;

typedef struct {
mac_entry_t entries[MAC_TABLE_CAPACITY];
uint64_t table_full_count; /* How many times table was full */
uint64_t aging_timeout_tsc; /* Timeout in TSC cycles (default 30s) */
} mac_table_t;

/**
* Initialize MAC table
* @param table Pointer to table structure
* @param aging_timeout_sec Aging timeout in seconds (default 30)
* @param cycles_per_ns TSC cycles per nanosecond (from calibration)
*/
void mac_table_init(mac_table_t *table, uint32_t aging_timeout_sec,
double cycles_per_ns);

/**
* Insert or update a MAC entry in the table
* @param table Pointer to table structure
* @param mac MAC address to insert
* @param port_id Port ID where the MAC was seen
* @return true if successful, false if table is full
*/
bool mac_table_insert(mac_table_t *table, const uint8_t mac[MAC_ADDR_LEN],
uint16_t port_id, uint64_t current_tsc);

/**
* Lookup MAC address in table
* @param table Pointer to table structure
* @param mac MAC address to lookup
* @param current_tsc Current TSC value for aging check
* @param out_port Output for port_id if found
* @return true if MAC found and not expired, false otherwise
*/
bool mac_table_lookup(mac_table_t *table, const uint8_t, mac[MAC_ADDR_LEN],
bool mac_table_lookup(mac_table_t *table, const uint8_t mac[MAC_ADDR_LEN],
uint64_t current_tsc, uint16_t *out_port);

/**
Expand Down
2 changes: 1 addition & 1 deletion router/include/router.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define MBUF_CACHE_SIZE 256
#define MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE

#define DEFAULT_AGING_TIMEOUT 30
#define DEFAULT_AGING_TIMEOUT_SEC 30

#define DEFAULT_LINK_WAIT_SEC 5

Expand Down
14 changes: 7 additions & 7 deletions router/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ static int port_init(uint16_t port_id, struct rte_mempool *mbuf_pool,
} while (wait_count < max_wait);

/* Link still down after timeout */
log_msg(LOG_WARN, "Port %u: Link down after %u second timeout,
continuing anyway", port_id, link_wait_sec);
log_msg(LOG_WARN, "Port %u: Link down after %u second timeout, continuing anyway",
port_id, link_wait_sec);
return 0;
}

static void print_stats(const rx_lcore_ctx_t *ctx, double cycles_per_ns) {
static void print_stats(const rx_lcore_ctx_t *ctx) {
/* Print latency histogram for each port */
for (uint16_t port = 0; port < NUM_PORTS; port++) {
const latency_histogram_t *hist = &ctx->latency_hist[port];
Expand Down Expand Up @@ -405,7 +405,7 @@ int main(int argc, char **argv) {
}
} else {
/* Normal mode */
print_stats(&g_router.rx_ctx, cycles_per_ns);
print_stats(&g_router.rx_ctx);
}
}

Expand Down Expand Up @@ -456,13 +456,13 @@ int main(int argc, char **argv) {
printf("}\n");

if (pps < 1000000.0) {
log_msg(LOG_WARN, "Throughput %.0f pps is below 1 Mpps floor,
need investigation...", pps);
log_msg(LOG_WARN, "Throughput %.0f pps is below 1 Mpps floor, need investigation...",
pps);
}
} else {
/* Normal mode: just print final stats */
log_msg(LOG_INFO, "Final statistics:");
print_stats(&g_router.rx_ctx, cycles_per_ns);
print_stats(&g_router.rx_ctx);
}

/* Stop and close ports */
Expand Down
Loading