rmnet_map.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Copyright (c) 2013-2017, 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. #include <linux/types.h>
  13. #include <linux/spinlock.h>
  14. #include <net/rmnet_config.h>
  15. #ifndef _RMNET_MAP_H_
  16. #define _RMNET_MAP_H_
  17. struct rmnet_map_control_command_s {
  18. u8 command_name;
  19. #ifndef RMNET_USE_BIG_ENDIAN_STRUCTS
  20. u8 cmd_type:2;
  21. u8 reserved:6;
  22. #else
  23. u8 reserved:6;
  24. u8 cmd_type:2;
  25. #endif /* RMNET_USE_BIG_ENDIAN_STRUCTS */
  26. u16 reserved2;
  27. u32 transaction_id;
  28. union {
  29. u8 data[65528];
  30. struct {
  31. #ifndef RMNET_USE_BIG_ENDIAN_STRUCTS
  32. u16 ip_family:2;
  33. u16 reserved:14;
  34. #else
  35. u16 reserved:14;
  36. u16 ip_family:2;
  37. #endif /* RMNET_USE_BIG_ENDIAN_STRUCTS */
  38. u16 flow_control_seq_num;
  39. u32 qos_id;
  40. } flow_control;
  41. };
  42. } __aligned(1);
  43. struct rmnet_map_dl_checksum_trailer_s {
  44. unsigned char reserved_h;
  45. #if defined(__LITTLE_ENDIAN_BITFIELD)
  46. unsigned char valid:1;
  47. unsigned char reserved_l:7;
  48. #elif defined(__BIG_ENDIAN_BITFIELD)
  49. unsigned char reserved_l:7;
  50. unsigned char valid:1;
  51. #else
  52. #error "Please fix <asm/byteorder.h>"
  53. #endif
  54. unsigned short checksum_start_offset;
  55. unsigned short checksum_length;
  56. unsigned short checksum_value;
  57. } __aligned(1);
  58. struct rmnet_map_ul_checksum_header_s {
  59. unsigned short checksum_start_offset;
  60. #if defined(__LITTLE_ENDIAN_BITFIELD)
  61. unsigned short checksum_insert_offset:14;
  62. unsigned short udp_ip4_ind:1;
  63. unsigned short cks_en:1;
  64. #elif defined(__BIG_ENDIAN_BITFIELD)
  65. unsigned short cks_en:1;
  66. unsigned short udp_ip4_ind:1;
  67. unsigned short checksum_insert_offset:14;
  68. #else
  69. #error "Please fix <asm/byteorder.h>"
  70. #endif
  71. } __aligned(1);
  72. enum rmnet_map_results_e {
  73. RMNET_MAP_SUCCESS,
  74. RMNET_MAP_CONSUMED,
  75. RMNET_MAP_GENERAL_FAILURE,
  76. RMNET_MAP_NOT_ENABLED,
  77. RMNET_MAP_FAILED_AGGREGATION,
  78. RMNET_MAP_FAILED_MUX
  79. };
  80. enum rmnet_map_mux_errors_e {
  81. RMNET_MAP_MUX_SUCCESS,
  82. RMNET_MAP_MUX_INVALID_MUX_ID,
  83. RMNET_MAP_MUX_INVALID_PAD_LENGTH,
  84. RMNET_MAP_MUX_INVALID_PKT_LENGTH,
  85. /* This should always be the last element */
  86. RMNET_MAP_MUX_ENUM_LENGTH
  87. };
  88. enum rmnet_map_checksum_errors_e {
  89. RMNET_MAP_CHECKSUM_OK,
  90. RMNET_MAP_CHECKSUM_VALID_FLAG_NOT_SET,
  91. RMNET_MAP_CHECKSUM_VALIDATION_FAILED,
  92. RMNET_MAP_CHECKSUM_ERR_UNKNOWN,
  93. RMNET_MAP_CHECKSUM_ERR_NOT_DATA_PACKET,
  94. RMNET_MAP_CHECKSUM_ERR_BAD_BUFFER,
  95. RMNET_MAP_CHECKSUM_ERR_UNKNOWN_IP_VERSION,
  96. RMNET_MAP_CHECKSUM_ERR_UNKNOWN_TRANSPORT,
  97. RMNET_MAP_CHECKSUM_FRAGMENTED_PACKET,
  98. RMNET_MAP_CHECKSUM_SKIPPED,
  99. RMNET_MAP_CHECKSUM_SW,
  100. /* This should always be the last element */
  101. RMNET_MAP_CHECKSUM_ENUM_LENGTH
  102. };
  103. enum rmnet_map_commands_e {
  104. RMNET_MAP_COMMAND_NONE,
  105. RMNET_MAP_COMMAND_FLOW_DISABLE,
  106. RMNET_MAP_COMMAND_FLOW_ENABLE,
  107. /* These should always be the last 2 elements */
  108. RMNET_MAP_COMMAND_UNKNOWN,
  109. RMNET_MAP_COMMAND_ENUM_LENGTH
  110. };
  111. enum rmnet_map_agg_state_e {
  112. RMNET_MAP_AGG_IDLE,
  113. RMNET_MAP_TXFER_SCHEDULED
  114. };
  115. #define RMNET_MAP_COMMAND_REQUEST 0
  116. #define RMNET_MAP_COMMAND_ACK 1
  117. #define RMNET_MAP_COMMAND_UNSUPPORTED 2
  118. #define RMNET_MAP_COMMAND_INVALID 3
  119. #define RMNET_MAP_NO_PAD_BYTES 0
  120. #define RMNET_MAP_ADD_PAD_BYTES 1
  121. uint8_t rmnet_map_demultiplex(struct sk_buff *skb);
  122. struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
  123. struct rmnet_phys_ep_config *config);
  124. struct rmnet_map_header_s *rmnet_map_add_map_header(struct sk_buff *skb,
  125. int hdrlen, int pad);
  126. rx_handler_result_t rmnet_map_command(struct sk_buff *skb,
  127. struct rmnet_phys_ep_config *config);
  128. void rmnet_map_aggregate(struct sk_buff *skb,
  129. struct rmnet_phys_ep_config *config);
  130. int rmnet_map_checksum_downlink_packet(struct sk_buff *skb);
  131. int rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
  132. struct net_device *orig_dev,
  133. u32 egress_data_format);
  134. int rmnet_ul_aggregation_skip(struct sk_buff *skb, int offset);
  135. enum hrtimer_restart rmnet_map_flush_packet_queue(struct hrtimer *t);
  136. #endif /* _RMNET_MAP_H_ */