/* Copyright (C) 2006 Ikanos Communications * See IKANOS_PROP_LICENSE.txt for license information. */ //====================================================================== // File Name : $RCSfile: apflow_vx180.h,v $ // Description : Format used for flow routing tables //====================================================================== #ifndef _APFLOW_VX180_H_ #define _APFLOW_VX180_H_ #include /* For ap2apMcastRtUpdWlanIfs */ /* This file defines the format used by entries in the AP IP flow table. * * Basically each entry contains five parts: * * 1. Linking and validity information * 2. The type of classification entry (IP, TCP/UDP, IPSec) * 3. The classification tuple (depends on classification type) * 4. NAT packet modification information * 5. Source and desitnation MAC addresses (if the destination port * needs packets with ethernet headers) * * A table of these entries is used by each routing ingress port to * determine how to route packets. The table is indexed using a hash of * the relevent tuple, followed by linked list resolution of hash collisions. */ #if defined(AP_FASTPATH_STATISTICS) && (AP_FASTPATH_STATISTICS) #include "../apstatistics.h" #endif typedef enum { AP_TCP_UDP_ENTRY, /* Entry is for TCP/UDP packets */ AP_IPSEC_ENTRY, /* Ennry is for IPsec packets */ AP_GRE_ENTRY, /* Entry is for GRE Packets */ AP_IP_ENTRY, /* Entry is for other IP packets */ AP_FRAGMENT_ENTRY, /* Entry is for fragmented packets */ AP_TCP_ENTRY = 0x6, /* Entry is for TCP packets */ AP_IPV6_ENTRY = 0x10, /* Entry is for IPv6 packets */ AP_UDP_ENTRY = 0x11 /* Entry is for UDP packets */ } apFlowEntryType_e; // Next definitions describe what type of processing a packet is going thru // (what type of entry has been used and how "operations" field should be used #define IPV4_ROUTING_BIT 0x0 #define IPV4_BRIDGING_BIT 0x1 #define IPV6_PROCESSING_BIT 0x2 #define IPV4_ROUTING (0x1 << IPV4_ROUTING_BIT) #define IPV4_BRIDGING (0x1 << IPV4_BRIDGING_BIT) #define IPV6_PROCESSING (0x1 << IPV6_PROCESSING_BIT) #define IPV6_HEADER_SIZE_WITHOUT_EXTN_HDRS 40 typedef struct apFlowEntry_s { /* Provide a mechanism to build a linked list of entries to resolve * hash collisions */ struct apFlowEntry_s *pNextEntry; /* The following list gives the "egress" ports for packets that * match this entry. Three egress ports are supplied to allow for * a "path" of security, ids, output port */ #define AP_MAX_FLOW_EGRESS 4 apEgressPort_t egressList[AP_MAX_FLOW_EGRESS]; /* The following describes what operations need to be performed * to packets that match this entry. */ // unsigned char operations; unsigned short operations; #if defined(AP_FASTPATH_STATISTICS) && (AP_FASTPATH_STATISTICS) struct apStatistics_s apStatistics; #endif #define AP_ROUTE_VALID_BIT 0 /* Table entry is valid */ #define AP_DO_ETH_HDR_BIT 1 /* Final packet needs ethernet header */ #define AP_DO_SRC_NAT_BIT 2 /* Do source IP addr/port NAT */ #define AP_DO_DST_NAT_BIT 3 /* Do destination IP addr/port NAT */ #define AP_CHECK_PPPOE_BIT 4 /* Incoming packet must be PPPoE */ #define AP_ADD_PPPOE_HDR_BIT 5 /* Add PPPoE header to outgoing pkts */ #define AP_ADD_VLAN_HDR_BIT 6 /* Add VLAN header to outgoing ptks */ #define AP_CHANGE_TOS 7 /* Replace the IP ToS value */ #if defined(WLAN_ETH_8023) && (WLAN_ETH_8023) #define AP_ADD_WLAN_HDR_BIT 10 #endif #if defined(IPV4_INTO_IPV6) && (IPV4_INTO_IPV6) #define AP_IPV4_TO_IPV6_TUNNEL_BIT 8 /* Tunnelling V4 -> V6 */ #define AP_IPV4_TO_IPV6_TRANSLATION_BIT 9 /* Translation V4 -> V6 */ #endif #define AP_MULTICAST_ROUTE_BIT 12 /* = 1 if packet is routed multicast * = 0 if packet is unicast */ #if defined(VENDOR_TAG) && (VENDOR_TAG) #define AP_VENDOR_RXTAG_PROCESS_BIT 14 /* compare and strip vendor tag of Rx pkts*/ #define AP_VENDOR_TXTAG_PROCESS_BIT 15 /* insert vendor tag to Tx pkts */ #endif /* The following defines what type of IP packet this entry represents. * * The value is one of the apFlowEntryType_e options, but put into a * 16 bit variable to save space. */ // unsigned char entryType; /* The following information is used to create the ethernet header if * required */ #ifndef AP_MAC_ADDR_LEN #define AP_MAC_ADDR_LEN 6 #endif unsigned char srcMacAddr[AP_MAC_ADDR_LEN]; unsigned char dstMacAddr[AP_MAC_ADDR_LEN]; /* The AP can apply simple NAT processing to IP, TCP, UDP packets. How * this information is used depends on the type of packet and which bits * are set in the operations word */ unsigned short natPort; unsigned int natIPAddr; /* The following union contains the "tuple" that this entry applies * to. This is necessary as the hash used is not "perfect" - many packet * flows may map to a single entry. */ union { struct { unsigned short srcPort; unsigned short dstPort; } tcpUdpInfo; struct { unsigned int spi; } ipsecInfo; struct { unsigned short callId; } greInfo; unsigned short identification; // for fragmented packets } otherInfo; unsigned int srcIPAddr; unsigned int dstIPAddr; #define protocol pktInfo.l3Proto.proto #define pktFloodCount pktInfo.pktCount union { struct { unsigned char proto; unsigned char unused[3]; } l3Proto; /* This 24-bit counter is incremented for every packet on this * flow. Host periodically checks if the counter exceeded the * configured threshold (packets per second). AP to ensure that * counter never goes beyond 24-bit maximum. */ unsigned int pktCount; } pktInfo; /* The following information is used to verify incoming PPPoE frame. It * is only used if the AP_ADD_PPPOE_HDR_BIT is set in operations */ unsigned char inSrcMacAddr[AP_MAC_ADDR_LEN]; unsigned short inSessionId; /* The following information is used to create the VLAN header if * required */ unsigned short vlanId; /* The following information is used to create the PPPoE header if * required */ unsigned short outSessionId; /* This is the value that is used to replace the IP ToS field if * AP_CHANGE_TOS is set in operations */ unsigned char ipTOS; /* The following defines what type of IP packet this entry represents. * * The value is one of the apFlowEntryType_e options, but put into a * 16 bit variable to save space. */ unsigned char entryType; /* dummyPad1 and dummyPad2 are created to fill holes between * elements ( these holes created by alignment process ) * Later these 2 elements mat be substituted by any USEFUL information. */ //unsigned char dummyPad1[2]; unsigned short natDstPort; /* This element contains User stack information related to this flow entry. * Example: When stack is creating AP flow entry it can write stack dynamic * flow entry pointer into "userHandle" element. * It will create a mapping between AP flow entry to stack dynamic entry. */ unsigned int userHandle; unsigned int natDstIPAddr; #if defined(VENDOR_TAG) && (VENDOR_TAG) /* The below two elements are used to store vendor specific TAGs need to be processed * by AP for incoming and outgoing packets based on the FLAGS in "operations" field of * flow entry. * For all the incoming packets, AP compares the TAG value in the packet with * the "vendorRxTag" value in the flow entry. If they match, AP should strip the header * otherwise send the packet to Host. * For all the outgoing packets, AP should insert the TAG as per the value in * "vendorTxTag" variable. * */ #if defined(MARVELL) && (MARVELL) unsigned int vendorRxTag; unsigned int vendorTxTag; #endif #if defined(REALTEK) && (REALTEK) unsigned short vendorRxTag; unsigned short vendorTxTag; unsigned short dummyPad3[2]; #endif /////////////// unsigned char dummyPad3[8]; #endif #if defined(WLAN_ETH_8023) && (WLAN_ETH_8023) unsigned char bssId[AP_MAC_ADDR_LEN]; unsigned char wlanFlags; unsigned char secHdrLen; // security header space in the pkt #define AP_DO_WLAN_WEP_HDR_BIT 0x01 #define AP_DO_WLAN_QOS_HDR_BIT 0x02 #define AP_DO_WLAN_HDR_BIT 0x03 unsigned int wlanNode; unsigned int secKey; // holds sec key specific to station #endif //unsigned char dummyPad2[4]; #ifndef AP_IPV6_IP_ADDR_LEN #define AP_IPV6_IP_ADDR_LEN 16 #endif #if IPV6 && IPV4_INTO_IPV6 /* 16 bytes: Source IPv6 address */ unsigned char srcIpv6Addr[AP_IPV6_IP_ADDR_LEN]; /* 16 bytes: Destination IPv6 address */ unsigned char dstIpv6Addr[AP_IPV6_IP_ADDR_LEN]; #endif } apFlowEntry_t; //RV-WB // Important for CACHE WRITE BACK MODE // Below definitions are created to have all entries on different cache lines // In this case a situation when Host and AP are updating elements of different structures // on the SAME cache line and Host is doing cache flush will be resolved properly // WITHOUT AP portion data loss. #ifdef AP_ASSEMBLER #define RT_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof typedef apFlowEntry_t & (CACHE_LINE_SIZE - 1))) #else #define RT_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof(apFlowEntry_t) & (CACHE_LINE_SIZE - 1))) #endif typedef struct apFlowEntry_s_chaligned { apFlowEntry_t apFlowEntryMain; unsigned char reserved[RT_PADDING_TILL_CLINE]; } apFlowEntry_t_chaligned; #undef RT_PADDING_TILL_CLINE #ifdef AP_ASSEMBLER assert (sizeof typedef apFlowEntry_t_chaligned & (CACHE_LINE_SIZE - 1)), 0 #else // will do it later //assert (0 == (sizeof(apFlowEntry_t_chaligned) & (CACHE_LINE_SIZE - 1))); #endif void ap2apRouteFlowDelete(void *); int ap2apMcastRtUpdWlanIfs (struct net_device* dev,struct net_device** wlanDevArray); #endif /* _APFLOW_H_ */