vector_kern.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. */
  5. #ifndef __UM_VECTOR_KERN_H
  6. #define __UM_VECTOR_KERN_H
  7. #include <linux/netdevice.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/skbuff.h>
  10. #include <linux/socket.h>
  11. #include <linux/list.h>
  12. #include <linux/ctype.h>
  13. #include <linux/workqueue.h>
  14. #include <linux/interrupt.h>
  15. #include <asm/atomic.h>
  16. #include "vector_user.h"
  17. /* Queue structure specially adapted for multiple enqueue/dequeue
  18. * in a mmsgrecv/mmsgsend context
  19. */
  20. /* Dequeue method */
  21. #define QUEUE_SENDMSG 0
  22. #define QUEUE_SENDMMSG 1
  23. #define VECTOR_RX 1
  24. #define VECTOR_TX (1 << 1)
  25. #define VECTOR_BPF (1 << 2)
  26. #define VECTOR_QDISC_BYPASS (1 << 3)
  27. #define VECTOR_BPF_FLASH (1 << 4)
  28. #define ETH_MAX_PACKET 1500
  29. #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */
  30. #define MAX_FILTER_PROG (2 << 16)
  31. struct vector_queue {
  32. struct mmsghdr *mmsg_vector;
  33. void **skbuff_vector;
  34. /* backlink to device which owns us */
  35. struct net_device *dev;
  36. spinlock_t head_lock;
  37. spinlock_t tail_lock;
  38. atomic_t queue_depth;
  39. int head, tail, max_depth, max_iov_frags;
  40. short options;
  41. };
  42. struct vector_estats {
  43. uint64_t rx_queue_max;
  44. uint64_t rx_queue_running_average;
  45. uint64_t tx_queue_max;
  46. uint64_t tx_queue_running_average;
  47. uint64_t rx_encaps_errors;
  48. uint64_t tx_timeout_count;
  49. uint64_t tx_restart_queue;
  50. uint64_t tx_kicks;
  51. uint64_t tx_flow_control_xon;
  52. uint64_t tx_flow_control_xoff;
  53. uint64_t rx_csum_offload_good;
  54. uint64_t rx_csum_offload_errors;
  55. uint64_t sg_ok;
  56. uint64_t sg_linearized;
  57. };
  58. #define VERIFY_HEADER_NOK -1
  59. #define VERIFY_HEADER_OK 0
  60. #define VERIFY_CSUM_OK 1
  61. struct vector_private {
  62. struct list_head list;
  63. struct net_device *dev;
  64. struct napi_struct napi ____cacheline_aligned;
  65. int unit;
  66. /* Timeout timer in TX */
  67. struct timer_list tl;
  68. /* Scheduled "remove device" work */
  69. struct work_struct reset_tx;
  70. struct vector_fds *fds;
  71. struct vector_queue *rx_queue;
  72. struct vector_queue *tx_queue;
  73. int rx_irq;
  74. int tx_irq;
  75. struct arglist *parsed;
  76. void *transport_data; /* transport specific params if needed */
  77. int max_packet;
  78. int req_size; /* different from max packet - used for TSO */
  79. int headroom;
  80. int options;
  81. /* remote address if any - some transports will leave this as null */
  82. int header_size;
  83. int rx_header_size;
  84. int coalesce;
  85. void *header_rxbuffer;
  86. void *header_txbuffer;
  87. int (*form_header)(uint8_t *header,
  88. struct sk_buff *skb, struct vector_private *vp);
  89. int (*verify_header)(uint8_t *header,
  90. struct sk_buff *skb, struct vector_private *vp);
  91. spinlock_t stats_lock;
  92. bool rexmit_scheduled;
  93. bool opened;
  94. bool in_write_poll;
  95. bool in_error;
  96. /* guest allowed to use ethtool flash to load bpf */
  97. bool bpf_via_flash;
  98. /* ethtool stats */
  99. struct vector_estats estats;
  100. struct sock_fprog *bpf;
  101. char user[];
  102. };
  103. extern int build_transport_data(struct vector_private *vp);
  104. #endif