/* ===================================================================== * Copyright (C) 2006 Ikanos Communications * See IKANOS_PROP_LICENSE.txt for license information. * ===================================================================== */ #ifndef _IPV6_APFLOW_H_ #define _IPV6_APFLOW_H_ /* This file defines the format used by entries in the AP IPV6 flow table. * * Basically each entry contains four parts: * * 1. Linking and validity information * 2. The type of classification entry (IP, TCP/UDP, IPSec) * 3. The classification information ( Src & Dst Ipv6 Addresses, Flow Label) * 4. 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 relevant tuple, followed by linked list resolution of hash collisions. */ typedef struct apIpv6FlowEntry_s { /* 4 bytes: Provide a mechanism to build a linked list of entries to resolve * hash collisions */ struct apIpv6FlowEntry_s *pNextEntry; /* 24 bytes: 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]; #define AP_ROUTE_VALID_BIT 0 /* Table entry is valid */ #define AP_DO_ETH_HDR_BIT 1 /* Final packet needs ethernet header */ #define AP_IPV6_TO_IPV4_TUNNEL_BIT 2 /* Tunnelling V6 -> V4 */ #define AP_IPV6_TO_IPV4_TRANSLATION_BIT 3 /* Translation V6 -> V4 */ #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 */ /* 1 byte: The following describes what operations need to be performed * to packets that match this entry. */ unsigned short operations; #if defined(AP_FASTPATH_STATISTICS) && (AP_FASTPATH_STATISTICS) struct apStatistics_s apStatistics; #endif /* The following information is used to create the ethernet header if * required */ #ifndef AP_MAC_ADDR_LEN #define AP_MAC_ADDR_LEN 6 #endif /* To transmit packet to Egress port */ /* 6 bytes */ unsigned char srcMacAddr[AP_MAC_ADDR_LEN]; /* 6 bytes */ unsigned char dstMacAddr[AP_MAC_ADDR_LEN]; /* 1 byte: This counter is used to indicate if traffic of specific * stream is still "active"Host will increment the value every timeout period. * When value will exceed the specific threshold Host should delete an entry. * AP will put 0 value into this element for every incoming packet. */ unsigned char pktCount; /* 1 byte: This is the value that is used to replace the IP ToS field if * AP_CHANGE_TOS is set in operations */ unsigned char ipTOS; #ifndef AP_IPV6_IP_ADDR_LEN #define AP_IPV6_IP_ADDR_LEN 16 #endif /* 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]; /* 4 bytes: */ union { struct { unsigned short srcPort; unsigned short dstPort; } tcpUdpInfo; /* 4 bytes(20 bits): Flow Label */ unsigned int flowLabel; /* 4 bytes: SPI for AH or ESP packets */ unsigned int spi; } otherInfo; /* Next 2 fields will be used for tunneling or translation of IPv6 packets into IPv4. * These are IPV4 addresses */ /* 4 bytes */ unsigned int srcIPAddr; /* 4 bytes */ unsigned int dstIPAddr; /* 6 bytes: 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]; /*2 bytes: */ unsigned short inSessionId; /* 2 bytes: The following information is used to create the VLAN header if * required */ unsigned short vlanId; /* 2 bytes: The following information is used to create the PPPoE header if * required */ unsigned short outSessionId; /* 1 byte: The following defines what type of IP packet this entry represents. * The value is one of the apFlowEntryType_e options. * Entry type can hold an information about protocol type * ( AP_TCP_ENTRY, AP_UDP_ENTRY ) in case if Flow label equals 0. * If Flow label is not 0, entyr type would be AP_IPV6_ENTRY */ unsigned char entryType; unsigned char dummyPad[3]; #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 unsigned int wlanNode; unsigned int secKey; // holds sec key specific to station #endif /* 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; } apIpv6FlowEntry_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 RTIPV6_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof typedef apIpv6FlowEntry_t & (CACHE_LINE_SIZE - 1))) #else #define RTIPV6_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof(apIpv6FlowEntry_t) & (CACHE_LINE_SIZE - 1))) #endif typedef struct apIpv6FlowEntry_s_chaligned { apIpv6FlowEntry_t apFlowEntryMain; unsigned char reserved[RTIPV6_PADDING_TILL_CLINE]; } apIpv6FlowEntry_t_chaligned; #define IPV4_HEADER_SIZE_WITHOUT_OPTIONS 20 #define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff) #define IN6_IS_ADDR_LINKLOCAL(a) \ ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ == htonl (0xfe800000)) #define IP_VERSION_V4 (4) #define IP_VERSION_V6 (6) #ifdef AP_ASSEMBLER assert (sizeof typedef apIpv6FlowEntry_t_chaligned & (CACHE_LINE_SIZE - 1)), 0 #else // will do it later //assert (0 == (sizeof(apIpv6FlowEntry_s_chaligned) & (CACHE_LINE_SIZE - 1))); #endif #endif /* _IPV6_APFLOW_H_ */