1*2bfe3f2eSlogwang /*- 2*2bfe3f2eSlogwang * BSD LICENSE 3*2bfe3f2eSlogwang * 4*2bfe3f2eSlogwang * Copyright(c) 2016-2017 Intel Corporation. All rights reserved. 5*2bfe3f2eSlogwang * All rights reserved. 6*2bfe3f2eSlogwang * 7*2bfe3f2eSlogwang * Redistribution and use in source and binary forms, with or without 8*2bfe3f2eSlogwang * modification, are permitted provided that the following conditions 9*2bfe3f2eSlogwang * are met: 10*2bfe3f2eSlogwang * 11*2bfe3f2eSlogwang * * Redistributions of source code must retain the above copyright 12*2bfe3f2eSlogwang * notice, this list of conditions and the following disclaimer. 13*2bfe3f2eSlogwang * * Redistributions in binary form must reproduce the above copyright 14*2bfe3f2eSlogwang * notice, this list of conditions and the following disclaimer in 15*2bfe3f2eSlogwang * the documentation and/or other materials provided with the 16*2bfe3f2eSlogwang * distribution. 17*2bfe3f2eSlogwang * * Neither the name of Intel Corporation nor the names of its 18*2bfe3f2eSlogwang * contributors may be used to endorse or promote products derived 19*2bfe3f2eSlogwang * from this software without specific prior written permission. 20*2bfe3f2eSlogwang * 21*2bfe3f2eSlogwang * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*2bfe3f2eSlogwang * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*2bfe3f2eSlogwang * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24*2bfe3f2eSlogwang * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25*2bfe3f2eSlogwang * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26*2bfe3f2eSlogwang * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27*2bfe3f2eSlogwang * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28*2bfe3f2eSlogwang * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29*2bfe3f2eSlogwang * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30*2bfe3f2eSlogwang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31*2bfe3f2eSlogwang * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*2bfe3f2eSlogwang */ 33*2bfe3f2eSlogwang 34*2bfe3f2eSlogwang #ifndef _COMMON_H_ 35*2bfe3f2eSlogwang #define _COMMON_H_ 36*2bfe3f2eSlogwang 37*2bfe3f2eSlogwang #include <rte_hash_crc.h> 38*2bfe3f2eSlogwang #include <rte_hash.h> 39*2bfe3f2eSlogwang 40*2bfe3f2eSlogwang #define MAX_NODES 16 41*2bfe3f2eSlogwang /* 42*2bfe3f2eSlogwang * Shared port info, including statistics information for display by server. 43*2bfe3f2eSlogwang * Structure will be put in a memzone. 44*2bfe3f2eSlogwang * - All port id values share one cache line as this data will be read-only 45*2bfe3f2eSlogwang * during operation. 46*2bfe3f2eSlogwang * - All rx statistic values share cache lines, as this data is written only 47*2bfe3f2eSlogwang * by the server process. (rare reads by stats display) 48*2bfe3f2eSlogwang * - The tx statistics have values for all ports per cache line, but the stats 49*2bfe3f2eSlogwang * themselves are written by the nodes, so we have a distinct set, on different 50*2bfe3f2eSlogwang * cache lines for each node to use. 51*2bfe3f2eSlogwang */ 52*2bfe3f2eSlogwang struct rx_stats { 53*2bfe3f2eSlogwang uint64_t rx[RTE_MAX_ETHPORTS]; 54*2bfe3f2eSlogwang } __rte_cache_aligned; 55*2bfe3f2eSlogwang 56*2bfe3f2eSlogwang struct tx_stats { 57*2bfe3f2eSlogwang uint64_t tx[RTE_MAX_ETHPORTS]; 58*2bfe3f2eSlogwang uint64_t tx_drop[RTE_MAX_ETHPORTS]; 59*2bfe3f2eSlogwang } __rte_cache_aligned; 60*2bfe3f2eSlogwang 61*2bfe3f2eSlogwang struct filter_stats { 62*2bfe3f2eSlogwang uint64_t drop; 63*2bfe3f2eSlogwang uint64_t passed; 64*2bfe3f2eSlogwang } __rte_cache_aligned; 65*2bfe3f2eSlogwang 66*2bfe3f2eSlogwang struct shared_info { 67*2bfe3f2eSlogwang uint8_t num_nodes; 68*2bfe3f2eSlogwang uint16_t num_ports; 69*2bfe3f2eSlogwang uint32_t num_flows; 70*2bfe3f2eSlogwang uint16_t id[RTE_MAX_ETHPORTS]; 71*2bfe3f2eSlogwang struct rx_stats rx_stats; 72*2bfe3f2eSlogwang struct tx_stats tx_stats[MAX_NODES]; 73*2bfe3f2eSlogwang struct filter_stats filter_stats[MAX_NODES]; 74*2bfe3f2eSlogwang }; 75*2bfe3f2eSlogwang 76*2bfe3f2eSlogwang /* define common names for structures shared between server and node */ 77*2bfe3f2eSlogwang #define MP_NODE_RXQ_NAME "MProc_Node_%u_RX" 78*2bfe3f2eSlogwang #define PKTMBUF_POOL_NAME "MProc_pktmbuf_pool" 79*2bfe3f2eSlogwang #define MZ_SHARED_INFO "MProc_shared_info" 80*2bfe3f2eSlogwang 81*2bfe3f2eSlogwang /* 82*2bfe3f2eSlogwang * Given the rx queue name template above, get the queue name 83*2bfe3f2eSlogwang */ 84*2bfe3f2eSlogwang static inline const char * 85*2bfe3f2eSlogwang get_rx_queue_name(unsigned int id) 86*2bfe3f2eSlogwang { 87*2bfe3f2eSlogwang /* 88*2bfe3f2eSlogwang * Buffer for return value. Size calculated by %u being replaced 89*2bfe3f2eSlogwang * by maximum 3 digits (plus an extra byte for safety) 90*2bfe3f2eSlogwang */ 91*2bfe3f2eSlogwang static char buffer[sizeof(MP_NODE_RXQ_NAME) + 2]; 92*2bfe3f2eSlogwang 93*2bfe3f2eSlogwang snprintf(buffer, sizeof(buffer) - 1, MP_NODE_RXQ_NAME, id); 94*2bfe3f2eSlogwang return buffer; 95*2bfe3f2eSlogwang } 96*2bfe3f2eSlogwang 97*2bfe3f2eSlogwang #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 98*2bfe3f2eSlogwang 99*2bfe3f2eSlogwang #endif 100