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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * generic net pointers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #ifndef __NET_GENERIC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define __NET_GENERIC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * Generic net pointers are to be used by modules to put some private
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * stuff on the struct net without explicit struct net modification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * The rules are simple:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * 1. set pernet_operations->id.  After register_pernet_device you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  *    will have the id of your private pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * 2. set pernet_operations->size to have the code allocate and free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *    a private structure pointed to from struct net.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * 3. do not change this pointer while the net is alive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * 4. do not try to have any private reference on the net_generic object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * After accomplishing all of the above, the private pointer can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * accessed with the net_generic() call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct net_generic {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 			unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 			struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		} s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		void *ptr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static inline void *net_generic(const struct net *net, unsigned int id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	struct net_generic *ng;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	void *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	ng = rcu_dereference(net->gen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	ptr = ng->ptr[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	return ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif