xref: /openbmc/linux/arch/um/include/shared/net_kern.h (revision 8365a898)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4  */
5 
6 #ifndef __UM_NET_KERN_H
7 #define __UM_NET_KERN_H
8 
9 #include <linux/netdevice.h>
10 #include <linux/platform_device.h>
11 #include <linux/skbuff.h>
12 #include <linux/socket.h>
13 #include <linux/list.h>
14 #include <linux/workqueue.h>
15 
16 struct uml_net {
17 	struct list_head list;
18 	struct net_device *dev;
19 	struct platform_device pdev;
20 	int index;
21 };
22 
23 struct uml_net_private {
24 	struct list_head list;
25 	spinlock_t lock;
26 	struct net_device *dev;
27 	struct timer_list tl;
28 
29 	struct work_struct work;
30 	int fd;
31 	unsigned char mac[ETH_ALEN];
32 	int max_packet;
33 	unsigned short (*protocol)(struct sk_buff *);
34 	int (*open)(void *);
35 	void (*close)(int, void *);
36 	void (*remove)(void *);
37 	int (*read)(int, struct sk_buff *skb, struct uml_net_private *);
38 	int (*write)(int, struct sk_buff *skb, struct uml_net_private *);
39 
40 	void (*add_address)(unsigned char *, unsigned char *, void *);
41 	void (*delete_address)(unsigned char *, unsigned char *, void *);
42 	char user[0];
43 };
44 
45 struct net_kern_info {
46 	void (*init)(struct net_device *, void *);
47 	unsigned short (*protocol)(struct sk_buff *);
48 	int (*read)(int, struct sk_buff *skb, struct uml_net_private *);
49 	int (*write)(int, struct sk_buff *skb, struct uml_net_private *);
50 };
51 
52 struct transport {
53 	struct list_head list;
54 	const char *name;
55 	int (* const setup)(char *, char **, void *);
56 	const struct net_user_info *user;
57 	const struct net_kern_info *kern;
58 	const int private_size;
59 	const int setup_size;
60 };
61 
62 extern struct net_device *ether_init(int);
63 extern unsigned short ether_protocol(struct sk_buff *);
64 extern int tap_setup_common(char *str, char *type, char **dev_name,
65 			    char **mac_out, char **gate_addr);
66 extern void register_transport(struct transport *new);
67 extern unsigned short eth_protocol(struct sk_buff *skb);
68 extern void uml_net_setup_etheraddr(struct net_device *dev, char *str);
69 
70 
71 #endif
72