162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Lan Emulation client header file 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Marko Kiiskila <mkiiskila@yahoo.com> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _LEC_H_ 962306a36Sopenharmony_ci#define _LEC_H_ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/atmdev.h> 1262306a36Sopenharmony_ci#include <linux/netdevice.h> 1362306a36Sopenharmony_ci#include <linux/atmlec.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#define LEC_HEADER_LEN 16 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct lecdatahdr_8023 { 1862306a36Sopenharmony_ci __be16 le_header; 1962306a36Sopenharmony_ci unsigned char h_dest[ETH_ALEN]; 2062306a36Sopenharmony_ci unsigned char h_source[ETH_ALEN]; 2162306a36Sopenharmony_ci __be16 h_type; 2262306a36Sopenharmony_ci}; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_cistruct lecdatahdr_8025 { 2562306a36Sopenharmony_ci __be16 le_header; 2662306a36Sopenharmony_ci unsigned char ac_pad; 2762306a36Sopenharmony_ci unsigned char fc; 2862306a36Sopenharmony_ci unsigned char h_dest[ETH_ALEN]; 2962306a36Sopenharmony_ci unsigned char h_source[ETH_ALEN]; 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define LEC_MINIMUM_8023_SIZE 62 3362306a36Sopenharmony_ci#define LEC_MINIMUM_8025_SIZE 16 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* 3662306a36Sopenharmony_ci * Operations that LANE2 capable device can do. Two first functions 3762306a36Sopenharmony_ci * are used to make the device do things. See spec 3.1.3 and 3.1.4. 3862306a36Sopenharmony_ci * 3962306a36Sopenharmony_ci * The third function is intended for the MPOA component sitting on 4062306a36Sopenharmony_ci * top of the LANE device. The MPOA component assigns it's own function 4162306a36Sopenharmony_ci * to (*associate_indicator)() and the LANE device will use that 4262306a36Sopenharmony_ci * function to tell about TLVs it sees floating through. 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_cistruct lane2_ops { 4662306a36Sopenharmony_ci int (*resolve) (struct net_device *dev, const u8 *dst_mac, int force, 4762306a36Sopenharmony_ci u8 **tlvs, u32 *sizeoftlvs); 4862306a36Sopenharmony_ci int (*associate_req) (struct net_device *dev, const u8 *lan_dst, 4962306a36Sopenharmony_ci const u8 *tlvs, u32 sizeoftlvs); 5062306a36Sopenharmony_ci void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr, 5162306a36Sopenharmony_ci const u8 *tlvs, u32 sizeoftlvs); 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* 5562306a36Sopenharmony_ci * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType 5662306a36Sopenharmony_ci * frames. 5762306a36Sopenharmony_ci * 5862306a36Sopenharmony_ci * 1. Dix Ethernet EtherType frames encoded by placing EtherType 5962306a36Sopenharmony_ci * field in h_type field. Data follows immediately after header. 6062306a36Sopenharmony_ci * 2. LLC Data frames whose total length, including LLC field and data, 6162306a36Sopenharmony_ci * but not padding required to meet the minimum data frame length, 6262306a36Sopenharmony_ci * is less than ETH_P_802_3_MIN MUST be encoded by placing that length 6362306a36Sopenharmony_ci * in the h_type field. The LLC field follows header immediately. 6462306a36Sopenharmony_ci * 3. LLC data frames longer than this maximum MUST be encoded by placing 6562306a36Sopenharmony_ci * the value 0 in the h_type field. 6662306a36Sopenharmony_ci * 6762306a36Sopenharmony_ci */ 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* Hash table size */ 7062306a36Sopenharmony_ci#define LEC_ARP_TABLE_SIZE 16 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistruct lec_priv { 7362306a36Sopenharmony_ci unsigned short lecid; /* Lecid of this client */ 7462306a36Sopenharmony_ci struct hlist_head lec_arp_empty_ones; 7562306a36Sopenharmony_ci /* Used for storing VCC's that don't have a MAC address attached yet */ 7662306a36Sopenharmony_ci struct hlist_head lec_arp_tables[LEC_ARP_TABLE_SIZE]; 7762306a36Sopenharmony_ci /* Actual LE ARP table */ 7862306a36Sopenharmony_ci struct hlist_head lec_no_forward; 7962306a36Sopenharmony_ci /* 8062306a36Sopenharmony_ci * Used for storing VCC's (and forward packets from) which are to 8162306a36Sopenharmony_ci * age out by not using them to forward packets. 8262306a36Sopenharmony_ci * This is because to some LE clients there will be 2 VCCs. Only 8362306a36Sopenharmony_ci * one of them gets used. 8462306a36Sopenharmony_ci */ 8562306a36Sopenharmony_ci struct hlist_head mcast_fwds; 8662306a36Sopenharmony_ci /* 8762306a36Sopenharmony_ci * With LANEv2 it is possible that BUS (or a special multicast server) 8862306a36Sopenharmony_ci * establishes multiple Multicast Forward VCCs to us. This list 8962306a36Sopenharmony_ci * collects all those VCCs. LANEv1 client has only one item in this 9062306a36Sopenharmony_ci * list. These entries are not aged out. 9162306a36Sopenharmony_ci */ 9262306a36Sopenharmony_ci spinlock_t lec_arp_lock; 9362306a36Sopenharmony_ci struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 9462306a36Sopenharmony_ci struct atm_vcc *lecd; 9562306a36Sopenharmony_ci struct delayed_work lec_arp_work; /* C10 */ 9662306a36Sopenharmony_ci unsigned int maximum_unknown_frame_count; 9762306a36Sopenharmony_ci /* 9862306a36Sopenharmony_ci * Within the period of time defined by this variable, the client will send 9962306a36Sopenharmony_ci * no more than C10 frames to BUS for a given unicast destination. (C11) 10062306a36Sopenharmony_ci */ 10162306a36Sopenharmony_ci unsigned long max_unknown_frame_time; 10262306a36Sopenharmony_ci /* 10362306a36Sopenharmony_ci * If no traffic has been sent in this vcc for this period of time, 10462306a36Sopenharmony_ci * vcc will be torn down (C12) 10562306a36Sopenharmony_ci */ 10662306a36Sopenharmony_ci unsigned long vcc_timeout_period; 10762306a36Sopenharmony_ci /* 10862306a36Sopenharmony_ci * An LE Client MUST not retry an LE_ARP_REQUEST for a 10962306a36Sopenharmony_ci * given frame's LAN Destination more than maximum retry count times, 11062306a36Sopenharmony_ci * after the first LEC_ARP_REQUEST (C13) 11162306a36Sopenharmony_ci */ 11262306a36Sopenharmony_ci unsigned short max_retry_count; 11362306a36Sopenharmony_ci /* 11462306a36Sopenharmony_ci * Max time the client will maintain an entry in its arp cache in 11562306a36Sopenharmony_ci * absence of a verification of that relationship (C17) 11662306a36Sopenharmony_ci */ 11762306a36Sopenharmony_ci unsigned long aging_time; 11862306a36Sopenharmony_ci /* 11962306a36Sopenharmony_ci * Max time the client will maintain an entry in cache when 12062306a36Sopenharmony_ci * topology change flag is true (C18) 12162306a36Sopenharmony_ci */ 12262306a36Sopenharmony_ci unsigned long forward_delay_time; /* Topology change flag (C19) */ 12362306a36Sopenharmony_ci int topology_change; 12462306a36Sopenharmony_ci /* 12562306a36Sopenharmony_ci * Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE 12662306a36Sopenharmony_ci * cycle to take (C20) 12762306a36Sopenharmony_ci */ 12862306a36Sopenharmony_ci unsigned long arp_response_time; 12962306a36Sopenharmony_ci /* 13062306a36Sopenharmony_ci * Time limit ot wait to receive an LE_FLUSH_RESPONSE after the 13162306a36Sopenharmony_ci * LE_FLUSH_REQUEST has been sent before taking recover action. (C21) 13262306a36Sopenharmony_ci */ 13362306a36Sopenharmony_ci unsigned long flush_timeout; 13462306a36Sopenharmony_ci /* The time since sending a frame to the bus after which the 13562306a36Sopenharmony_ci * LE Client may assume that the frame has been either discarded or 13662306a36Sopenharmony_ci * delivered to the recipient (C22) 13762306a36Sopenharmony_ci */ 13862306a36Sopenharmony_ci unsigned long path_switching_delay; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci u8 *tlvs; /* LANE2: TLVs are new */ 14162306a36Sopenharmony_ci u32 sizeoftlvs; /* The size of the tlv array in bytes */ 14262306a36Sopenharmony_ci int lane_version; /* LANE2 */ 14362306a36Sopenharmony_ci int itfnum; /* e.g. 2 for lec2, 5 for lec5 */ 14462306a36Sopenharmony_ci struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */ 14562306a36Sopenharmony_ci int is_proxy; /* bridge between ATM and Ethernet */ 14662306a36Sopenharmony_ci}; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cistruct lec_vcc_priv { 14962306a36Sopenharmony_ci void (*old_pop) (struct atm_vcc *vcc, struct sk_buff *skb); 15062306a36Sopenharmony_ci int xoff; 15162306a36Sopenharmony_ci}; 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back)) 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci#endif /* _LEC_H_ */ 156