From 51cd08d9a3f2826088d122e2a5683315c77a2786 Mon Sep 17 00:00:00 2001 From: Vishwesh M Rudramuni Date: Tue, 18 Apr 2017 19:41:40 +0530 Subject: common: Adding common library for sample vnf JIRA: SAMPLEVNF-3 This patch adds common libraries required as part of the sample vnf. This includes the following libraries 1. ACL library 2. SIP 3. FTP 4. Connection tracker 5. L2l3 stack - Interface Manager - ARP & ICMPv4 - ND & ICMPv6 and other common libraries needed for ip pipeline framework Change-Id: I117690b6b63fbcd76974cd7274518484e60980ab Signed-off-by: Vishwesh M Rudramuni [Push patch to gerrit] Signed-off-by: Deepak S --- common/VIL/l2l3_stack/interface.h | 873 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 873 insertions(+) create mode 100644 common/VIL/l2l3_stack/interface.h (limited to 'common/VIL/l2l3_stack/interface.h') diff --git a/common/VIL/l2l3_stack/interface.h b/common/VIL/l2l3_stack/interface.h new file mode 100644 index 00000000..0f654fa1 --- /dev/null +++ b/common/VIL/l2l3_stack/interface.h @@ -0,0 +1,873 @@ +/* +// Copyright (c) 2017 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ +#ifndef INTERFACE_H +#define INTERFACE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RTE_LOGTYPE_IFM RTE_LOGTYPE_USER1 +#define IFM_SUCCESS 0 +#define IFM_FAILURE -1 +/* + * IFM Ether link related macros + */ +#define IFM_ETH_LINK_HALF_DUPLEX 0 +#define IFM_ETH_LINK_FULL_DUPLEX 1 +#define IFM_ETH_LINK_DOWN 0 +#define IFM_ETH_LINK_UP 1 +#define IFM_ETH_LINK_FIXED 0 + +/* + * Bonding + */ +#define IFM_SLAVE (1<<0) +#define IFM_MASTER (1<<1) +#define IFM_BONDED (1<<2) +#define IFM_IPV4_ENABLED (1<<3) +#define IFM_IPV6_ENABLED (1<<4) + +#define IFM_BONDING_MODE_ROUND_ROBIN 0 +#define IFM_BONDING_MODE_ACTIVE_BACKUP 1 +#define IFM_BONDING_MODE_BALANCE 2 +#define IFM_BONDING_MODE_BROADCAST 3 +#define IFM_BONDING_MODE_8023AD 4 +#define IFM_BONDING_MODE_TLB 5 +#define IFM_BONDING_MODE_ALB 6 + +#define IFM_BALANCE_XMIT_POLICY_LAYER2 0 +#define IFM_BALANCE_XMIT_POLICY_LAYER23 1 +#define IFM_BALANCE_XMIT_POLICY_LAYER34 2 +/* + * Queue related macros + */ +#define IFM_QUEUE_STAT_CNTRS 16 +#define IFM_TX_DEFAULT_Q 0 +#define IFM_RX_DEFAULT_Q 0 +#define IFM_RX_DESC_DEFAULT 128 +#define IFM_TX_DESC_DEFAULT 512 +#define IFM_BURST_SIZE 32 +#define IFM_BURST_TX_WAIT_US 1 +#define IFM_BURST_TX_RETRIES 64 +#define BURST_TX_DRAIN_US 100 + +/* + * Misc + */ +#define IFM_IFNAME_LEN 16 +#define IFM_CLIENT_NAME 20 +#define IFM_MAX_CLIENT 10 + +#define IFM_ETHER_ADDR_SIZE 6 +#define IFM_IPV6_ADDR_SIZE 16 + +#define IFM_DEBUG_CONFIG (1<<0) +#define IFM_DEBUG_RXTX (1<<1) +#define IFM_DEBUG_LOCKS (1<<2) +#define IFM_DEBUG (1<<4) +#define IFM_MAX_PORTARR_SZ 64 +#define IFM_MAX_PORTARR_SZ 64 +/** + * Mempool configuration details: + * Stores the mempool configuration information for the port. + */ +struct mempool_config { + uint32_t pool_size;/**< The number of elements in the mempool.*/ + uint32_t buffer_size; + /**< The size of an element*/ + uint32_t cache_size; + /**< Cache size */ + uint32_t cpu_socket_id; + /**< The socket identifier in the case of NUMA.*/ +} __rte_cache_aligned; + +/** + * Port configuration: + * Stores the configuration information for the port. + * This structure is used during port and tx/rx queue setup. + */ +typedef struct _port_config_ { + uint8_t port_id; /**< port id or pmd id to be configured */ + int nrx_queue; /**< no of rx queues */ + int ntx_queue; /**< no of tx queues */ + uint32_t tx_buf_size; + uint32_t state; /**< noshut/shut the admin state of the port*/ + uint32_t promisc; /**< enable/diable promisc mode*/ + struct mempool_config mempool; + /**< Mempool configurations */ + struct rte_eth_conf port_conf; + /**< port configuration */ + struct rte_eth_rxconf rx_conf; + /**< rx queue configurations */ + struct rte_eth_txconf tx_conf; + /**< tx queue configurations */ +} port_config_t; + +/** + * Port statistics: + * if_stats structure is a member variable of structure l2_phy_interface_t. + * Used to maintain stats retreived from rte_eth_stats structure. + */ +typedef struct _if_stats_ { + uint64_t rx_npkts;/**< Total number of successfully received packets.*/ + uint64_t tx_npkts;/**< Total number of successfully transmitted bytes. */ + uint64_t rx_bytes;/**< Total number of successfully received bytes.*/ + uint64_t tx_bytes;/**< Total number of successfully transmitted bytes.*/ + uint64_t rx_missed_pkts; + /**< no of packets dropped by hw due because rx queues are full*/ + uint64_t rx_err_pkts;/**< Total number of erroneous received packets. */ + uint64_t rx_nobuf_fail;/**< Total number of RX mbuf allocation failures. */ + uint64_t tx_failed_pkts;/**< Total number of failed transmitted packets.*/ + uint64_t q_rxpkts[IFM_QUEUE_STAT_CNTRS];/**< Total number of queue RX packets.*/ + uint64_t q_txpkts[IFM_QUEUE_STAT_CNTRS];/**< Total number of queue TX packets.*/ + uint64_t q_rx_bytes[IFM_QUEUE_STAT_CNTRS]; + /**< Total number of successfully received queue bytes.*/ + uint64_t q_tx_bytes[IFM_QUEUE_STAT_CNTRS]; + /**< Total number of successfully transmitted queue bytes.*/ + uint64_t q_rx_pkt_drop[IFM_QUEUE_STAT_CNTRS]; + /**