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