xref: /openbmc/linux/arch/um/drivers/vector_kern.h (revision 96ac6d43)
1 /*
2  * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5 
6 #ifndef __UM_VECTOR_KERN_H
7 #define __UM_VECTOR_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/ctype.h>
15 #include <linux/workqueue.h>
16 #include <linux/interrupt.h>
17 #include "vector_user.h"
18 
19 /* Queue structure specially adapted for multiple enqueue/dequeue
20  * in a mmsgrecv/mmsgsend context
21  */
22 
23 /* Dequeue method */
24 
25 #define QUEUE_SENDMSG 0
26 #define QUEUE_SENDMMSG 1
27 
28 #define VECTOR_RX 1
29 #define VECTOR_TX (1 << 1)
30 #define VECTOR_BPF (1 << 2)
31 #define VECTOR_QDISC_BYPASS (1 << 3)
32 
33 #define ETH_MAX_PACKET 1500
34 #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */
35 
36 struct vector_queue {
37 	struct mmsghdr *mmsg_vector;
38 	void **skbuff_vector;
39 	 /* backlink to device which owns us */
40 	struct net_device *dev;
41 	spinlock_t head_lock;
42 	spinlock_t tail_lock;
43 	int queue_depth, head, tail, max_depth, max_iov_frags;
44 	short options;
45 };
46 
47 struct vector_estats {
48 	uint64_t rx_queue_max;
49 	uint64_t rx_queue_running_average;
50 	uint64_t tx_queue_max;
51 	uint64_t tx_queue_running_average;
52 	uint64_t rx_encaps_errors;
53 	uint64_t tx_timeout_count;
54 	uint64_t tx_restart_queue;
55 	uint64_t tx_kicks;
56 	uint64_t tx_flow_control_xon;
57 	uint64_t tx_flow_control_xoff;
58 	uint64_t rx_csum_offload_good;
59 	uint64_t rx_csum_offload_errors;
60 	uint64_t sg_ok;
61 	uint64_t sg_linearized;
62 };
63 
64 #define VERIFY_HEADER_NOK -1
65 #define VERIFY_HEADER_OK 0
66 #define VERIFY_CSUM_OK 1
67 
68 struct vector_private {
69 	struct list_head list;
70 	spinlock_t lock;
71 	struct net_device *dev;
72 
73 	int unit;
74 
75 	/* Timeout timer in TX */
76 
77 	struct timer_list tl;
78 
79 	/* Scheduled "remove device" work */
80 	struct work_struct reset_tx;
81 	struct vector_fds *fds;
82 
83 	struct vector_queue *rx_queue;
84 	struct vector_queue *tx_queue;
85 
86 	int rx_irq;
87 	int tx_irq;
88 
89 	struct arglist *parsed;
90 
91 	void *transport_data; /* transport specific params if needed */
92 
93 	int max_packet;
94 	int req_size; /* different from max packet - used for TSO */
95 	int headroom;
96 
97 	int options;
98 
99 	/* remote address if any - some transports will leave this as null */
100 
101 	int header_size;
102 	int rx_header_size;
103 	int coalesce;
104 
105 	void *header_rxbuffer;
106 	void *header_txbuffer;
107 
108 	int (*form_header)(uint8_t *header,
109 		struct sk_buff *skb, struct vector_private *vp);
110 	int (*verify_header)(uint8_t *header,
111 		struct sk_buff *skb, struct vector_private *vp);
112 
113 	spinlock_t stats_lock;
114 
115 	struct tasklet_struct tx_poll;
116 	bool rexmit_scheduled;
117 	bool opened;
118 	bool in_write_poll;
119 
120 	/* ethtool stats */
121 
122 	struct vector_estats estats;
123 	void *bpf;
124 
125 	char user[0];
126 };
127 
128 extern int build_transport_data(struct vector_private *vp);
129 
130 #endif
131