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)  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * James Leu (jleu@mindspring.net).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2001 by various other people who didn't put their name here.
^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/init.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 <net_kern.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "daemon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct daemon_init {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	char *sock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	char *ctl_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static void daemon_init(struct net_device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	struct uml_net_private *pri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	struct daemon_data *dpri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	struct daemon_init *init = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	pri = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	dpri = (struct daemon_data *) pri->user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	dpri->sock_type = init->sock_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	dpri->ctl_sock = init->ctl_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	dpri->fd = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	dpri->control = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	dpri->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	/* We will free this pointer. If it contains crap we're burned. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	dpri->ctl_addr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	dpri->data_addr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	dpri->local_addr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	printk("daemon backend (uml_switch version %d) - %s:%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	       SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	printk("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static int daemon_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	return net_recvfrom(fd, skb_mac_header(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			    skb->dev->mtu + ETH_HEADER_OTHER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static int daemon_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return daemon_user_write(fd, skb->data, skb->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 				 (struct daemon_data *) &lp->user);
^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) static const struct net_kern_info daemon_kern_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	.init			= daemon_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	.protocol		= eth_protocol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	.read			= daemon_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	.write			= daemon_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static int daemon_setup(char *str, char **mac_out, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	struct daemon_init *init = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	char *remain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	*init = ((struct daemon_init)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		{ .sock_type 		= "unix",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		  .ctl_sock 		= "/tmp/uml.ctl" });
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 			       NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	if (remain != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 		printk(KERN_WARNING "daemon_setup : Ignoring data socket "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 		       "specification\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static struct transport daemon_transport = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	.list 		= LIST_HEAD_INIT(daemon_transport.list),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	.name 		= "daemon",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	.setup  	= daemon_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	.user 		= &daemon_user_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	.kern 		= &daemon_kern_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	.private_size 	= sizeof(struct daemon_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	.setup_size 	= sizeof(struct daemon_init),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static int register_daemon(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	register_transport(&daemon_transport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) late_initcall(register_daemon);