sched: remove useless malloc in PIE data init
[dpdk.git] / examples / l2fwd-event / l2fwd_common.h
index a4e17ab..396e238 100644 (file)
@@ -27,7 +27,6 @@
 #include <rte_memcpy.h>
 #include <rte_eal.h>
 #include <rte_launch.h>
-#include <rte_atomic.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
 #include <rte_lcore.h>
@@ -56,6 +55,9 @@
 #define DEFAULT_TIMER_PERIOD   10 /* default period is 10 seconds */
 #define MAX_TIMER_PERIOD       86400 /* 1 day max */
 
+#define VECTOR_SIZE_DEFAULT   MAX_PKT_BURST
+#define VECTOR_TMO_NS_DEFAULT 1E6 /* 1ms */
+
 /* Per-port statistics struct */
 struct l2fwd_port_statistics {
        uint64_t dropped;
@@ -63,20 +65,30 @@ struct l2fwd_port_statistics {
        uint64_t rx;
 } __rte_cache_aligned;
 
+/* Event vector attributes */
+struct l2fwd_event_vector_params {
+       uint8_t enabled;
+       uint16_t size;
+       uint64_t timeout_ns;
+};
+
 struct l2fwd_resources {
        volatile uint8_t force_quit;
        uint8_t event_mode;
        uint8_t sched_type;
        uint8_t mac_updating;
        uint8_t rx_queue_per_lcore;
+       bool port_pairs;
        uint16_t nb_rxd;
        uint16_t nb_txd;
        uint32_t enabled_port_mask;
        uint64_t timer_period;
        struct rte_mempool *pktmbuf_pool;
+       struct rte_mempool *evt_vec_pool;
        uint32_t dst_ports[RTE_MAX_ETHPORTS];
        struct rte_ether_addr eth_addr[RTE_MAX_ETHPORTS];
        struct l2fwd_port_statistics port_stats[RTE_MAX_ETHPORTS];
+       struct l2fwd_event_vector_params evt_vec;
        void *evt_rsrc;
        void *poll_rsrc;
 } __rte_cache_aligned;
@@ -91,11 +103,11 @@ l2fwd_mac_updating(struct rte_mbuf *m, uint32_t dest_port_id,
        eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
 
        /* 02:00:00:00:00:xx */
-       tmp = &eth->d_addr.addr_bytes[0];
+       tmp = &eth->dst_addr.addr_bytes[0];
        *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_port_id << 40);
 
        /* src addr */
-       rte_ether_addr_copy(addr, &eth->s_addr);
+       rte_ether_addr_copy(addr, &eth->src_addr);
 }
 
 static __rte_always_inline struct l2fwd_resources *
@@ -114,6 +126,7 @@ l2fwd_get_rsrc(void)
 
                memset(rsrc, 0, sizeof(struct l2fwd_resources));
                rsrc->mac_updating = true;
+               rsrc->event_mode = true;
                rsrc->rx_queue_per_lcore = 1;
                rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC;
                rsrc->timer_period = 10 * rte_get_timer_hz();