• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3  * This file contains confidential and proprietary information of
4  * OSWare Technology Co., Ltd
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #include "hdf_wifi_product.h"
19 #include "wifi_mac80211_ops.h"
20 #include "hdf_wlan_utils.h"
21 
22 /***********************************************************/
23 /*      marco declare                                      */
24 /***********************************************************/
25 #define AP_SUCCESS (0)
26 #define HDF_LOG_TAG Ap6212Driver
27 
28 /***********************************************************/
29 /*      variable and function declare                      */
30 /***********************************************************/
31 struct NetDevice *g_hdf_netdevice;
32 struct net_device *g_save_kernel_net = NULL;
33 
34 /***********************************************************/
35 /*      variable and function declare                      */
36 /***********************************************************/
37 extern struct net_device_ops dhd_ops_pri;
38 extern int get_dhd_priv_data_size(void);
39 extern int32_t hdf_netdev_init(struct NetDevice *netDev);
40 extern int32_t hdf_netdev_open(struct NetDevice *netDev);
41 extern int32_t hdf_netdev_stop(struct NetDevice *netDev);
42 
InitAp6212Chip(struct HdfWlanDevice * device)43 int32_t InitAp6212Chip(struct HdfWlanDevice *device)
44 {
45     HDF_LOGE("%s: start...", __func__);
46     return HDF_SUCCESS;
47 }
48 
DeinitAp6212Chip(struct HdfWlanDevice * device)49 int32_t DeinitAp6212Chip(struct HdfWlanDevice *device)
50 {
51     int32_t ret = 0;
52 
53     (void)device;
54     HDF_LOGE("%s: start...", __func__);
55     if (ret != 0) {
56         HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret);
57     }
58     return ret;
59 }
60 
Ap6212Init(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)61 int32_t Ap6212Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
62 {
63     int32_t ret = 0;
64     int private_data_size = 0;
65     struct HdfWifiNetDeviceData *data = NULL;
66 
67     (void)chipDriver;
68     HDF_LOGE("%s: start...", __func__);
69 
70     if (netDevice == NULL) {
71         HDF_LOGE("%s:para is null!", __func__);
72         return HDF_FAILURE;
73     }
74 
75     data = GetPlatformData(netDevice);
76     if (data == NULL) {
77         HDF_LOGE("%s:netdevice data null!", __func__);
78         return HDF_FAILURE;
79     }
80 
81     /* set netdevice ops to netDevice */
82     hdf_netdev_init(netDevice);
83     netDevice->classDriverName = netDevice->classDriverName;
84     netDevice->classDriverPriv = data;
85     g_hdf_netdevice = netDevice;
86 
87     private_data_size = get_dhd_priv_data_size();
88     g_hdf_netdevice->mlPriv = kzalloc(private_data_size, GFP_KERNEL);
89     if (g_hdf_netdevice->mlPriv == NULL) {
90         printk("%s:kzalloc mlPriv failed\n", __func__);
91         return HDF_FAILURE;
92     }
93     strcpy_s(netDevice->name, sizeof("wlan0"), "wlan0");
94     dhd_module_init(netDevice);
95     NetDeviceAdd(netDevice);
96 
97     HDF_LOGE("%s:NetDeviceAdd success", __func__);
98 
99     ret = hdf_netdev_open(netDevice);
100     return HDF_SUCCESS;
101 }
102 
Ap6212Deinit(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)103 int32_t Ap6212Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
104 {
105     HDF_LOGE("%s: start...", __func__);
106     (void)netDevice;
107     (void)chipDriver;
108     hdf_netdev_stop(netDevice);
109     return HDF_SUCCESS;
110 }
111 
set_krn_netdev(struct net_device * dev)112 void set_krn_netdev(struct net_device *dev)
113 {
114     g_save_kernel_net = dev;
115 }
116 
get_krn_netdev(void)117 struct net_device *get_krn_netdev(void)
118 {
119     return g_save_kernel_net;
120 }
121 
getDevicePrivateData(void)122 void* getDevicePrivateData(void)
123 {
124     return g_hdf_netdevice->mlPriv;
125 }
126 
get_hdf_netdev(void)127 struct NetDevice* get_hdf_netdev(void)
128 {
129     return g_hdf_netdevice;
130 }
131 
132 EXPORT_SYMBOL(get_hdf_netdev);
133 EXPORT_SYMBOL(set_krn_netdev);
134 EXPORT_SYMBOL(get_krn_netdev);
135 EXPORT_SYMBOL(getDevicePrivateData);