/* ===================================================================== * Copyright (C) 2011 Ikanos Communications * See IKANOS_PROP_LICENSE.txt for license information. * ===================================================================== */ /*_____________________________________Header Guard_____________________________________*/ #ifndef _APFLOW_IPV6_VX185_H_ #define _APFLOW_IPV6_VX185_H_ /*_________________________________________MACRO________________________________________*/ #define AP_MAX_FLOW_EGRESS 4 #ifndef AP_MAC_ADDR_LEN #define AP_MAC_ADDR_LEN 6 #endif #ifndef AP_IPV6_IP_ADDR_LEN #define AP_IPV6_IP_ADDR_LEN 16 #endif #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) /*_______________________________________Includes_______________________________________*/ /*_______________________________________Structures_____________________________________*/ 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; /**************************************************************************************** * Structure Name: apCompare_ipv6_s * * Description : The following structures are used to compare IPv6 received packet with * * IPv6 flow entry. * * * ****************************************************************************************/ typedef struct apCompare_ipv6_s { /* 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]; union ipv6_fields_s { struct ipv6_ports_s { unsigned short srcPort; unsigned short dstPort; }ports; unsigned int SPI; unsigned int Flowlabel; }fields; /* 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 inMAC[AP_MAC_ADDR_LEN]; /*2 bytes: */ unsigned short inSessionID; /* 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; }apCompare_ipv6_t; /**************************************************************************************** * Structure Name: apModify_ipv6_s * * Description : The following structures are used to modify IPv6 received packet with * * information available in this structure. * * * ****************************************************************************************/ typedef struct apModify_ipv6_s { unsigned char dstMacAddr[6]; unsigned char srcMacAddr[6]; unsigned short etherType; /* 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 sessionID; /* 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 tosValue; }apModify_ipv6_t; // apWLANheader_s is common for IPv4 and IPv6 and its typedef will be taken from apflow_vx185.h /*___________________________________Main Structure_____________________________________*/ /**************************************************************************************** * Structure Name: apIpv6FlowEntry_s * * Description : The following apIpv6FlowEntry_s structure contains what fields to be * * compared with received IPv6 packet and the fields which are used to * * modify the IPv6 packet. * * * ****************************************************************************************/ typedef struct apIpv6FlowEntry_s { /* 4 bytes: Provide a mechanism to build a linked list of entries to resolve * hash collisions */ struct apIpv6FlowEntry_s *pNextEntry; 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 */ #define AP_IPV4_TUNNEL_TO_IPV6_BIT 8 /* Tunnelling V6 -> V4 - decapsulation */ /* 1 byte: The following describes what operations need to be performed * to packets that match this entry. */ unsigned short operations; unsigned short ops[OPTBL_MAX_OPERATIONS];//Contains PIO addr. Index 0 is used by MESH_NETWORK //Index 1 is used for storing ipv6/ipv4 tunneling/translation //information /* 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: 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 */ //Moved into apCompare // unsigned char entryType; unsigned short descAddr; unsigned int userHandle; apCompare_ipv6_t apCompare; apModify_ipv6_t apModify; #if defined(WLAN_ETH_8023) && (WLAN_ETH_8023) apWLANheader_t WLANheader; #endif } 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; #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 /*_____________________________________Header Guard_______________________*/ #endif /* _APFLOW_IPV6_VX185_H_ */