xref: /wlan-dirver/qca-wifi-host-cmn/utils/nlink/inc/wlan_nlink_srv.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
1 /*
2  * Copyright (c) 2012-2017, 2019-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
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 
31 #ifndef WLAN_NLINK_SRV_H
32 #define WLAN_NLINK_SRV_H
33 
34 #include <linux/skbuff.h>
35 #include <net/netlink.h>
36 #include <wlan_nlink_common.h>
37 
38 #define INVALID_PID -1
39 #define NLINK_MAX_CALLBACKS (WLAN_NL_MSG_MAX - WLAN_NL_MSG_BASE)
40 
41 typedef int (*nl_srv_msg_callback)(struct sk_buff *skb);
42 
43 /**
44  * cld80211_oem_send_reply() - API to send cld80211 msg
45  * @skb: Sk buffer
46  * @hdr: nl80211hdr pointer
47  * @nest: pointer of vendor nested attribute
48  * @flags: Flags
49  *
50  * API to send cld80211 msg to applications
51  *
52  * Return: None
53  */
54 void cld80211_oem_send_reply(struct sk_buff *msg, void *hdr,
55 				    struct nlattr *nest, int flags);
56 
57 /**
58  * nl80211hdr_put() - API to allocate skb for cld80211 msg
59  * @hdr: nl80211hdr pointer
60  * @portid: Port ID
61  * @nest: pointer of vendor nested attribute
62  * @flags: Flags
63  *
64  * API to allocate skb for cld80211 msg
65  *
66  * Return: Pointer to skbuff
67  */
68 
69 struct sk_buff *
70 cld80211_oem_rsp_alloc_skb(uint32_t portid, void **hdr, struct nlattr **nest,
71 			   int *flags);
72 int nl_srv_init(void *wiphy, int proto);
73 void nl_srv_exit(void);
74 int nl_srv_register(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler);
75 int nl_srv_unregister(tWlanNlModTypes msg_type,
76 		      nl_srv_msg_callback msg_handler);
77 
78 #ifdef CNSS_GENL
79 int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag,
80 			int app_id, int mcgroup_id);
81 int nl_srv_bcast(struct sk_buff *skb, int mcgroup_id, int app_id);
82 
83 /**
84  * nl80211hdr_put() - API to fill genlmsg header
85  * @skb: Sk buffer
86  * @portid: Port ID
87  * @seq: Sequence number
88  * @flags: Flags
89  * @cmd: Command id
90  *
91  * API to fill genl message header for brodcast events to user space
92  *
93  * Return: Pointer to user specific header/payload
94  */
95 void *nl80211hdr_put(struct sk_buff *skb, uint32_t portid,
96 		     uint32_t seq, int flags, uint8_t cmd);
97 #else
98 int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag);
99 int nl_srv_bcast(struct sk_buff *skb);
100 #endif
101 
102 int nl_srv_is_initialized(void);
103 void nl_srv_ucast_oem(struct sk_buff *skb, int dst_pid, int flag);
104 
105 #endif
106