rmnet_descriptor.h 3.5 KB

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