rmnet_descriptor.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * RMNET Packet Descriptor Framework
  13. *
  14. */
  15. #ifndef _RMNET_DESCRIPTOR_H_
  16. #define _RMNET_DESCRIPTOR_H_
  17. #include <linux/netdevice.h>
  18. #include <linux/list.h>
  19. #include <linux/skbuff.h>
  20. #include "rmnet_config.h"
  21. #include "rmnet_map.h"
  22. struct rmnet_frag_descriptor_pool {
  23. struct list_head free_list;
  24. u32 pool_size;
  25. };
  26. struct rmnet_fragment {
  27. struct list_head list;
  28. skb_frag_t frag;
  29. };
  30. struct rmnet_frag_descriptor {
  31. struct list_head list;
  32. struct list_head frags;
  33. struct net_device *dev;
  34. u32 coal_bufsize;
  35. u32 coal_bytes;
  36. u32 len;
  37. u32 hash;
  38. u32 priority;
  39. __be32 tcp_seq;
  40. __be16 ip_id;
  41. __be16 tcp_flags;
  42. u16 data_offset;
  43. u16 gso_size;
  44. u16 gso_segs;
  45. u16 ip_len;
  46. u16 trans_len;
  47. u8 ip_proto;
  48. u8 trans_proto;
  49. u8 pkt_id;
  50. u8 csum_valid:1,
  51. hdrs_valid:1,
  52. ip_id_set:1,
  53. tcp_seq_set:1,
  54. flush_shs:1,
  55. tcp_flags_set:1,
  56. reserved:2;
  57. };
  58. /* Descriptor management */
  59. struct rmnet_frag_descriptor *
  60. rmnet_get_frag_descriptor(struct rmnet_port *port);
  61. void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc,
  62. struct rmnet_port *port);
  63. void *rmnet_frag_pull(struct rmnet_frag_descriptor *frag_desc,
  64. struct rmnet_port *port, unsigned int size);
  65. void *rmnet_frag_trim(struct rmnet_frag_descriptor *frag_desc,
  66. struct rmnet_port *port, unsigned int size);
  67. void *rmnet_frag_header_ptr(struct rmnet_frag_descriptor *frag_desc, u32 off,
  68. u32 len, void *buf);
  69. int rmnet_frag_descriptor_add_frag(struct rmnet_frag_descriptor *frag_desc,
  70. struct page *p, u32 page_offset, u32 len);
  71. int rmnet_frag_descriptor_add_frags_from(struct rmnet_frag_descriptor *to,
  72. struct rmnet_frag_descriptor *from,
  73. u32 off, u32 len);
  74. int rmnet_frag_ipv6_skip_exthdr(struct rmnet_frag_descriptor *frag_desc,
  75. int start, u8 *nexthdrp, __be16 *fragp);
  76. /* QMAP command packets */
  77. void rmnet_frag_command(struct rmnet_frag_descriptor *frag_desc,
  78. struct rmnet_map_header *qmap, struct rmnet_port *port);
  79. int rmnet_frag_flow_command(struct rmnet_frag_descriptor *frag_desc,
  80. struct rmnet_port *port, u16 pkt_len);
  81. /* Ingress data handlers */
  82. void rmnet_frag_deaggregate(struct sk_buff *skb, struct rmnet_port *port,
  83. struct list_head *list, u32 priority);
  84. void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc,
  85. struct rmnet_port *port);
  86. int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc,
  87. struct rmnet_port *port,
  88. struct list_head *list,
  89. u16 len);
  90. void rmnet_frag_ingress_handler(struct sk_buff *skb,
  91. struct rmnet_port *port);
  92. int rmnet_descriptor_init(struct rmnet_port *port);
  93. void rmnet_descriptor_deinit(struct rmnet_port *port);
  94. static inline void *rmnet_frag_data_ptr(struct rmnet_frag_descriptor *frag_desc)
  95. {
  96. struct rmnet_fragment *frag;
  97. frag = list_first_entry_or_null(&frag_desc->frags,
  98. struct rmnet_fragment, list);
  99. if (!frag)
  100. return NULL;
  101. return skb_frag_address(&frag->frag);
  102. }
  103. #endif /* _RMNET_DESCRIPTOR_H_ */