rmnet_genl.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2019, The Linux Foundation. All rights reserved.
  3. *
  4. * RMNET Data Generic Netlink
  5. *
  6. */
  7. #ifndef _RMNET_GENL_H_
  8. #define _RMNET_GENL_H_
  9. #include <net/genetlink.h>
  10. #define RMNET_CORE_DEBUG 0
  11. #define rm_err(fmt, ...) \
  12. do { if (RMNET_CORE_DEBUG) pr_err(fmt, __VA_ARGS__); } while (0)
  13. /* Generic Netlink Definitions */
  14. #define RMNET_CORE_GENL_VERSION 1
  15. #define RMNET_CORE_GENL_FAMILY_NAME "RMNET_CORE"
  16. #define RMNET_CORE_GENL_MAX_PIDS 32
  17. #define RMNET_GENL_SUCCESS (0)
  18. #define RMNET_GENL_FAILURE (-1)
  19. extern int rmnet_core_userspace_connected;
  20. enum {
  21. RMNET_CORE_GENL_CMD_UNSPEC,
  22. RMNET_CORE_GENL_CMD_PID_BPS_REQ,
  23. RMNET_CORE_GENL_CMD_PID_BOOST_REQ,
  24. __RMNET_CORE_GENL_CMD_MAX,
  25. };
  26. enum {
  27. RMNET_CORE_GENL_ATTR_UNSPEC,
  28. RMNET_CORE_GENL_ATTR_STR,
  29. RMNET_CORE_GENL_ATTR_INT,
  30. RMNET_CORE_GENL_ATTR_PID_BPS,
  31. RMNET_CORE_GENL_ATTR_PID_BOOST,
  32. __RMNET_CORE_GENL_ATTR_MAX,
  33. };
  34. #define RMNET_CORE_GENL_ATTR_MAX (__RMNET_CORE_GENL_ATTR_MAX - 1)
  35. struct rmnet_core_pid_bps_info {
  36. u64 tx_bps;
  37. u32 pid;
  38. u32 boost_remaining_ms;
  39. };
  40. struct rmnet_core_pid_boost_info {
  41. u32 boost_enabled;
  42. /* Boost period in ms */
  43. u32 boost_period;
  44. u32 pid;
  45. };
  46. struct rmnet_core_pid_bps_req {
  47. struct rmnet_core_pid_bps_info list[RMNET_CORE_GENL_MAX_PIDS];
  48. u64 timestamp;
  49. u16 list_len;
  50. u8 valid;
  51. };
  52. struct rmnet_core_pid_bps_resp {
  53. struct rmnet_core_pid_bps_info list[RMNET_CORE_GENL_MAX_PIDS];
  54. u64 timestamp;
  55. u16 list_len;
  56. u8 valid;
  57. };
  58. struct rmnet_core_pid_boost_req {
  59. struct rmnet_core_pid_boost_info list[RMNET_CORE_GENL_MAX_PIDS];
  60. u64 timestamp;
  61. u16 list_len;
  62. u8 valid;
  63. };
  64. /* Function Prototypes */
  65. int rmnet_core_genl_pid_bps_req_hdlr(struct sk_buff *skb_2,
  66. struct genl_info *info);
  67. int rmnet_core_genl_pid_boost_req_hdlr(struct sk_buff *skb_2,
  68. struct genl_info *info);
  69. /* Called by vnd select queue */
  70. void rmnet_update_pid_and_check_boost(pid_t pid, unsigned int len,
  71. int *boost_enable, u64 *boost_period);
  72. int rmnet_core_genl_init(void);
  73. int rmnet_core_genl_deinit(void);
  74. #endif /*_RMNET_CORE_GENL_H_*/