1dbddf429SAlex Dewar /* SPDX-License-Identifier: GPL-2.0 */ 249da7e64SAnton Ivanov /* 349da7e64SAnton Ivanov * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 449da7e64SAnton Ivanov */ 549da7e64SAnton Ivanov 649da7e64SAnton Ivanov #ifndef __UM_VECTOR_KERN_H 749da7e64SAnton Ivanov #define __UM_VECTOR_KERN_H 849da7e64SAnton Ivanov 949da7e64SAnton Ivanov #include <linux/netdevice.h> 1049da7e64SAnton Ivanov #include <linux/platform_device.h> 1149da7e64SAnton Ivanov #include <linux/skbuff.h> 1249da7e64SAnton Ivanov #include <linux/socket.h> 1349da7e64SAnton Ivanov #include <linux/list.h> 1449da7e64SAnton Ivanov #include <linux/ctype.h> 1549da7e64SAnton Ivanov #include <linux/workqueue.h> 1649da7e64SAnton Ivanov #include <linux/interrupt.h> 17*b35507a4SAnton Ivanov 1849da7e64SAnton Ivanov #include "vector_user.h" 1949da7e64SAnton Ivanov 2049da7e64SAnton Ivanov /* Queue structure specially adapted for multiple enqueue/dequeue 2149da7e64SAnton Ivanov * in a mmsgrecv/mmsgsend context 2249da7e64SAnton Ivanov */ 2349da7e64SAnton Ivanov 2449da7e64SAnton Ivanov /* Dequeue method */ 2549da7e64SAnton Ivanov 2649da7e64SAnton Ivanov #define QUEUE_SENDMSG 0 2749da7e64SAnton Ivanov #define QUEUE_SENDMMSG 1 2849da7e64SAnton Ivanov 2949da7e64SAnton Ivanov #define VECTOR_RX 1 3049da7e64SAnton Ivanov #define VECTOR_TX (1 << 1) 3149da7e64SAnton Ivanov #define VECTOR_BPF (1 << 2) 32e40238deSAnton Ivanov #define VECTOR_QDISC_BYPASS (1 << 3) 339807019aSAnton Ivanov #define VECTOR_BPF_FLASH (1 << 4) 3449da7e64SAnton Ivanov 3549da7e64SAnton Ivanov #define ETH_MAX_PACKET 1500 3649da7e64SAnton Ivanov #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */ 3749da7e64SAnton Ivanov 389807019aSAnton Ivanov #define MAX_FILTER_PROG (2 << 16) 399807019aSAnton Ivanov 4049da7e64SAnton Ivanov struct vector_queue { 4149da7e64SAnton Ivanov struct mmsghdr *mmsg_vector; 4249da7e64SAnton Ivanov void **skbuff_vector; 4349da7e64SAnton Ivanov /* backlink to device which owns us */ 4449da7e64SAnton Ivanov struct net_device *dev; 4549da7e64SAnton Ivanov spinlock_t head_lock; 4649da7e64SAnton Ivanov spinlock_t tail_lock; 4749da7e64SAnton Ivanov int queue_depth, head, tail, max_depth, max_iov_frags; 4849da7e64SAnton Ivanov short options; 4949da7e64SAnton Ivanov }; 5049da7e64SAnton Ivanov 5149da7e64SAnton Ivanov struct vector_estats { 5249da7e64SAnton Ivanov uint64_t rx_queue_max; 5349da7e64SAnton Ivanov uint64_t rx_queue_running_average; 5449da7e64SAnton Ivanov uint64_t tx_queue_max; 5549da7e64SAnton Ivanov uint64_t tx_queue_running_average; 5649da7e64SAnton Ivanov uint64_t rx_encaps_errors; 5749da7e64SAnton Ivanov uint64_t tx_timeout_count; 5849da7e64SAnton Ivanov uint64_t tx_restart_queue; 5949da7e64SAnton Ivanov uint64_t tx_kicks; 6049da7e64SAnton Ivanov uint64_t tx_flow_control_xon; 6149da7e64SAnton Ivanov uint64_t tx_flow_control_xoff; 6249da7e64SAnton Ivanov uint64_t rx_csum_offload_good; 6349da7e64SAnton Ivanov uint64_t rx_csum_offload_errors; 6449da7e64SAnton Ivanov uint64_t sg_ok; 6549da7e64SAnton Ivanov uint64_t sg_linearized; 6649da7e64SAnton Ivanov }; 6749da7e64SAnton Ivanov 6849da7e64SAnton Ivanov #define VERIFY_HEADER_NOK -1 6949da7e64SAnton Ivanov #define VERIFY_HEADER_OK 0 7049da7e64SAnton Ivanov #define VERIFY_CSUM_OK 1 7149da7e64SAnton Ivanov 7249da7e64SAnton Ivanov struct vector_private { 7349da7e64SAnton Ivanov struct list_head list; 7449da7e64SAnton Ivanov spinlock_t lock; 7549da7e64SAnton Ivanov struct net_device *dev; 76*b35507a4SAnton Ivanov struct napi_struct napi ____cacheline_aligned; 7749da7e64SAnton Ivanov 7849da7e64SAnton Ivanov int unit; 7949da7e64SAnton Ivanov 8049da7e64SAnton Ivanov /* Timeout timer in TX */ 8149da7e64SAnton Ivanov 8249da7e64SAnton Ivanov struct timer_list tl; 8349da7e64SAnton Ivanov 8449da7e64SAnton Ivanov /* Scheduled "remove device" work */ 8549da7e64SAnton Ivanov struct work_struct reset_tx; 8649da7e64SAnton Ivanov struct vector_fds *fds; 8749da7e64SAnton Ivanov 8849da7e64SAnton Ivanov struct vector_queue *rx_queue; 8949da7e64SAnton Ivanov struct vector_queue *tx_queue; 9049da7e64SAnton Ivanov 9149da7e64SAnton Ivanov int rx_irq; 9249da7e64SAnton Ivanov int tx_irq; 9349da7e64SAnton Ivanov 9449da7e64SAnton Ivanov struct arglist *parsed; 9549da7e64SAnton Ivanov 9649da7e64SAnton Ivanov void *transport_data; /* transport specific params if needed */ 9749da7e64SAnton Ivanov 9849da7e64SAnton Ivanov int max_packet; 9949da7e64SAnton Ivanov int req_size; /* different from max packet - used for TSO */ 10049da7e64SAnton Ivanov int headroom; 10149da7e64SAnton Ivanov 10249da7e64SAnton Ivanov int options; 10349da7e64SAnton Ivanov 10449da7e64SAnton Ivanov /* remote address if any - some transports will leave this as null */ 10549da7e64SAnton Ivanov 10649da7e64SAnton Ivanov int header_size; 10749da7e64SAnton Ivanov int rx_header_size; 10849da7e64SAnton Ivanov int coalesce; 10949da7e64SAnton Ivanov 11049da7e64SAnton Ivanov void *header_rxbuffer; 11149da7e64SAnton Ivanov void *header_txbuffer; 11249da7e64SAnton Ivanov 11349da7e64SAnton Ivanov int (*form_header)(uint8_t *header, 11449da7e64SAnton Ivanov struct sk_buff *skb, struct vector_private *vp); 11549da7e64SAnton Ivanov int (*verify_header)(uint8_t *header, 11649da7e64SAnton Ivanov struct sk_buff *skb, struct vector_private *vp); 11749da7e64SAnton Ivanov 11849da7e64SAnton Ivanov spinlock_t stats_lock; 11949da7e64SAnton Ivanov 12049da7e64SAnton Ivanov bool rexmit_scheduled; 12149da7e64SAnton Ivanov bool opened; 12249da7e64SAnton Ivanov bool in_write_poll; 123d47761dbSAnton Ivanov bool in_error; 12449da7e64SAnton Ivanov 1259807019aSAnton Ivanov /* guest allowed to use ethtool flash to load bpf */ 1269807019aSAnton Ivanov bool bpf_via_flash; 1279807019aSAnton Ivanov 12849da7e64SAnton Ivanov /* ethtool stats */ 12949da7e64SAnton Ivanov 13049da7e64SAnton Ivanov struct vector_estats estats; 1319807019aSAnton Ivanov struct sock_fprog *bpf; 13249da7e64SAnton Ivanov 133f6e8c474SGustavo A. R. Silva char user[]; 13449da7e64SAnton Ivanov }; 13549da7e64SAnton Ivanov 13649da7e64SAnton Ivanov extern int build_transport_data(struct vector_private *vp); 13749da7e64SAnton Ivanov 13849da7e64SAnton Ivanov #endif 139