高通平台wlan mac地址分析以及更改方法

几种wlan mac地址的方法

1. wlan_mac.bin

如果通过wlan_mac.bin指定了MAC地址,则将相同的MAC地址用于wlan0-wlan3接口,最多支持四个不同的自定义MAC地址。

2. NV#04678

如果不存在wlan_mac.bin,且在modem中NV#04678中指定了MAC地址,那就将此地址作为wlan0接口的地址,其余三个地址则由此地址通过改变第一和第四字节来派生出。

3. bdf file

如果没有有效的wlan_mac.bin以及NV#04678,则可以在bdf文件中来确定wlan接口的mac地址。同样,必须通过更改wlan0第1和第四字节的更改来随机派生其余三个mac地址!

4. ini file

如果上述3者都没有,则可以使用WCNSS_qcom_cfg.ini文件来设置。如果ini文件中指定的mac地址不是默认值(00:0a:f5:89:89:ff),请在ini中使用mac地址用于wlan0-wlan3接口,因为ini文件中最多支持4个不同的自定义mac地址。

5. Auto generate

如果上述条件均不适用,则使用设备的Soc serial number来自动生成Mac地址。前三个字节为OUI,后三个字节与Soc serial number的后三字节匹配。其余接口的mac地址由wlan0更改第四字节来随机派生出。

总结

一般来说,软件版本中任何都mac地址在不会包含在wlan_mac.bin,NV#04678、bdf file 以及ini file ,都需要自己手动配置。

优先级:wlan_mac.bin > NV#04678 > BDF file > ini file

更改wlan mac的方法

1.通过wlan_mac.bin更改

添加或修改/persist/wlan_mac.bin

Intf0MacAddress=
Intf1MacAddress=
Intf2MacAddress=
Intf3MacAddress=
END
For example:
Intf0MacAddress=000AF58989FF
Intf1MacAddress=000AF58989FE
Intf2MacAddress=000AF58989FD
Intf3MacAddress=000AF58989FC
END

adb push wlan_mac.bin /persist

2.通过设置 NV item来改mac地址

通过QXDM更改wlan 地址

3. 通过bdf file 来设置

bdf一般为射频工程师调较,我对这块不太了解,故不阐述此方法。

4. 通过ini file来设置

修改WCNSS_qcom_cfg.ini,文件路径:/vendor/etc/wifi/WCNSS_qcom_cfg.ini

# Assigned MAC Addresses - This will be used until NV items are in place
# Each byte of MAC address is represented in Hex format as XX
Intf0MacAddress=000AF58989FF
Intf1MacAddress=000AF58989FE
Intf2MacAddress=000AF58989FD
Intf3MacAddress=000AF58989FC

5. 临时生效的方法

这是通过ifconfig指令修改mac地址临时生效的方式,重启后就恢复成默认的。

ifconfig wlan0 down
ifconfig wlan0 hw ether xx:xx:xx:xx:xx:xx
ifconfig wlan0 up

这个方法的原理如下:

设置mac地址的代码逻辑

文件路径:

AOSP/vendor/qcom/opensource/wlan/qcacld-3.0/core/hdd/src/wlan_hdd_cfg.c
AOSP/vendor/qcom/opensource/wlan/qcacld-3.0/core/hdd/src/wlan_hdd_main.c

从log开始分析吧:

[   14.322629] cnss_utils: WLAN MAC address is not set, type 0
[   14.323334] icnss 18800000.qcom,icnss: loading /system/vendor/firmware/wlan/qca_cld/wlan_mac.bin failed with error -13
[   14.324340] msm_vidc: info: Opening video instance: 0000000000000000, 1
[   14.332306] ueventd: firmware: loading 'wlan/qca_cld/wlan_mac.bin' for '/devices/platform/soc/18800000.qcom,icnss/firmware/wlan!qca_cld!wlan_mac.bin'
[   14.333007] ueventd: firmware: could not find firmware for wlan/qca_cld/wlan_mac.bin
[   14.333090] firmware wlan!qca_cld!wlan_mac.bin: _request_firmware_load: firmware state wait timeout: rc = -2
[   14.333582] [kworker/u16:15][0x19883eca][09:23:47.373107] wlan: [328:I:HDD] hdd_initialize_mac_address: 11045: using default MAC address
[   14.333592] [kworker/u16:15][0x19883fb8][09:23:47.373119] wlan: [328:I:HDD] hdd_update_macaddr: 1105: hdd_ctx->provisioned_mac_addr[0]: 90:78:b2:b0:c5:4a
[   14.333599] [kworker/u16:15][0x19884048][09:23:47.373127] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[0]: 92:78:b2:33:c5:4a
[   14.333607] [kworker/u16:15][0x198840d0][09:23:47.373134] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[1]: 92:78:b2:34:c5:4a
[   14.333616] [kworker/u16:15][0x19884189][09:23:47.373144] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[2]: 92:78:b2:35:c5:4a
[   14.333957] [kworker/u16:15][0x19885b16][09:23:47.373484] wlan: [328:I:HDD] wlan_hdd_get_provisioned_intf_addr: 3754: Assigning MAC from provisioned list90:78:b2:b0:c5:4a
[   14.337590] [kworker/u16:15][0x19896b07][09:23:47.377111] wlan: [328:E:HDD] hdd_open_adapter: 5555: Interface wlan0 wow debug_fs init failed
[   14.337599] [kworker/u16:15][0x19896c4a][09:23:47.377127] wlan: [328:I:HDD] hdd_open_adapter: 5558: wlan0 interface created. iftype: 0
[   14.337657] [kworker/u16:15][0x1989705f][09:23:47.377182] wlan: [328:E:HDD] wlan_hdd_debugfs_csr_init: 341: Failed to create debugfs file: connect_info
[   14.337703] [kworker/u16:15][0x19897406][09:23:47.377230] wlan: [328:E:HDD] wlan_hdd_debugfs_csr_init: 353: Failed to create generic_info debugfs file
[   14.337789] [kworker/u16:15][0x198976d4][09:23:47.377268] wlan: [328:E:HDD] wlan_hdd_debugfs_csr_init: 365: Failed to create generic_info debugfs file
[   14.337801] [kworker/u16:15][0x19897b58][09:23:47.377328] wlan: [328:I:HDD] wlan_hdd_get_derived_intf_addr: 3723: Assigning MAC from derived list92:78:b2:33:c5:4a
[   14.340179] [kworker/u16:15][0x198a2d6b][09:23:47.379702] wlan: [328:I:HDD] hdd_open_adapter: 5558: p2p0 interface created. iftype: 7
[   14.340343] [kworker/u16:15][0x198a39e2][09:23:47.379868] wlan: [328:I:HDD] hdd_set_idle_ps_config: 8495: Already in the requested power state:1

从log里看可以看到一开始先找wlan_mac.bin,没有找到才使用默认的mac address。

hdd_initialize_mac_address()

hdd_platform_wlan_mac

这个也对应着log中的

[   14.322629] cnss_utils: WLAN MAC address is not set, type 0

返回NULL,所以hdd_get_platform_wlan_mac_buff函数直接退出了。所以也就说明当前的代码逻辑中驱动里并没有设置mac地址。

hdd_update_mac_config

上面就很清楚了,这段代码就是去读取wlan_mac.bin,从log里看出wlan_mac.bin我们是没有的,所以这个函数是直接退出的。上面我说了可以通过wlan_mac.bin来修改mac地址,那我们也看一下逻辑。

modem侧上传nv#04678

走到这一步,说明platform driver和wlan_mac.bin都没有设置mac地址,这时候就选择使用默认的方式,也就是从fw(NV#04678)。下面将一下modem测读取NV#04678并通过qmi消息机制上传消息到hostdriver层。这部分是modem测代码,我不是很熟悉,只能简单介绍一下:

那这时候host driver层就会接收到modem测传来的数据,但是这部分的内容我不是很熟悉,不太清楚这块。但是从log里可以看到mac地址确实上传上来了。

[   14.333582] [kworker/u16:15][0x19883eca][09:23:47.373107] wlan: [328:I:HDD] hdd_initialize_mac_address: 11045: using default MAC address
[   14.333592] [kworker/u16:15][0x19883fb8][09:23:47.373119] wlan: [328:I:HDD] hdd_update_macaddr: 1105: hdd_ctx->provisioned_mac_addr[0]: 90:78:b2:b0:c5:4a
[   14.333599] [kworker/u16:15][0x19884048][09:23:47.373127] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[0]: 92:78:b2:33:c5:4a
[   14.333607] [kworker/u16:15][0x198840d0][09:23:47.373134] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[1]: 92:78:b2:34:c5:4a
[   14.333616] [kworker/u16:15][0x19884189][09:23:47.373144] wlan: [328:E:HDD] hdd_update_macaddr: 1136: hdd_ctx->derived_mac_addr[2]: 92:78:b2:35:c5:4a

hdd_update_mac_addr

剑气纵横三万里

“为什么要努力?” “想去的地方很远,想要的东西很贵,喜欢的人很优秀,父母的白发,朋友的约定,周围人的嘲笑,以及,天生傲骨。”

留下你的评论

*评论支持代码高亮<pre class="prettyprint linenums">代码</pre>

相关推荐