/* Copyright (C) 2006 Ikanos Communications * See IKANOS_PROP_LICENSE.txt for license information. */ //====================================================================== // File Name : $RCSfile: apbridge.h,v $ // Description : Format of bridging table entries // CVS ID : $Id: apbridge.h,v 1.1 2005/03/09 13:37:14 sadiq Exp $ //====================================================================== #ifndef _APBRIDGE_H_ #define _APBRIDGE_H_ #include #include #include #include #if defined(AP_FASTPATH_STATISTICS) && (AP_FASTPATH_STATISTICS) #include "apstatistics.h" #endif /* Define the state of the bridging part of the module. These states are * intended to support the implementation of spanning-tree bridge */ // Disable means no Bridge processing. // In ETH case AP will get the packets already filtered by MAC. // Only packets with matched MAC address will arrive to ETH AP. // ETH AP should provide this packets for routing // ( later these packets can go to Host - if no route entry found ). // // At ATM case, we do not have the H/W support to do this-> // It means that ATM AP will provide all packets to BM and // BM will do macthing of MAC address and will give to routing only // packets with matched MAC address. // ( Bridge disabled state is NOT promiscous mode ) // In reality, this state is not needed because we have same information about BRIDGE DISABLE state // from NULL pointer to Bridge Table #define AP_BRIDGE_DISABLED 0 // Listening means dropping ALL packets except specific Spanning packets. // Spanning packets will come with specific destination MAC address // 0x0180c2000000 and provide these packets to Host #define AP_BRIDGE_LISTENING 1 // Learning means register packets inside of Bridge table and // provide them to Host #define AP_BRIDGE_LEARNING 2 // DO all stuff- matching SRC MAC and DST MAC, if Yes send to rxPortId. // If No, provide packets to Host #define AP_BRIDGE_OPERATIONAL 3 // ( States presented below is promiscous mode ) // Blocking means dropping ALL packets. #define AP_BRIDGE_BLOCKING 4 #ifndef AP_MAC_ADDR_LEN #define AP_MAC_ADDR_LEN 6 #endif #if defined(IS_VX185) && (IS_VX185) #define MESH_TAG_BIT 15 #else // We are removing this as this is not used in vx185; instead this bit is redefined and now it is used by MESH_NETWORK // This bit is responsible for tagging or not of a packet at transmit part // Value 1 at this bit is TAG, 0 - UNTAG #define VLAN_TAG_BIT 15 #endif typedef struct apNewBridgeEntry_s { /* Link used to resolve hash collisions */ struct apNewBridgeEntry_s *pNextEntry; /* The following set of egress ports determines where the packet is * sent when bridged. Having a list of egress ports allows limited * flooding that may be useful for multicast / broadcast addresses */ #define AP_MAX_BRIDGE_EGRESS 4 apEgressPort_t egressList[AP_MAX_BRIDGE_EGRESS]; /* The following set of bits specify the operations that should be * performed on the packet. Note that in some cases there are port * configuration bits that will modify the action performed */ unsigned short operations; #if defined(AP_FASTPATH_STATISTICS) && (AP_FASTPATH_STATISTICS) struct apStatistics_s apStatistics; #endif #define AP_BRIDGE_VALID_BIT 0 /* Set if this entry is valid. Used * to denote unused entries */ #define AP_VLAN_CTRL_BIT 1 /* 1 = Insert VLAN tag if not present * 0 = Delete VLAN tag if present * Overridden by port VLAN disable bit */ #define AP_BRIDGE_ROUTING_BIT 2 /* 1 = Switch to Routing for this packet * 0 = Continue Bridging * This bit is relevant only when Dst MAC of packet * matched with macAddr of Bridge entry */ #if defined(WLAN_ETH_8023) && (WLAN_ETH_8023) #define AP_BRIDGE_ADD_WLAN_HDR_BIT 11 /* Add 802.11 header */ #endif #define AP_PACKET_MULTICAST_BIT 12 /* 1 = Packet is Multicast * 0 = Packet is unicast * This bit is relevant only when Dst MAC of packet * matched with macAddr of Bridge entry * Multicast sign should be set in apPreHdr */ #if defined(IS_VX185) && (IS_VX185) #define AP_BRIDGE_CPY_APPREHDR_BIT 13 /* apPreHdr cpy to sdram by postClassifier: must be same as AP_CPY_APPREHDR_BIT */ #endif #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 #if defined(IS_VX185) && (IS_VX185) unsigned short reserved; unsigned short ops[OPTBL_MAX_OPERATIONS]; //This will contain PIO addr. #if defined(MESH_NETWORK) && (MESH_NETWORK) void *expIface; //holds virtual/physical interface dev #endif #endif /* The following contains a flag that say whether the AP has used this * entry since the flag was last reset. This is important to detect * entries that refer to devices that are no longer active. * * 0 = not used * non-zero = used * * Simple eh? */ unsigned short used; /* The following gives the MAC address this entry represents. This * is necessary because the hash used to look up this entry is not * perfect */ unsigned char macAddr[AP_MAC_ADDR_LEN]; /* The following records the VLAN ID that should be associated with this * device. It is used (12 bits) in a number of ways * * - When the packet is received it is checked to see if the VLAN address * is correct (ignoring CPI) * - When the packet is sent, does not have a VLAN address and needs * a VLAN address this one will be used (also includes CPI) */ unsigned short vlanAddr; /* This entry records the "port" (i.e. AP input queue) that the * device is attached to. This is mainly to detect when a device is moved * from one port to another. * The value should be 16 MSB of Receive port identifier. * ( For example, for ETH0 it's 0x1911, for ETH1 it's 0x1915 ) */ unsigned short rxPort; //RVRV+ /* This entry is used for ATM traffic ONLY. * ATM can have more than one logical interface */ unsigned short subPort; //RVRV+ /* This entry is used ( 3 bits ) to differentiate packet priority * To optimize we'll put these 3 bits at place of bits 15-13. * So we don't need to shift them at Ap code * ATTENTION!!! User SHOULD SHIFT THE PRIORITY VALUE 13 BITS LEFT */ unsigned short priority; /* The following information controls the handling of VLAN and S-VLAN for * the port. * * Note that some of the operations are only performed if the packet has * bridge processing applied. */ unsigned short control; #define AP_VLAN_ENABLE_BIT 0 /* Enable VLAN processing */ #define AP_VLAN_ACCEPT_BIT 1 /* Only accept VLAN packets [bridge] */ #define AP_VLAN_SVLAN_BIT 2 /* Packets entering/leaving port * must have S-VLAN headers */ #define AP_ALL_ROUTE_BIT 3 /* Treat all received packets as * routeable (ie. ignore the * destination MAC address) */ #define AP_NON_MAC_FILTER_BIT 4 /* Do or Not additional filtering * for bridge packets */ #define AP_MULTI_PORT_BRIDGE_MODE_BIT 5 /* Do or Not transmit to same group of logical subports. * This bit makes a sense for ATM ONLY. * For Ethernet AP this value SHOULD BE ALWAYS 0 */ #define AP_PPPOE_PASS_THROUGH_BIT 6 /* PPPoE Passthrough */ /* RVRV+ The following information presents SVLAN data */ // unsigned short svlanData; /* The following information represents PPPoE Session Id */ unsigned short sessionId; /* The state of bridging (as far as the AP is concerned can be represented * as three states * * - Disabled. All non-routed packets are dropped * - Listening. All non-routed packets are forwarded to the host CPU * - Operational. All non-routed packets are bridge processed */ unsigned char bridgeState; /* 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; #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) #if defined(IS_VX185) && (IS_VX185) apWLANheader_t WLANheader; #else unsigned char bssId[AP_MAC_ADDR_LEN]; unsigned char wlanFlags; unsigned char secHdrLen; // security header space in the pkt #ifndef AP_DO_WLAN_WEP_HDR_BIT #define AP_DO_WLAN_WEP_HDR_BIT 0x01 #endif #ifndef AP_DO_WLAN_QOS_HDR_BIT #define AP_DO_WLAN_QOS_HDR_BIT 0x02 #endif #ifndef AP_DO_WLAN_HDR_BIT #define AP_DO_WLAN_HDR_BIT 0x03 #endif unsigned int wlanNode; unsigned int secKey; // holds sec key specific to station #endif #endif #if defined(IS_VX185) && (IS_VX185) unsigned short br_ifIndex; /*hold bridge's->netdevice->ifindex value. used to compare ingress and egress interfaces are on same bridge. */ unsigned short descAddr; unsigned char cbPort; /*contains cbport number 0 -> eth0 | eth0.x 3 -> eth1 | eth1.x 1 -> wlan | wlan.x 4 -> vdsl | vdsl.x */ #endif } apNewBridgeEntry_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 BR_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof typedef apNewBridgeEntry_t & (CACHE_LINE_SIZE - 1)) ) #else #define BR_PADDING_TILL_CLINE (CACHE_LINE_SIZE - (sizeof(apNewBridgeEntry_t) & (CACHE_LINE_SIZE - 1)) ) #endif typedef struct apBridgeEntry_s_chaligned { apNewBridgeEntry_t apBridgeEntryMain; unsigned char reserved[BR_PADDING_TILL_CLINE]; } apBridgeEntry_t_chaligned; #ifdef AP_ASSEMBLER assert (sizeof typedef apBridgeEntry_t_chaligned & (CACHE_LINE_SIZE - 1)), 0 #else // will do it later //assert (0 == (sizeof(apBridgeEntry_t_chaligned) & 0x1f)); #endif /* This structure represents on actions to be performed on the packet like marking the TOS, COS etc ***/ typedef struct { // flags field contains the action to be performed. The corresponding // bits has to set to perform the action. /* 1. AP_MARK_TOS_BIT marks the TOS of the packet with the value in markTOS 2. AP_MARK_COS_BIT marks the COS of the packet with the value in markCOS */ #define AP_SET_PRIORITY 0 #define AP_MARK_TOS_BIT 1 #define AP_MARK_COS_BIT 2 unsigned char flags; unsigned char priority; unsigned char markTOS; unsigned char markCOS; }apbridgeAction_t; #if defined(IS_VX185) && (IS_VX185) #define MAX_BRIDGE_AP_PORTS (4 + 1) //Wlan1 also considered #else #define MAX_BRIDGE_AP_PORTS 4 #endif typedef struct { unsigned char txApId; unsigned char flags; unsigned char priority; unsigned char markTOS; unsigned char markCOS; #if defined(IS_VX185) && (IS_VX185) unsigned short rxIfIndex; /* Stores rx interface name */ unsigned short txIfIndex; /* Stores tx interface name */ #endif }apbridgeMark_t; #if defined(IS_VX185) && (IS_VX185) #define DEFAULT_VLANID 0 #else #define DEFAULT_VLANID 1 #endif #if defined(POLICY_BASED_VLAN) && (POLICY_BASED_VLAN) // Modified with policy based VLAN implementation #if IS_VX180 || IS_VX185 #define MAX_VLAN_CLASS_ENTRIES 10 #else #if defined(ETH_NO_CLASSIFICATION) && (ETH_NO_CLASSIFICATION) #define MAX_VLAN_CLASS_ENTRIES 16 #else #define MAX_VLAN_CLASS_ENTRIES 8 #endif //ETH_NO_CLASSIFICATION #endif //IS_VX180 // match_flags: // below are bit numbers and for each bit 0- disable 1- enable // only one bit need to be set for match operation #define VLAN_SIPADR_MATCH 0 #define VLAN_DIPADR_MATCH 1 #define VLAN_ETH_TYPE_MATCH 2 #define VLAN_DHCP_MATCH 3 #define VLAN_DEFAULT_MATCH 4 #define VLAN_PROTOCOL_MATCH 5 //action_flags: // below are bit numbers #define VLAN_TAG_ACTION 0 // 0 - untag 1- tag #define VLAN_HOST_ACTION 1 // Send pkts to Host #define VLAN_MASK_BIT 3 // Higer order 5 bits contains netmask value #define VLAN_CFI_BIT 12 // 0 - untag 1- tag typedef struct { union { unsigned int ipAddr; unsigned short ethType; unsigned short dhcp; unsigned char proto; }matchField; unsigned short vlanHdr; unsigned char matchFlags; unsigned char actionFlags; #if (defined(IS_VX185) && (IS_VX185)) || (defined(IS_VX175) && (IS_VX175)) unsigned char ifaceIndex; //dekumar:Store interface index for WLAN mssid to support P.Vlan for mssid. unsigned char reserved[3]; #endif }apVlanClass_t; #endif //Protocol based vlan #endif /* _APBRIDGE_H_ */