1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Lan Emulation client header file 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Marko Kiiskila <mkiiskila@yahoo.com> 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _LEC_H_ 9*4882a593Smuzhiyun #define _LEC_H_ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/atmdev.h> 12*4882a593Smuzhiyun #include <linux/netdevice.h> 13*4882a593Smuzhiyun #include <linux/atmlec.h> 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #define LEC_HEADER_LEN 16 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun struct lecdatahdr_8023 { 18*4882a593Smuzhiyun __be16 le_header; 19*4882a593Smuzhiyun unsigned char h_dest[ETH_ALEN]; 20*4882a593Smuzhiyun unsigned char h_source[ETH_ALEN]; 21*4882a593Smuzhiyun __be16 h_type; 22*4882a593Smuzhiyun }; 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun struct lecdatahdr_8025 { 25*4882a593Smuzhiyun __be16 le_header; 26*4882a593Smuzhiyun unsigned char ac_pad; 27*4882a593Smuzhiyun unsigned char fc; 28*4882a593Smuzhiyun unsigned char h_dest[ETH_ALEN]; 29*4882a593Smuzhiyun unsigned char h_source[ETH_ALEN]; 30*4882a593Smuzhiyun }; 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #define LEC_MINIMUM_8023_SIZE 62 33*4882a593Smuzhiyun #define LEC_MINIMUM_8025_SIZE 16 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* 36*4882a593Smuzhiyun * Operations that LANE2 capable device can do. Two first functions 37*4882a593Smuzhiyun * are used to make the device do things. See spec 3.1.3 and 3.1.4. 38*4882a593Smuzhiyun * 39*4882a593Smuzhiyun * The third function is intended for the MPOA component sitting on 40*4882a593Smuzhiyun * top of the LANE device. The MPOA component assigns it's own function 41*4882a593Smuzhiyun * to (*associate_indicator)() and the LANE device will use that 42*4882a593Smuzhiyun * function to tell about TLVs it sees floating through. 43*4882a593Smuzhiyun * 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun struct lane2_ops { 46*4882a593Smuzhiyun int (*resolve) (struct net_device *dev, const u8 *dst_mac, int force, 47*4882a593Smuzhiyun u8 **tlvs, u32 *sizeoftlvs); 48*4882a593Smuzhiyun int (*associate_req) (struct net_device *dev, const u8 *lan_dst, 49*4882a593Smuzhiyun const u8 *tlvs, u32 sizeoftlvs); 50*4882a593Smuzhiyun void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr, 51*4882a593Smuzhiyun const u8 *tlvs, u32 sizeoftlvs); 52*4882a593Smuzhiyun }; 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun /* 55*4882a593Smuzhiyun * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType 56*4882a593Smuzhiyun * frames. 57*4882a593Smuzhiyun * 58*4882a593Smuzhiyun * 1. Dix Ethernet EtherType frames encoded by placing EtherType 59*4882a593Smuzhiyun * field in h_type field. Data follows immediately after header. 60*4882a593Smuzhiyun * 2. LLC Data frames whose total length, including LLC field and data, 61*4882a593Smuzhiyun * but not padding required to meet the minimum data frame length, 62*4882a593Smuzhiyun * is less than ETH_P_802_3_MIN MUST be encoded by placing that length 63*4882a593Smuzhiyun * in the h_type field. The LLC field follows header immediately. 64*4882a593Smuzhiyun * 3. LLC data frames longer than this maximum MUST be encoded by placing 65*4882a593Smuzhiyun * the value 0 in the h_type field. 66*4882a593Smuzhiyun * 67*4882a593Smuzhiyun */ 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun /* Hash table size */ 70*4882a593Smuzhiyun #define LEC_ARP_TABLE_SIZE 16 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun struct lec_priv { 73*4882a593Smuzhiyun unsigned short lecid; /* Lecid of this client */ 74*4882a593Smuzhiyun struct hlist_head lec_arp_empty_ones; 75*4882a593Smuzhiyun /* Used for storing VCC's that don't have a MAC address attached yet */ 76*4882a593Smuzhiyun struct hlist_head lec_arp_tables[LEC_ARP_TABLE_SIZE]; 77*4882a593Smuzhiyun /* Actual LE ARP table */ 78*4882a593Smuzhiyun struct hlist_head lec_no_forward; 79*4882a593Smuzhiyun /* 80*4882a593Smuzhiyun * Used for storing VCC's (and forward packets from) which are to 81*4882a593Smuzhiyun * age out by not using them to forward packets. 82*4882a593Smuzhiyun * This is because to some LE clients there will be 2 VCCs. Only 83*4882a593Smuzhiyun * one of them gets used. 84*4882a593Smuzhiyun */ 85*4882a593Smuzhiyun struct hlist_head mcast_fwds; 86*4882a593Smuzhiyun /* 87*4882a593Smuzhiyun * With LANEv2 it is possible that BUS (or a special multicast server) 88*4882a593Smuzhiyun * establishes multiple Multicast Forward VCCs to us. This list 89*4882a593Smuzhiyun * collects all those VCCs. LANEv1 client has only one item in this 90*4882a593Smuzhiyun * list. These entries are not aged out. 91*4882a593Smuzhiyun */ 92*4882a593Smuzhiyun spinlock_t lec_arp_lock; 93*4882a593Smuzhiyun struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 94*4882a593Smuzhiyun struct atm_vcc *lecd; 95*4882a593Smuzhiyun struct delayed_work lec_arp_work; /* C10 */ 96*4882a593Smuzhiyun unsigned int maximum_unknown_frame_count; 97*4882a593Smuzhiyun /* 98*4882a593Smuzhiyun * Within the period of time defined by this variable, the client will send 99*4882a593Smuzhiyun * no more than C10 frames to BUS for a given unicast destination. (C11) 100*4882a593Smuzhiyun */ 101*4882a593Smuzhiyun unsigned long max_unknown_frame_time; 102*4882a593Smuzhiyun /* 103*4882a593Smuzhiyun * If no traffic has been sent in this vcc for this period of time, 104*4882a593Smuzhiyun * vcc will be torn down (C12) 105*4882a593Smuzhiyun */ 106*4882a593Smuzhiyun unsigned long vcc_timeout_period; 107*4882a593Smuzhiyun /* 108*4882a593Smuzhiyun * An LE Client MUST not retry an LE_ARP_REQUEST for a 109*4882a593Smuzhiyun * given frame's LAN Destination more than maximum retry count times, 110*4882a593Smuzhiyun * after the first LEC_ARP_REQUEST (C13) 111*4882a593Smuzhiyun */ 112*4882a593Smuzhiyun unsigned short max_retry_count; 113*4882a593Smuzhiyun /* 114*4882a593Smuzhiyun * Max time the client will maintain an entry in its arp cache in 115*4882a593Smuzhiyun * absence of a verification of that relationship (C17) 116*4882a593Smuzhiyun */ 117*4882a593Smuzhiyun unsigned long aging_time; 118*4882a593Smuzhiyun /* 119*4882a593Smuzhiyun * Max time the client will maintain an entry in cache when 120*4882a593Smuzhiyun * topology change flag is true (C18) 121*4882a593Smuzhiyun */ 122*4882a593Smuzhiyun unsigned long forward_delay_time; /* Topology change flag (C19) */ 123*4882a593Smuzhiyun int topology_change; 124*4882a593Smuzhiyun /* 125*4882a593Smuzhiyun * Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE 126*4882a593Smuzhiyun * cycle to take (C20) 127*4882a593Smuzhiyun */ 128*4882a593Smuzhiyun unsigned long arp_response_time; 129*4882a593Smuzhiyun /* 130*4882a593Smuzhiyun * Time limit ot wait to receive an LE_FLUSH_RESPONSE after the 131*4882a593Smuzhiyun * LE_FLUSH_REQUEST has been sent before taking recover action. (C21) 132*4882a593Smuzhiyun */ 133*4882a593Smuzhiyun unsigned long flush_timeout; 134*4882a593Smuzhiyun /* The time since sending a frame to the bus after which the 135*4882a593Smuzhiyun * LE Client may assume that the frame has been either discarded or 136*4882a593Smuzhiyun * delivered to the recipient (C22) 137*4882a593Smuzhiyun */ 138*4882a593Smuzhiyun unsigned long path_switching_delay; 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun u8 *tlvs; /* LANE2: TLVs are new */ 141*4882a593Smuzhiyun u32 sizeoftlvs; /* The size of the tlv array in bytes */ 142*4882a593Smuzhiyun int lane_version; /* LANE2 */ 143*4882a593Smuzhiyun int itfnum; /* e.g. 2 for lec2, 5 for lec5 */ 144*4882a593Smuzhiyun struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */ 145*4882a593Smuzhiyun int is_proxy; /* bridge between ATM and Ethernet */ 146*4882a593Smuzhiyun }; 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun struct lec_vcc_priv { 149*4882a593Smuzhiyun void (*old_pop) (struct atm_vcc *vcc, struct sk_buff *skb); 150*4882a593Smuzhiyun int xoff; 151*4882a593Smuzhiyun }; 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun #define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back)) 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun #endif /* _LEC_H_ */ 156