18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Lan Emulation client header file 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Marko Kiiskila <mkiiskila@yahoo.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _LEC_H_ 98c2ecf20Sopenharmony_ci#define _LEC_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/atmdev.h> 128c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 138c2ecf20Sopenharmony_ci#include <linux/atmlec.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define LEC_HEADER_LEN 16 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct lecdatahdr_8023 { 188c2ecf20Sopenharmony_ci __be16 le_header; 198c2ecf20Sopenharmony_ci unsigned char h_dest[ETH_ALEN]; 208c2ecf20Sopenharmony_ci unsigned char h_source[ETH_ALEN]; 218c2ecf20Sopenharmony_ci __be16 h_type; 228c2ecf20Sopenharmony_ci}; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct lecdatahdr_8025 { 258c2ecf20Sopenharmony_ci __be16 le_header; 268c2ecf20Sopenharmony_ci unsigned char ac_pad; 278c2ecf20Sopenharmony_ci unsigned char fc; 288c2ecf20Sopenharmony_ci unsigned char h_dest[ETH_ALEN]; 298c2ecf20Sopenharmony_ci unsigned char h_source[ETH_ALEN]; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define LEC_MINIMUM_8023_SIZE 62 338c2ecf20Sopenharmony_ci#define LEC_MINIMUM_8025_SIZE 16 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * Operations that LANE2 capable device can do. Two first functions 378c2ecf20Sopenharmony_ci * are used to make the device do things. See spec 3.1.3 and 3.1.4. 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * The third function is intended for the MPOA component sitting on 408c2ecf20Sopenharmony_ci * top of the LANE device. The MPOA component assigns it's own function 418c2ecf20Sopenharmony_ci * to (*associate_indicator)() and the LANE device will use that 428c2ecf20Sopenharmony_ci * function to tell about TLVs it sees floating through. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cistruct lane2_ops { 468c2ecf20Sopenharmony_ci int (*resolve) (struct net_device *dev, const u8 *dst_mac, int force, 478c2ecf20Sopenharmony_ci u8 **tlvs, u32 *sizeoftlvs); 488c2ecf20Sopenharmony_ci int (*associate_req) (struct net_device *dev, const u8 *lan_dst, 498c2ecf20Sopenharmony_ci const u8 *tlvs, u32 sizeoftlvs); 508c2ecf20Sopenharmony_ci void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr, 518c2ecf20Sopenharmony_ci const u8 *tlvs, u32 sizeoftlvs); 528c2ecf20Sopenharmony_ci}; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* 558c2ecf20Sopenharmony_ci * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType 568c2ecf20Sopenharmony_ci * frames. 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * 1. Dix Ethernet EtherType frames encoded by placing EtherType 598c2ecf20Sopenharmony_ci * field in h_type field. Data follows immediately after header. 608c2ecf20Sopenharmony_ci * 2. LLC Data frames whose total length, including LLC field and data, 618c2ecf20Sopenharmony_ci * but not padding required to meet the minimum data frame length, 628c2ecf20Sopenharmony_ci * is less than ETH_P_802_3_MIN MUST be encoded by placing that length 638c2ecf20Sopenharmony_ci * in the h_type field. The LLC field follows header immediately. 648c2ecf20Sopenharmony_ci * 3. LLC data frames longer than this maximum MUST be encoded by placing 658c2ecf20Sopenharmony_ci * the value 0 in the h_type field. 668c2ecf20Sopenharmony_ci * 678c2ecf20Sopenharmony_ci */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* Hash table size */ 708c2ecf20Sopenharmony_ci#define LEC_ARP_TABLE_SIZE 16 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistruct lec_priv { 738c2ecf20Sopenharmony_ci unsigned short lecid; /* Lecid of this client */ 748c2ecf20Sopenharmony_ci struct hlist_head lec_arp_empty_ones; 758c2ecf20Sopenharmony_ci /* Used for storing VCC's that don't have a MAC address attached yet */ 768c2ecf20Sopenharmony_ci struct hlist_head lec_arp_tables[LEC_ARP_TABLE_SIZE]; 778c2ecf20Sopenharmony_ci /* Actual LE ARP table */ 788c2ecf20Sopenharmony_ci struct hlist_head lec_no_forward; 798c2ecf20Sopenharmony_ci /* 808c2ecf20Sopenharmony_ci * Used for storing VCC's (and forward packets from) which are to 818c2ecf20Sopenharmony_ci * age out by not using them to forward packets. 828c2ecf20Sopenharmony_ci * This is because to some LE clients there will be 2 VCCs. Only 838c2ecf20Sopenharmony_ci * one of them gets used. 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_ci struct hlist_head mcast_fwds; 868c2ecf20Sopenharmony_ci /* 878c2ecf20Sopenharmony_ci * With LANEv2 it is possible that BUS (or a special multicast server) 888c2ecf20Sopenharmony_ci * establishes multiple Multicast Forward VCCs to us. This list 898c2ecf20Sopenharmony_ci * collects all those VCCs. LANEv1 client has only one item in this 908c2ecf20Sopenharmony_ci * list. These entries are not aged out. 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_ci spinlock_t lec_arp_lock; 938c2ecf20Sopenharmony_ci struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 948c2ecf20Sopenharmony_ci struct atm_vcc *lecd; 958c2ecf20Sopenharmony_ci struct delayed_work lec_arp_work; /* C10 */ 968c2ecf20Sopenharmony_ci unsigned int maximum_unknown_frame_count; 978c2ecf20Sopenharmony_ci /* 988c2ecf20Sopenharmony_ci * Within the period of time defined by this variable, the client will send 998c2ecf20Sopenharmony_ci * no more than C10 frames to BUS for a given unicast destination. (C11) 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci unsigned long max_unknown_frame_time; 1028c2ecf20Sopenharmony_ci /* 1038c2ecf20Sopenharmony_ci * If no traffic has been sent in this vcc for this period of time, 1048c2ecf20Sopenharmony_ci * vcc will be torn down (C12) 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_ci unsigned long vcc_timeout_period; 1078c2ecf20Sopenharmony_ci /* 1088c2ecf20Sopenharmony_ci * An LE Client MUST not retry an LE_ARP_REQUEST for a 1098c2ecf20Sopenharmony_ci * given frame's LAN Destination more than maximum retry count times, 1108c2ecf20Sopenharmony_ci * after the first LEC_ARP_REQUEST (C13) 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_ci unsigned short max_retry_count; 1138c2ecf20Sopenharmony_ci /* 1148c2ecf20Sopenharmony_ci * Max time the client will maintain an entry in its arp cache in 1158c2ecf20Sopenharmony_ci * absence of a verification of that relationship (C17) 1168c2ecf20Sopenharmony_ci */ 1178c2ecf20Sopenharmony_ci unsigned long aging_time; 1188c2ecf20Sopenharmony_ci /* 1198c2ecf20Sopenharmony_ci * Max time the client will maintain an entry in cache when 1208c2ecf20Sopenharmony_ci * topology change flag is true (C18) 1218c2ecf20Sopenharmony_ci */ 1228c2ecf20Sopenharmony_ci unsigned long forward_delay_time; /* Topology change flag (C19) */ 1238c2ecf20Sopenharmony_ci int topology_change; 1248c2ecf20Sopenharmony_ci /* 1258c2ecf20Sopenharmony_ci * Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE 1268c2ecf20Sopenharmony_ci * cycle to take (C20) 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci unsigned long arp_response_time; 1298c2ecf20Sopenharmony_ci /* 1308c2ecf20Sopenharmony_ci * Time limit ot wait to receive an LE_FLUSH_RESPONSE after the 1318c2ecf20Sopenharmony_ci * LE_FLUSH_REQUEST has been sent before taking recover action. (C21) 1328c2ecf20Sopenharmony_ci */ 1338c2ecf20Sopenharmony_ci unsigned long flush_timeout; 1348c2ecf20Sopenharmony_ci /* The time since sending a frame to the bus after which the 1358c2ecf20Sopenharmony_ci * LE Client may assume that the frame has been either discarded or 1368c2ecf20Sopenharmony_ci * delivered to the recipient (C22) 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci unsigned long path_switching_delay; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci u8 *tlvs; /* LANE2: TLVs are new */ 1418c2ecf20Sopenharmony_ci u32 sizeoftlvs; /* The size of the tlv array in bytes */ 1428c2ecf20Sopenharmony_ci int lane_version; /* LANE2 */ 1438c2ecf20Sopenharmony_ci int itfnum; /* e.g. 2 for lec2, 5 for lec5 */ 1448c2ecf20Sopenharmony_ci struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */ 1458c2ecf20Sopenharmony_ci int is_proxy; /* bridge between ATM and Ethernet */ 1468c2ecf20Sopenharmony_ci}; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_cistruct lec_vcc_priv { 1498c2ecf20Sopenharmony_ci void (*old_pop) (struct atm_vcc *vcc, struct sk_buff *skb); 1508c2ecf20Sopenharmony_ci int xoff; 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back)) 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci#endif /* _LEC_H_ */ 156