1 /*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "wifi_hal_chip_interface.h"
16 #include <stdlib.h>
17 #include <string.h>
18 #include "securec.h"
19 #include "wifi_log.h"
20 #include "wifi_hal_adapter.h"
21 #undef LOG_TAG
22 #define LOG_TAG "WifiHalChipInterface"
23
GetWifiChip(uint8_t id,WifiChip * chip)24 WifiErrorNo GetWifiChip(uint8_t id, WifiChip *chip)
25 {
26 LOGD("GetWifiChip() id: %{public}u", id);
27 if (chip != NULL) {
28 chip->chip = 0; /* fixed compile error, -Werror,-Wunused-parameter */
29 }
30 return WIFI_HAL_SUCCESS;
31 }
32
GetWifiChipIds(uint8_t * ids,int32_t * size)33 WifiErrorNo GetWifiChipIds(uint8_t *ids, int32_t *size)
34 {
35 LOGD("GetWifiChipIds()");
36 if (ids != NULL && size != NULL) {
37 LOGD("input size %{public}d", *size);
38 }
39 return WIFI_HAL_SUCCESS;
40 }
41
GetChipId(int32_t * id)42 WifiErrorNo GetChipId(int32_t *id)
43 {
44 LOGD("GetChipId()");
45 if (id != NULL) {
46 *id = 0; /* fixed compile error, -Werror,-Wunused-parameter */
47 }
48 return WIFI_HAL_SUCCESS;
49 }
50
CreateIface(int32_t type,WifiIface * iface)51 WifiErrorNo CreateIface(int32_t type, WifiIface *iface)
52 {
53 LOGD("CreateIface() type: %{public}d", type);
54 if (iface == NULL) {
55 return WIFI_HAL_FAILED;
56 }
57 const int bufferSize = 8;
58 char name[bufferSize] = {0};
59 if (strcpy_s(iface->name, sizeof(iface->name), name) != EOK) {
60 return WIFI_HAL_FAILED;
61 }
62
63 iface->type = type;
64 return WIFI_HAL_SUCCESS;
65 }
66
GetIface(const char * ifname,WifiIface * iface)67 WifiErrorNo GetIface(const char *ifname, WifiIface *iface)
68 {
69 if (ifname == NULL || iface == NULL) {
70 return WIFI_HAL_FAILED;
71 }
72 LOGD("GetIface() ifname: %{public}s", ifname);
73
74 WifiIface tmpIface;
75 tmpIface.index = 0; /* fixed compile error, -Werror,-Wunused-parameter */
76 tmpIface.type = 0;
77 tmpIface.name[0] = '\0';
78 if (strcpy_s(tmpIface.macAddr, sizeof(tmpIface.macAddr), "00:00:00:00:00:00") != EOK) {
79 return WIFI_HAL_FAILED;
80 }
81
82 iface = &tmpIface;
83 return WIFI_HAL_SUCCESS;
84 }
85
GetIfaceNames(int32_t type,char * ifaces,int32_t size)86 WifiErrorNo GetIfaceNames(int32_t type, char *ifaces, int32_t size)
87 {
88 LOGD("GetIfaceNames() type: %{public}d size: %{public}d", type, size);
89 if (ifaces != NULL) {
90 ifaces[0] = '\0'; /* fixed compile error, -Werror,-Wunused-parameter */
91 }
92 return WIFI_HAL_SUCCESS;
93 }
94
RemoveIface(const char * ifname)95 WifiErrorNo RemoveIface(const char *ifname)
96 {
97 if (ifname == NULL) {
98 return WIFI_HAL_FAILED;
99 }
100 LOGD("RemoveIface() ifname:%{public}s", ifname);
101 return WIFI_HAL_SUCCESS;
102 }
103
GetCapabilities(uint32_t * capabilities)104 WifiErrorNo GetCapabilities(uint32_t *capabilities)
105 {
106 LOGD("GetCapabilities()");
107 if (capabilities != NULL) {
108 *capabilities = 0; /* fixed compile error, -Werror,-Wunused-parameter */
109 }
110 return WIFI_HAL_SUCCESS;
111 }
112
GetSupportedComboModes(int32_t * modes,int32_t * size)113 WifiErrorNo GetSupportedComboModes(int32_t *modes, int32_t *size)
114 {
115 LOGD("GetSupportedComboModes()");
116 if (modes == NULL || size == NULL) {
117 return WIFI_HAL_FAILED;
118 }
119 return WIFI_HAL_NOT_SUPPORT;
120 }
121
ConfigComboModes(int32_t mode)122 WifiErrorNo ConfigComboModes(int32_t mode)
123 {
124 LOGD("ConfigComboModes() mode: %{public}d", mode);
125 WifiHalVendorInterface *pInterface = GetWifiHalVendorInterface();
126 if (pInterface == NULL) {
127 return WIFI_HAL_GET_VENDOR_HAL_FAILED;
128 }
129 HalVendorError err = pInterface->func.wifiConfigComboModes(mode);
130 return ConvertErrorCode(err);
131 }
132
GetComboModes(int32_t * id)133 WifiErrorNo GetComboModes(int32_t *id)
134 {
135 LOGD("GetComboModes()");
136 if (id == NULL) {
137 return WIFI_HAL_FAILED;
138 }
139 WifiHalVendorInterface *pInterface = GetWifiHalVendorInterface();
140 if (pInterface == NULL) {
141 return WIFI_HAL_GET_VENDOR_HAL_FAILED;
142 }
143 HalVendorError err = pInterface->func.wifiGetComboModes(id);
144 return ConvertErrorCode(err);
145 }
146
RequestFirmwareDebugDump(unsigned char * bytes,int32_t * size)147 WifiErrorNo RequestFirmwareDebugDump(unsigned char *bytes, int32_t *size)
148 {
149 LOGD("RequestFirmwareDebugDump()");
150 if (bytes == NULL || size == NULL) {
151 return WIFI_HAL_FAILED;
152 }
153 WifiHalVendorInterface *pInterface = GetWifiHalVendorInterface();
154 if (pInterface == NULL) {
155 return WIFI_HAL_GET_VENDOR_HAL_FAILED;
156 }
157 HalVendorError err = pInterface->func.wifiRequestFirmwareDebugDump(bytes, size);
158 return ConvertErrorCode(err);
159 }
160
SetPowerMode(uint8_t mode)161 WifiErrorNo SetPowerMode(uint8_t mode)
162 {
163 LOGD("SetPowerMode() %{public}u", mode);
164 return WIFI_HAL_SUCCESS;
165 }