xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/wl_android.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Linux cfg80211 driver - Android related functions
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 1999-2017, Broadcom Corporation
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
9*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
10*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
11*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12*4882a593Smuzhiyun  * following added to such license:
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
15*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
16*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
17*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
18*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
19*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
20*4882a593Smuzhiyun  * modifications of the software.
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  *      Notwithstanding the above, under no circumstances may you combine this
23*4882a593Smuzhiyun  * software in any way with any other Broadcom software provided under a license
24*4882a593Smuzhiyun  * other than the GPL, without Broadcom's express prior written consent.
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Open:>>
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * $Id: wl_android.h 794110 2018-12-12 05:03:21Z $
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include <linux/module.h>
33*4882a593Smuzhiyun #include <linux/netdevice.h>
34*4882a593Smuzhiyun #include <wldev_common.h>
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /* If any feature uses the Generic Netlink Interface, put it here to enable WL_GENL
37*4882a593Smuzhiyun  * automatically
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun #if defined(BT_WIFI_HANDOVER)
40*4882a593Smuzhiyun #define WL_GENL
41*4882a593Smuzhiyun #endif // endif
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #ifdef WL_GENL
44*4882a593Smuzhiyun #include <net/genetlink.h>
45*4882a593Smuzhiyun #endif // endif
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun typedef struct _android_wifi_priv_cmd {
48*4882a593Smuzhiyun     char *buf;
49*4882a593Smuzhiyun     int used_len;
50*4882a593Smuzhiyun     int total_len;
51*4882a593Smuzhiyun } android_wifi_priv_cmd;
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /**
54*4882a593Smuzhiyun  * Android platform dependent functions, feel free to add Android specific functions here
55*4882a593Smuzhiyun  * (save the macros in dhd). Please do NOT declare functions that are NOT exposed to dhd
56*4882a593Smuzhiyun  * or cfg, define them as static in wl_android.c
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /**
60*4882a593Smuzhiyun  * wl_android_init will be called from module init function (dhd_module_init now), similarly
61*4882a593Smuzhiyun  * wl_android_exit will be called from module exit function (dhd_module_cleanup now)
62*4882a593Smuzhiyun  */
63*4882a593Smuzhiyun int wl_android_init(void);
64*4882a593Smuzhiyun int wl_android_exit(void);
65*4882a593Smuzhiyun void wl_android_post_init(void);
66*4882a593Smuzhiyun int wl_android_wifi_on(struct net_device *dev);
67*4882a593Smuzhiyun int wl_android_wifi_off(struct net_device *dev, bool on_failure);
68*4882a593Smuzhiyun int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr);
69*4882a593Smuzhiyun int wl_handle_private_cmd(struct net_device *net, char *command, u32 cmd_len);
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun #ifdef WL_GENL
72*4882a593Smuzhiyun typedef struct bcm_event_hdr {
73*4882a593Smuzhiyun 	u16 event_type;
74*4882a593Smuzhiyun 	u16 len;
75*4882a593Smuzhiyun } bcm_event_hdr_t;
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /* attributes (variables): the index in this enum is used as a reference for the type,
78*4882a593Smuzhiyun  *             userspace application has to indicate the corresponding type
79*4882a593Smuzhiyun  *             the policy is used for security considerations
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun enum {
82*4882a593Smuzhiyun 	BCM_GENL_ATTR_UNSPEC,
83*4882a593Smuzhiyun 	BCM_GENL_ATTR_STRING,
84*4882a593Smuzhiyun 	BCM_GENL_ATTR_MSG,
85*4882a593Smuzhiyun 	__BCM_GENL_ATTR_MAX
86*4882a593Smuzhiyun };
87*4882a593Smuzhiyun #define BCM_GENL_ATTR_MAX (__BCM_GENL_ATTR_MAX - 1)
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun /* commands: enumeration of all commands (functions),
90*4882a593Smuzhiyun  * used by userspace application to identify command to be ececuted
91*4882a593Smuzhiyun  */
92*4882a593Smuzhiyun enum {
93*4882a593Smuzhiyun 	BCM_GENL_CMD_UNSPEC,
94*4882a593Smuzhiyun 	BCM_GENL_CMD_MSG,
95*4882a593Smuzhiyun 	__BCM_GENL_CMD_MAX
96*4882a593Smuzhiyun };
97*4882a593Smuzhiyun #define BCM_GENL_CMD_MAX (__BCM_GENL_CMD_MAX - 1)
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun /* Enum values used by the BCM supplicant to identify the events */
100*4882a593Smuzhiyun enum {
101*4882a593Smuzhiyun 	BCM_E_UNSPEC,
102*4882a593Smuzhiyun 	BCM_E_SVC_FOUND,
103*4882a593Smuzhiyun 	BCM_E_DEV_FOUND,
104*4882a593Smuzhiyun 	BCM_E_DEV_LOST,
105*4882a593Smuzhiyun #ifdef BT_WIFI_HANDOVER
106*4882a593Smuzhiyun 	BCM_E_DEV_BT_WIFI_HO_REQ,
107*4882a593Smuzhiyun #endif // endif
108*4882a593Smuzhiyun 	BCM_E_MAX
109*4882a593Smuzhiyun };
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun s32 wl_genl_send_msg(struct net_device *ndev, u32 event_type,
112*4882a593Smuzhiyun 	const u8 *string, u16 len, u8 *hdr, u16 hdrlen);
113*4882a593Smuzhiyun #endif /* WL_GENL */
114*4882a593Smuzhiyun s32 wl_netlink_send_msg(int pid, int type, int seq, const void *data, size_t size);
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun /* hostap mac mode */
117*4882a593Smuzhiyun #define MACLIST_MODE_DISABLED   0
118*4882a593Smuzhiyun #define MACLIST_MODE_DENY       1
119*4882a593Smuzhiyun #define MACLIST_MODE_ALLOW      2
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun /* max number of assoc list */
122*4882a593Smuzhiyun #define MAX_NUM_OF_ASSOCLIST    64
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun /* Bandwidth */
125*4882a593Smuzhiyun #define WL_CH_BANDWIDTH_20MHZ 20
126*4882a593Smuzhiyun #define WL_CH_BANDWIDTH_40MHZ 40
127*4882a593Smuzhiyun #define WL_CH_BANDWIDTH_80MHZ 80
128*4882a593Smuzhiyun /* max number of mac filter list
129*4882a593Smuzhiyun  * restrict max number to 10 as maximum cmd string size is 255
130*4882a593Smuzhiyun  */
131*4882a593Smuzhiyun #define MAX_NUM_MAC_FILT        10
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun int wl_android_set_ap_mac_list(struct net_device *dev, int macmode, struct maclist *maclist);
134*4882a593Smuzhiyun #ifdef WL_BCNRECV
135*4882a593Smuzhiyun extern int wl_android_bcnrecv_config(struct net_device *ndev, char *data,
136*4882a593Smuzhiyun 		int total_len);
137*4882a593Smuzhiyun extern int wl_android_bcnrecv_stop(struct net_device *ndev, uint reason);
138*4882a593Smuzhiyun extern int wl_android_bcnrecv_resume(struct net_device *ndev);
139*4882a593Smuzhiyun extern int wl_android_bcnrecv_suspend(struct net_device *ndev);
140*4882a593Smuzhiyun extern int wl_android_bcnrecv_event(struct net_device *ndev,
141*4882a593Smuzhiyun 		uint attr_type, uint status, uint reason, uint8 *data, uint data_len);
142*4882a593Smuzhiyun #endif /* WL_BCNRECV */
143*4882a593Smuzhiyun #ifdef WL_CAC_TS
144*4882a593Smuzhiyun #define TSPEC_UPLINK_DIRECTION (0 << 5)	/* uplink direction traffic stream */
145*4882a593Smuzhiyun #define TSPEC_DOWNLINK_DIRECTION (1 << 5)	/* downlink direction traffic stream */
146*4882a593Smuzhiyun #define TSPEC_BI_DIRECTION (3 << 5)	/* bi direction traffic stream */
147*4882a593Smuzhiyun #define TSPEC_EDCA_ACCESS (1 << 7)	/* EDCA access policy */
148*4882a593Smuzhiyun #define TSPEC_UAPSD_PSB (1 << 2)		/* U-APSD power saving behavior */
149*4882a593Smuzhiyun #define TSPEC_TSINFO_TID_SHIFT 1		/* TID Shift */
150*4882a593Smuzhiyun #define TSPEC_TSINFO_PRIO_SHIFT 3		/* PRIO Shift */
151*4882a593Smuzhiyun #define TSPEC_MAX_ACCESS_CATEGORY 3
152*4882a593Smuzhiyun #define TSPEC_MAX_USER_PRIO	7
153*4882a593Smuzhiyun #define TSPEC_MAX_DIALOG_TOKEN	255
154*4882a593Smuzhiyun #define TSPEC_MAX_SURPLUS_BW 12410
155*4882a593Smuzhiyun #define TSPEC_MIN_SURPLUS_BW 11210
156*4882a593Smuzhiyun #define TSPEC_MAX_MSDU_SIZE 1520
157*4882a593Smuzhiyun #define TSPEC_DEF_MEAN_DATA_RATE 120000
158*4882a593Smuzhiyun #define TSPEC_DEF_MIN_PHY_RATE 6000000
159*4882a593Smuzhiyun #define TSPEC_DEF_DIALOG_TOKEN 7
160*4882a593Smuzhiyun #endif /* WL_CAC_TS */
161