wlan_nlink_srv.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2012-2017, 2019-2020 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /******************************************************************************
  20. * wlan_nlink_srv.h
  21. *
  22. * wlan_nlink_srv is used to RX/TX Netlink messages from user space to kernel
  23. * modules and vice versa. Kernel modules must register a message handler for a
  24. * message type so that the wlan_nlink_srv can invoke the corresponding msg handler
  25. * whenever a Netlink message of a particular type has been received from an
  26. * application. In the opposite direction, wlan_nlink_srv provides a mechanism
  27. * which kernel modules can use to send Netlink messages to applications.
  28. *
  29. ******************************************************************************/
  30. #ifndef WLAN_NLINK_SRV_H
  31. #define WLAN_NLINK_SRV_H
  32. #include <linux/skbuff.h>
  33. #include <net/netlink.h>
  34. #include <wlan_nlink_common.h>
  35. #define INVALID_PID -1
  36. #define NLINK_MAX_CALLBACKS (WLAN_NL_MSG_MAX - WLAN_NL_MSG_BASE)
  37. typedef int (*nl_srv_msg_callback)(struct sk_buff *skb);
  38. /**
  39. * cld80211_oem_send_reply() - API to send cld80211 msg
  40. * @skb: Sk buffer
  41. * @hdr: nl80211hdr pointer
  42. * @nest: pointer of vendor nested attribute
  43. * @flags: Flags
  44. *
  45. * API to send cld80211 msg to applications
  46. *
  47. * Return: None
  48. */
  49. void cld80211_oem_send_reply(struct sk_buff *msg, void *hdr,
  50. struct nlattr *nest, int flags);
  51. /**
  52. * nl80211hdr_put() - API to allocate skb for cld80211 msg
  53. * @hdr: nl80211hdr pointer
  54. * @portid: Port ID
  55. * @nest: pointer of vendor nested attribute
  56. * @flags: Flags
  57. *
  58. * API to allocate skb for cld80211 msg
  59. *
  60. * Return: Pointer to skbuff
  61. */
  62. struct sk_buff *
  63. cld80211_oem_rsp_alloc_skb(uint32_t portid, void **hdr, struct nlattr **nest,
  64. int *flags);
  65. int nl_srv_init(void *wiphy, int proto);
  66. void nl_srv_exit(void);
  67. int nl_srv_register(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler);
  68. int nl_srv_unregister(tWlanNlModTypes msg_type,
  69. nl_srv_msg_callback msg_handler);
  70. #ifdef CNSS_GENL
  71. int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag,
  72. int app_id, int mcgroup_id);
  73. int nl_srv_bcast(struct sk_buff *skb, int mcgroup_id, int app_id);
  74. /**
  75. * nl80211hdr_put() - API to fill genlmsg header
  76. * @skb: Sk buffer
  77. * @portid: Port ID
  78. * @seq: Sequence number
  79. * @flags: Flags
  80. * @cmd: Command id
  81. *
  82. * API to fill genl message header for broadcast events to user space
  83. *
  84. * Return: Pointer to user specific header/payload
  85. */
  86. void *nl80211hdr_put(struct sk_buff *skb, uint32_t portid,
  87. uint32_t seq, int flags, uint8_t cmd);
  88. #else
  89. int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag);
  90. int nl_srv_bcast(struct sk_buff *skb);
  91. #endif
  92. int nl_srv_is_initialized(void);
  93. void nl_srv_ucast_oem(struct sk_buff *skb, int dst_pid, int flag);
  94. #endif