Skip to content

Commit 2264cfe

Browse files
bugfix(wifi_init): Updated to add missing wifi init configs
- updated protobuf and RPC for missing wifi init configs - checked incoming wifi init config from host - disable cache_tx_buffer in config if slave does not have SPIRAM enabled - bug fix in stats.c for CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
1 parent 0c4aa5f commit 2264cfe

File tree

7 files changed

+181
-28
lines changed

7 files changed

+181
-28
lines changed

common/proto/esp_hosted_rpc.pb-c.c

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7387,7 +7387,7 @@ void rpc__free_unpacked
73877387
assert(message->base.descriptor == &rpc__descriptor);
73887388
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
73897389
}
7390-
static const ProtobufCFieldDescriptor wifi_init_config__field_descriptors[20] =
7390+
static const ProtobufCFieldDescriptor wifi_init_config__field_descriptors[24] =
73917391
{
73927392
{
73937393
"static_rx_buf_num",
@@ -7629,6 +7629,54 @@ static const ProtobufCFieldDescriptor wifi_init_config__field_descriptors[20] =
76297629
0, /* flags */
76307630
0,NULL,NULL /* reserved1,reserved2, etc */
76317631
},
7632+
{
7633+
"rx_mgmt_buf_type",
7634+
21,
7635+
PROTOBUF_C_LABEL_NONE,
7636+
PROTOBUF_C_TYPE_INT32,
7637+
0, /* quantifier_offset */
7638+
offsetof(WifiInitConfig, rx_mgmt_buf_type),
7639+
NULL,
7640+
NULL,
7641+
0, /* flags */
7642+
0,NULL,NULL /* reserved1,reserved2, etc */
7643+
},
7644+
{
7645+
"rx_mgmt_buf_num",
7646+
22,
7647+
PROTOBUF_C_LABEL_NONE,
7648+
PROTOBUF_C_TYPE_INT32,
7649+
0, /* quantifier_offset */
7650+
offsetof(WifiInitConfig, rx_mgmt_buf_num),
7651+
NULL,
7652+
NULL,
7653+
0, /* flags */
7654+
0,NULL,NULL /* reserved1,reserved2, etc */
7655+
},
7656+
{
7657+
"tx_hetb_queue_num",
7658+
23,
7659+
PROTOBUF_C_LABEL_NONE,
7660+
PROTOBUF_C_TYPE_INT32,
7661+
0, /* quantifier_offset */
7662+
offsetof(WifiInitConfig, tx_hetb_queue_num),
7663+
NULL,
7664+
NULL,
7665+
0, /* flags */
7666+
0,NULL,NULL /* reserved1,reserved2, etc */
7667+
},
7668+
{
7669+
"dump_hesigb_enable",
7670+
24,
7671+
PROTOBUF_C_LABEL_NONE,
7672+
PROTOBUF_C_TYPE_INT32,
7673+
0, /* quantifier_offset */
7674+
offsetof(WifiInitConfig, dump_hesigb_enable),
7675+
NULL,
7676+
NULL,
7677+
0, /* flags */
7678+
0,NULL,NULL /* reserved1,reserved2, etc */
7679+
},
76327680
};
76337681
static const unsigned wifi_init_config__field_indices_by_name[] = {
76347682
7, /* field[7] = ampdu_rx_enable */
@@ -7637,6 +7685,7 @@ static const unsigned wifi_init_config__field_indices_by_name[] = {
76377685
14, /* field[14] = beacon_max_len */
76387686
5, /* field[5] = cache_tx_buf_num */
76397687
6, /* field[6] = csi_enable */
7688+
23, /* field[23] = dump_hesigb_enable */
76407689
1, /* field[1] = dynamic_rx_buf_num */
76417690
4, /* field[4] = dynamic_tx_buf_num */
76427691
18, /* field[18] = espnow_max_encrypt_num */
@@ -7646,16 +7695,19 @@ static const unsigned wifi_init_config__field_indices_by_name[] = {
76467695
11, /* field[11] = nano_enable */
76477696
10, /* field[10] = nvs_enable */
76487697
12, /* field[12] = rx_ba_win */
7698+
21, /* field[21] = rx_mgmt_buf_num */
7699+
20, /* field[20] = rx_mgmt_buf_type */
76497700
17, /* field[17] = sta_disconnected_pm */
76507701
0, /* field[0] = static_rx_buf_num */
76517702
3, /* field[3] = static_tx_buf_num */
76527703
2, /* field[2] = tx_buf_type */
7704+
22, /* field[22] = tx_hetb_queue_num */
76537705
13, /* field[13] = wifi_task_core_id */
76547706
};
76557707
static const ProtobufCIntRange wifi_init_config__number_ranges[1 + 1] =
76567708
{
76577709
{ 1, 0 },
7658-
{ 0, 20 }
7710+
{ 0, 24 }
76597711
};
76607712
const ProtobufCMessageDescriptor wifi_init_config__descriptor =
76617713
{
@@ -7665,7 +7717,7 @@ const ProtobufCMessageDescriptor wifi_init_config__descriptor =
76657717
"WifiInitConfig",
76667718
"",
76677719
sizeof(WifiInitConfig),
7668-
20,
7720+
24,
76697721
wifi_init_config__field_descriptors,
76707722
wifi_init_config__field_indices_by_name,
76717723
1, wifi_init_config__number_ranges,

common/proto/esp_hosted_rpc.pb-c.h

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/proto/esp_hosted_rpc.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ message wifi_init_config {
581581
bool sta_disconnected_pm = 18; /**< WiFi Power Management for station at disconnected status */
582582
int32 espnow_max_encrypt_num = 19; /**< Maximum encrypt number of peers supported by espnow */
583583
int32 magic = 20; /**< WiFi init magic number, it should be the last field */
584+
int32 rx_mgmt_buf_type = 21; /**< WiFi RX MGMT buffer type */
585+
int32 rx_mgmt_buf_num = 22; /**< WiFi RX MGMT buffer number */
586+
int32 tx_hetb_queue_num = 23; /**< WiFi TX HE TB QUEUE number for STA HE TB PPDU transmission */
587+
int32 dump_hesigb_enable = 24; /**< enable dump sigb field */
584588
}
585589

586590
message wifi_country {

host/drivers/rpc/core/rpc_req.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ int compose_rpc_req(Rpc *req, ctrl_cmd_t *app_req, int32_t *failure_status)
168168
req_payload->cfg->tx_buf_type = p_a->tx_buf_type ;
169169
req_payload->cfg->static_tx_buf_num = p_a->static_tx_buf_num ;
170170
req_payload->cfg->dynamic_tx_buf_num = p_a->dynamic_tx_buf_num ;
171+
req_payload->cfg->rx_mgmt_buf_type = p_a->rx_mgmt_buf_type ;
172+
req_payload->cfg->rx_mgmt_buf_num = p_a->rx_mgmt_buf_num ;
171173
req_payload->cfg->cache_tx_buf_num = p_a->cache_tx_buf_num ;
172174
req_payload->cfg->csi_enable = p_a->csi_enable ;
173175
req_payload->cfg->ampdu_rx_enable = p_a->ampdu_rx_enable ;
@@ -178,9 +180,12 @@ int compose_rpc_req(Rpc *req, ctrl_cmd_t *app_req, int32_t *failure_status)
178180
req_payload->cfg->rx_ba_win = p_a->rx_ba_win ;
179181
req_payload->cfg->wifi_task_core_id = p_a->wifi_task_core_id ;
180182
req_payload->cfg->beacon_max_len = p_a->beacon_max_len ;
183+
req_payload->cfg->feature_caps = p_a->feature_caps ;
181184
req_payload->cfg->mgmt_sbuf_num = p_a->mgmt_sbuf_num ;
182185
req_payload->cfg->sta_disconnected_pm = p_a->sta_disconnected_pm ;
183186
req_payload->cfg->espnow_max_encrypt_num = p_a->espnow_max_encrypt_num ;
187+
req_payload->cfg->tx_hetb_queue_num = p_a->tx_hetb_queue_num ;
188+
req_payload->cfg->dump_hesigb_enable = p_a->dump_hesigb_enable ;
184189
req_payload->cfg->magic = p_a->magic ;
185190

186191
/* uint64 - TODO: portable? */

idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.13"
1+
version: "2.0.14"
22
description: ESP-Hosted-MCU provide drivers to act any ESP chipset as Wi-Fi or Bluetooth co-processor.
33
url: https://github.com/espressif/esp-hosted-mcu
44
examples:

slave/main/slave_control.c

Lines changed: 98 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,103 @@ static void event_handler(void* arg, esp_event_base_t event_base,
739739
}
740740
}
741741

742+
// macros to format output
743+
#define PRINT_HEADER() ESP_LOGI(TAG, " Wifi Init Param | Default | Host | Actual");
744+
#define PRINT_FOOTER() ESP_LOGI(TAG, " End Wifi Init Param |");
745+
#define PRINT_USE_HOST_VALUE(param_str, default, host, final) \
746+
ESP_LOGD(TAG, "% 20s | % 7d | % 7d | % 7d", param_str, default, host, final);
747+
#define PRINT_USE_DEFAULT_VALUE(param_str, default, host, final) \
748+
ESP_LOGW(TAG, "% 20s | % 7d | % 7d | % 7d", param_str, default, host, final);
749+
#define PRINT_HEX64_USE_HOST_VALUE(param_str, default, host, final) \
750+
ESP_LOGD(TAG, "% 20s | 0x% 5"PRIx32" | 0x% 5"PRIx64" | 0x% 5"PRIx64, param_str, default, host, final);
751+
#define PRINT_HEX64_USE_DEFAULT_VALUE(param_str, default, host, final) \
752+
ESP_LOGW(TAG, "% 20s | % 7"PRIx32" | % 7"PRIx64" | % 7"PRIx64, param_str, default, host, final);
753+
754+
// macros to copy host or default value
755+
#define USE_HOST_VALUE(PARAM_STR, DEFAULT, PARAM) \
756+
do { \
757+
dst_config->PARAM = src_config->PARAM; \
758+
PRINT_USE_HOST_VALUE(PARAM_STR, \
759+
DEFAULT, \
760+
src_config->PARAM, \
761+
dst_config->PARAM); \
762+
} while(0);
763+
764+
#define USE_DEFAULT_VALUE(PARAM_STR, DEFAULT, PARAM) \
765+
do { \
766+
dst_config->PARAM = DEFAULT; \
767+
PRINT_USE_DEFAULT_VALUE(PARAM_STR, \
768+
DEFAULT, \
769+
src_config->PARAM, \
770+
dst_config->PARAM); \
771+
} while(0);
772+
773+
/** Returns the merged wifi init config
774+
* Compares the src config from the host with our Wi-Fi defaults
775+
* and adjust dst_config as necessary.
776+
*
777+
* Also displays the changed configs.
778+
*/
779+
static wifi_init_config_t * get_merged_init_config(wifi_init_config_t *dst_config, WifiInitConfig *src_config)
780+
{
781+
/* always use value from host, except for
782+
* - cache_tx_buf_num
783+
* - feature_caps
784+
*/
785+
PRINT_HEADER();
786+
USE_HOST_VALUE("static_rx_buf", CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM, static_rx_buf_num);
787+
USE_HOST_VALUE("dynamic_rx_buf", CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM, dynamic_rx_buf_num);
788+
USE_HOST_VALUE("tx_buf_type", CONFIG_ESP_WIFI_TX_BUFFER_TYPE, tx_buf_type);
789+
USE_HOST_VALUE("static_tx_buf", WIFI_STATIC_TX_BUFFER_NUM, static_tx_buf_num);
790+
USE_HOST_VALUE("dynamic_tx_buf", WIFI_DYNAMIC_TX_BUFFER_NUM, dynamic_tx_buf_num);
791+
USE_HOST_VALUE("rx_mgmt_buf_type", CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF, rx_mgmt_buf_type);
792+
USE_HOST_VALUE("rx_mgmt_buf", WIFI_RX_MGMT_BUF_NUM_DEF, rx_mgmt_buf_num);
793+
794+
if (WIFI_ENABLE_CACHE_TX_BUFFER) {
795+
// use setting from host
796+
USE_HOST_VALUE("cache_tx_buf", WIFI_CACHE_TX_BUFFER_NUM, cache_tx_buf_num);
797+
dst_config->feature_caps = src_config->feature_caps;
798+
PRINT_HEX64_USE_HOST_VALUE("feature_caps", WIFI_FEATURE_CAPS,
799+
src_config->feature_caps,
800+
dst_config->feature_caps);
801+
} else {
802+
if (WIFI_FEATURE_CAPS != src_config->feature_caps) {
803+
// don't use host setting, which may have enabled CACHE_TX_BUFFER
804+
USE_DEFAULT_VALUE("cache_tx_buf", WIFI_CACHE_TX_BUFFER_NUM, cache_tx_buf_num);
805+
dst_config->feature_caps = WIFI_FEATURE_CAPS;
806+
PRINT_HEX64_USE_DEFAULT_VALUE("feature_caps", WIFI_FEATURE_CAPS,
807+
src_config->feature_caps,
808+
dst_config->feature_caps);
809+
} else {
810+
USE_HOST_VALUE("cache_tx_buf", WIFI_CACHE_TX_BUFFER_NUM, cache_tx_buf_num);
811+
dst_config->feature_caps = src_config->feature_caps;
812+
PRINT_HEX64_USE_HOST_VALUE("feature_caps", WIFI_FEATURE_CAPS,
813+
src_config->feature_caps,
814+
dst_config->feature_caps);
815+
}
816+
}
817+
818+
USE_HOST_VALUE("csi_enable", WIFI_CSI_ENABLED, csi_enable);
819+
USE_HOST_VALUE("ampdu_rx_enable", WIFI_AMPDU_RX_ENABLED, ampdu_rx_enable);
820+
USE_HOST_VALUE("ampdu_tx_enable", WIFI_AMPDU_TX_ENABLED, ampdu_tx_enable);
821+
USE_HOST_VALUE("amsdu_tx_enable", WIFI_AMSDU_TX_ENABLED, amsdu_tx_enable);
822+
USE_HOST_VALUE("nvs_enable", WIFI_NVS_ENABLED, nvs_enable);
823+
USE_HOST_VALUE("nano_enable", WIFI_NANO_FORMAT_ENABLED, nano_enable);
824+
USE_HOST_VALUE("rx_ba_win", WIFI_DEFAULT_RX_BA_WIN, rx_ba_win);
825+
USE_HOST_VALUE("wifi_task_core", WIFI_TASK_CORE_ID, wifi_task_core_id);
826+
USE_HOST_VALUE("beacon_max_len", WIFI_SOFTAP_BEACON_MAX_LEN, beacon_max_len);
827+
USE_HOST_VALUE("mgmt_sbuf_num", WIFI_MGMT_SBUF_NUM, mgmt_sbuf_num);
828+
USE_HOST_VALUE("sta_disconnected_pm", WIFI_STA_DISCONNECTED_PM_ENABLED, sta_disconnected_pm);
829+
USE_HOST_VALUE("espnow_max_encrypt",CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, espnow_max_encrypt_num);
830+
USE_HOST_VALUE("tx_hetb_queue", WIFI_TX_HETB_QUEUE_NUM, tx_hetb_queue_num);
831+
USE_HOST_VALUE("dump_hesigb_enable", WIFI_DUMP_HESIGB_ENABLED, dump_hesigb_enable);
832+
PRINT_FOOTER();
833+
834+
dst_config->magic = src_config->magic;
835+
836+
return dst_config;
837+
}
838+
742839
static esp_err_t req_wifi_init(Rpc *req, Rpc *resp, void *priv_data)
743840
{
744841
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
@@ -748,28 +845,7 @@ static esp_err_t req_wifi_init(Rpc *req, Rpc *resp, void *priv_data)
748845
rpc__resp__wifi_init__init);
749846

750847
RPC_RET_FAIL_IF(!req_payload->cfg);
751-
cfg.static_rx_buf_num = req_payload->cfg->static_rx_buf_num ;
752-
cfg.dynamic_rx_buf_num = req_payload->cfg->dynamic_rx_buf_num ;
753-
cfg.tx_buf_type = req_payload->cfg->tx_buf_type ;
754-
cfg.static_tx_buf_num = req_payload->cfg->static_tx_buf_num ;
755-
cfg.dynamic_tx_buf_num = req_payload->cfg->dynamic_tx_buf_num ;
756-
cfg.cache_tx_buf_num = req_payload->cfg->cache_tx_buf_num ;
757-
cfg.csi_enable = req_payload->cfg->csi_enable ;
758-
cfg.ampdu_rx_enable = req_payload->cfg->ampdu_rx_enable ;
759-
cfg.ampdu_tx_enable = req_payload->cfg->ampdu_tx_enable ;
760-
cfg.amsdu_tx_enable = req_payload->cfg->amsdu_tx_enable ;
761-
cfg.nvs_enable = req_payload->cfg->nvs_enable ;
762-
cfg.nano_enable = req_payload->cfg->nano_enable ;
763-
cfg.rx_ba_win = req_payload->cfg->rx_ba_win ;
764-
cfg.wifi_task_core_id = req_payload->cfg->wifi_task_core_id ;
765-
cfg.beacon_max_len = req_payload->cfg->beacon_max_len ;
766-
cfg.mgmt_sbuf_num = req_payload->cfg->mgmt_sbuf_num ;
767-
cfg.feature_caps = req_payload->cfg->feature_caps ;
768-
cfg.sta_disconnected_pm = req_payload->cfg->sta_disconnected_pm ;
769-
cfg.espnow_max_encrypt_num = req_payload->cfg->espnow_max_encrypt_num ;
770-
cfg.magic = req_payload->cfg->magic ;
771-
772-
RPC_RET_FAIL_IF(esp_wifi_init(&cfg));
848+
RPC_RET_FAIL_IF(esp_wifi_init(get_merged_init_config(&cfg, req_payload->cfg)));
773849

774850
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
775851
ESP_EVENT_ANY_ID,

slave/main/stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "esp_log.h"
2020
#include "esp_hosted_transport_init.h"
2121

22-
#if TEST_RAW_TP || ESP_PKT_STATS
22+
#if TEST_RAW_TP || ESP_PKT_STATS || CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
2323
static const char TAG[] = "stats";
2424
#endif
2525

0 commit comments

Comments
 (0)