]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/examples/server_node_efd/shared/common.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / seastar / dpdk / examples / server_node_efd / shared / common.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
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
16 * distribution.
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.
20 *
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.
32 */
33
34 #ifndef _COMMON_H_
35 #define _COMMON_H_
36
37 #include <rte_hash_crc.h>
38 #include <rte_hash.h>
39
40 #define MAX_NODES 16
41 /*
42 * Shared port info, including statistics information for display by server.
43 * Structure will be put in a memzone.
44 * - All port id values share one cache line as this data will be read-only
45 * during operation.
46 * - All rx statistic values share cache lines, as this data is written only
47 * by the server process. (rare reads by stats display)
48 * - The tx statistics have values for all ports per cache line, but the stats
49 * themselves are written by the nodes, so we have a distinct set, on different
50 * cache lines for each node to use.
51 */
52 struct rx_stats {
53 uint64_t rx[RTE_MAX_ETHPORTS];
54 } __rte_cache_aligned;
55
56 struct tx_stats {
57 uint64_t tx[RTE_MAX_ETHPORTS];
58 uint64_t tx_drop[RTE_MAX_ETHPORTS];
59 } __rte_cache_aligned;
60
61 struct filter_stats {
62 uint64_t drop;
63 uint64_t passed;
64 } __rte_cache_aligned;
65
66 struct shared_info {
67 uint8_t num_nodes;
68 uint8_t num_ports;
69 uint32_t num_flows;
70 uint8_t id[RTE_MAX_ETHPORTS];
71 struct rx_stats rx_stats;
72 struct tx_stats tx_stats[MAX_NODES];
73 struct filter_stats filter_stats[MAX_NODES];
74 };
75
76 /* define common names for structures shared between server and node */
77 #define MP_NODE_RXQ_NAME "MProc_Node_%u_RX"
78 #define PKTMBUF_POOL_NAME "MProc_pktmbuf_pool"
79 #define MZ_SHARED_INFO "MProc_shared_info"
80
81 /*
82 * Given the rx queue name template above, get the queue name
83 */
84 static inline const char *
85 get_rx_queue_name(unsigned int id)
86 {
87 /*
88 * Buffer for return value. Size calculated by %u being replaced
89 * by maximum 3 digits (plus an extra byte for safety)
90 */
91 static char buffer[sizeof(MP_NODE_RXQ_NAME) + 2];
92
93 snprintf(buffer, sizeof(buffer) - 1, MP_NODE_RXQ_NAME, id);
94 return buffer;
95 }
96
97 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
98
99 #endif