X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl3fwd%2Fl3fwd.h;h=ad39496e6431235eb4488bb2c2219406b9947fb4;hb=7c0c63c9a53964d40b27da618ab94303f28ea92e;hp=d8798b7d4b9ec5ab2aecd41a6c018c80fd2e925f;hpb=71a7e2424e07e458ef0e31536ea23890702efd3c;p=dpdk.git diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index d8798b7d4b..ad39496e64 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -1,54 +1,35 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2021 Intel Corporation */ #ifndef __L3_FWD_H__ #define __L3_FWD_H__ +#include #include #define DO_RFC_1812_CHECKS #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1 -#if !defined(NO_HASH_MULTI_LOOKUP) && defined(RTE_MACHINE_CPUFLAG_NEON) +#if !defined(NO_HASH_MULTI_LOOKUP) && defined(__ARM_NEON) #define NO_HASH_MULTI_LOOKUP 1 #endif +/* + * Configurable number of RX/TX ring descriptors + */ +#define RTE_TEST_RX_DESC_DEFAULT 1024 +#define RTE_TEST_TX_DESC_DEFAULT 1024 + #define MAX_PKT_BURST 32 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ +#define MEMPOOL_CACHE_SIZE 256 #define MAX_RX_QUEUE_PER_LCORE 16 +#define VECTOR_SIZE_DEFAULT MAX_PKT_BURST +#define VECTOR_TMO_NS_DEFAULT 1E6 /* 1ms */ /* * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to send. */ @@ -68,14 +49,19 @@ #define MASK_ETH 0x3f /* Hash parameters. */ -#ifdef RTE_ARCH_X86_64 +#ifdef RTE_ARCH_64 /* default to 4 million hash entries (approx) */ #define L3FWD_HASH_ENTRIES (1024*1024*4) #else /* 32-bit has less address-space for hugepage memory, limit to 1M entries */ #define L3FWD_HASH_ENTRIES (1024*1024*1) #endif -#define HASH_ENTRY_NUMBER_DEFAULT 4 +#define HASH_ENTRY_NUMBER_DEFAULT 16 + +struct parm_cfg { + const char *rule_ipv4_name; + const char *rule_ipv6_name; +}; struct mbuf_table { uint16_t len; @@ -83,7 +69,7 @@ struct mbuf_table { }; struct lcore_rx_queue { - uint8_t port_id; + uint16_t port_id; uint8_t queue_id; } __rte_cache_aligned; @@ -100,9 +86,13 @@ struct lcore_conf { extern volatile bool force_quit; +/* RX and TX queue depths */ +extern uint16_t nb_rxd; +extern uint16_t nb_txd; + /* ethernet addresses of ports */ extern uint64_t dest_eth_addr[RTE_MAX_ETHPORTS]; -extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; +extern struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; /* mask of enabled ports */ extern uint32_t enabled_port_mask; @@ -115,9 +105,11 @@ extern xmm_t val_eth[RTE_MAX_ETHPORTS]; extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; +extern struct parm_cfg parm_config; + /* Send burst of packets on an output interface */ static inline int -send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) +send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port) { struct rte_mbuf **m_table; int ret; @@ -139,7 +131,7 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) /* Enqueue a single packet, and send burst if queue is filled */ static inline int send_single_packet(struct lcore_conf *qconf, - struct rte_mbuf *m, uint8_t port) + struct rte_mbuf *m, uint16_t port) { uint16_t len; @@ -159,14 +151,14 @@ send_single_packet(struct lcore_conf *qconf, #ifdef DO_RFC_1812_CHECKS static inline int -is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len) +is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len) { /* From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2 */ /* * 1. The packet length reported by the Link Layer must be large * enough to hold the minimum length legal IP datagram (20 bytes). */ - if (link_len < sizeof(struct ipv4_hdr)) + if (link_len < sizeof(struct rte_ipv4_hdr)) return -1; /* 2. The IP checksum must be correct. */ @@ -191,20 +183,26 @@ is_valid_ipv4_pkt(struct ipv4_hdr *pkt, uint32_t link_len) * datagram header, whose length is specified in the IP header length * field. */ - if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct ipv4_hdr)) + if (rte_cpu_to_be_16(pkt->total_length) < sizeof(struct rte_ipv4_hdr)) return -5; return 0; } #endif /* DO_RFC_1812_CHECKS */ -/* Function pointers for LPM or EM functionality. */ +int +init_mem(uint16_t portid, unsigned int nb_mbuf); + +/* Function pointers for LPM, EM or FIB functionality. */ void setup_lpm(const int socketid); void setup_hash(const int socketid); +void +setup_fib(const int socketid); + int em_check_ptype(int portid); @@ -212,20 +210,75 @@ int lpm_check_ptype(int portid); uint16_t -em_cb_parse_ptype(uint8_t port, uint16_t queue, struct rte_mbuf *pkts[], +em_cb_parse_ptype(uint16_t port, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts, void *user_param); uint16_t -lpm_cb_parse_ptype(uint8_t port, uint16_t queue, struct rte_mbuf *pkts[], +lpm_cb_parse_ptype(uint16_t port, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts, void *user_param); int -em_main_loop(__attribute__((unused)) void *dummy); +em_main_loop(__rte_unused void *dummy); int -lpm_main_loop(__attribute__((unused)) void *dummy); +lpm_main_loop(__rte_unused void *dummy); -/* Return ipv4/ipv6 fwd lookup struct for LPM or EM. */ +int +fib_main_loop(__rte_unused void *dummy); + +int +lpm_event_main_loop_tx_d(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_d_burst(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_q(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_q_burst(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_d_vector(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_d_burst_vector(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_q_vector(__rte_unused void *dummy); +int +lpm_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy); + +int +em_event_main_loop_tx_d(__rte_unused void *dummy); +int +em_event_main_loop_tx_d_burst(__rte_unused void *dummy); +int +em_event_main_loop_tx_q(__rte_unused void *dummy); +int +em_event_main_loop_tx_q_burst(__rte_unused void *dummy); +int +em_event_main_loop_tx_d_vector(__rte_unused void *dummy); +int +em_event_main_loop_tx_d_burst_vector(__rte_unused void *dummy); +int +em_event_main_loop_tx_q_vector(__rte_unused void *dummy); +int +em_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy); + +int +fib_event_main_loop_tx_d(__rte_unused void *dummy); +int +fib_event_main_loop_tx_d_burst(__rte_unused void *dummy); +int +fib_event_main_loop_tx_q(__rte_unused void *dummy); +int +fib_event_main_loop_tx_q_burst(__rte_unused void *dummy); +int +fib_event_main_loop_tx_d_vector(__rte_unused void *dummy); +int +fib_event_main_loop_tx_d_burst_vector(__rte_unused void *dummy); +int +fib_event_main_loop_tx_q_vector(__rte_unused void *dummy); +int +fib_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy); + + +/* Return ipv4/ipv6 fwd lookup struct for LPM, EM or FIB. */ void * em_get_ipv4_l3fwd_lookup_struct(const int socketid); @@ -238,4 +291,10 @@ lpm_get_ipv4_l3fwd_lookup_struct(const int socketid); void * lpm_get_ipv6_l3fwd_lookup_struct(const int socketid); +void * +fib_get_ipv4_l3fwd_lookup_struct(const int socketid); + +void * +fib_get_ipv6_l3fwd_lookup_struct(const int socketid); + #endif /* __L3_FWD_H__ */