#ifndef _UAPI_PPA_API_H #define _UAPI_PPA_API_H /******************************************************************************* ** ** FILE NAME : ppa_api.h ** PROJECT : PPA ** MODULES : PPA API (Routing/Bridging Acceleration APIs) ** ** DATE : 31 OCT 2008 ** AUTHOR : Xu Liang ** DESCRIPTION : PPA Protocol Stack Hook API Header File ** COPYRIGHT : Copyright (c) 2017 Intel Corporation ** Copyright (c) 2010 - 2016 Lantiq Beteiligungs-GmbH & Co. KG ** ** HISTORY ** $Date $Author $Comment ** 31 OCT 2008 Xu Liang Initiate Version ** 10 DEC 2012 Manamohan Shetty Added the support for RTP,MIB mode ** 08 APR 2014 Kamal Eradath GRX500 Adaptations ** 18 AUG 2017 Kamal Eradath Splitting to UAPI *******************************************************************************/ /*! \file ppa_api.h \brief This file contains es. provide PPA API. */ /** \defgroup PPA_IOCTL PPA Userspace API \brief The subset of PPA API which is exposed to userspace for control and configuration of the PPA is invoked through an ioctls()/system call interface as described in this section. The API is defined in the following two source files: - ppa_api.h: Header file for PPA API - ppa_api.c: C Implementation file for PPA API */ #include #include #include /* * #################################### * Definition * #################################### */ /*! \brief PPA_MAX_IFS_NUM */ #define PPA_MAX_IFS_NUM 16 /*!< Maximum interface number supported */ #define MAX_SUBIF 16 /*!< Maximum sub interface supported */ /*! \brief PPA_MAX_MC_IFS_NUM */ #define PPA_MAX_MC_IFS_NUM 16 /*!< Maximum number of Multicast supporting interfaces */ #define DEFAULT_TOS 0 #define DEFAULT_TTL 1 #define DEFAULT_MAX_FRG_SIZE 1518 #define SESSION_LIST_HASH_SHIFT 8 #define SESSION_LIST_HASH_BIT_LENGTH 9 #define SESSION_LIST_HASH_MASK ((1 << SESSION_LIST_HASH_BIT_LENGTH) - 1) #define SESSION_LIST_HASH_TABLE_SIZE (1 << (SESSION_LIST_HASH_BIT_LENGTH + 1)) #define SESSION_LIST_HASH_VALUE(x, is_reply) (((((uint32_t)(x) >> SESSION_LIST_HASH_SHIFT) & SESSION_LIST_HASH_MASK) << 1) | ((is_reply) ? 1 : 0)) #define SESSION_LIST_MC_HASH_SHIFT 0 #define SESSION_LIST_MC_HASH_BIT_LENGTH 6 #define SESSION_LIST_MC_HASH_MASK ((1 << SESSION_LIST_MC_HASH_BIT_LENGTH) - 1) #define SESSION_LIST_MC_HASH_TABLE_SIZE (1 << SESSION_LIST_MC_HASH_BIT_LENGTH) #define SESSION_LIST_MC_HASH_VALUE(x) (((uint32_t)(x) >> SESSION_LIST_MC_HASH_SHIFT) & SESSION_LIST_MC_HASH_MASK) #define BRIDGING_SESSION_LIST_HASH_BIT_LENGTH 8 #define BRIDGING_SESSION_LIST_HASH_MASK ((1 << BRIDGING_SESSION_LIST_HASH_BIT_LENGTH) - 1) #define BRIDGING_SESSION_LIST_HASH_TABLE_SIZE (1 << BRIDGING_SESSION_LIST_HASH_BIT_LENGTH) #define PPA_BRIDGING_SESSION_LIST_HASH_VALUE(x) ((((uint32_t)((uint8_t *)(x))[4] << 8) | ((uint8_t *)(x))[5]) & BRIDGING_SESSION_LIST_HASH_MASK) /*! \brief PPA_MAX_VLAN_FILTER */ #define PPA_MAX_VLAN_FILTER 32 /*!< Maximum number of VLAN fitler */ /*! \brief PPA_IOC_MAGIC */ #define PPA_IOC_MAGIC ((uint32_t)'p') /*!< Magic number to differentiate PPA ioctl commands */ /*! \brief PPA_SUCCESS */ #define PPA_SUCCESS 0 /*!< Operation was successful. */ /*! \brief PPA_FAILURE */ #define PPA_FAILURE -1 /*!< Operation failed */ /*! \brief PPA_EPERM */ #define PPA_EPERM -2 /*!< not permitted */ /*! \brief PPA_EIO */ #define PPA_EIO -5 /*!< I/O/Hardware/Firmware error */ /*! \brief PPA_EAGAIN */ #define PPA_EAGAIN -11 /*!< try again later */ /*! \brief PPA_ENOMEM */ #define PPA_ENOMEM -12 /*!< out of memory */ /*! \brief PPA_NETIF_FAIL */ #define PPA_NETIF_FAIL 0 /*!< netif passed is NULL */ /*! \brief PPA_EACCESS */ #define PPA_EACCESS PPA_EPERM /*! \brief PPA_EFAULT */ #define PPA_EFAULT -14 /*!< bad address */ /*! \brief PPA_EBUSY */ #define PPA_EBUSY -16 /*!< busy */ /*! \brief PPA_EINVAL */ #define PPA_EINVAL -22 /*!< invalid argument */ /*! \brief PPA_ENOTAVAIL */ #define PPA_ENOTAVAIL -97 /*! \brief PPA_ENOTPOSSIBLE */ #define PPA_ENOTPOSSIBLE -98 /*! \brief PPA_ENOTIMPL */ #define PPA_ENOTIMPL -99 /*!< not implemented */ /*! \brief PPA_INDEX_OVERFLOW */ #define PPA_INDEX_OVERFLOW -100 /*! \brief PPA_ENABLED */ #define PPA_ENABLED 1 /*!< Status enabled / Device was enabled */ /*! \brief PPA_DISABLED */ #define PPA_DISABLED 0 /*!< Status disabled / Device was disabled. */ /*! \brief PPA_MAX_PORT_NUM */ #define PPA_MAX_PORT_NUM 16 /*!< Maximum PPE FW Port number supported in PPA layer. */ /*! \brief PPA_MAX_QOS_QUEUE_NUM */ #define PPA_MAX_QOS_QUEUE_NUM 16 /*!< Maximum PPE FW QoS Queue number supported in PPA layer for one port. */ /* * flags */ /*! \brief PPA_F_BEFORE_NAT_TRANSFORM \note PPA Routing Session add hook is called before NAT transform has taken place. \n In Linux OS, this NSFORM corresponds to the netfilter PREROUTING hook */ #define PPA_F_BEFORE_NAT_TRANSFORM 0x00000001 /*! \brief PPA_F_ACCEL_MODE \note notify PPA to enable or disable acceleration for one routing session. It is only for Hook/ioctl, not for PPE FW usage */ #define PPA_F_ACCEL_MODE 0x00000002 /*! \brief PPA_F_SESSION_ORG_DIR \note Packet in original direction of session i.e. the direction in which the session was established */ #define PPA_F_SESSION_ORG_DIR 0x00000010 /*! \brief PPA_F_SESSION_REPLY_DIR \note Packet in reply direction of session i.e. opposite to the direction in which session was initiated. */ #define PPA_F_SESSION_REPLY_DIR 0x00000020 /*! \brief PPA_F_SESSION_BIDIRECTIONAL \note For PPA Session add, add a bidirectional session, else unidirection session is assumed. */ #define PPA_F_SESSION_BIDIRECTIONAL (PPA_F_SESSION_ORG_DIR | PPA_F_SESSION_REPLY_DIR) /*! \brief PPA_F_BRIDGED_SESSION \note Denotes that the PPA session is bridged */ #define PPA_F_BRIDGED_SESSION 0x00000100 /*! \brief PPA_F_SESSION_LOCAL_IN \note Denotes that the PPA session is local in */ #define PPA_F_SESSION_LOCAL_IN 0x00000200 /*! \brief PPA_F_SESSION_LOCAL_OUT \note Denotes that the PPA session is local out */ #define PPA_F_SESSION_LOCAL_OUT 0x00000400 /*! \brief PPA_F_SESSION_NEW_DSCP \note Denotes that the PPA session has DSCP remarking enabled */ #define PPA_F_SESSION_NEW_DSCP 0x00001000 /*! \brief PPA_F_SESSION_VLAN \note Denotes that the PPA session has VLAN tagging enabled. */ #define PPA_F_SESSION_VLAN 0x00002000 /*! \brief PPA_F_MTU \note Denotes that the PPA session has a MTU limit specified */ #define PPA_F_MTU 0x00004000 /*! \brief PPA_F_SESSION_OUT_VLAN \note Denotes that the PPA session has Outer VLAN tagging enable */ #define PPA_F_SESSION_OUT_VLAN 0x00008000 /*! \brief PPA_F_BRIDGE_LOCAL \note Denotes that the PPA bridge session is for a flow terminated at the CPE (i.e. not bridged out). Such an entry will not be accelerated */ #define PPA_F_BRIDGE_LOCAL 0x00010000 /*! \brief PPA_F_PPPOE \note Denotes that the PPA session has PPPOE header */ #define PPA_F_PPPOE 0x00020000 /*! \brief PPA_F_LAN_IF \note Indicates that the interface is a LAN interface */ #define PPA_F_LAN_IF 0x01000000 /*! \brief PPA_F_LAN_IPSEC \note Indicates that the interface is a LAN interface */ #define PPA_F_LAN_IPSEC 0x08000000 /*! \brief PPA_F_STATIC_ENTRY \note Indicates that it is a static entry */ #define PPA_F_STATIC_ENTRY 0x20000000 /*! \brief PPA_F_DROP_PACKET \note Denotes that the PPA session has a drop action specified. In other words, this acts as a fast path \n packet filter drop action */ #define PPA_F_DROP_PACKET 0x40000000 /*! \brief PPA_F_BRIDGE_ACCEL_MODE \note Flag denoting that the PPA should accelerate bridging sessions. Reserved currently */ #define PPA_F_BRIDGE_ACCEL_MODE 0x80000000 /* * interface flags */ /*! \brief PPA_SESSION_NOT_ADDED */ #define PPA_SESSION_NOT_ADDED -1 /*!< PPA Session Add failed. This can happen either because the Session is not yet ready for addition or \n that PPA cannot accelerate the session because the packet is looped back */ /*! \brief PPA_SESSION_NOT_DELETED */ #define PPA_SESSION_NOT_DELETED -1 /*!< PPA Session Add failed. This can happen either because the Session is not yet ready for addition or \n that PPA cannot accelerate the session because the packet is looped back */ /*! \brief PPA_SESSION_ADDED */ #define PPA_SESSION_ADDED 0 /*!< Indicates PPA was able to successfully add the session */ /*! \brief PPA_SESSION_DELETED */ #define PPA_SESSION_DELETED 0 /*!< Indicates PPA was able to successfully add the session */ /*! \brief PPA_SESSION_EXISTS */ #define PPA_SESSION_EXISTS 1 /*!< Indicates PPA already has the session added. This is also a success indication */ /*! \brief PPA_MC_SESSION_VIOLATION */ #define PPA_MC_SESSION_VIOLATION -2 /*!< PPA MC Session lookup failed. This can happen when you search IGMP V2 entry but hit one IGMPv3 entry with same \n Multicast Group IP or vise versa*/ /*! \brief PPA_SESSION_FILTED */ #define PPA_SESSION_FILTED -1 /*!< Indicates session is not qualified to be accelerated yet */ /*! \brief PPA_SESSION_NOT_FILTED */ #define PPA_SESSION_NOT_FILTED 0 /*!< Indicates session can be further processed */ /* * ppa_inactivity_status return value */ /*! \brief PPA_HIT \note PPA Session is active i.e. was hit with packets within the configured inactivity time inter */ #define PPA_HIT 0 /*! \brief PPA_TIMEOUT \note PPA Session is inactive and hence has timed out */ #define PPA_TIMEOUT 1 /*! \brief PPA_F_VLAN_FILTER_IFNAME */ #define PPA_F_VLAN_FILTER_IFNAME 0 /*!< Port based VLAN */ /*! \brief PPA_F_VLAN_FILTER_IP_SRC */ #define PPA_F_VLAN_FILTER_IP_SRC 1 /*!< SRC IP based VLAN */ /*! \brief PPA_F_VLAN_FILTER_ETH_PROTO */ #define PPA_F_VLAN_FILTER_ETH_PROTO 2 /*!< Ethernet Type based VLAN */ /*! \brief PPA_F_VLAN_FILTER_VLAN_TAG */ #define PPA_F_VLAN_FILTER_VLAN_TAG 3 /*!< Vlan tag based VLAN */ /*! \brief PPA_F_NETIF_PORT_MIB */ #define PPA_F_NETIF_PORT_MIB 0x00000001 /*!< PPE Port MIB stats */ /*! \brief PPA_F_NETIF_HW_ACCEL */ #define PPA_F_NETIF_HW_ACCEL 0x00000002 /*!< HW accelerated session stats */ /*! \brief PPA_F_NETIF_SW_ACCEL */ #define PPA_F_NETIF_SW_ACCEL 0x00000004 /*!< SW accelerated session stats */ /*! \brief PPA_INVALID_QID */ #define PPA_INVALID_QID 0xFFFF /*!< Invalid VLAN ID. Note, it is used only in IOCTL */ /*! \brief PPA_VLAN_TAG_MASK */ #define PPA_VLAN_TAG_MASK 0xFFFF1FFF /*!< VLAN MASK to remove VLAN priority*/ /*! \brief MAX_HOOK_NAME_LEN */ #define MAX_HOOK_NAME_LEN 71 /*!< maximum hook name length */ /*! \brief PPA_PORT_MODE_ETH */ #define PPA_PORT_MODE_ETH 1 /*!< Ethernet Port */ /*! \brief PPA_PORT_MODE_DSL */ #define PPA_PORT_MODE_DSL 2 /*!< DSL Port */ /*! \brief PPA_PORT_MODE_EXT */ #define PPA_PORT_MODE_EXT 3 /*!< Extension Port, like USB/WLAN */ /*! \brief PPA_PORT_MODE_CPU */ #define PPA_PORT_MODE_CPU 4 /*!< CPU */ /*! \brief MAX_Q_NAME_LEN */ #define MAX_Q_NAME_LEN 128 /*! \brief MAX_TC_NUM */ #define MAX_TC_NUM 16 /*! \brief MAX_PRIO_NUM */ #define MAX_PRIO_NUM 8 /*! * \brief MAX_WLAN_DEV */ #define MAX_WLAN_DEV 4 #define TC_START_BIT_POS 0 #define TC_MASK 0x1f /*! \brief PPA_QOS_OP_F_ADD */ #define PPA_QOS_OP_F_ADD 0x00000001 /*! \brief PPA_QOS_OP_F_ADD */ #define PPA_QOS_OP_F_MODIFY 0x00000002 /*! \brief PPA_QOS_OP_F_DELETE */ #define PPA_QOS_OP_F_DELETE 0x00000004 /*! \brief PPA_QOS_OP_F_INGRESS */ #define PPA_QOS_OP_F_INGRESS 0x00000080 /*! \brief PPA_QOS_Q_F_INGRESS */ #define PPA_QOS_Q_F_INGRESS 0x00000010 /*! \brief PPA_QOS_Q_F_DEFAULT */ #define PPA_QOS_Q_F_DEFAULT 0x00000020 /*! \brief PPA_QOS_Q_F_WLANDP */ #define PPA_QOS_Q_F_WLANDP 0x00000040 /*! \brief PPA_QOS_Q_F_INGGRP1 */ #define PPA_QOS_Q_F_INGGRP1 0x00000100 /*! \brief PPA_QOS_Q_F_INGGRP2 */ #define PPA_QOS_Q_F_INGGRP2 0x00000200 /*! \brief PPA_QOS_Q_F_INGGRP3 */ #define PPA_QOS_Q_F_INGGRP3 0x00000400 /*! \brief PPA_QOS_Q_F_INGGRP4 */ #define PPA_QOS_Q_F_INGGRP4 0x00000800 /*! \brief PPA_QOS_Q_F_INGGRP5 */ #define PPA_QOS_Q_F_INGGRP5 0x00001000 /*! \brief PPA_QOS_Q_F_INGGRP6 */ #define PPA_QOS_Q_F_INGGRP6 0x00002000 /*! \brief PPA_QOS_Q_F_WFQ_UPDATE */ #define PPA_QOS_Q_F_WFQ_UPDATE 0x00008000 /*! \brief PPA_QOS_CL_CPU */ #define PPA_QOS_CL_CPU 0x00010000 /*! \brief PPA_QOS_Q_F_SP_WFQ */ #define PPA_QOS_Q_F_SP_WFQ 0x00020000 /*!< QoS configured in SP+WFQ mode */ /*! \brief Macro specifying VAP QoS Operations */ #define PPA_QOS_Q_F_VAP_QOS 0x00040000 /*! \brief PPA_F_PPPOATM */ #define PPA_F_PPPOATM 0x80000000 /* * Queue Threshold Color Drop Flags */ /** PPA_QOS_DT_F_GREEN_THRESHOLD:Set Green color threshold drop tail flag */ #define PPA_QOS_DT_F_GREEN_THRESHOLD 0x00000001 /** PPA_QOS_DT_F_YELLOW_THRESHOLD:Set Yellow color threshold drop tail flag*/ #define PPA_QOS_DT_F_YELLOW_THRESHOLD 0x00000002 /** PPA_QOS_DT_F_RED_THRESHOLD:Set Red color threshold drop tail flag*/ #define PPA_QOS_DT_F_RED_THRESHOLD 0x00000004 /* * internal flag */ #define SESSION_INTERNAL_FLAG_BASE 0 #define SESSION_IS_REPLY 0x00000001 #define SESSION_SWAP 0x00000002 #define SESSION_IS_TCP 0x00000004 #define SESSION_BYTE_STAMPING 0x00000008 /*for PPA session management purpose*/ #define SESSION_ADDED_IN_HW 0x00000010 #define SESSION_NON_ACCE_MASK ~SESSION_ADDED_IN_HW /*for ioctl only*/ #define SESSION_NOT_ACCEL_FOR_MGM 0x00000020 /*Only for sesson management purpose to disable acceleration*/ #define SESSION_CAN_NOT_ACCEL SESSION_NOT_ACCEL_FOR_MGM /*since Session Management is using this flag, we have to reserve it*/ #define SESSION_STATIC 0x00000040 #define SESSION_DROP 0x00000080 #define SESSION_VALID_NAT_IP 0x00000100 #define SESSION_VALID_NAT_PORT 0x00000200 #define SESSION_VALID_NAT_SNAT 0x00000400 /* src IP is replaced, otherwise dest IP is replaced*/ #define SESSION_NOT_ACCELABLE 0x00000800 /*Session cannot be accelerated for PPE FW Limitations like dont support hairpin NAT or ATM mode does not support two VLAN since PVC will use another VLAN*/ #define SESSION_VALID_VLAN_INS 0x00001000 #define SESSION_VALID_VLAN_RM 0x00002000 #define SESSION_VALID_OUT_VLAN_INS 0x00004000 #define SESSION_VALID_OUT_VLAN_RM 0x00008000 #define SESSION_VALID_PPPOE 0x00010000 #define SESSION_VALID_NEW_SRC_MAC 0x00020000 #define SESSION_VALID_SRC_MAC SESSION_VALID_NEW_SRC_MAC #define SESSION_VALID_MTU 0x00040000 #define SESSION_VALID_NEW_DSCP 0x00080000 #define SESSION_VALID_DSLWAN_QID 0x00100000 #define SESSION_TX_ITF_IPOA 0x00200000 #define SESSION_TX_ITF_PPPOA 0x00400000 #define SESSION_TX_ITF_IPOA_PPPOA_MASK (SESSION_TX_ITF_IPOA | SESSION_TX_ITF_PPPOA) #define SESSION_NOT_VALID_PHY_PORT 0x00800000 #define SESSION_VALID_PPPOL2TP 0x01000000 /* SESSION_SRC_MAC_DROP_EN is also same bitmap but will not be used for a routing session*/ #define SESSION_SRC_MAC_DROP_EN 0x01000000 #define SESSION_TUNNEL_6RD 0x02000000 #define SESSION_TUNNEL_DSLITE 0x04000000 #define SESSION_TUNNEL_ESP 0x08000000 #define SESSION_LAN_ENTRY 0x10000000 #define SESSION_WAN_ENTRY 0x20000000 #define SESSION_IS_IPV6 0x40000000 #define SESSION_ADDED_IN_SW 0x80000000 /*Note, if a session cannot get hash index, it maybe ip output hook not work, or bridge mac address failed and so on*/ #define SESSION_FLAG2_LRO 0x00400000 #define SESSION_FLAG2_HASH_INDEX_DONE 0x00000001 #define SESSION_FLAG2_ADD_HW_FAIL 0x00000002 /*PPE hash full in this hash index, or IPV6 table full ,.*/ #define SESSION_FLAG2_HW_LOCK_FAIL 0x00000004 #define SESSION_FLAG2_BRIDGED_SESSION 0x00000010 #define SESSION_FLAG2_GRE 0x00000020 #define SESSION_FLAG2_VALID_IPSEC_OUTBOUND 0x00000040 #define SESSION_FLAG2_VALID_IPSEC_INBOUND 0x00000080 #define SESSION_FLAG2_VALID_IPSEC_OUTBOUND_SA 0x00000100 #define SESSION_FLAG2_VALID_IPSEC_OUTBOUND_LAN 0x00000200 #define SESSION_FLAG2_VALID_L2_SNAT 0x00000400 #define SESSION_FLAG2_VALID_NAT_LOOPBACK 0x00000800 #define SESSION_FLAG2_CPU_IN 0x00001000 /*session is locally terminating*/ #define SESSION_FLAG2_CPU_OUT 0x00002000 /*session is locally generated*/ #define SESSION_FLAG2_CPU_BOUND (SESSION_FLAG2_CPU_IN | SESSION_FLAG2_CPU_OUT) /*local session*/ /* Container Session Flags */ #define SESSION_FLAG2_VETH 0x00004000 #define SESSION_FLAG2_CONTAINER 0x00008000 #define SESSION_FLAG2_NON_ETHWAN_SESSION 0x00010000 #define SESSION_FLAG2_DS_MPE_QOS 0x00020000 /* Flag for DS_QOS capability */ #define SESSION_FLAG2_VALID_IPSEC_TRANS 0x00040000 /* Flag for L2TP over IPSec Transport mode */ #define SESSION_FLAG2_IG_GRE 0x00080000 /* Flag for Ingress GRE session*/ #define SESSION_FLAG2_EG_GRE 0x00100000 /* Flag for Engress GRE session*/ #define SESSION_FLAG2_VXLAN 0x00200000 /* Flag for VxLAN session*/ /* Other flags */ #define FLG_PPA_PROCESSED 0x100 /* this used to mark ecah packets which are processed by ppa datapath driver*/ #define SESSION_FLAG_TC_REMARK 0x40000000 /*Flag to sepcify bit 30 in extmark which specifies packet classified by iptables when set to 1*/ #define SESSION_FLAG2_UPDATE_INFO_PROCESSED 0x10000000 /*Flag to specify ppa_update_session_info is complete*/ #define MAX_DATA_FLOW_ENGINES 3 /* will be changed to runtime value*/ #define MAX_SESSION_PRIORITY 3 #define MAX_SESSION_TYPE 2 #ifndef __KERNEL__ /*! \def ETH_ALEN \brief Macro that specifies the maximum length of an Ethernet MAC address. */ #define ETH_ALEN 6 /*! \def IFNAMSIZ \brief Macro that specifies the maximum size of an interface NAME */ #define IFNAMSIZ 16 /*! \def PPA_ETH_ALEN \brief Macro that specifies the maximum length of an Ethernet MAC address. */ #define PPA_ETH_ALEN ETH_ALEN /*! \def PPA_ETH_HLEN \brief Macro that specifies the maximum length of an Ethernet MAC header. */ #define PPA_ETH_HLEN ETH_HLEN /*! \def PPA_ETH_CRCLEN \brief Macro that specifies the maximum length of an Ethernet CRC. */ #define PPA_ETH_CRCLEN 4 /*! \def PPA_IF_NAME_SIZE \brief Macro that specifies the maximum size of one interface name */ #define PPA_IF_NAME_SIZE IFNAMSIZ /*! \def PPA_IF_SUB_NAME_MAX_NUM \brief Macro that specifies the maximum size of one interface name */ #define PPA_IF_SUB_NAME_MAX_NUM 5 /*! \def PPA_IPPROTO_TCP \brief Macro that specifies TCP flag */ #define PPA_IPPROTO_TCP 6 /*! \def PPA_IPPROTO_UDP \brief Macro that specifies UDP flag */ #define PPA_IPPROTO_UDP 17 /*! \def PPA_USER \brief Macro that specifies the flag for the buffer type from User Space via ioctl */ #define PPA_USER __user /*! \def NIP6_FMT \brief Macro that specifies NIP6_FMT format definition for printing IPV6 address */ #define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" /*! \def nipquad_fmt \brief macro that specifies nipquad_fmt format definition for printing ipv4 address */ #define NIPQUAD_FMT "%u.%u.%u.%u" #endif /* ifndef __KERNEL__ */ #define PPA_VERSION_LEN 64 /* * #################################### * Data Type * #################################### */ #ifndef __KERNEL__ /*! \brief This is the unsigned char 32-bit data type. */ typedef unsigned int uint32_t; /*! \brief This is the unsigned char 16-bit data type. */ typedef unsigned short uint16_t; /*! \brief This is the unsigned char 8-bit data type. */ typedef unsigned char uint8_t; /*! \brief This is the unsigned char 64-bit data type. */ typedef unsigned long long uint64_t; #endif /* -------------------------------------------------------------------------- */ /* Structure and Enumeration Type Defintions */ /* -------------------------------------------------------------------------- */ #ifndef __KERNEL__ /*! \brief Pointer to interface name */ typedef char PPA_IFNAME; /*! \brief This is the data structure holding the IP address. It helps to provide future compatibility for IPv6 support. Currently it only supports IPv4. */ typedef uint32_t IPADDR; /*! \brief Union of PPA network address */ typedef union { uint32_t ip; /*!< the storage buffer for ipv4 */ uint32_t ip6[4]; /*!< the storage buffer for ipv6 */ } PPA_IPADDR; #endif typedef enum { PPA_VARIABLE_EARY_DROP_FLAG = 0, PPA_VARIABLE_PPA_DIRECTPATH_IMQ_FLAG, PPA_LAN_SEPARATE_FLAG, PPA_WAN_SEPARATE_FLAG, PPA_VARIABLE_MAX, } PPA_VARIABLE_ID; struct variable_info { char *name; uint32_t id; int32_t min; int32_t max; }; typedef enum { PPA_SESS_DEL_USING_IPv4, PPA_SESS_DEL_USING_IPv6, PPA_SESS_DEL_USING_MAC } PPA_SESS_DEL_TYPE; /*! \brief This is the data structure for PPA Packet header verification checks. */ typedef struct ppa_verify_checks { uint32_t f_ip_verify : 1; /*!< Enable/Disable IP verification checks. Valid values are PPA_ENABLED or PPA_DISABLED */ uint32_t f_tcp_udp_verify : 1; /*!< Enable/Disable TCP/UDP verification checks. Valid values are PPA_ENABLED or PPA_DISABLED */ uint32_t f_tcp_udp_err_drop : 1; /*!< Enable/Disable drop packet if TCP/UDP checksum is wrong. \n If packet is not dropped, then it is forwarded to the control CPU. \n Valid values are PPA_ENABLED or PPA_DISABLED */ uint32_t f_drop_on_no_hit : 1; /*!< Drop unicast packets on no hit, forward to MIPS/Control CPU otherwise (default). Valid values are PPA_ENABLED or PPA_DISABLED */ uint32_t f_mc_drop_on_no_hit : 1; /*!< Drop multicast on no hit, forward to MIPS/Control CPU otherwise (default). Valid values are PPA_ENABLED or PPA_DISABLED */ } PPA_VERIFY_CHECKS; /*! \brief This is the data structure for additional session related information for the PPA. It specifies on a per session basis attributes like VLAN tagging, DSCP remarking etc. This structure depends on the PPE acceleration firmware capabilities. New versions of PPA will only support the capabilities as in PPE A4/D4 firmware, The current PPA driver (for PPE A4/D4 firmware) supports 2-level of VLANs (or stacked VLANs). The outer VLAN is the one used for separating LAN and WAN traffic on a switch (for Ethernet WAN). Inner VLAN tag is application specific VLAN. In case, there is no outer VLAN tag required (for LAN/WAN separation on the switch), then this field is not specified. */ typedef struct { uint32_t new_dscp : 6; /*!< New DSCP code point value for the session.Valid values are 0-63. */ uint32_t dscp_remark : 1; /*!< DSCP remarking needs to be carried out for the session.Valid values are:PPA_ENABLED and PPA_DISABLED */ uint32_t vlan_insert : 1; /*!< If inner VLAN tag should be inserted into the frame at egress. Valid values are: PPA_ENABLED and PPA_DISABLED */ uint32_t vlan_remove : 1; /*!< If inner VLAN untagging should be performed on the received frame. Untagging, if enabled, is \n carried out before any VLAN tag insert. Valid values are:PPA_ENABLED and PPA_DISABLED */ uint32_t out_vlan_insert : 1; /*!< If outer VLAN tag should be inserted into the frame at egress. Valid values are: PPA_ENABLED and PPA_DISABLED */ uint32_t out_vlan_remove : 1; /*!< If outer VLAN untagging should be performed on the received frame. Untagging, if enabled, is \n carried out before any VLAN tag insert. Valid values are:PPA_ENABLED and PPA_DISABLED */ uint16_t dslwan_qid_remark : 1; /*!< if dslwan qid should be set. Valid values are: PPA_ENABLED and PPA_DISABLED */ uint32_t reserved1 : 4; /*!< reserved */ uint32_t vlan_prio : 3; /*!< 802.1p VLAN priority configuration. Valid values are 0-7. */ uint32_t vlan_cfi : 1; /*!< lways set to 1 for Ethernet frames */ uint32_t vlan_id : 12; /*!< VLAN Id to be used to tag the frame. Valid values are 0-4095. */ uint16_t mtu; /*!< MTU of frames classified to this session */ uint16_t dslwan_qid; /*!< dslwan_qid. Valid values are 0 ~ 16 */ uint16_t pppoe_id; /*!< pppoe session id. */ uint32_t session_flags; /*!< Session flags used to identify which fields in the PPA_SESSION_EXTRA structure are valid in \n a call to the PPA Session Modify API. \n Valid values are one or more of: \n PPA_F_SESSION_NEW_DSCP \n PPA_F_SESSION_VLAN \n PPA_F_SESSION_OUT_VLAN \n PPA_F_MTU \n PPA_F_PPPOE\n */ uint32_t out_vlan_tag; /*!< VLAN tag value including VLAN Id */ uint16_t accel_enable : 1; /*!< to enable/disable acceleartion for one specified routing session. It will be used only in PPA API level, not HAL and PPE FW level */ } PPA_SESSION_EXTRA; /*! \brief This is the data structure which is used to return the session statistics. */ typedef struct { uint64_t host_bytes; /*!< Number of bytes transmitted through CPU path */ uint64_t acc_bytes; /*!< Number of bytes accelerated by hardware engines */ } PPA_SESSION_STATS; typedef PPA_IPADDR IP_ADDR; /*! \brief This is the data structure for complex IPV4/IPV6 address */ typedef struct { uint32_t f_ipv6; /*!< flag to specify the ipv4 version: 0---IPV4, 1 -- IPV6 */ IP_ADDR ip; /*!< multiple ip address format support */ } IP_ADDR_C; /*! \brief This is the data structure for VLAN tag control on a per interface basis. It is currently supported only for bridging paths. For PPE A4 firmware, 2 levels of VLAN is configurable, while for older PPE D4 firmware, only inner VLAN tag is configurable. Please see discussion in section PPA_SESSION_EXTRA. Briefly, couter VLAN tag configuration is used for LAN and WAN isolation on the same external switch, while the other set of VLAN tag configuration is driven from application needs (i.e. not stripped off when the packet hits the wire). */ typedef struct { uint32_t unmodified : 1; /*!< Indicates if there is no VLAN tag modification. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t insertion : 1; /*!< Indicates if there is a VLAN tag inserted. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t remove : 1; /*!< Indicates if there is a VLAN tag removed. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t replace : 1; /*!< Indicates if there is a VLAN tag replaced. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t out_unmodified : 1; /*!< Indicates if there is no outer VLAN tag modification. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t out_insertion : 1; /*!< Indicates if there is a outer VLAN tag inserted. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t out_remove : 1; /*!< Indicates if there is a outer VLAN tag removed. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t out_replace : 1; /*!< Indicates if there is a outerVLAN tag replaced. Valid values are PPA_ENABLED and PPA_DISABLED */ } PPA_VLAN_TAG_CTRL; /*! \brief This is the data structure for VLAN configuration control on a per interface basis. It is currently supported only for bridging paths. */ typedef struct { uint32_t src_ip_based_vlan : 1; /*!< Indicates if Source IP address filter based VLAN tagging is enabled for this interface. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t eth_type_based_vlan : 1; /*!< Indicates if Ethernet header type based VLAN tagging is enabled for this interface. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t vlanid_based_vlan : 1; /*!< Indicates if VLAN re-tagging is enabled based on existing VLAN Id of received frame. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t port_based_vlan : 1; /*!< Indicates if port based VLAN tagging is enabled for this interface. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t vlan_aware : 1; /*!< Indicates if bridge is VLAN aware and enforces VLAN based forwarding for this interface. Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t out_vlan_aware : 1; /*!< Indicates if bridge is outer VLAN aware and enforces VLAN based forwarding for this interface. If this field is not enabled, then outer VLAN processing is don't care. interface. If this field is not enabled, then outer VLAN processing is don't care. Valid values are PPA_ENABLED and PPA_DISABLED */ } PPA_VLAN_CFG; /*! \brief This is the data structure for cout information, like lan interface count, LAN acceleration count and so on */ typedef struct { uint32_t count; /*!< the number */ uint32_t flag; /*!< the flag */ uint32_t stamp_flag; /*!< the stamping flag */ uint32_t hash_index; /*!< to specify hash index */ } PPA_CMD_COUNT_INFO; /*! \brief This is the data structure for get some structure size */ typedef struct { uint32_t rout_session_size; /*!< the structure size of one routing session */ uint32_t mc_session_size; /*!< the structure size of one multicast session */ uint32_t br_session_size; /*!< the structure size of one bridge session */ uint32_t netif_size; /*!< the structure size of one network interface information*/ } PPA_CMD_SIZE_INFO; /*@}*/ /* PPA_HOOK_API */ /* * ioctl command structures */ /** \addtogroup PPA_IOCTL */ /*@{*/ /*! \brief This is the data structure for PPA Interface information used from the userspacef */ typedef struct { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; /*!< Name of the stack interface (provide storage buffer) */ uint32_t force_wanitf_flag; /*!< force_wanitf_flag is used for force change PPE FW's LAN/WAN interface */ uint64_t acc_tx; /*!< tx tx mib (bytes counter/packet counter) */ uint64_t acc_rx; /*!< rx rx mib (bytes counter/packet counter) */ uint32_t if_flags; /*!< Flags for Interface. Valid values are below: PPA_F_LAN_IF and PPA_F_WAN_IF */ PPA_IFNAME ifname_lower[PPA_IF_NAME_SIZE]; /*!< Name of the manually configured its lower stack interface (provide storage buffer) */ uint8_t hw_disable; /*!< If this flag is set then only HW acceleration would be disabled for ifname (SW acceleration would still work for ifname) */ uint64_t acc_tx_ipv4; /*!< tx tx mib (bytes counter/packet counter) */ uint64_t acc_rx_ipv4; /*!< rx rx mib (bytes counter/packet counter) */ uint64_t acc_tx_ipv6; /*!< tx tx mib (bytes counter/packet counter) */ uint64_t acc_rx_ipv6; /*!< rx rx mib (bytes counter/packet counter) */ } PPA_CMD_IFINFO; /*! \brief This is the data structure for PPA Init used from the userspace */ typedef struct { PPA_VERIFY_CHECKS lan_rx_checks; /*!< LAN Ingress checks */ PPA_VERIFY_CHECKS wan_rx_checks; /*!< WAN Ingress checks */ uint32_t num_lanifs; /*!< Number of LAN side interfaces */ PPA_CMD_IFINFO p_lanifs[PPA_MAX_IFS_NUM]; /*!< Array of LAN Interface Info structures (provides storage buffer). */ uint32_t num_wanifs; /*!< Number of WAN side interfaces */ PPA_CMD_IFINFO p_wanifs[PPA_MAX_IFS_NUM]; /*!< Array of WAN Interface Info structures (provides storage buffer). */ uint32_t max_lan_source_entries; /*!< Number of session entries with LAN source */ uint32_t max_wan_source_entries; /*!< Number of session entries with WAN source */ uint32_t max_mc_entries; /*!< Number of multicast sessions */ uint32_t max_bridging_entries; /*!< Number of bridging entries */ uint32_t add_requires_min_hits; /*!< Minimum number of calls to ppa_add before session would be added in h/w */ uint32_t add_requires_lan_collisions; /*!< Minimum number of LAN collision entries to be reserved in h/w*/ uint32_t add_requires_wan_collisions; /*!< Minimum number of WAN collision entries to be reserved in h/w*/ uint32_t mtu; /*!< specify PPA network internface's MTU size, default is 1500 */ uint32_t flags; /*!< Flags for PPA Initialization. Currently this field is reserved. */ uint8_t mib_mode; /*!< mib mode: 0-Byte mode,1-Packet mode */ } PPA_CMD_INIT_INFO; /*! \brief This is the data structure for PPA Acceleration Enable / Disable configuration */ typedef struct { uint32_t lan_rx_ppa_enable; /*!< lan Interface specific flags. Current Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t wan_rx_ppa_enable; /*!< wan Interface specific flags. Current Valid values are PPA_ENABLED and PPA_DISABLED */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_ENABLE_INFO; /*! \brief This is the data structure for MAC table entry used in PPA ioctl interface */ typedef struct { IP_ADDR_C mcast_addr; /*!< MC address of the entry */ IP_ADDR_C source_ip; /*!< source ip */ uint8_t SSM_flag; /*!< ssm flag */ PPA_SESSION_EXTRA mc_extra; /*!< Pointer to PPA Multicast session parameters like VLAN configuration, DSCP remarking */ uint32_t flags; /*!< Flags for the PPA Multicast entry info structure. Reserved currently. */ uint64_t host_bytes; /*!< bytes processed by the mips */ uint64_t hw_bytes; /*!< bytes proccesed by hareware acceleration unit*/ uint8_t RTP_flag; /*!< rtp flag */ uint32_t rtp_pkt_cnt; /*!< RTP packet mib */ uint32_t rtp_seq_num; /*!< RTP sequence number */ } PPA_CMD_MC_ENTRY; /*! \brief This is the data structure for MIB mode configuration */ typedef struct { uint8_t mib_mode; /*!< mib mode: 0-Byte mode,1-Packet mode */ } PPA_CMD_MIB_MODE_INFO; /*! \brief This is the data structure for learned MAC address used in PPA ioctl interface */ typedef struct { uint8_t mac_addr[PPA_ETH_ALEN]; /*!< MAC address learned */ PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; /*!< The interface which learned the MAC address */ PPA_IFNAME brname[PPA_IF_NAME_SIZE]; /*!< The bridge which learned the MAC address */ uint32_t flags; /*!< for future */ } PPA_CMD_MAC_ENTRY; /*! \brief This is the data structure for PPA VLAN configuration ioctl() on a per interface basis from userspace. It is currently supported only for bridging paths. */ typedef struct { PPA_IFNAME if_name[PPA_IF_NAME_SIZE]; /*!< Pointer to interface name for which VLAN related configuration is specified. */ PPA_VLAN_TAG_CTRL vlan_tag_ctrl; /*!< VLAN Tag Control structure for the interface */ PPA_VLAN_CFG vlan_cfg; /*!< VLAN Configuration control structure for the interface */ uint32_t flags; /*!< Flags field. Reserved currently and omitted in implementation. */ } PPA_CMD_BR_IF_VLAN_CONFIG; /*! \brief Union for VLAN filter matching criteria. */ typedef union { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; /*!< Pointer to interface name on which VLAN filter match is to be performed. */ IPADDR ip_src; /*!< IP source address of ingress frame for VLAN filter matching. */ uint32_t eth_protocol; /*!< Ethernet protocol as a match filter for VLAN filter matching. */ uint32_t ingress_vlan_tag; /*!< Ingress frame VLAN tag as match criteria for VLAN filter matching. */ } filter_criteria; /*! \brief This data structure specifies the filter or match criteria for applying VLAN transforms based on rules. It is currently supported only for bridging paths. */ typedef struct { filter_criteria match_field; /*!< Union for VLAN filter criteria. */ uint32_t match_flags; /*!< Indicates which VLAN filter criteria is specified in this VLAN match entry. \n Valid values are one of the following: \n - PPA_F_VLAN_FILTER_IFNAME \n - PPA_F_VLAN_FILTER_IP_SRC \n - PPA_F_VLAN_FILTER_ETH_PROTO \n - PPA_F_VLAN_FILTER_VLAN_TAG */ } PPA_CMD_VLAN_MATCH_FIELD; /*! \brief This is the data structure for PPA VLAN configuration ioctl() on a per interface basis from userspace. It is currently supported only for bridging paths. */ typedef struct { uint16_t vlan_vci; /*!< VLAN Information including VLAN Id, 802.1p and CFI bits */ uint16_t qid; /*!< dest_qos */ uint32_t out_vlan_id; /*!< new out vlan id */ uint32_t out_vlan_tag_ctrl; /*!< unmodify(0)/remove(1)/insert(2)/replac(3), for vlan tag based only. */ uint32_t inner_vlan_tag_ctrl; /*!< unmodify(0)/remove(1)/insert(2)/replac(3), for vlan tag based only. */ uint16_t num_ifs; /*!< Number of interfaces in the array of PPA_IFINFO structures. */ PPA_CMD_IFINFO vlan_if_membership[PPA_MAX_IFS_NUM]; /*!< Pointer to array of interface info structures for each interface which is a member of this VLAN group. The number of entries is given by num_ifs. */ } PPA_CMD_VLAN_INFO; /*! \brief This is the data structure for basic VLAN filter setting in PPA ioctl interface */ typedef struct { PPA_CMD_VLAN_MATCH_FIELD match_field; /*!< vlan filter match field */ PPA_CMD_VLAN_INFO vlan_info; /*!< vlan information */ } _PPA_CMD_VLAN_FILTER_CONFIG; /*! \brief This is the data structure for VLAN filter configure in PPA ioctl interface */ typedef struct { _PPA_CMD_VLAN_FILTER_CONFIG vlan_filter_cfg; /*!< vlan filter basc information */ uint32_t flags; /*!< flag */ } PPA_CMD_VLAN_FILTER_CONFIG; /*! \brief This is the data structure for PPA VLAN configuration as passed to the PPA ioctl() API from userspace. It is currently supported only for bridging paths. */ typedef struct { PPA_CMD_COUNT_INFO count_info; /*!< Number of filters returned in pointer to array of filters. */ PPA_CMD_VLAN_FILTER_CONFIG filters[1]; /*!< it is a dummy array. Userspace should apply storage buffer for it */ } PPA_CMD_VLAN_ALL_FILTER_CONFIG; /*! \brief This is the data structure for PPA accelerated statistics for an interface. Depending on the platform and acceleration capabilities, some of the statistics may not be available. */ typedef struct { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; /*!< interface name (provides storage buffer) */ uint8_t mac[PPA_ETH_ALEN]; /*!< MAC address of the Ethernet Interface (provides storage buffer) */ uint32_t flags; /*!< reserved for future */ } PPA_CMD_IF_MAC_INFO; /*! \brief This is the data structure for LAN/WAN interface setting */ typedef struct { uint32_t num_ifinfos; /*!< number of interface in the list */ PPA_CMD_IFINFO ifinfo[PPA_MAX_IFS_NUM]; /*!< buffer for storing network interface list */ } PPA_CMD_IFINFOS; /*! \brief This is the data structure for Multicast group related ioctl */ typedef struct { uint8_t mac[PPA_ETH_ALEN]; /*!< mac address of the multicast group, reserved for future */ PPA_IFNAME lan_ifname[PPA_MAX_MC_IFS_NUM][PPA_IF_NAME_SIZE]; /*!< downstream interface list buffer */ PPA_IFNAME src_ifname[PPA_IF_NAME_SIZE]; /*!< source interface which receive multicast streaming packet */ uint32_t num_ifs; /*!< downstream interface number */ uint32_t bridging_flag; /*!< IGMP Proxy/snooping flag: 0 - routing mode/igmp proxy, 1 - bring mode/igmp snooping. */ uint32_t new_dscp_en; /*!< dscp editing flag: 1 -- need to edit, 0 --unmodify */ PPA_CMD_MC_ENTRY mc; /*!< multicast group information */ } PPA_CMD_MC_GROUP_INFO; /*! \brief This is the data structure for get all Multicast group via ioctl */ typedef struct { PPA_CMD_COUNT_INFO count_info; /*!< the multicast counter */ PPA_CMD_MC_GROUP_INFO mc_group_list[1]; /*!< Note, here is a dummy array, user need to malloc memory accordingly to the session number */ } PPA_CMD_MC_GROUPS_INFO; /*! \brief This is the data structure contains PPA session information. */ typedef struct { void *session; /*!< PPA SESSION pointer. Note, here we just use its address to delete a session for ioctl*/ uint32_t hash; uint16_t ip_proto; /*!< IP portocol TCP,UDP. */ uint16_t ip_tos; /*!< IP ToS value */ PPA_IPADDR src_ip; /*!< source IP address */ uint16_t src_port; /*!< source port */ PPA_IPADDR dst_ip; /*!< destination IP address */ uint16_t dst_port; /*!< destination port */ PPA_IPADDR natip; /*!< IP address to be replaced by NAT if NAT applies */ uint16_t nat_port; /*!< Port to be replaced by NAT if NAT applies */ uint32_t new_dscp; /*!< If DSCP remarking required */ uint16_t new_vci; /*!< new vci (in fact, it is new inner vlan id)*/ uint32_t out_vlan_tag; /*!< Out VLAN tag */ uint16_t dslwan_qid; /*!< WAN qid */ uint16_t dest_ifid; /*!< Destination interface */ uint32_t flags; /*!< Internal flag: SESSION_IS_REPLY, SESSION_IS_TCP, \n SESSION_ADDED_IN_HW, SESSION_NOT_ACCEL_FOR_MGM \n SESSION_VALID_NAT_IP, SESSION_VALID_NAT_PORT, \n SESSION_VALID_VLAN_INS, SESSION_VALID_VLAN_RM, \n SESSION_VALID_OUT_VLAN_INS, SESSION_VALID_OUT_VLAN_RM, \n SESSION_VALID_PPPOE, SESSION_VALID_NEW_SRC_MAC, \n SESSION_VALID_MTU, SESSION_VALID_NEW_DSCP, \n SESSION_VALID_DSLWAN_QID, \n SESSION_TX_ITF_IPOA, SESSION_TX_ITF_PPPOA \n SESSION_LAN_ENTRY, SESSION_WAN_ENTRY, */ uint32_t flag2; /*!priority*/ uint32_t session_priority; /*!< session priority */ /*below variable is used for session management debugging purpose */ uint16_t hash_index; /*!< hash_index according to PPE FW hash algo */ uint16_t hash_table_id; /*!< 0-first hash table, 1 WAN */ uint16_t src_ip6_index; /*!< Note, 0 means not valid data. so for its correct value, it should be "real index + 1 " */ uint16_t src_ip6_psuedo_ip; uint16_t dst_ip6_index; /*!< Note, 0 means not valid data. so for its correct value, it should be "real index + 1 " */ uint16_t dst_ip6_psuedo_ip; /*!< psuedo_ip */ uint16_t reserved; /*!< reserved flag */ } PPA_CMD_SESSION_ENTRY; /*! \brief This is the data structure contains PPA session extra information. */ typedef struct { void *session; /*!< PPA SESSION pointer. Note, here we just use its address to modify a session for ioctl*/ uint32_t hash; /* Hash value of the session */ PPA_SESSION_EXTRA session_extra; /*!< PPA SESSION extra pointer. */ uint32_t flags; /*!< Internal flag: PPA_F_SESSION_NEW_DSCP \n PPA_F_MTU, PPA_F_SESSION_OUT_VLAN, PPA_F_ACCEL_MODE ....\n */ uint32_t lan_wan_flags; /*!< Internal flag: the flag to matcn LAN only, or WAN only or both \n The possible value is SESSION_WAN_ENTRY, SESSION_LAN_ENTRY */ } PPA_CMD_SESSION_EXTRA_ENTRY; /*! \brief This is the data structure for routing session Timer Info */ typedef struct { void *session; /*!< PPA SESSION pointer. Note, here we just use its address to modify a session for ioctl*/ int32_t timer_in_sec; /*!< PPA SESSION polling timer in seconds. */ uint32_t flags; /*!< Reserved for future */ } PPA_CMD_SESSION_TIMER; /*! \brief This is the data structure for routing session information */ typedef struct { PPA_CMD_COUNT_INFO count_info; /*!< session count */ PPA_CMD_SESSION_ENTRY session_list[1]; /*!< Note, here is a dummy array, user need to malloc memory accordingly to the session number */ } PPA_CMD_SESSIONS_INFO; /*! \brief This is the data structure for session criteria information */ typedef struct { uint32_t ppa_low_prio_data_rate; /*!< low priority session data rate */ uint32_t ppa_def_prio_data_rate; /*!< default priority session data rate */ uint32_t ppa_low_prio_thresh; /*!< low priority session threshold */ uint32_t ppa_def_prio_thresh; /*!< default priority session threshold */ } PPA_CMD_SESSIONS_CRITERIA_INFO; /*! \brief This is the data structure for session criteria information */ typedef struct { uint32_t sessions_low_prio_data_rate; /*!< low priority session data rate */ uint32_t sessions_def_prio_data_rate; /*!< default priority session data rate */ uint32_t sessions_low_prio_thresh; /*!< low priority session threshold */ uint32_t sessions_def_prio_thresh; /*!< default priority session threshold */ } PPA_CMD_SESSIONS_CRITERIA; /*! \brief This is the data structure for session criteria information */ typedef struct { uint32_t flags; } PPA_CMD_SWAP_SESSIONS; typedef struct { PPA_CMD_COUNT_INFO count_info[MAX_SESSION_TYPE][MAX_SESSION_PRIORITY][MAX_DATA_FLOW_ENGINES]; } PPA_CMD_SESSION_COUNT_INFO; typedef struct { PPA_CMD_COUNT_INFO count_info; PPA_CMD_SESSION_EXTRA_ENTRY session_extra_info[1]; } PPA_CMD_MANAGE_SESSION; typedef struct { PPA_CMD_SESSION_COUNT_INFO session_count; PPA_CMD_SESSION_ENTRY session_list[1]; /*!< Note, here is a dummy array, user need to malloc memory accordingly to the session number */ } PPA_CMD_GET_SESSIONS_INFO; /*! \brief This is the data structure for routing detail session information */ typedef struct { uint16_t ip_proto; /*!< IP portocol TCP,UDP. */ PPA_IPADDR src_ip; /*!< source IP address */ uint16_t src_port; /*!< source port */ PPA_IPADDR dst_ip; /*!< destination IP address */ uint16_t dst_port; /*!< destination port */ PPA_IPADDR natip; /*!< IP address to be replaced by NAT if NAT applies */ uint16_t nat_port; /*!< Port to be replaced by NAT if NAT applies */ uint32_t new_dscp; /*!< If DSCP remarking required */ uint16_t in_vci_vlanid; /*!< new vci (in fact, it is new inner vlan id)*/ uint32_t out_vlan_tag; /*!< Out VLAN tag */ uint16_t qid; /*!< WAN qid */ uint32_t flags; /*!< Internal flag: SESSION_IS_REPLY, SESSION_IS_TCP, \n SESSION_ADDED_IN_HW, SESSION_NOT_ACCEL_FOR_MGM \n SESSION_VALID_NAT_IP, SESSION_VALID_NAT_PORT, \n SESSION_VALID_VLAN_INS, SESSION_VALID_VLAN_RM, \n SESSION_VALID_OUT_VLAN_INS, SESSION_VALID_OUT_VLAN_RM, \n SESSION_VALID_PPPOE, SESSION_VALID_NEW_SRC_MAC, \n SESSION_VALID_MTU, SESSION_VALID_NEW_DSCP, \n SESSION_VALID_DSLWAN_QID, \n SESSION_TX_ITF_IPOA, SESSION_TX_ITF_PPPOA \n SESSION_LAN_ENTRY, SESSION_WAN_ENTRY, */ uint32_t dest_ifid; /*!< txansmit interface name. */ uint8_t src_mac[PPA_ETH_ALEN]; /*!< src mac addres */ uint8_t dst_mac[PPA_ETH_ALEN]; /*!< dst mac address */ uint16_t pppoe_session_id; /*!< pppoe session id */ uint32_t mtu; /*!< mtu */ } PPA_CMD_SESSIONS_DETAIL_INFO; /*! \brief This is the data structure for basic ppa Versions */ typedef struct { uint32_t index; /*!< index for PP32 */ uint32_t family; /*!< ppa version hardware family */ uint32_t type; /*!< ppa version hardware type */ uint32_t itf; /*!< ppa version itf */ uint32_t mode; /*!< ppa version mode */ uint32_t major; /*!< ppa version major version number */ uint32_t mid; /*!< ppa version mid version number */ uint32_t minor; /*!< ppa version minor version number */ uint32_t tag; /*!< ppa version tag number. Normally for internal usage */ uint32_t id; char name[PPA_VERSION_LEN]; char version[PPA_VERSION_LEN]; } PPA_VERSION; /*! \brief This is the data structure for ppa wan mode information */ typedef struct { uint32_t wan_port_map; /*!< wan port map information*/ uint32_t mixed; /*!< mixed flag */ } PPA_WAN_INFO; /*! \brief This is the data structure for ppa supported feature list information */ typedef struct { uint8_t ipv6_en; /*!< ipv6 enable/disable status */ uint8_t qos_en; /*!< qos enable/disable status */ } PPA_FEATURE_INFO; /*! \brief This is the data structure for PPA subsystem Versions, like ppa subsystem, ppe fw, ppe driver and so on */ typedef struct { PPA_VERSION ppa_api_ver; /*!< PPA API verion */ PPA_VERSION ppa_stack_al_ver; /*!< PPA stack verion */ PPA_VERSION ppe_hal_ver; /*!< PPA HAL verion */ PPA_VERSION mpe_hal_ver; /*!< PPA HAL verion */ PPA_VERSION ppe_fw_ver[2]; /*!< PPA FW verion */ PPA_VERSION ppa_subsys_ver; /*!< PPA Subsystem verion */ PPA_WAN_INFO ppa_wan_info; /*!< PPA WAN INFO */ PPA_FEATURE_INFO ppe_fw_feature; /*!< PPE FW feature lists */ PPA_FEATURE_INFO ppa_feature; /*!< PPA Level feature lists */ } PPA_CMD_VERSION_INFO; /*! \brief This is the data structure for basic vlan range */ typedef struct { uint32_t start_vlan_range; /*!< WAN interface start vlan id */ uint32_t end_vlan_range; /*!< WAN interface end vlan id */ } PPA_VLAN_RANGE; /*! \brief This is the data structure VLAN range in mixed mode */ typedef struct { PPA_CMD_COUNT_INFO count_info; /*!< PPA Count info */ PPA_VLAN_RANGE ranges[1]; /*!< it is dummy array, need to malloc in userspace */ } PPA_CMD_VLAN_RANGES; /*! \brief This is the data structure for MAC INFO */ typedef struct { PPA_CMD_COUNT_INFO count_info; /*!< PPA Count info */ PPA_CMD_MAC_ENTRY session_list[1]; /*!< it is a dummy array, need to malloc bedore use it in userspace */ } PPA_CMD_ALL_MAC_INFO; /*! \brief This is the data structure for BRIGE MAC LEARNING ENABLE/DISABLE INFO */ typedef struct { uint32_t bridge_enable; /*!< enable/disable bridging mac address learning flag */ uint32_t flags; /*!< reserved for future */ } PPA_CMD_BRIDGE_ENABLE_INFO; /*! \brief QoS Shaper Mode Configuration */ typedef enum { PPA_QOS_SHAPER_NONE = 0, PPA_QOS_SHAPER_COLOR_BLIND = 1, PPA_QOS_SHAPER_TR_TCM = 2, PPA_QOS_SHAPER_TR_TCM_RFC4115 = 3, PPA_QOS_SHAPER_LOOSE_COLOR_BLIND = 4 } PPA_QOS_SHAPER_MODE; typedef enum { PPA_QOS_METER_TOKEN_BUCKET = 1, /*!< Simple Token Bucket */ PPA_QOS_METER_SR_TCM = 2, /*!< Single Rate Three Color Marker */ PPA_QOS_METER_TR_TCM = 3 /*!< Two Rate Three Color Marker */ } PPA_QOS_METER_TYPE; /*! \brief QoS Shaper configuration structure */ typedef struct { PPA_QOS_SHAPER_MODE mode; /*!< Mode of Token Bucket shaper */ uint32_t enable; /*!< Enable for Shaper */ uint32_t cir; /*!< Committed Information Rate in bytes/s */ uint32_t cbs; /*!< Committed Burst Size in bytes */ uint32_t pir; /*!< Peak Information Rate in bytes/s */ uint32_t pbs; /*!< Peak Burst Size */ uint32_t flags; /*!< Flags define which shapers are enabled - QOS_SHAPER_F_PIR - QOS_SHAPER_F_CIR */ int32_t phys_shaperid; } PPA_QOS_SHAPER_CFG; /*! \brief QoS Meter configuration structure */ typedef struct { PPA_QOS_METER_TYPE type; /*!< Mode of Meter*/ uint32_t enable; /*!< Enable for meter */ uint32_t cir; /*!< Committed Information Rate in bytes/s */ uint32_t cbs; /*!< Committed Burst Size in bytes */ uint32_t pir; /*!< Peak Information Rate in bytes/s */ uint32_t pbs; /*!< Peak Burst Size */ uint32_t meterid; /*!< Meter ID Configured on the system*/ uint32_t flags; /*!< Flags define operations on meters enbled*/ int32_t phys_meterid; /*!< Meter ID Configured on the system*/ uint32_t pce_id; /*!< ID of PCE rule configured for this meter*/ uint32_t port_id; /*!< port on which Meter Configured*/ } PPA_QOS_METER_INFO; /*! \brief QoS Meter configuration structure */ typedef struct { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; PPA_IFNAME meter_name[PPA_IF_NAME_SIZE]; PPA_QOS_METER_TYPE type; /*!< Mode of Meter*/ uint32_t enable; /*!< Enable for meter */ uint32_t cir; /*!< Committed Information Rate in bytes/s */ uint32_t cbs; /*!< Committed Burst Size in bytes */ uint32_t pir; /*!< Peak Information Rate in bytes/s */ uint32_t pbs; /*!< Peak Burst Size */ uint32_t flags; /*!< Flags define operations on meters enbled*/ int32_t phys_meterid; /*!< Meter ID Configured on the system*/ uint32_t pce_id; /*!< ID of PCE rule configured for this meter*/ uint32_t port_id; /*!< port on which Meter Configured*/ } PPA_QOS_METER_CFG; /*! \brief This is the data structure for PPA QOS Internal INFO */ typedef struct { uint32_t t; /*!< Time Tick */ uint32_t w; /*!< weight */ uint32_t s; /*!< burst */ uint32_t r; /*!< Replenish */ uint32_t d; /*!< ppe internal variable */ uint32_t tick_cnt; /*!< ppe internal variable */ uint32_t b; /*!< ppe internal variable */ /*For PPA Level only */ uint32_t reg_addr; /*!< register address */ uint32_t bit_rate_kbps; /*!< rate shaping in kbps */ uint32_t weight_level; /*!< internal wfq weight */ } PPA_QOS_INTERVAL; /*! \brief This is the data structure for PPA QOS Internal Debug INFO */ typedef struct { /*struct wtx_qos_q_desc_cfg*/ uint32_t threshold; /*!< qos wtx threshold */ uint32_t length; /*!< qos wtx length */ uint32_t addr; /*!< qos wtx address */ uint32_t rd_ptr; /*!< qos wtx read pointer */ uint32_t wr_ptr; /*!< qos wtx write pointer */ /*For PPA Level only */ uint32_t reg_addr; /*!< register address */ } PPA_QOS_DESC_CFG_INTERNAL; /*! \brief This is the data structure for PPA QOS to get the maximum queue number supported for one physical port */ typedef struct { uint32_t portid; /*!< the phisical port id which support qos queue */ uint32_t queue_num; /*!< the maximum queue number is supported */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_QUEUE_NUM_INFO; /*! \brief This is the data structure for PPA QOS MIB Counter */ typedef struct { uint64_t total_rx_pkt; /*!< all packets received by this queue */ uint64_t total_rx_bytes; /*!< all bytes received by thi queue */ uint64_t total_tx_pkt; /*!< all packets trasmitted by this queue */ uint64_t total_tx_bytes; /*!< all bytes trasmitted by thi queue */ uint64_t cpu_path_small_pkt_drop_cnt; /*!< all small packets dropped in CPU path for lack of TX DMA descriptor in the queue*/ uint64_t cpu_path_total_pkt_drop_cnt; /*!< all packets dropped in CPU path for lack of TX DMA descriptor in the queue*/ uint64_t fast_path_small_pkt_drop_cnt; /*!< all small packets dropped in fast path for lack of TX DMA descriptor */ uint64_t fast_path_total_pkt_drop_cnt; /*!< all packets dropped in fast path for lack of TX DMA descriptor */ uint64_t tx_diff; /*!< tx bytes since last read */ uint64_t tx_diff_L1; /*!< tx bytes plus L1 overheader since last read */ uint64_t tx_diff_jiffy; /*!< jiffy diff since last read */ uint32_t sys_hz; /*!< system HZ value. For debugging purpose */ uint32_t q_occ; /*!< instantaneous number of packets present in this queue */ } PPA_QOS_MIB; typedef struct { uint32_t portid; uint32_t num; uint32_t flags; } PPA_QOS_COUNT_CFG; typedef struct { char *ifname; /*!< Interface name on which Queue is to be added*/ uint32_t portid; uint32_t queueid; PPA_QOS_MIB mib; uint32_t reg_addr; uint32_t flag; } PPA_QOS_MIB_INFO; typedef struct { uint32_t portid; uint32_t queueid; uint32_t weight_level; uint32_t flag; } PPA_QOS_WFQ_CFG; typedef struct { uint32_t portid; uint32_t f_enable; uint32_t flag; } PPA_QOS_ENABLE_CFG; typedef struct { uint32_t portid; uint32_t queueid; int32_t shaperid; uint32_t rate_in_kbps; uint32_t burst; uint32_t flag; } PPA_QOS_RATE_SHAPING_CFG; /*! \brief This is the data structure for PPA QOS to get the maximum queue number supported for one physical port */ typedef struct { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; /*!< Interface name on which the Queue is modified*/ uint32_t portid; /*!< the phisical port id which support qos queue */ int32_t queue_num; /*!< Logical queue number added will be filled up in this field */ PPA_QOS_MIB mib; /*!< the mib information for the current specified queue */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_QOS_MIB_INFO; /*! \brief This is the data structure for PPA QOS to be enabled/disabled */ typedef struct { uint32_t portid; /*!< which support qos queue. */ uint32_t enable; /*!< enable/disable flag */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_QOS_CTRL_INFO; /*! \brief This is the data structure for PPA Rate Shapping Set/Get/Reset one queue's rate limit */ typedef struct { PPA_IFNAME ifname[PPA_IF_NAME_SIZE]; uint32_t portid; /*!< the phisical port id which support qos queue */ int32_t queueid; /*!< the queu id. Now it only support 0 ~ 7 */ int32_t shaperid; /*!< the shaper id. Now it only support 0 ~ 7 */ PPA_QOS_SHAPER_CFG shaper; uint32_t rate; /*!< rate limit in kbps */ uint32_t burst; /*!< rate limit in bytes. Note: it is PPE FW QOS internal value. Normally there is no need to set this value or just set to default value zero */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_RATE_INFO; /*! \brief This is the data structure for PPA WFQ Set/Get/Reset one queue's weight */ typedef struct { uint32_t portid; /*!< the phisical port id which support qos queue */ uint32_t queueid; /*!< the queu id. Now it only support 0 ~ 7 */ uint32_t weight; /*!< WFQ weight. The value is from 0 ~ 100 */ uint32_t flags; /*!< Reserved currently */ } PPA_CMD_WFQ_INFO; /*! \brief This is the data structure for getting all exported PPA hooks. */ typedef struct EXP_FN_INFO { uint8_t hookname[MAX_HOOK_NAME_LEN]; /*!< hook name */ void *hook_addr; /*!< mid hook address */ uint8_t hook_flag : 1; /*!< hook_flag: 0-disabled, otherwise -enabled */ uint8_t used_flag : 1; /*!< used_flag: 0-not used, otherwise -used */ uint8_t reserved : 6; /*!< reserved for future */ } PPA_HOOK_INFO; /*! \brief This is the data structure for getting all exported PPA hooks. */ typedef struct { uint32_t hook_count; /*!< hook counter */ uint32_t flag; /*!< reserved for future */ PPA_HOOK_INFO list[1]; /*!< it is a dummy array. Userspace should apply storage buffer for it. */ } PPA_CMD_HOOK_LIST_INFO; /*! \brief This is the data structure for enable/disable ppa hook */ typedef struct { uint8_t hookname[MAX_HOOK_NAME_LEN]; /*!< hook name */ uint32_t enable; /*!< enable/disable ppa hook */ uint32_t flag; /*!< reserved for future */ } PPA_HOOK_ENABLE_INFO; /*! \brief This is the data structure for IOCTL to enable/disable ppa hook */ typedef PPA_HOOK_ENABLE_INFO PPA_CMD_HOOK_ENABLE_INFO; /*! \brief This is the data structure to get the memory value. */ typedef struct { uint32_t addr; /*!< The memory adddress to read */ uint32_t addr_mapped; /*!< The mapped memory adddress to read */ uint32_t shift; /*!< the bits to shitf */ uint32_t size; /*!< size of bits to read*/ uint32_t repeat; /*!< read repeat times */ uint32_t flag; /*!< reserved for future */ uint32_t buffer[1]; /*!< the buffer to store the value. it is a dummy array. Userspace should apply storage buffer for it. Its size should be at least size * sizeof (uint32_t) */ } PPA_READ_MEM_INFO; typedef PPA_READ_MEM_INFO PPA_CMD_READ_MEM_INFO; /*! \brief This is the data structure to set the memory value. */ typedef struct { uint32_t addr; /*!< The memory adddress to set */ uint32_t addr_mapped; /*!< The mapped memory adddress to read */ uint32_t shift; /*!< the bits to shitf */ uint32_t size; /*!< size of bits */ uint32_t value; /*!< value of the data*/ uint32_t repeat; /*!< set repeat times*/ uint32_t flag; /*!< reserved for future */ } PPA_SET_MEM_INFO; /*! \brief This is the data structure to set the memory value for IOCTL. */ typedef PPA_SET_MEM_INFO PPA_CMD_SET_MEM_INFO; /*! \brief This is the data structure to get the maximum entries, like lan/wan/mc/bridging */ typedef struct { uint32_t max_lan_entries; /*!< Maximum LAN session entries, including collision */ uint32_t max_wan_entries; /*!< Maximum WAN session entries, including collision */ uint32_t max_lan_collision_entries; /*!< Maximum LAN session entries */ uint32_t max_wan_collision_entries; /*!< Maximum WAN session entries */ uint32_t max_mc_entries; /*!< Maximum Multicast session entries */ uint32_t max_bridging_entries; /*!< Maximum Bridge session entries */ uint32_t max_ipv6_addr_entries; /*!< Maximum IPV6 address entries */ uint32_t max_fw_queue; /*!< Maximum PPE FW queue number */ uint32_t max_6rd_entries; /*!