rmnet_descriptor.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (c) 2013-2020, 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 len;
  35. u32 hash;
  36. __be32 tcp_seq;
  37. __be16 ip_id;
  38. u16 data_offset;
  39. u16 gso_size;
  40. u16 gso_segs;
  41. u16 ip_len;
  42. u16 trans_len;
  43. u8 ip_proto;
  44. u8 trans_proto;
  45. u8 pkt_id;
  46. u8 csum_valid:1,
  47. hdrs_valid:1,
  48. ip_id_set:1,
  49. tcp_seq_set:1,
  50. flush_shs:1,
  51. reserved:3;
  52. };
  53. /* Descriptor management */
  54. struct rmnet_frag_descriptor *
  55. rmnet_get_frag_descriptor(struct rmnet_port *port);
  56. void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc,
  57. struct rmnet_port *port);
  58. void *rmnet_frag_pull(struct rmnet_frag_descriptor *frag_desc,
  59. struct rmnet_port *port, unsigned int size);
  60. void *rmnet_frag_trim(struct rmnet_frag_descriptor *frag_desc,
  61. struct rmnet_port *port, unsigned int size);
  62. void *rmnet_frag_header_ptr(struct rmnet_frag_descriptor *frag_desc, u32 off,
  63. u32 len, void *buf);
  64. int rmnet_frag_descriptor_add_frag(struct rmnet_frag_descriptor *frag_desc,
  65. struct page *p, u32 page_offset, u32 len);
  66. int rmnet_frag_descriptor_add_frags_from(struct rmnet_frag_descriptor *to,
  67. struct rmnet_frag_descriptor *from,
  68. u32 off, u32 len);
  69. int rmnet_frag_ipv6_skip_exthdr(struct rmnet_frag_descriptor *frag_desc,
  70. int start, u8 *nexthdrp, __be16 *fragp);
  71. /* QMAP command packets */
  72. void rmnet_frag_command(struct rmnet_frag_descriptor *frag_desc,
  73. struct rmnet_map_header *qmap, struct rmnet_port *port);
  74. int rmnet_frag_flow_command(struct rmnet_frag_descriptor *frag_desc,
  75. struct rmnet_port *port, u16 pkt_len);
  76. /* Ingress data handlers */
  77. void rmnet_frag_deaggregate(struct sk_buff *skb, struct rmnet_port *port,
  78. struct list_head *list);
  79. void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc,
  80. struct rmnet_port *port);
  81. int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc,
  82. struct rmnet_port *port,
  83. struct list_head *list,
  84. u16 len);
  85. void rmnet_frag_ingress_handler(struct sk_buff *skb,
  86. struct rmnet_port *port);
  87. int rmnet_descriptor_init(struct rmnet_port *port);
  88. void rmnet_descriptor_deinit(struct rmnet_port *port);
  89. static inline void *rmnet_frag_data_ptr(struct rmnet_frag_descriptor *frag_desc)
  90. {
  91. struct rmnet_fragment *frag;
  92. frag = list_first_entry_or_null(&frag_desc->frags,
  93. struct rmnet_fragment, list);
  94. if (!frag)
  95. return NULL;
  96. return skb_frag_address(&frag->frag);
  97. }
  98. #endif /* _RMNET_DESCRIPTOR_H_ */