4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _IVSHMEM_COMMON_H_
35 #define _IVSHMEM_COMMON_H_
37 #define RTE_LOGTYPE_L2FWD_IVSHMEM RTE_LOGTYPE_USER1
39 #define CTRL_MZ_NAME "CTRL_MEMZONE"
40 #define MBUF_MP_NAME "MBUF_MEMPOOL"
41 #define RX_RING_PREFIX "RX_"
42 #define TX_RING_PREFIX "TX_"
44 /* A tsc-based timer responsible for triggering statistics printout */
45 #define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
46 #define MAX_TIMER_PERIOD 86400 /* 1 day max */
47 static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* default period is 10 seconds */
50 (sizeof(x)/sizeof(x)[0])
52 #define MAX_PKT_BURST 32
54 const struct rte_memzone * ctrl_mz;
63 /* Per-port statistics struct */
64 struct port_statistics {
68 } __rte_cache_aligned;
72 struct rte_mbuf *m_table[MAX_PKT_BURST * 2]; /**< allow up to two bursts */
75 struct vm_port_param {
76 struct rte_ring * rx_ring; /**< receiving ring for current port */
77 struct rte_ring * tx_ring; /**< transmitting ring for current port */
78 struct vm_port_param * dst; /**< current port's destination port */
79 volatile struct port_statistics stats; /**< statistics for current port */
80 struct ether_addr ethaddr; /**< Ethernet address of the port */
83 /* control structure, to synchronize host and VM */
86 uint8_t nb_ports; /**< total nr of ports */
87 volatile enum l2fwd_state state; /**< report state */
88 struct vm_port_param vm_ports[RTE_MAX_ETHPORTS];
91 struct ivshmem_ctrl * ctrl;
93 static unsigned int l2fwd_ivshmem_rx_queue_per_lcore = 1;
95 static void sighandler(int __rte_unused s)
97 ctrl->state = STATE_EXIT;
100 static void sigsetup(void)
102 struct sigaction sigIntHandler;
104 sigIntHandler.sa_handler = sighandler;
105 sigemptyset(&sigIntHandler.sa_mask);
106 sigIntHandler.sa_flags = 0;
108 sigaction(SIGINT, &sigIntHandler, NULL);
111 #endif /* _IVSHMEM_COMMON_H_ */