xref: /wlan-dirver/qca-wifi-host-cmn/os_if/linux/spectral/inc/os_if_spectral_netlink.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
1 /*
2  * Copyright (c) 2011, 2017-2020 The Linux Foundation. All rights reserved.
3  *
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 #ifndef _OS_IF_SPECTRAL_NETLINK_H
21 #define _OS_IF_SPECTRAL_NETLINK_H
22 
23 #include <net/netlink.h>
24 #include <wlan_objmgr_pdev_obj.h>
25 #include <linux/version.h>
26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <wlan_spectral_public_structs.h>
29 
30 /* NETLINK related declarations */
31 #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
32 void os_if_spectral_nl_data_ready(struct sock *sk, int len);
33 #else
34 void os_if_spectral_nl_data_ready(struct sk_buff *skb);
35 #endif /* VERSION CHECK */
36 
37 #ifndef SPECTRAL_NETLINK
38 #define SPECTRAL_NETLINK              (NETLINK_GENERIC + 1)
39 #endif
40 #define MAX_SPECTRAL_PAYLOAD         (2004)
41 
42 /* Init's network namespace */
43 extern struct net init_net;
44 
45 /**
46  * os_if_spectral_netlink_init() - Initialize Spectral Netlink data structures
47  * and register the NL handlers with Spectral target_if
48  * @pdev: Pointer to pdev
49  *
50  * Preparing socket buffer and sending Netlink messages to application layer are
51  * defined in os_if layer, they need to be registered with Spectral target_if
52  *
53  * Return: None
54  */
55 #ifdef WLAN_CONV_SPECTRAL_ENABLE
56 void os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev);
57 /**
58  * os_if_spectral_prep_skb() - Prepare socket buffer
59  * @pdev : Pointer to pdev
60  * @smsg_type:  Spectral scan message type
61  * @buf_type: Spectral report buffer type
62  *
63  * Prepare socket buffer to send the data to application layer
64  *
65  * Return: NLMSG_DATA of the created skb or NULL if no memory
66  */
67 void *os_if_spectral_prep_skb(struct wlan_objmgr_pdev *pdev,
68 			      enum spectral_msg_type smsg_type,
69 			      enum spectral_msg_buf_type buf_type);
70 
71 /**
72  * os_if_spectral_netlink_deinit() - De-initialize Spectral Netlink data
73  * structures and de-register the NL handlers from Spectral target_if
74  * @pdev: Pointer to pdev
75  *
76  * Return: None
77  */
78 void os_if_spectral_netlink_deinit(struct wlan_objmgr_pdev *pdev);
79 #else
80 
81 static inline void os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev)
82 {
83 }
84 
85 static inline void os_if_spectral_netlink_deinit(struct wlan_objmgr_pdev *pdev)
86 {
87 }
88 
89 #endif
90 #endif /* _OS_IF_SPECTRAL_NETLINK_H */
91