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