uint64_t index; void *va; }; struct _mempool_gntalloc_info { struct rte_mempool *mp; uint32_t pg_num; uint32_t *gref_arr; phys_addr_t *pa_arr; void *va; uint32_t mempool_idx; uint64_t start_index; }; static rte_atomic32_t global_xenvirt_mempool_idx = RTE_ATOMIC32_INIT(-1); static int compare(const void *p1, const void *p2) { return ((const struct _gntarr *)p1)->pa - ((const struct _gntarr *)p2)->pa; } static struct _mempool_gntalloc_info _create_mempool(const char *name, unsigned elt_num, unsigned elt_size, unsigned cache_size, unsigned private_data_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg, rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, int socket_id, unsigned flags) {
#include "test.h" typedef int (*case_func_t)(void* arg); typedef void (*case_clean_t)(unsigned lcore_id); #define MAX_STRING_SIZE (256) #define MAX_ITER_TIMES (16) #define MAX_LPM_ITER_TIMES (8) #define MEMPOOL_ELT_SIZE (0) #define MEMPOOL_SIZE (4) #define MAX_LCORES RTE_MAX_MEMZONE / (MAX_ITER_TIMES * 4U) static rte_atomic32_t synchro = RTE_ATOMIC32_INIT(0); #define WAIT_SYNCHRO_FOR_SLAVES() do{ \ if (lcore_self != rte_get_master_lcore()) \ while (rte_atomic32_read(&synchro) == 0); \ } while(0) /* * rte_eal_init only init once */ static int test_eal_init_once(__attribute__((unused)) void *arg) { unsigned lcore_self = rte_lcore_id(); WAIT_SYNCHRO_FOR_SLAVES();
/* libpaxos proposer */ #include "proposer.h" /* paxos header definition */ #include "rte_paxos.h" #include "const.h" #include "utils.h" static struct rte_timer timer; static struct rte_timer stat_timer; static bool first_time; static const struct rte_eth_conf port_conf_default = { .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN, }, }; static rte_atomic32_t stat = RTE_ATOMIC32_INIT(0); struct rte_mempool *mbuf_pool; static void send_paxos_message(paxos_message *pm) { uint8_t port_id = 0; struct rte_mbuf *created_pkt = rte_pktmbuf_alloc(mbuf_pool); created_pkt->l2_len = sizeof(struct ether_hdr); created_pkt->l3_len = sizeof(struct ipv4_hdr); created_pkt->l4_len = sizeof(struct udp_hdr) + sizeof(paxos_message); craft_new_packet(&created_pkt, IPv4(192,168,4,99), ACCEPTOR_ADDR, PROPOSER_PORT, ACCEPTOR_PORT, sizeof(paxos_message), port_id); //struct udp_hdr *udp; size_t udp_offset = sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr); //udp = rte_pktmbuf_mtod_offset(created_pkt, struct udp_hdr *, udp_offset);
#include "kni.h" #include "config.h" /* Total octets in ethernet header */ #define KNI_ENET_HEADER_SIZE 14 /* Total octets in the FCS */ #define KNI_ENET_FCS_SIZE 4 struct kni_port_params* kni_port_params_array[RTE_MAX_ETHPORTS]; uint8_t kni_port_rdy[RTE_MAX_ETHPORTS] = {0}; static int kni_change_mtu(uint8_t port_id, unsigned new_mtu); static int kni_config_network_interface(uint8_t port_id, uint8_t if_up); static rte_atomic32_t kni_stop = RTE_ATOMIC32_INIT(0); void kni_burst_free_mbufs(struct rte_mbuf** pkts, unsigned num) { unsigned i; if (pkts == NULL) return; for (i = 0; i < num; i++) { rte_pktmbuf_free(pkts[i]); pkts[i] = NULL; } }
#include <rte_string_fns.h> #include "lagopus/ethertype.h" #include "lagopus/flowdb.h" #include "lagopus/meter.h" #include "lagopus/port.h" #include "lagopus_gstate.h" #include "lagopus/ofp_dp_apis.h" #include "lagopus/vector.h" #include "lagopus/dataplane.h" #include "pktbuf.h" #include "packet.h" #include "dpdk/dpdk.h" rte_atomic32_t dpdk_stop = RTE_ATOMIC32_INIT(0); int app_lcore_main_loop(void *arg) { struct app_lcore_params *lp; unsigned lcore; lcore = rte_lcore_id(); lp = &app.lcore_params[lcore]; if (lp->type == e_APP_LCORE_IO) { printf("Logical core %u (I/O) main loop.\n", lcore); #ifdef HAVE_PTHREAD_SETNAME_NP (void)pthread_setname_np(pthread_self(), "main_loop_io"); #endif /* HAVE_PTHREAD_SETNAME_NP */ app_lcore_main_loop_io(arg);