internal.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef __PACKET_INTERNAL_H__
  2. #define __PACKET_INTERNAL_H__
  3. struct packet_mclist {
  4. struct packet_mclist *next;
  5. int ifindex;
  6. int count;
  7. unsigned short type;
  8. unsigned short alen;
  9. unsigned char addr[MAX_ADDR_LEN];
  10. };
  11. /* kbdq - kernel block descriptor queue */
  12. struct tpacket_kbdq_core {
  13. struct pgv *pkbdq;
  14. unsigned int feature_req_word;
  15. unsigned int hdrlen;
  16. unsigned char reset_pending_on_curr_blk;
  17. unsigned char delete_blk_timer;
  18. unsigned short kactive_blk_num;
  19. unsigned short blk_sizeof_priv;
  20. /* last_kactive_blk_num:
  21. * trick to see if user-space has caught up
  22. * in order to avoid refreshing timer when every single pkt arrives.
  23. */
  24. unsigned short last_kactive_blk_num;
  25. char *pkblk_start;
  26. char *pkblk_end;
  27. int kblk_size;
  28. unsigned int knum_blocks;
  29. uint64_t knxt_seq_num;
  30. char *prev;
  31. char *nxt_offset;
  32. struct sk_buff *skb;
  33. atomic_t blk_fill_in_prog;
  34. /* Default is set to 8ms */
  35. #define DEFAULT_PRB_RETIRE_TOV (8)
  36. unsigned short retire_blk_tov;
  37. unsigned short version;
  38. unsigned long tov_in_jiffies;
  39. /* timer to retire an outstanding block */
  40. struct timer_list retire_blk_timer;
  41. };
  42. struct pgv {
  43. char *buffer;
  44. };
  45. struct packet_ring_buffer {
  46. struct pgv *pg_vec;
  47. unsigned int head;
  48. unsigned int frames_per_block;
  49. unsigned int frame_size;
  50. unsigned int frame_max;
  51. unsigned int pg_vec_order;
  52. unsigned int pg_vec_pages;
  53. unsigned int pg_vec_len;
  54. struct tpacket_kbdq_core prb_bdqc;
  55. atomic_t pending;
  56. };
  57. struct packet_fanout;
  58. struct packet_sock {
  59. /* struct sock has to be the first member of packet_sock */
  60. struct sock sk;
  61. struct packet_fanout *fanout;
  62. struct tpacket_stats stats;
  63. union tpacket_stats_u stats_u;
  64. struct packet_ring_buffer rx_ring;
  65. struct packet_ring_buffer tx_ring;
  66. int copy_thresh;
  67. spinlock_t bind_lock;
  68. struct mutex pg_vec_lock;
  69. unsigned int running:1, /* prot_hook is attached*/
  70. auxdata:1,
  71. origdev:1,
  72. has_vnet_hdr:1;
  73. int ifindex; /* bound device */
  74. __be16 num;
  75. struct packet_mclist *mclist;
  76. atomic_t mapped;
  77. enum tpacket_versions tp_version;
  78. unsigned int tp_hdrlen;
  79. unsigned int tp_reserve;
  80. unsigned int tp_loss:1;
  81. unsigned int tp_tstamp;
  82. struct packet_type prot_hook ____cacheline_aligned_in_smp;
  83. };
  84. static struct packet_sock *pkt_sk(struct sock *sk)
  85. {
  86. return (struct packet_sock *)sk;
  87. }
  88. #endif