static void process_pkts(struct rte_mbuf *buf[], int n) { int i; uint8_t *pkt; int ret; uint32_t ft[5]; unsigned char *payload; int len; for(i = 0; i < n; i++) { #ifdef EXEC_MBUF_PA_CNT uint32_t lcoreid = rte_lcore_id(); uint32_t *count; struct rte_hash *h = lcore_args[lcoreid].pa_ht; if(rte_hash_lookup_data(h, (const void *)&(buf[i]->buf_physaddr), (void**)&count) >= 0) { *count = *count + 1; } else { if(pacnt_hash_add(h, (const void *)&(buf[i]->buf_physaddr), 1) < 0) { rte_exit(EINVAL, "pacnt hash add failed in lcore %d\n", lcoreid); } } #endif #if defined(EXEC_PC) || defined(EXEC_HASH) parse_packet_to_tuple(buf[i], ft); #ifdef EXEC_PC ret = packet_classifier_search(ft); if(ret < 0) { fprintf(stderr, "packet classifing failed!\n"); } #else ret = hash_table_lkup((void*)ft); #endif #endif #ifdef EXEC_CRC calc_chk_sum(buf[i]); #endif #ifdef EXEC_DPI ret = get_payload(buf[i], &payload, &len); if(ret < 0) { fprintf(stderr, "packet get payload failed!\n"); continue; } ret = dpi_engine_exec(payload, len); #endif } }
static int timed_lookups(unsigned with_hash, unsigned with_data, unsigned table_index) { unsigned i, j; const uint64_t start_tsc = rte_rdtsc(); void *ret_data; void *expected_data; int32_t ret; for (i = 0; i < NUM_LOOKUPS/KEYS_TO_ADD; i++) { for (j = 0; j < KEYS_TO_ADD; j++) { if (with_hash && with_data) { ret = rte_hash_lookup_with_hash_data(h[table_index], (const void *) keys[j], signatures[j], &ret_data); if (ret < 0) { printf("Key number %u was not found\n", j); return -1; } expected_data = (void *) ((uintptr_t) signatures[j]); if (ret_data != expected_data) { printf("Data returned for key number %u is %p," " but should be %p\n", j, ret_data, expected_data); return -1; } } else if (with_hash && !with_data) { ret = rte_hash_lookup_with_hash(h[table_index], (const void *) keys[j], signatures[j]); if (ret < 0 || ret != positions[j]) { printf("Key looked up in %d, should be in %d\n", ret, positions[j]); return -1; } } else if (!with_hash && with_data) { ret = rte_hash_lookup_data(h[table_index], (const void *) keys[j], &ret_data); if (ret < 0) { printf("Key number %u was not found\n", j); return -1; } expected_data = (void *) ((uintptr_t) signatures[j]); if (ret_data != expected_data) { printf("Data returned for key number %u is %p," " but should be %p\n", j, ret_data, expected_data); return -1; } } else { ret = rte_hash_lookup(h[table_index], keys[j]); if (ret < 0 || ret != positions[j]) { printf("Key looked up in %d, should be in %d\n", ret, positions[j]); return -1; } } } } const uint64_t end_tsc = rte_rdtsc(); const uint64_t time_taken = end_tsc - start_tsc; cycles[table_index][LOOKUP][with_hash][with_data] = time_taken/NUM_LOOKUPS; return 0; }
#include "ipsec.h" #include "esp.h" static inline int create_session(struct ipsec_ctx *ipsec_ctx __rte_unused, struct ipsec_sa *sa) { unsigned long cdev_id_qp = 0; int32_t ret; struct cdev_key key = { 0 }; key.lcore_id = (uint8_t)rte_lcore_id(); key.cipher_algo = (uint8_t)sa->cipher_algo; key.auth_algo = (uint8_t)sa->auth_algo; ret = rte_hash_lookup_data(ipsec_ctx->cdev_map, &key, (void **)&cdev_id_qp); if (ret < 0) { RTE_LOG(ERR, IPSEC, "No cryptodev: core %u, cipher_algo %u, " "auth_algo %u\n", key.lcore_id, key.cipher_algo, key.auth_algo); return -1; } RTE_LOG_DP(DEBUG, IPSEC, "Create session for SA spi %u on cryptodev " "%u qp %u\n", sa->spi, ipsec_ctx->tbl[cdev_id_qp].id, ipsec_ctx->tbl[cdev_id_qp].qp); sa->crypto_session = rte_cryptodev_sym_session_create( ipsec_ctx->tbl[cdev_id_qp].id, sa->xforms);