blob: 699696deb3968d9a499f45c7277178031fb17a5d [file] [log] [blame]
Anton Ivanov49da7e62017-11-20 21:17:59 +00001/*
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
32#define ETH_MAX_PACKET 1500
33#define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */
34
35struct vector_queue {
36 struct mmsghdr *mmsg_vector;
37 void **skbuff_vector;
38 /* backlink to device which owns us */
39 struct net_device *dev;
40 spinlock_t head_lock;
41 spinlock_t tail_lock;
42 int queue_depth, head, tail, max_depth, max_iov_frags;
43 short options;
44};
45
46struct vector_estats {
47 uint64_t rx_queue_max;
48 uint64_t rx_queue_running_average;
49 uint64_t tx_queue_max;
50 uint64_t tx_queue_running_average;
51 uint64_t rx_encaps_errors;
52 uint64_t tx_timeout_count;
53 uint64_t tx_restart_queue;
54 uint64_t tx_kicks;
55 uint64_t tx_flow_control_xon;
56 uint64_t tx_flow_control_xoff;
57 uint64_t rx_csum_offload_good;
58 uint64_t rx_csum_offload_errors;
59 uint64_t sg_ok;
60 uint64_t sg_linearized;
61};
62
63#define VERIFY_HEADER_NOK -1
64#define VERIFY_HEADER_OK 0
65#define VERIFY_CSUM_OK 1
66
67struct vector_private {
68 struct list_head list;
69 spinlock_t lock;
70 struct net_device *dev;
71
72 int unit;
73
74 /* Timeout timer in TX */
75
76 struct timer_list tl;
77
78 /* Scheduled "remove device" work */
79 struct work_struct reset_tx;
80 struct vector_fds *fds;
81
82 struct vector_queue *rx_queue;
83 struct vector_queue *tx_queue;
84
85 int rx_irq;
86 int tx_irq;
87
88 struct arglist *parsed;
89
90 void *transport_data; /* transport specific params if needed */
91
92 int max_packet;
93 int req_size; /* different from max packet - used for TSO */
94 int headroom;
95
96 int options;
97
98 /* remote address if any - some transports will leave this as null */
99
100 int header_size;
101 int rx_header_size;
102 int coalesce;
103
104 void *header_rxbuffer;
105 void *header_txbuffer;
106
107 int (*form_header)(uint8_t *header,
108 struct sk_buff *skb, struct vector_private *vp);
109 int (*verify_header)(uint8_t *header,
110 struct sk_buff *skb, struct vector_private *vp);
111
112 spinlock_t stats_lock;
113
114 struct tasklet_struct tx_poll;
115 bool rexmit_scheduled;
116 bool opened;
117 bool in_write_poll;
118
119 /* ethtool stats */
120
121 struct vector_estats estats;
122 void *bpf;
123
124 char user[0];
125};
126
127extern int build_transport_data(struct vector_private *vp);
128
129#endif