• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hdfinit_bdh.c
3  *
4  * hdf driver
5  *
6  * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  */
18 #include <uapi/linux/nl80211.h>
19 #include <securec.h>
20 #include <asm/byteorder.h>
21 #include <linux/kernel.h>
22 
23 #include "hdf_wifi_product.h"
24 #include "wifi_mac80211_ops.h"
25 #include "hdf_wlan_utils.h"
26 #include "hdf_wl_interface.h"
27 #include "net_bdh_adpater.h"
28 #include "hdf_public_ap6256.h"
29 #include "eapol.h"
30 
31 #define HDF_LOG_TAG BDH6Driver
32 int hdf_cfgp2p_register_ndev(struct net_device *p2p_netdev, struct net_device *primary_netdev, struct wiphy *wiphy);
33 void dhd_module_exit(void);
34 struct NetDeviceInterFace *wal_get_net_p2p_ops(void);
35 struct hdf_inf_map g_hdf_infmap[HDF_INF_MAX];
36 
37 int g_hdf_ifidx = HDF_INF_WLAN0;
38 int g_event_ifidx = HDF_INF_WLAN0;
39 int g_scan_event_ifidx = HDF_INF_WLAN0;
40 int g_conn_event_ifidx = HDF_INF_WLAN0;
41 int g_mgmt_tx_event_ifidx = HDF_INF_P2P0;
42 int bdh6_reset_driver_flag = 0;
43 
44 // BDH Wifi6 chip driver init
InitBDH6Chip(struct HdfWlanDevice * device)45 int32_t InitBDH6Chip(struct HdfWlanDevice *device)
46 {
47     (void)device;
48     HDF_LOGW("bdh6: call InitBDH6Chip");
49     return HDF_SUCCESS;
50 }
51 
DeinitBDH6Chip(struct HdfWlanDevice * device)52 int32_t DeinitBDH6Chip(struct HdfWlanDevice *device)
53 {
54     int32_t ret = HDF_SUCCESS;
55     (void)device;
56     if (ret != 0) {
57         HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret);
58     }
59     return ret;
60 }
61 
BDH6Deinit(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)62 int32_t BDH6Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
63 {
64     // free p2p0
65     int32_t i = 0;
66     struct NetDevice *p2p_hnetdev = get_hdf_netdev(HDF_INF_P2P0);
67 
68     (void)chipDriver;
69     kfree(p2p_hnetdev->mlPriv);
70     p2p_hnetdev->mlPriv = NULL;
71     DestroyEapolData(p2p_hnetdev);
72     if (NetDeviceDelete(p2p_hnetdev) != 0) {
73         return HDF_FAILURE;
74     }
75     if (NetDeviceDeInit(p2p_hnetdev) != 0) {
76         return HDF_FAILURE;
77     }
78 
79     hdf_bdh6_netdev_stop(netDevice);
80     dhd_module_exit();
81 
82     // free primary wlan0
83     kfree(netDevice->mlPriv);
84     netDevice->mlPriv = NULL;
85     DestroyEapolData(netDevice);
86 
87     for (i = 0; i < HDF_INF_MAX; i ++) {
88         cancel_work_sync(&g_hdf_infmap[i].eapolEvent.eapol_report);
89         NetBufQueueClear(&g_hdf_infmap[i].eapolEvent.eapolQueue);
90     }
91 
92     bdh6_reset_driver_flag = 1;
93     HDF_LOGE("%s: ok", __func__);
94 
95     return HDF_SUCCESS;
96 }
97 
get_real_netdev(NetDevice * netDev)98 struct NetDevice *get_real_netdev(NetDevice *netDev)
99 {
100     if (strcmp(netDev->name, "p2p0") == 0) {
101         return get_hdf_netdev(HDF_INF_WLAN0);
102     } else {
103         return netDev;
104     }
105 }
106