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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /* net/atm/raw.c - Raw AAL0 and AAL5 transports */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/atmdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/capability.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "protocols.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * SKB == NULL indicates that the link is being closed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	if (skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		struct sock *sk = sk_atm(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		skb_queue_tail(&sk->sk_receive_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		sk->sk_data_ready(sk);
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	struct sock *sk = sk_atm(vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	pr_debug("(%d) %d -= %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		 vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	sk->sk_write_space(sk);
^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) static int atm_send_aal0(struct atm_vcc *vcc, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	 * Note that if vpi/vci are _ANY or _UNSPEC the below will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	 * still work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	if (!capable(CAP_NET_ADMIN) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	    (((u32 *)skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	    ((vcc->vpi << ATM_HDR_VPI_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	     (vcc->vci << ATM_HDR_VCI_SHIFT))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		return -EADDRNOTAVAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	return vcc->dev->ops->send(vcc, skb);
^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) int atm_init_aal0(struct atm_vcc *vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	vcc->push = atm_push_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	vcc->pop = atm_pop_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	vcc->push_oam = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	vcc->send = atm_send_aal0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int atm_init_aal34(struct atm_vcc *vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	vcc->push = atm_push_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	vcc->pop = atm_pop_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	vcc->push_oam = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	vcc->send = vcc->dev->ops->send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int atm_init_aal5(struct atm_vcc *vcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	vcc->push = atm_push_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	vcc->pop = atm_pop_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	vcc->push_oam = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	vcc->send = vcc->dev->ops->send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) EXPORT_SYMBOL(atm_init_aal5);