1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #ifndef _COMMON_H_ 6 #define _COMMON_H_ 7 8 #define MAX_CLIENTS 16 9 10 /* 11 * Shared port info, including statistics information for display by server. 12 * Structure will be put in a memzone. 13 * - All port id values share one cache line as this data will be read-only 14 * during operation. 15 * - All rx statistic values share cache lines, as this data is written only 16 * by the server process. (rare reads by stats display) 17 * - The tx statistics have values for all ports per cache line, but the stats 18 * themselves are written by the clients, so we have a distinct set, on different 19 * cache lines for each client to use. 20 */ 21 struct __rte_cache_aligned rx_stats { 22 uint64_t rx[RTE_MAX_ETHPORTS]; 23 }; 24 25 struct __rte_cache_aligned tx_stats { 26 uint64_t tx[RTE_MAX_ETHPORTS]; 27 uint64_t tx_drop[RTE_MAX_ETHPORTS]; 28 }; 29 30 struct port_info { 31 uint16_t num_ports; 32 uint16_t id[RTE_MAX_ETHPORTS]; 33 volatile struct rx_stats rx_stats; 34 volatile struct tx_stats tx_stats[MAX_CLIENTS]; 35 }; 36 37 /* define common names for structures shared between server and client */ 38 #define MP_CLIENT_RXQ_NAME "MProc_Client_%u_RX" 39 #define PKTMBUF_POOL_NAME "MProc_pktmbuf_pool" 40 #define MZ_PORT_INFO "MProc_port_info" 41 42 /* 43 * Given the rx queue name template above, get the queue name 44 */ 45 static inline const char * get_rx_queue_name(uint8_t id)46get_rx_queue_name(uint8_t id) 47 { 48 /* buffer for return value. Size calculated by %u being replaced 49 * by maximum 3 digits (plus an extra byte for safety) */ 50 static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2]; 51 52 snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id); 53 return buffer; 54 } 55 56 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 57 58 #endif 59