summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2024-04-19 09:29:40 +0000
committersongyanchao <[email protected]>2024-04-19 11:42:37 +0000
commit8db7b2a63bdc241c9f476604097a65855ef4b661 (patch)
tree804dfeb3f03489c64707df2dcd24263223b31fd5
parent90f2fc3e155e6643bd21caf1c1ffe354b0422281 (diff)
🐞 fix: fix rte_hash usage error.v4.7.2-20240419
fix rte_hash usage error.
-rw-r--r--service/src/node_etherfabric.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c
index ef5bb81..a7f9237 100644
--- a/service/src/node_etherfabric.c
+++ b/service/src/node_etherfabric.c
@@ -11,6 +11,11 @@
#include <port_adapter_mapping.h>
#include <sc_node_common.h>
+/* Should match the #define LCORE_CACHE_SIZE value in rte_cuckoo_hash.h */
+#define LCORE_CACHE_SIZE 64
+#define NR_EF_PEER_ENTRIES 256
+#define NR_EF_PEER_MEMBER (NR_EF_PEER_ENTRIES + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1)
+
/* Etherfabric ingress next node */
enum
{
@@ -71,8 +76,8 @@ struct ef_mgr
uint32_t sid_end;
struct rte_hash * ef_peer_hash;
struct ef_adapter * ef_adapters;
- struct ef_peer ef_peers[1024];
struct link_db_ctx * link_db_ctx;
+ struct ef_peer * ef_peers;
};
/* Etherfabric ingress stat struct */
@@ -158,12 +163,12 @@ int ef_peer_setup_hash(struct ef_mgr * ef_mgr)
{
struct rte_hash_parameters ef_peer_hash_params = {
.name = "ef_peer_hash",
- .entries = RTE_DIM(ef_mgr->ef_peers),
+ .entries = NR_EF_PEER_ENTRIES,
.key_len = sizeof(union ef_peer_key),
.hash_func = ef_peer_hash_crc,
.hash_func_init_val = 0,
.socket_id = 0,
- .extra_flag = RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT |
+ .extra_flag = RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD |
RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF,
};
@@ -363,8 +368,12 @@ int ef_init(struct sc_main * sc)
if (ef_peer_setup_hash(ef_mgr) != RT_SUCCESS)
return RT_ERR;
+ /* Malloc ef_peers */
+ ef_mgr->ef_peers = ZMALLOC(sizeof(struct ef_peer) * NR_EF_PEER_MEMBER);
+ MR_VERIFY_MALLOC(ef_mgr->ef_peers);
+
/* Init state */
- for (int index = 0; index < RTE_DIM(ef_mgr->ef_peers); index++)
+ for (int index = 0; index < NR_EF_PEER_MEMBER; index++)
rte_atomic64_init(&ef_mgr->ef_peers[index].state);
return RT_SUCCESS;
@@ -424,7 +433,8 @@ int ef_peer_lookup_and_add(struct rte_hash * ef_peer_hash, struct ef_peer * ef_p
char str_mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
rte_ether_format_addr(str_mac_addr, sizeof(str_mac_addr), &ef_peer_item->ef_mac_addr);
- MR_INFO("Ef Peer add, ip addr:%s, mac addr:%s", str_in_addr, str_mac_addr);
+ MR_INFO("Ef Peer add, index %d, core %u, ip addr:%s, mac addr:%s", ret, rte_lcore_id(), str_in_addr,
+ str_mac_addr);
}
return ret;
@@ -703,7 +713,7 @@ static __rte_always_inline uint16_t ef_egress_node_process(struct rte_graph * gr
/* Fill Ether IPv4 Udp Vxlan hdr for the pkt */
if (unlikely(mrb_meta->packet_create_from_nf))
{
- assert(mrb_meta->ef_peer_index < RTE_DIM(ef_mgr->ef_peers));
+ assert(mrb_meta->ef_peer_index < NR_EF_PEER_MEMBER);
struct ef_peer * ef_peer_item = &ef_peers[mrb_meta->ef_peer_index];
vxlan_encap_constructed_pkt(mbuf, mrb_meta, ef_peer_item, listen_device);
egress_stat.vxlan_encap++;
@@ -835,7 +845,7 @@ cJSON * ef_peer_monit_loop(struct sc_main * sc)
struct ef_mgr * ef_mgr = &sc->node_ef_main->ef_mgr;
cJSON * json_root = cJSON_CreateObject();
- for (int i = 0; i < RTE_DIM(ef_mgr->ef_peers); i++)
+ for (int i = 0; i < NR_EF_PEER_MEMBER; i++)
{
struct ef_peer * ef_peer_item = &ef_mgr->ef_peers[i];