1 /*
2 * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-2023 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_net_if_hold_dev() - Hold reference to network device
70 * @nif: network device
71 *
72 * This function holds reference to the network device
73 *
74 * Return: QDF_STATUS_SUCCESS on success
75 */
76 QDF_STATUS
77 qdf_net_if_hold_dev(struct qdf_net_if *nif);
78
79 /**
80 * qdf_napi_enable() - Enable the napi schedule
81 * @napi: NAPI context
82 *
83 * This function resume NAPI from being scheduled on this context
84 *
85 * Return: NONE
86 */
87 void qdf_napi_enable(struct napi_struct *napi);
88
89 /**
90 * qdf_napi_disable() - Disable the napi schedule
91 * @napi: NAPI context
92 *
93 * This function suspends NAPI from being scheduled on this context
94 *
95 * Return: NONE
96 */
97 void qdf_napi_disable(struct napi_struct *napi);
98
99 /**
100 * qdf_netif_napi_add - initialize a NAPI context
101 * @netdev: network device
102 * @napi: NAPI context
103 * @poll: polling function
104 * @weight: default weight
105 *
106 * Return: NONE
107 */
108 void qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
109 int (*poll)(struct napi_struct *, int), int weight);
110
111 /**
112 * qdf_netif_napi_del - remove a NAPI context
113 * @napi: NAPI context
114 *
115 * Return: NONE
116 */
117 void qdf_netif_napi_del(struct napi_struct *napi);
118
119 /**
120 * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
121 * @ndev: net_device
122 * @src_addr: source mac address
123 * @len: length
124 *
125 * This function updates dev_addr in net_device
126 *
127 * Return: void
128 */
129 void
130 qdf_net_update_net_device_dev_addr(struct net_device *ndev,
131 const void *src_addr,
132 size_t len);
133 #else /* ENHANCED_OS_ABSTRACTION */
134 static inline QDF_STATUS
qdf_net_if_create_dummy_if(struct qdf_net_if * nif)135 qdf_net_if_create_dummy_if(struct qdf_net_if *nif)
136 {
137 return __qdf_net_if_create_dummy_if(nif);
138 }
139
140 static inline struct qdf_net_if *
qdf_net_if_get_dev_by_name(char * nif_name)141 qdf_net_if_get_dev_by_name(char *nif_name)
142 {
143 return __qdf_net_if_get_dev_by_name(nif_name);
144 }
145
146 static inline QDF_STATUS
qdf_net_if_release_dev(struct qdf_net_if * nif)147 qdf_net_if_release_dev(struct qdf_net_if *nif)
148 {
149 return __qdf_net_if_release_dev(nif);
150 }
151
152 static inline QDF_STATUS
qdf_net_if_hold_dev(struct qdf_net_if * nif)153 qdf_net_if_hold_dev(struct qdf_net_if *nif)
154 {
155 return __qdf_net_if_hold_dev(nif);
156 }
157
158 /**
159 * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
160 * @ndev: net_device
161 * @src_addr: source mac address
162 * @len: length
163 *
164 * This function updates dev_addr in net_device
165 *
166 * Return: void
167 */
168 static inline void
qdf_net_update_net_device_dev_addr(struct net_device * ndev,const void * src_addr,size_t len)169 qdf_net_update_net_device_dev_addr(struct net_device *ndev,
170 const void *src_addr,
171 size_t len)
172 {
173 __qdf_net_update_net_device_dev_addr(ndev, src_addr, len);
174 }
175
176 static inline void
qdf_napi_enable(struct napi_struct * napi)177 qdf_napi_enable(struct napi_struct *napi)
178 {
179 __qdf_napi_enable(napi);
180 }
181
182 static inline void
qdf_napi_disable(struct napi_struct * napi)183 qdf_napi_disable(struct napi_struct *napi)
184 {
185 __qdf_napi_disable(napi);
186 }
187
188 static inline void
qdf_netif_napi_add(struct net_device * netdev,struct napi_struct * napi,int (* poll)(struct napi_struct *,int),int weight)189 qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
190 int (*poll)(struct napi_struct *, int), int weight)
191 {
192 __qdf_netif_napi_add(netdev, napi, poll, weight);
193 }
194
195 static inline void
qdf_netif_napi_del(struct napi_struct * napi)196 qdf_netif_napi_del(struct napi_struct *napi)
197 {
198 __qdf_netif_napi_del(napi);
199 }
200 #endif /* ENHANCED_OS_ABSTRACTION */
201
202 /**
203 * qdf_net_if_get_devname() - Retrieve netdevice name
204 * @nif: Abstraction of netdevice
205 *
206 * Return: netdevice name
207 */
208 char *qdf_net_if_get_devname(struct qdf_net_if *nif);
209 #endif /* __QDF_NET_IF_H */
210