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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * llc_output.c - LLC minimal output path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (c) 1997 by Procom Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * 		 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/if_arp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <net/llc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <net/llc_pdu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  *	llc_mac_hdr_init - fills MAC header fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  *	@skb: Address of the frame to initialize its MAC header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  *	@sa: The MAC source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *	@da: The MAC destination address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  *	Fills MAC header fields, depending on MAC type. Returns 0, If MAC type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  *	is a valid type and initialization completes correctly 1, otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int llc_mac_hdr_init(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		     const unsigned char *sa, const unsigned char *da)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	int rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	switch (skb->dev->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	case ARPHRD_ETHER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	case ARPHRD_LOOPBACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 				     skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		if (rc > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 			rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  *	llc_build_and_send_ui_pkt - unitdata request interface for upper layers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  *	@sap: sap to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  *	@skb: packet to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  *	@dmac: destination mac address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  *	@dsap: destination sap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  *	Upper layers calls this function when upper layer wants to send data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  *	using connection-less mode communication (UI pdu).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)  *	Accept data frame from network layer to be sent using connection-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)  *	less mode communication; timeout/retries handled by network layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)  *	package primitive as an event and send to SAP event handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			      unsigned char *dmac, unsigned char dsap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	llc_pdu_header_init(skb, LLC_PDU_TYPE_U, sap->laddr.lsap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 			    dsap, LLC_PDU_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	llc_pdu_init_as_ui_cmd(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	if (likely(!rc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		rc = dev_queue_xmit(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) EXPORT_SYMBOL(llc_mac_hdr_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) EXPORT_SYMBOL(llc_build_and_send_ui_pkt);