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