xref: /openbmc/linux/net/atm/lec.h (revision b2441318)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * Lan Emulation client header file
41da177e4SLinus Torvalds  *
51c9d3e72SChas Williams  * Marko Kiiskila <mkiiskila@yahoo.com>
61da177e4SLinus Torvalds  */
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #ifndef _LEC_H_
91da177e4SLinus Torvalds #define _LEC_H_
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #include <linux/atmdev.h>
121da177e4SLinus Torvalds #include <linux/netdevice.h>
131da177e4SLinus Torvalds #include <linux/atmlec.h>
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds #define LEC_HEADER_LEN 16
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds struct lecdatahdr_8023 {
1830d492daSAl Viro 	__be16 le_header;
191da177e4SLinus Torvalds 	unsigned char h_dest[ETH_ALEN];
201da177e4SLinus Torvalds 	unsigned char h_source[ETH_ALEN];
2130d492daSAl Viro 	__be16 h_type;
221da177e4SLinus Torvalds };
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds struct lecdatahdr_8025 {
2530d492daSAl Viro 	__be16 le_header;
261da177e4SLinus Torvalds 	unsigned char ac_pad;
271da177e4SLinus Torvalds 	unsigned char fc;
281da177e4SLinus Torvalds 	unsigned char h_dest[ETH_ALEN];
291da177e4SLinus Torvalds 	unsigned char h_source[ETH_ALEN];
301da177e4SLinus Torvalds };
311da177e4SLinus Torvalds 
321da177e4SLinus Torvalds #define LEC_MINIMUM_8023_SIZE   62
331da177e4SLinus Torvalds #define LEC_MINIMUM_8025_SIZE   16
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds /*
361da177e4SLinus Torvalds  * Operations that LANE2 capable device can do. Two first functions
371da177e4SLinus Torvalds  * are used to make the device do things. See spec 3.1.3 and 3.1.4.
381da177e4SLinus Torvalds  *
3925985edcSLucas De Marchi  * The third function is intended for the MPOA component sitting on
401da177e4SLinus Torvalds  * top of the LANE device. The MPOA component assigns it's own function
411da177e4SLinus Torvalds  * to (*associate_indicator)() and the LANE device will use that
421da177e4SLinus Torvalds  * function to tell about TLVs it sees floating through.
431da177e4SLinus Torvalds  *
441da177e4SLinus Torvalds  */
451da177e4SLinus Torvalds struct lane2_ops {
4661c33e01SMitchell Blank Jr 	int (*resolve) (struct net_device *dev, const u8 *dst_mac, int force,
471da177e4SLinus Torvalds 			u8 **tlvs, u32 *sizeoftlvs);
4861c33e01SMitchell Blank Jr 	int (*associate_req) (struct net_device *dev, const u8 *lan_dst,
4961c33e01SMitchell Blank Jr 			      const u8 *tlvs, u32 sizeoftlvs);
5061c33e01SMitchell Blank Jr 	void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
5161c33e01SMitchell Blank Jr 				     const u8 *tlvs, u32 sizeoftlvs);
521da177e4SLinus Torvalds };
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds /*
551da177e4SLinus Torvalds  * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
561da177e4SLinus Torvalds  * frames.
571c9d3e72SChas Williams  *
581da177e4SLinus Torvalds  * 1. Dix Ethernet EtherType frames encoded by placing EtherType
5961282f37SAlexandra Vintila  *    field in h_type field. Data follows immediately after header.
601da177e4SLinus Torvalds  * 2. LLC Data frames whose total length, including LLC field and data,
611da177e4SLinus Torvalds  *    but not padding required to meet the minimum data frame length,
62e5c5d22eSSimon Horman  *    is less than ETH_P_802_3_MIN MUST be encoded by placing that length
6361282f37SAlexandra Vintila  *    in the h_type field. The LLC field follows header immediately.
641da177e4SLinus Torvalds  * 3. LLC data frames longer than this maximum MUST be encoded by placing
651da177e4SLinus Torvalds  *    the value 0 in the h_type field.
661da177e4SLinus Torvalds  *
671da177e4SLinus Torvalds  */
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds /* Hash table size */
701da177e4SLinus Torvalds #define LEC_ARP_TABLE_SIZE 16
711da177e4SLinus Torvalds 
721da177e4SLinus Torvalds struct lec_priv {
731da177e4SLinus Torvalds 	unsigned short lecid;			/* Lecid of this client */
74d0732f64SChas Williams 	struct hlist_head lec_arp_empty_ones;
751da177e4SLinus Torvalds 						/* Used for storing VCC's that don't have a MAC address attached yet */
76d0732f64SChas Williams 	struct hlist_head lec_arp_tables[LEC_ARP_TABLE_SIZE];
771da177e4SLinus Torvalds 						/* Actual LE ARP table */
78d0732f64SChas Williams 	struct hlist_head lec_no_forward;
791c9d3e72SChas Williams 						/*
801c9d3e72SChas Williams 						 * Used for storing VCC's (and forward packets from) which are to
811c9d3e72SChas Williams 						 * age out by not using them to forward packets.
821c9d3e72SChas Williams 						 * This is because to some LE clients there will be 2 VCCs. Only
831c9d3e72SChas Williams 						 * one of them gets used.
841c9d3e72SChas Williams 						 */
85d0732f64SChas Williams 	struct hlist_head mcast_fwds;
861c9d3e72SChas Williams 						/*
871c9d3e72SChas Williams 						 * With LANEv2 it is possible that BUS (or a special multicast server)
881c9d3e72SChas Williams 						 * establishes multiple Multicast Forward VCCs to us. This list
891c9d3e72SChas Williams 						 * collects all those VCCs. LANEv1 client has only one item in this
901c9d3e72SChas Williams 						 * list. These entries are not aged out.
911c9d3e72SChas Williams 						 */
921da177e4SLinus Torvalds 	spinlock_t lec_arp_lock;
931da177e4SLinus Torvalds 	struct atm_vcc *mcast_vcc;		/* Default Multicast Send VCC */
941da177e4SLinus Torvalds 	struct atm_vcc *lecd;
95c4028958SDavid Howells 	struct delayed_work lec_arp_work;	/* C10 */
961da177e4SLinus Torvalds 	unsigned int maximum_unknown_frame_count;
971c9d3e72SChas Williams 						/*
981c9d3e72SChas Williams 						 * Within the period of time defined by this variable, the client will send
991c9d3e72SChas Williams 						 * no more than C10 frames to BUS for a given unicast destination. (C11)
1001c9d3e72SChas Williams 						 */
1011da177e4SLinus Torvalds 	unsigned long max_unknown_frame_time;
1021c9d3e72SChas Williams 						/*
1031c9d3e72SChas Williams 						 * If no traffic has been sent in this vcc for this period of time,
1041c9d3e72SChas Williams 						 * vcc will be torn down (C12)
1051c9d3e72SChas Williams 						 */
1061da177e4SLinus Torvalds 	unsigned long vcc_timeout_period;
1071c9d3e72SChas Williams 						/*
1081c9d3e72SChas Williams 						 * An LE Client MUST not retry an LE_ARP_REQUEST for a
1091c9d3e72SChas Williams 						 * given frame's LAN Destination more than maximum retry count times,
1101c9d3e72SChas Williams 						 * after the first LEC_ARP_REQUEST (C13)
1111c9d3e72SChas Williams 						 */
1121da177e4SLinus Torvalds 	unsigned short max_retry_count;
1131c9d3e72SChas Williams 						/*
1141c9d3e72SChas Williams 						 * Max time the client will maintain an entry in its arp cache in
1151c9d3e72SChas Williams 						 * absence of a verification of that relationship (C17)
1161c9d3e72SChas Williams 						 */
1171da177e4SLinus Torvalds 	unsigned long aging_time;
1181c9d3e72SChas Williams 						/*
1191c9d3e72SChas Williams 						 * Max time the client will maintain an entry in cache when
1201c9d3e72SChas Williams 						 * topology change flag is true (C18)
1211c9d3e72SChas Williams 						 */
1221c9d3e72SChas Williams 	unsigned long forward_delay_time;	/* Topology change flag (C19) */
1231da177e4SLinus Torvalds 	int topology_change;
1241c9d3e72SChas Williams 						/*
1251c9d3e72SChas Williams 						 * Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE
1261c9d3e72SChas Williams 						 * cycle to take (C20)
1271c9d3e72SChas Williams 						 */
1281da177e4SLinus Torvalds 	unsigned long arp_response_time;
1291c9d3e72SChas Williams 						/*
1301c9d3e72SChas Williams 						 * Time limit ot wait to receive an LE_FLUSH_RESPONSE after the
1311c9d3e72SChas Williams 						 * LE_FLUSH_REQUEST has been sent before taking recover action. (C21)
1321c9d3e72SChas Williams 						 */
1331da177e4SLinus Torvalds 	unsigned long flush_timeout;
1341da177e4SLinus Torvalds 						/* The time since sending a frame to the bus after which the
1351c9d3e72SChas Williams 						 * LE Client may assume that the frame has been either discarded or
1361c9d3e72SChas Williams 						 * delivered to the recipient (C22)
1371c9d3e72SChas Williams 						 */
1381da177e4SLinus Torvalds 	unsigned long path_switching_delay;
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds 	u8 *tlvs;				/* LANE2: TLVs are new */
1411da177e4SLinus Torvalds 	u32 sizeoftlvs;				/* The size of the tlv array in bytes */
1421da177e4SLinus Torvalds 	int lane_version;			/* LANE2 */
1431da177e4SLinus Torvalds 	int itfnum;				/* e.g. 2 for lec2, 5 for lec5 */
1441da177e4SLinus Torvalds 	struct lane2_ops *lane2_ops;		/* can be NULL for LANE v1 */
1451da177e4SLinus Torvalds 	int is_proxy;				/* bridge between ATM and Ethernet */
1461da177e4SLinus Torvalds };
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds struct lec_vcc_priv {
1491da177e4SLinus Torvalds 	void (*old_pop) (struct atm_vcc *vcc, struct sk_buff *skb);
1501da177e4SLinus Torvalds 	int xoff;
1511da177e4SLinus Torvalds };
1521da177e4SLinus Torvalds 
1531da177e4SLinus Torvalds #define LEC_VCC_PRIV(vcc)	((struct lec_vcc_priv *)((vcc)->user_back))
1541da177e4SLinus Torvalds 
1551da177e4SLinus Torvalds #endif				/* _LEC_H_ */
156