rmnet_data_config.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* Copyright (c) 2013-2014, 2016-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. * RMNET Data configuration engine
  13. */
  14. #include <linux/types.h>
  15. #include <linux/time.h>
  16. #include <linux/spinlock.h>
  17. #include <net/rmnet_config.h>
  18. #include <linux/hrtimer.h>
  19. #ifndef _RMNET_DATA_CONFIG_H_
  20. #define _RMNET_DATA_CONFIG_H_
  21. #define RMNET_DATA_MAX_LOGICAL_EP 256
  22. /**
  23. * struct rmnet_logical_ep_conf_s - Logical end-point configuration
  24. *
  25. * @refcount: Reference count for this endpoint. 0 signifies the endpoint is not
  26. * configured for use
  27. * @rmnet_mode: Specifies how the traffic should be finally delivered. Possible
  28. * options are available in enum rmnet_config_endpoint_modes_e
  29. * @mux_id: Virtual channel ID used by MAP protocol
  30. * @egress_dev: Next device to deliver the packet to. Exact usage of this
  31. * parmeter depends on the rmnet_mode
  32. */
  33. struct rmnet_logical_ep_conf_s {
  34. struct net_device *egress_dev;
  35. struct timespec last_flush_time;
  36. long curr_time_limit;
  37. unsigned int flush_byte_count;
  38. unsigned int curr_byte_threshold;
  39. u8 refcount;
  40. u8 rmnet_mode;
  41. u8 mux_id;
  42. };
  43. /**
  44. * struct rmnet_phys_ep_conf_s - Physical endpoint configuration
  45. * One instance of this structure is instantiated for each net_device associated
  46. * with rmnet_data.
  47. *
  48. * @dev: The device which is associated with rmnet_data. Corresponds to this
  49. * specific instance of rmnet_phys_ep_conf_s
  50. * @local_ep: Default non-muxed endpoint. Used for non-MAP protocols/formats
  51. * @muxed_ep: All multiplexed logical endpoints associated with this device
  52. * @ingress_data_format: RMNET_INGRESS_FORMAT_* flags from rmnet_data.h
  53. * @egress_data_format: RMNET_EGRESS_FORMAT_* flags from rmnet_data.h
  54. *
  55. * @egress_agg_size: Maximum size (bytes) of data which should be aggregated
  56. * @egress_agg_count: Maximum count (packets) of data which should be aggregated
  57. * Smaller of the two parameters above are chosen for
  58. * aggregation
  59. * @tail_spacing: Guaranteed padding (bytes) when de-aggregating ingress frames
  60. * @agg_time: Wall clock time when aggregated frame was created
  61. * @agg_last: Last time the aggregation routing was invoked
  62. */
  63. struct rmnet_phys_ep_config {
  64. struct net_device *dev;
  65. struct rmnet_logical_ep_conf_s local_ep;
  66. struct rmnet_logical_ep_conf_s muxed_ep[RMNET_DATA_MAX_LOGICAL_EP];
  67. u32 ingress_data_format;
  68. u32 egress_data_format;
  69. /* MAP specific */
  70. u16 egress_agg_size;
  71. u16 egress_agg_count;
  72. u8 tail_spacing;
  73. /* MAP aggregation state machine
  74. * - This is not sctrictly configuration and is updated at runtime
  75. * Make sure all of these are protected by the agg_lock
  76. */
  77. spinlock_t agg_lock;
  78. struct sk_buff *agg_skb;
  79. u8 agg_state;
  80. u8 agg_count;
  81. struct timespec agg_time;
  82. struct timespec agg_last;
  83. struct hrtimer hrtimer;
  84. };
  85. int rmnet_config_init(void);
  86. void rmnet_config_exit(void);
  87. int rmnet_unassociate_network_device(struct net_device *dev);
  88. int rmnet_set_ingress_data_format(struct net_device *dev,
  89. u32 ingress_data_format,
  90. u8 tail_spacing);
  91. int rmnet_set_egress_data_format(struct net_device *dev,
  92. u32 egress_data_format,
  93. u16 agg_size,
  94. u16 agg_count);
  95. int rmnet_associate_network_device(struct net_device *dev);
  96. int _rmnet_set_logical_endpoint_config
  97. (struct net_device *dev, int config_id,
  98. struct rmnet_logical_ep_conf_s *epconfig);
  99. int rmnet_set_logical_endpoint_config(struct net_device *dev,
  100. int config_id,
  101. u8 rmnet_mode,
  102. struct net_device *egress_dev);
  103. int _rmnet_unset_logical_endpoint_config(struct net_device *dev,
  104. int config_id);
  105. int rmnet_unset_logical_endpoint_config(struct net_device *dev,
  106. int config_id);
  107. int _rmnet_get_logical_endpoint_config
  108. (struct net_device *dev, int config_id,
  109. struct rmnet_logical_ep_conf_s *epconfig);
  110. int rmnet_get_logical_endpoint_config(struct net_device *dev,
  111. int config_id,
  112. u8 *rmnet_mode,
  113. u8 *egress_dev_name,
  114. size_t egress_dev_name_size);
  115. void rmnet_config_netlink_msg_handler (struct sk_buff *skb);
  116. int rmnet_config_notify_cb(struct notifier_block *nb,
  117. unsigned long event, void *data);
  118. int rmnet_create_vnd(int id);
  119. int rmnet_create_vnd_prefix(int id, const char *name);
  120. int rmnet_create_vnd_name(int id, const char *name);
  121. int rmnet_free_vnd(int id);
  122. struct rmnet_phys_ep_config *_rmnet_get_phys_ep_config
  123. (struct net_device *dev);
  124. #endif /* _RMNET_DATA_CONFIG_H_ */