xref: /wlan-dirver/qca-wifi-host-cmn/qdf/inc/qdf_net_if.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2014-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 /**
21  * DOC: qdf_net_if
22  * QCA driver framework (QDF) network interface management APIs
23  */
24 
25 #if !defined(__QDF_NET_IF_H)
26 #define __QDF_NET_IF_H
27 
28 /* Include Files */
29 #include <qdf_types.h>
30 #include <i_qdf_net_if.h>
31 
32 struct qdf_net_if;
33 
34 #ifdef ENHANCED_OS_ABSTRACTION
35 /**
36  * qdf_net_if_create_dummy_if() - create dummy interface
37  * @nif: interface handle
38  *
39  * This function will create a dummy network interface
40  *
41  * Return: QDF_STATUS_SUCCESS on success
42  */
43 QDF_STATUS
44 qdf_net_if_create_dummy_if(struct qdf_net_if *nif);
45 
46 /**
47  * qdf_net_if_get_dev_by_name() - Find a network device by its name
48  * @nif_name: network device name
49  *
50  * This function retrieves the network device by its name
51  *
52  * Return: qdf network device
53  */
54 struct qdf_net_if *
55 qdf_net_if_get_dev_by_name(char *nif_name);
56 
57 /**
58  * qdf_net_if_release_dev() - Release reference to network device
59  * @nif: network device
60  *
61  * This function releases reference to the network device
62  *
63  * Return: QDF_STATUS_SUCCESS on success
64  */
65 QDF_STATUS
66 qdf_net_if_release_dev(struct qdf_net_if *nif);
67 
68 /**
69  * qdf_napi_enable() - Enable the napi schedule
70  * @napi: NAPI context
71  *
72  * This function resume NAPI from being scheduled on this context
73  *
74  * Return: NONE
75  */
76 void qdf_napi_enable(struct napi_struct *napi);
77 
78 /**
79  * qdf_napi_disable() - Disable the napi schedule
80  * @napi: NAPI context
81  *
82  * This function suspends NAPI from being scheduled on this context
83  *
84  * Return: NONE
85  */
86 void qdf_napi_disable(struct napi_struct *napi);
87 
88 /**
89  * qdf_netif_napi_add - initialize a NAPI context
90  * @netdev:  network device
91  * @napi: NAPI context
92  * @poll: polling function
93  * @weight: default weight
94  *
95  * Return: NONE
96  */
97 void qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
98 			int (*poll)(struct napi_struct *, int), int weight);
99 
100 /**
101  *  qdf_netif_napi_del - remove a NAPI context
102  *  @napi: NAPI context
103  *
104  *  Return: NONE
105  */
106 void qdf_netif_napi_del(struct napi_struct *napi);
107 
108 /**
109  * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
110  * @ndev: net_device
111  * @src_addr: source mac address
112  * @len: length
113  *
114  * This function updates dev_addr in net_device
115  *
116  * Return: void
117  */
118 void
119 qdf_net_update_net_device_dev_addr(struct net_device *ndev,
120 				   const void *src_addr,
121 				   size_t len);
122 #else /* ENHANCED_OS_ABSTRACTION */
123 static inline QDF_STATUS
124 qdf_net_if_create_dummy_if(struct qdf_net_if *nif)
125 {
126 	return __qdf_net_if_create_dummy_if(nif);
127 }
128 
129 static inline struct qdf_net_if *
130 qdf_net_if_get_dev_by_name(char *nif_name)
131 {
132 	return __qdf_net_if_get_dev_by_name(nif_name);
133 }
134 
135 static inline QDF_STATUS
136 qdf_net_if_release_dev(struct qdf_net_if *nif)
137 {
138 	return __qdf_net_if_release_dev(nif);
139 }
140 
141 /**
142  * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
143  * @ndev: net_device
144  * @src_addr: source mac address
145  * @len: length
146  *
147  * This function updates dev_addr in net_device
148  *
149  * Return: void
150  */
151 static inline void
152 qdf_net_update_net_device_dev_addr(struct net_device *ndev,
153 				   const void *src_addr,
154 				   size_t len)
155 {
156 	__qdf_net_update_net_device_dev_addr(ndev, src_addr, len);
157 }
158 
159 static inline void
160 qdf_napi_enable(struct napi_struct *napi)
161 {
162 	__qdf_napi_enable(napi);
163 }
164 
165 static inline void
166 qdf_napi_disable(struct napi_struct *napi)
167 {
168 	__qdf_napi_disable(napi);
169 }
170 
171 static inline void
172 qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
173 		   int (*poll)(struct napi_struct *, int), int weight)
174 {
175 	__qdf_netif_napi_add(netdev, napi, poll, weight);
176 }
177 
178 static inline void
179 qdf_netif_napi_del(struct napi_struct *napi)
180 {
181 	__qdf_netif_napi_del(napi);
182 }
183 #endif /* ENHANCED_OS_ABSTRACTION */
184 
185 /**
186  * qdf_net_if_get_devname() - Retrieve netdevice name
187  * @nif: Abstraction of netdevice
188  *
189  * Return: netdevice name
190  */
191 char *qdf_net_if_get_devname(struct qdf_net_if *nif);
192 #endif /* __QDF_NET_IF_H */
193