vector_kern.h 2.9 KB

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