vector_kern.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  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 ETH_MAX_PACKET 1500
  27. #define ETH_HEADER_OTHER 32 /* just in case someone decides to go mad on QnQ */
  28. struct vector_queue {
  29. struct mmsghdr *mmsg_vector;
  30. void **skbuff_vector;
  31. /* backlink to device which owns us */
  32. struct net_device *dev;
  33. spinlock_t head_lock;
  34. spinlock_t tail_lock;
  35. int queue_depth, head, tail, max_depth, max_iov_frags;
  36. short options;
  37. };
  38. struct vector_estats {
  39. uint64_t rx_queue_max;
  40. uint64_t rx_queue_running_average;
  41. uint64_t tx_queue_max;
  42. uint64_t tx_queue_running_average;
  43. uint64_t rx_encaps_errors;
  44. uint64_t tx_timeout_count;
  45. uint64_t tx_restart_queue;
  46. uint64_t tx_kicks;
  47. uint64_t tx_flow_control_xon;
  48. uint64_t tx_flow_control_xoff;
  49. uint64_t rx_csum_offload_good;
  50. uint64_t rx_csum_offload_errors;
  51. uint64_t sg_ok;
  52. uint64_t sg_linearized;
  53. };
  54. #define VERIFY_HEADER_NOK -1
  55. #define VERIFY_HEADER_OK 0
  56. #define VERIFY_CSUM_OK 1
  57. struct vector_private {
  58. struct list_head list;
  59. spinlock_t lock;
  60. struct net_device *dev;
  61. int unit;
  62. /* Timeout timer in TX */
  63. struct timer_list tl;
  64. /* Scheduled "remove device" work */
  65. struct work_struct reset_tx;
  66. struct vector_fds *fds;
  67. struct vector_queue *rx_queue;
  68. struct vector_queue *tx_queue;
  69. int rx_irq;
  70. int tx_irq;
  71. struct arglist *parsed;
  72. void *transport_data; /* transport specific params if needed */
  73. int max_packet;
  74. int req_size; /* different from max packet - used for TSO */
  75. int headroom;
  76. int options;
  77. /* remote address if any - some transports will leave this as null */
  78. int header_size;
  79. int rx_header_size;
  80. int coalesce;
  81. void *header_rxbuffer;
  82. void *header_txbuffer;
  83. int (*form_header)(uint8_t *header,
  84. struct sk_buff *skb, struct vector_private *vp);
  85. int (*verify_header)(uint8_t *header,
  86. struct sk_buff *skb, struct vector_private *vp);
  87. spinlock_t stats_lock;
  88. struct tasklet_struct tx_poll;
  89. bool rexmit_scheduled;
  90. bool opened;
  91. bool in_write_poll;
  92. /* ethtool stats */
  93. struct vector_estats estats;
  94. void *bpf;
  95. char user[0];
  96. };
  97. extern int build_transport_data(struct vector_private *vp);
  98. #endif