1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "hdf_wifi_product.h"
10 #include "wifi_mac80211_ops.h"
11 #include "hdf_wlan_utils.h"
12 #include "net_bdh_adpater.h"
13
14 #define HDF_LOG_TAG BDH6Driver
15
16
17 int dhd_module_init(void);
18 int get_dhd_priv_data_size(void);
19
20 struct NetDevice *g_hdf_netdev = NULL;
21
get_dhd_priv_data(void)22 void* get_dhd_priv_data(void)
23 {
24 return g_hdf_netdev->mlPriv;
25 }
26
27 // BDH Wifi6 chip driver init
InitBDH6Chip(struct HdfWlanDevice * device)28 int32_t InitBDH6Chip(struct HdfWlanDevice *device)
29 {
30 (void)device;
31 HDF_LOGW("bdh6: call InitBDH6Chip");
32 return HDF_SUCCESS;
33 }
34
DeinitBDH6Chip(struct HdfWlanDevice * device)35 int32_t DeinitBDH6Chip(struct HdfWlanDevice *device)
36 {
37 int32_t ret = HDF_SUCCESS;
38 (void)device;
39 if (ret != 0) {
40 HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret);
41 }
42 return ret;
43 }
44
BDH6Init(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)45 int32_t BDH6Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
46 {
47 int32_t ret = 0;
48 struct HdfWifiNetDeviceData *data = NULL;
49 void *netdev = NULL;
50 int private_data_size = 0;
51
52 (void)chipDriver;
53 HDF_LOGW("bdh6: call BDH6Init");
54
55 if (netDevice == NULL) {
56 HDF_LOGE("%s netdevice is null!", __func__);
57 return HDF_FAILURE;
58 }
59
60 netdev = GetLinuxInfByNetDevice(netDevice);
61 if (netdev == NULL) {
62 HDF_LOGE("%s net_device is null!", __func__);
63 return HDF_FAILURE;
64 }
65
66 set_krn_netdev(netdev);
67
68 data = GetPlatformData(netDevice);
69 if (data == NULL) {
70 HDF_LOGE("%s:netdevice data null!", __func__);
71 return HDF_FAILURE;
72 }
73
74 /* set netdevice ops to netDevice */
75 hdf_bdh6_netdev_init(netDevice);
76 netDevice->classDriverPriv = data;
77
78 // create bdh6 private object
79 private_data_size = get_dhd_priv_data_size();
80 netDevice->mlPriv = kzalloc(private_data_size, GFP_KERNEL);
81 if (netDevice->mlPriv == NULL) {
82 HDF_LOGE("%s:kzalloc mlPriv failed", __func__);
83 return HDF_FAILURE;
84 }
85 g_hdf_netdev = netDevice;
86
87 dhd_module_init();
88
89 ret = hdf_bdh6_netdev_open(netDevice);
90 return HDF_SUCCESS;
91 }
92
BDH6Deinit(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)93 int32_t BDH6Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
94 {
95 (void)chipDriver;
96 (void)netDevice;
97 hdf_bdh6_netdev_stop(netDevice);
98 return HDF_SUCCESS;
99 }
100