xref: /wlan-driver/platform/inc/cnss_nl.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */
3 
4 #ifndef _NET_CNSS_GENETLINK_H_
5 #define _NET_CNSS_GENETLINK_H_
6 
7 #include <linux/types.h>
8 
9 #define CLD80211_MAX_COMMANDS 40
10 #define CLD80211_MAX_NL_DATA  4096
11 
12 /**
13  * enum cld80211_attr - Driver/Application embeds the data in nlmsg with the
14  *			help of below attributes
15  *
16  * @CLD80211_ATTR_VENDOR_DATA: Embed all other attributes in this nested
17  *	attribute.
18  * @CLD80211_ATTR_DATA: Embed complete data in this attribute
19  * @CLD80211_ATTR_META_DATA: Embed meta data for above data. This will help
20  * wlan driver to peek into request message packet without opening up definition
21  * of complete request message.
22  * @CLD80211_ATTR_CMD: cld80211 vendor subcommand in this attribute
23  * @CLD80211_ATTR_CMD_TAG_DATA: cld80211 vendor subcommand data is present in
24  * this attribute. It is a nested attribute with sub attributes of specified
25  * vendor sub command.
26  * @CLD80211_ATTR_IFINDEX: Embed Intrerface indx in this attribute
27  *
28  * Any new message in future can be added as another attribute
29  */
30 enum cld80211_attr {
31 	CLD80211_ATTR_VENDOR_DATA = 1,
32 	CLD80211_ATTR_DATA,
33 	CLD80211_ATTR_META_DATA,
34 	CLD80211_ATTR_CMD,
35 	CLD80211_ATTR_CMD_TAG_DATA,
36 	CLD80211_ATTR_IFINDEX,
37 	/* add new attributes above here */
38 
39 	__CLD80211_ATTR_AFTER_LAST,
40 	CLD80211_ATTR_MAX = __CLD80211_ATTR_AFTER_LAST - 1
41 };
42 
43 /**
44  * enum cld80211_multicast_groups - List of multicast groups supported
45  *
46  * @CLD80211_MCGRP_SVC_MSGS: WLAN service message will be sent to this group.
47  *	Ex: Status ind messages
48  * @CLD80211_MCGRP_HOST_LOGS: All logging related messages from driver will be
49  *	sent to this multicast group
50  * @CLD80211_MCGRP_FW_LOGS: Firmware logging messages will be sent to this group
51  * @CLD80211_MCGRP_PER_PKT_STATS: Messages related packet stats debugging infra
52  *	will be sent to this group
53  * @CLD80211_MCGRP_DIAG_EVENTS: Driver/Firmware status logging diag events will
54  *	be sent to this group
55  * @CLD80211_MCGRP_FATAL_EVENTS: Any fatal message generated in driver/firmware
56  *	will be sent to this group
57  * @CLD80211_MCGRP_OEM_MSGS: All OEM message will be sent to this group
58  *	Ex: LOWI messages
59  */
60 enum cld80211_multicast_groups {
61 	CLD80211_MCGRP_SVC_MSGS,
62 	CLD80211_MCGRP_HOST_LOGS,
63 	CLD80211_MCGRP_FW_LOGS,
64 	CLD80211_MCGRP_PER_PKT_STATS,
65 	CLD80211_MCGRP_DIAG_EVENTS,
66 	CLD80211_MCGRP_FATAL_EVENTS,
67 	CLD80211_MCGRP_OEM_MSGS,
68 };
69 
70 /**
71  * typedef cld80211_cb - Callback to be called when an nlmsg is received with
72  *			 the registered cmd_id command from userspace
73  * @data: Payload of the message to be sent to driver
74  * @data_len: Length of the payload
75  * @cb_ctx: callback context to be returned to driver when the callback
76  *	 is called
77  * @pid: process id of the sender
78  */
79 typedef void (*cld80211_cb)(const void *data, int data_len,
80 			    void *cb_ctx, int pid);
81 
82 /**
83  * register_cld_cmd_cb() - Allows cld driver to register for commands with
84  *	callback
85  * @cmd_id: Command to be registered. Valid range [1, CLD80211_MAX_COMMANDS]
86  * @cb: Callback to be called when an nlmsg is received with cmd_id command
87  *       from userspace
88  * @cb_ctx: context provided by driver; Send this as cb_ctx of func()
89  *         to driver
90  */
91 int register_cld_cmd_cb(u8 cmd_id, cld80211_cb cb, void *cb_ctx);
92 
93 /**
94  * deregister_cld_cmd_cb() - Allows cld driver to de-register the command it
95  *	has already registered
96  * @cmd_id: Command to be deregistered.
97  */
98 int deregister_cld_cmd_cb(u8 cmd_id);
99 
100 /**
101  * cld80211_get_genl_family() - Returns current netlink family context
102  */
103 struct genl_family *cld80211_get_genl_family(void);
104 
105 #endif /* _NET_CNSS_GENETLINK_H_ */
106