Skip to content

Commit

Permalink
Clean up Tofino dynamic hash library. (#5059)
Browse files Browse the repository at this point in the history
Signed-off-by: fruffy <[email protected]>
  • Loading branch information
fruffy authored Dec 17, 2024
1 parent 5dc7f87 commit 8a91796
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 1,130 deletions.
4 changes: 2 additions & 2 deletions backends/tofino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ set (BF_P4C_IR_SRCS
bf-p4c/parde/match_register.cpp
bf-p4c/parde/clot/clot.cpp
bf-p4c/phv/phv.cpp
bf-utils/src/dynamic_hash/dynamic_hash.cpp
bf-utils/src/dynamic_hash/bfn_hash_algorithm.cpp
bf-utils/dynamic_hash/dynamic_hash.cpp
bf-utils/dynamic_hash/bfn_hash_algorithm.cpp
)

set(QUAL_BF_P4C_IR_SRCS)
Expand Down
2 changes: 1 addition & 1 deletion backends/tofino/bf-p4c/control-plane/bfruntime_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "barefoot/p4info.pb.h"
#pragma GCC diagnostic pop
#include "backends/tofino/bf-p4c/device.h"
#include "backends/tofino/bf-utils/include/dynamic_hash/bfn_hash_algorithm.h"
#include "backends/tofino/bf-utils/dynamic_hash/bfn_hash_algorithm.h"
#include "bfruntime.h"

namespace BFN {
Expand Down
2 changes: 1 addition & 1 deletion backends/tofino/bf-p4c/mau/hash_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "lib/hex.h"
#include "lib/big_int_util.h"
#include "backends/tofino/bf-p4c/mau/hash_function.h"
#include "backends/tofino/bf-utils/include/dynamic_hash/dynamic_hash.h"
#include "backends/tofino/bf-utils/dynamic_hash/dynamic_hash.h"

using namespace P4::literals;

Expand Down
2 changes: 1 addition & 1 deletion backends/tofino/bf-p4c/mau/input_xbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "backends/tofino/bf-p4c/mau/resource_estimate.h"
#include "backends/tofino/bf-p4c/mau/tofino/input_xbar.h"
#include "backends/tofino/bf-p4c/phv/phv_fields.h"
#include "backends/tofino/bf-utils/include/dynamic_hash/dynamic_hash.h"
#include "backends/tofino/bf-utils/dynamic_hash/dynamic_hash.h"
#include "lib/algorithm.h"
#include "lib/bitops.h"
#include "lib/bitrange.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/tofino/bf-p4c/mau/tofino/input_xbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "backends/tofino/bf-p4c/mau/resource.h"
#include "backends/tofino/bf-p4c/mau/resource_estimate.h"
#include "backends/tofino/bf-p4c/phv/phv_fields.h"
#include "backends/tofino/bf-utils/include/dynamic_hash/dynamic_hash.h"
#include "backends/tofino/bf-utils/dynamic_hash/dynamic_hash.h"
#include "lib/algorithm.h"
#include "lib/bitvec.h"
#include "lib/bitops.h"
Expand Down
2 changes: 1 addition & 1 deletion backends/tofino/bf-p4c/midend/fold_constant_hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "ir/ir.h"
#include "backends/tofino/bf-p4c/midend/type_checker.h"
#include "backends/tofino/bf-p4c/mau/hash_function.h"
#include "backends/tofino/bf-utils/include/dynamic_hash/dynamic_hash.h"
#include "backends/tofino/bf-utils/dynamic_hash/dynamic_hash.h"

namespace BFN {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
project(libdynhash VERSION 0.1 LANGUAGES C)
add_library(dynhash_o OBJECT
dynamic_hash.c
bfn_hash_algorithm.c)
dynamic_hash.cpp
bfn_hash_algorithm.cpp
)

add_library(dynhash SHARED EXCLUDE_FROM_ALL $<TARGET_OBJECTS:dynhash_o>)

# static lib for compiler with no syslibs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "backends/tofino/bf-utils/include/dynamic_hash/bfn_hash_algorithm.h"
#include "backends/tofino/bf-utils/dynamic_hash/bfn_hash_algorithm.h"

#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <vector>

/**
* These values are based on the crc calculations provided at this url:
* http://reveng.sourceforge.net/crc-catalogue/all.htm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_
#define BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_
#ifndef BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_
#define BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_

#ifndef __KERNEL__
#include <stdbool.h>
Expand Down Expand Up @@ -419,4 +419,4 @@ void initialize_crc_matrix(bfn_hash_algorithm_t *alg);
void calculate_crc(bfn_hash_algorithm_t *alg, uint32_t hash_output_bits, uint8_t *stream,
uint32_t stream_len, uint8_t *crc);

#endif /* BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_ */
#endif /* BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_BFN_HASH_ALGORITHM_H_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "backends/tofino/bf-utils/include/dynamic_hash/dynamic_hash.h"
#include "backends/tofino/bf-utils/dynamic_hash/dynamic_hash.h"

#include <assert.h>
#include <inttypes.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_DYNAMIC_HASH_H_
#define BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_DYNAMIC_HASH_H_
#ifndef BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_DYNAMIC_HASH_H_
#define BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_DYNAMIC_HASH_H_

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

#include "backends/tofino/bf-utils/include/dynamic_hash/bfn_hash_algorithm.h"
#include "backends/tofino/bf-utils/dynamic_hash/bfn_hash_algorithm.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -213,4 +213,4 @@ void determine_tofino_regs(const ixbar_init_t *ixbar_init, const ixbar_input_t *
}
#endif

#endif /* BACKENDS_TOFINO_BF_UTILS_INCLUDE_DYNAMIC_HASH_DYNAMIC_HASH_H_ */
#endif /* BACKENDS_TOFINO_BF_UTILS_DYNAMIC_HASH_DYNAMIC_HASH_H_ */
Loading

0 comments on commit 8a91796

Please sign in to comment.