rmnet_map.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright (c) 2013-2018, 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. #ifndef _RMNET_MAP_H_
  13. #define _RMNET_MAP_H_
  14. struct rmnet_map_control_command {
  15. u8 command_name;
  16. u8 cmd_type:2;
  17. u8 reserved:6;
  18. u16 reserved2;
  19. u32 transaction_id;
  20. union {
  21. struct {
  22. u16 ip_family:2;
  23. u16 reserved:14;
  24. __be16 flow_control_seq_num;
  25. __be32 qos_id;
  26. } flow_control;
  27. u8 data[0];
  28. };
  29. } __aligned(1);
  30. enum rmnet_map_commands {
  31. RMNET_MAP_COMMAND_NONE,
  32. RMNET_MAP_COMMAND_FLOW_DISABLE,
  33. RMNET_MAP_COMMAND_FLOW_ENABLE,
  34. /* These should always be the last 2 elements */
  35. RMNET_MAP_COMMAND_UNKNOWN,
  36. RMNET_MAP_COMMAND_ENUM_LENGTH
  37. };
  38. struct rmnet_map_header {
  39. u8 pad_len:6;
  40. u8 reserved_bit:1;
  41. u8 cd_bit:1;
  42. u8 mux_id;
  43. __be16 pkt_len;
  44. } __aligned(1);
  45. struct rmnet_map_dl_csum_trailer {
  46. u8 reserved1;
  47. u8 valid:1;
  48. u8 reserved2:7;
  49. u16 csum_start_offset;
  50. u16 csum_length;
  51. __be16 csum_value;
  52. } __aligned(1);
  53. struct rmnet_map_ul_csum_header {
  54. __be16 csum_start_offset;
  55. u16 csum_insert_offset:14;
  56. u16 udp_ip4_ind:1;
  57. u16 csum_enabled:1;
  58. } __aligned(1);
  59. #define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \
  60. (Y)->data)->mux_id)
  61. #define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \
  62. (Y)->data)->cd_bit)
  63. #define RMNET_MAP_GET_PAD(Y) (((struct rmnet_map_header *) \
  64. (Y)->data)->pad_len)
  65. #define RMNET_MAP_GET_CMD_START(Y) ((struct rmnet_map_control_command *) \
  66. ((Y)->data + \
  67. sizeof(struct rmnet_map_header)))
  68. #define RMNET_MAP_GET_LENGTH(Y) (ntohs(((struct rmnet_map_header *) \
  69. (Y)->data)->pkt_len))
  70. #define RMNET_MAP_COMMAND_REQUEST 0
  71. #define RMNET_MAP_COMMAND_ACK 1
  72. #define RMNET_MAP_COMMAND_UNSUPPORTED 2
  73. #define RMNET_MAP_COMMAND_INVALID 3
  74. #define RMNET_MAP_NO_PAD_BYTES 0
  75. #define RMNET_MAP_ADD_PAD_BYTES 1
  76. struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
  77. struct rmnet_port *port);
  78. struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
  79. int hdrlen, int pad);
  80. void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port);
  81. int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len);
  82. void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
  83. struct net_device *orig_dev);
  84. #endif /* _RMNET_MAP_H_ */