enable the config file for aic8800

this can be used to configure a mac address
This commit is contained in:
LevitatingBusinessMan (Rein Fernhout)
2024-06-23 02:42:04 +02:00
parent 66daf080a3
commit a4490dd1ed
2 changed files with 26 additions and 25 deletions

View File

@ -13,6 +13,10 @@
#include "rwnx_defs.h" #include "rwnx_defs.h"
#include "rwnx_cfgfile.h" #include "rwnx_cfgfile.h"
int rwnx_request_firmware_common(struct rwnx_hw *rwnx_hw,
u32** buffer, const char *filename);
void rwnx_release_firmware_common(u32** buffer);
/** /**
* *
*/ */
@ -52,36 +56,36 @@ static const char *rwnx_find_tag(const u8 *file_data, unsigned int file_size,
int rwnx_parse_configfile(struct rwnx_hw *rwnx_hw, const char *filename, int rwnx_parse_configfile(struct rwnx_hw *rwnx_hw, const char *filename,
struct rwnx_conf_file *config) struct rwnx_conf_file *config)
{ {
const struct firmware *config_fw; u32 *config_fw=NULL;
u8 dflt_mac[ETH_ALEN] = { 0, 111, 111, 111, 111, 0 }; int size;
int ret;
const u8 *tag_ptr; const u8 *tag_ptr;
RWNX_DBG(RWNX_FN_ENTRY_STR); RWNX_DBG(RWNX_FN_ENTRY_STR);
ret = request_firmware(&config_fw, filename, rwnx_hw->dev); size = rwnx_request_firmware_common(rwnx_hw, &config_fw, filename);
if (ret) { if (size <= 0) {
printk(KERN_CRIT "%s: Failed to get %s (%d)\n", __func__, filename, ret); RWNX_DBG("%s: Failed to get %s (%d)\n", __func__, filename, size);
return ret; return -1;
} }
/* Get MAC Address */ /* Get MAC Address */
tag_ptr = rwnx_find_tag(config_fw->data, config_fw->size, tag_ptr = rwnx_find_tag((u8*) config_fw, size,
"MAC_ADDR=", strlen("00:00:00:00:00:00")); "MAC_ADDR=", strlen("00:00:00:00:00:00"));
if (tag_ptr != NULL) { if (tag_ptr != NULL) {
u8 *addr = config->mac_addr; u8 *addr = config->mac_addr;
if (sscanf(tag_ptr, if (sscanf(tag_ptr,
"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
addr + 0, addr + 1, addr + 2, addr + 0, addr + 1, addr + 2,
addr + 3, addr + 4, addr + 5) != ETH_ALEN) addr + 3, addr + 4, addr + 5) != ETH_ALEN) {
memcpy(config->mac_addr, dflt_mac, ETH_ALEN); printk(KERN_CRIT "%s: Invalid MAC_ADDR in %s\n", __func__, filename);
} else return -1;
memcpy(config->mac_addr, dflt_mac, ETH_ALEN); }
}
RWNX_DBG("MAC Address is:\n%pM\n", config->mac_addr);
/* Release the configuration file */ /* Release the configuration file */
release_firmware(config_fw); if (config_fw) {
rwnx_release_firmware_common(&config_fw);
}
return 0; return 0;
} }

View File

@ -6781,15 +6781,13 @@ int rwnx_cfg80211_init(struct rwnx_plat *rwnx_plat, void **platform_data)
tcp_ack_init(rwnx_hw); tcp_ack_init(rwnx_hw);
#endif #endif
#if 0 /* Set a default mac address with the last 2 bytes randomized */
memcpy(init_conf.mac_addr, dflt_mac, ETH_ALEN);
ret = rwnx_parse_configfile(rwnx_hw, RWNX_CONFIG_FW_NAME, &init_conf); ret = rwnx_parse_configfile(rwnx_hw, RWNX_CONFIG_FW_NAME, &init_conf);
if (ret) { if (ret) {
wiphy_err(wiphy, "rwnx_parse_configfile failed\n"); // do nothing
goto err_config;
} }
#else
memcpy(init_conf.mac_addr, dflt_mac, ETH_ALEN);
#endif
rwnx_hw->vif_started = 0; rwnx_hw->vif_started = 0;
rwnx_hw->monitor_vif = RWNX_INVALID_VIF; rwnx_hw->monitor_vif = RWNX_INVALID_VIF;
@ -6976,14 +6974,13 @@ int rwnx_cfg80211_init(struct rwnx_plat *rwnx_plat, void **platform_data)
if (mac_addr_efuse[0] | mac_addr_efuse[1] | mac_addr_efuse[2] | mac_addr_efuse[3]) { if (mac_addr_efuse[0] | mac_addr_efuse[1] | mac_addr_efuse[2] | mac_addr_efuse[3]) {
memcpy(init_conf.mac_addr, mac_addr_efuse, ETH_ALEN); memcpy(init_conf.mac_addr, mac_addr_efuse, ETH_ALEN);
}else{
memcpy(init_conf.mac_addr, dflt_mac, ETH_ALEN);
} }
AICWFDBG(LOGINFO, "get macaddr: %02x:%02x:%02x:%02x:%02x:%02x\r\n", AICWFDBG(LOGINFO, "efuse macaddr: %02x:%02x:%02x:%02x:%02x:%02x\r\n",
mac_addr_efuse[0], mac_addr_efuse[1], mac_addr_efuse[2], mac_addr_efuse[0], mac_addr_efuse[1], mac_addr_efuse[2],
mac_addr_efuse[3], mac_addr_efuse[4], mac_addr_efuse[5]); mac_addr_efuse[3], mac_addr_efuse[4], mac_addr_efuse[5]);
memcpy(wiphy->perm_addr, init_conf.mac_addr, ETH_ALEN); memcpy(wiphy->perm_addr, init_conf.mac_addr, ETH_ALEN);
/* Reset FW */ /* Reset FW */