]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/examples/server_node_efd/shared/common.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / examples / server_node_efd / shared / common.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
3 */
4
5 #ifndef _COMMON_H_
6 #define _COMMON_H_
7
8 #include <rte_hash_crc.h>
9 #include <rte_hash.h>
10
11 #define MAX_NODES 16
12 /*
13 * Shared port info, including statistics information for display by server.
14 * Structure will be put in a memzone.
15 * - All port id values share one cache line as this data will be read-only
16 * during operation.
17 * - All rx statistic values share cache lines, as this data is written only
18 * by the server process. (rare reads by stats display)
19 * - The tx statistics have values for all ports per cache line, but the stats
20 * themselves are written by the nodes, so we have a distinct set, on different
21 * cache lines for each node to use.
22 */
23 struct rx_stats {
24 uint64_t rx[RTE_MAX_ETHPORTS];
25 } __rte_cache_aligned;
26
27 struct tx_stats {
28 uint64_t tx[RTE_MAX_ETHPORTS];
29 uint64_t tx_drop[RTE_MAX_ETHPORTS];
30 } __rte_cache_aligned;
31
32 struct filter_stats {
33 uint64_t drop;
34 uint64_t passed;
35 } __rte_cache_aligned;
36
37 struct shared_info {
38 uint8_t num_nodes;
39 uint16_t num_ports;
40 uint32_t num_flows;
41 uint16_t id[RTE_MAX_ETHPORTS];
42 struct rx_stats rx_stats;
43 struct tx_stats tx_stats[MAX_NODES];
44 struct filter_stats filter_stats[MAX_NODES];
45 };
46
47 /* define common names for structures shared between server and node */
48 #define MP_NODE_RXQ_NAME "MProc_Node_%u_RX"
49 #define PKTMBUF_POOL_NAME "MProc_pktmbuf_pool"
50 #define MZ_SHARED_INFO "MProc_shared_info"
51
52 /*
53 * Given the rx queue name template above, get the queue name
54 */
55 static inline const char *
56 get_rx_queue_name(unsigned int id)
57 {
58 /*
59 * Buffer for return value. Size calculated by %u being replaced
60 * by maximum 3 digits (plus an extra byte for safety)
61 */
62 static char buffer[sizeof(MP_NODE_RXQ_NAME) + 2];
63
64 snprintf(buffer, sizeof(buffer), MP_NODE_RXQ_NAME, id);
65 return buffer;
66 }
67
68 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
69
70 #endif