Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *	NET3:	Support for 802.2 demultiplexing off Ethernet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *		Demultiplex 802.2 encoded protocols. We match the entry by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *		SSAP/DSAP pair and then deliver to the registered datalink that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *		matches. The control byte is ignored and handling of such items
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *		is up to the routine passed the frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  *		Unlike the 802.3 datalink we have a list of 802.2 entries as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  *		there are multiple protocols to demux. The list is currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  *		short (3 or 4 entries at most). The current demux assumes this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <net/datalink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <net/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <net/p8022.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 			 unsigned char *dest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct datalink_proto *register_8022_client(unsigned char type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 					    int (*func)(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 							struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 							struct packet_type *pt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 							struct net_device *orig_dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	struct datalink_proto *proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	if (proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		proto->type[0]		= type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		proto->header_length	= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		proto->request		= p8022_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		proto->sap = llc_sap_open(type, func);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		if (!proto->sap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			kfree(proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			proto = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	return proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void unregister_8022_client(struct datalink_proto *proto)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	llc_sap_put(proto->sap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	kfree(proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) EXPORT_SYMBOL(register_8022_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) EXPORT_SYMBOL(unregister_8022_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) MODULE_LICENSE("GPL");