1 /*
2  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 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: i_qal_bridge
22  * QCA abstraction layer (QAL) bridge APIs
23  */
24 
25 #if !defined(__I_QAL_BRIDGE_H)
26 #define __I_QAL_BRIDGE_H
27 
28 /* Include Files */
29 #include <linux/if_bridge.h>
30 #include "qdf_types.h"
31 
32 typedef struct notifier_block *__qal_notify_blk_t;
33 typedef struct net_device *__qal_netdev_t;
34 typedef struct net_bridge_fdb_entry *__qal_br_fdb_entry_t;
35 
36 static inline QDF_STATUS
__qal_bridge_fdb_register_notify(__qal_notify_blk_t nb)37 __qal_bridge_fdb_register_notify(__qal_notify_blk_t nb)
38 {
39 	br_fdb_register_notify(nb);
40 	return QDF_STATUS_SUCCESS;
41 }
42 
43 static inline QDF_STATUS
__qal_bridge_fdb_unregister_notify(__qal_notify_blk_t nb)44 __qal_bridge_fdb_unregister_notify(__qal_notify_blk_t nb)
45 {
46 	br_fdb_unregister_notify(nb);
47 	return QDF_STATUS_SUCCESS;
48 }
49 
50 static inline __qal_br_fdb_entry_t
__qal_bridge_fdb_has_entry(__qal_netdev_t dev,const char * addr,uint16_t vid)51 __qal_bridge_fdb_has_entry(__qal_netdev_t dev, const char *addr, uint16_t vid)
52 {
53 	return br_fdb_has_entry(dev, addr, vid);
54 }
55 
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 24)
57 static inline QDF_STATUS
__qal_bridge_fdb_delete_by_netdev(__qal_netdev_t dev,const unsigned char * addr,uint16_t vid)58 __qal_bridge_fdb_delete_by_netdev(__qal_netdev_t dev,
59 				  const unsigned char *addr, uint16_t vid)
60 {
61 	/* Use 5.4-specific API */
62 	return QDF_STATUS_SUCCESS;
63 }
64 #else
65 static inline QDF_STATUS
__qal_bridge_fdb_delete_by_netdev(__qal_netdev_t dev,const unsigned char * addr,uint16_t vid)66 __qal_bridge_fdb_delete_by_netdev(__qal_netdev_t dev,
67 				  const unsigned char *addr, uint16_t vid)
68 {
69 	int ret;
70 
71 	ret = br_fdb_delete_by_netdev(dev, addr, vid);
72 
73 	return qdf_status_from_os_return(ret);
74 }
75 #endif
76 
77 static inline QDF_STATUS
__qal_bridge_fdb_update_register_notify(__qal_notify_blk_t nb)78 __qal_bridge_fdb_update_register_notify(__qal_notify_blk_t nb)
79 {
80 	br_fdb_update_register_notify(nb);
81 	return QDF_STATUS_SUCCESS;
82 }
83 
84 static inline QDF_STATUS
__qal_bridge_fdb_update_unregister_notify(__qal_notify_blk_t nb)85 __qal_bridge_fdb_update_unregister_notify(__qal_notify_blk_t nb)
86 {
87 	br_fdb_update_unregister_notify(nb);
88 	return QDF_STATUS_SUCCESS;
89 }
90 
91 #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
92 static inline QDF_STATUS
__qal_bridge_fdb_add_or_refresh_by_netdev(__qal_netdev_t dev,const unsigned char * addr,uint16_t vid,uint16_t state)93 __qal_bridge_fdb_add_or_refresh_by_netdev(__qal_netdev_t dev,
94 					  const unsigned char *addr,
95 					  uint16_t vid,
96 					  uint16_t state)
97 {
98 	int ret;
99 
100 	ret = br_fdb_add_or_refresh_by_netdev(dev, addr, vid, state);
101 	return qdf_status_from_os_return(ret);
102 }
103 #else
104 static inline QDF_STATUS
__qal_bridge_fdb_add_or_refresh_by_netdev(__qal_netdev_t dev,const unsigned char * addr,uint16_t vid,uint16_t state)105 __qal_bridge_fdb_add_or_refresh_by_netdev(__qal_netdev_t dev,
106 					  const unsigned char *addr,
107 					  uint16_t vid,
108 					  uint16_t state)
109 {
110 	return QDF_STATUS_SUCCESS;
111 }
112 #endif
113 #endif /* __I_QAL_BRIDGE_H */
114