Skip to content

Commit 6a389d7

Browse files
committed
Raw tx fixes/debugs
Signed-off-by: Chaitanya Tata <[email protected]>
1 parent cbc7f21 commit 6a389d7

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

drivers/wifi/nrf_wifi/Kconfig.nrfwifi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ config NRF70_WORKQ_MAX_ITEMS
221221

222222
config NRF70_MAX_TX_PENDING_QLEN
223223
int "Maximum number of pending TX packets"
224-
default 18
224+
default 48
225225

226226
config NRF70_UTIL
227227
depends on SHELL

drivers/wifi/nrf_wifi/src/net_if.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
2929
#include "fmac_main.h"
3030
#include "wpa_supp_if.h"
3131
#include "net_if.h"
32+
unsigned int tx_sent_dbg_1, tx_sent_dbg_2, tx_sent_dbg_3;
3233

3334
extern char *net_sprint_ll_addr_buf(const uint8_t *ll, uint8_t ll_len,
3435
char *buf, int buflen);
@@ -253,6 +254,10 @@ void nrf_wifi_if_sniffer_rx_frm(void *os_vif_ctx, void *frm,
253254

254255
net_capture_pkt(iface, pkt);
255256

257+
LOG_INF("Received packet: len: %d, freq: %d, signal: %d, rate_flags: 0x%x, rate: %d",
258+
net_pkt_get_len(pkt), raw_rx_hdr->frequency,
259+
raw_rx_hdr->signal, raw_rx_hdr->rate_flags,
260+
raw_rx_hdr->rate);
256261
ret = net_recv_data(iface, pkt);
257262
if (ret < 0) {
258263
LOG_DBG("RCV Packet dropped by NET stack: %d", ret);
@@ -363,6 +368,8 @@ int nrf_wifi_if_send(const struct device *dev,
363368
struct raw_tx_pkt_header raw_hdr;
364369
#endif /* CONFIG_NRF70_RAW_DATA_TX */
365370

371+
tx_sent_dbg_3++;
372+
366373
if (!dev || !pkt) {
367374
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
368375
goto out;
@@ -392,14 +399,19 @@ int nrf_wifi_if_send(const struct device *dev,
392399
if (!nbuf) {
393400
LOG_DBG("Failed to allocate net_pkt");
394401
host_stats->total_tx_drop_pkts++;
402+
tx_sent_dbg_1++;
395403
goto out;
396404
}
397405

398406
#ifdef CONFIG_NRF70_RAW_DATA_TX
399407
memcpy(&raw_hdr, net_pkt_data(pkt), sizeof(raw_hdr));
400-
if ((ntohl(raw_hdr.magic_num) == NRF_WIFI_MAGIC_NUM_RAWTX) ||
401-
ntohl(raw_hdr.magic_num) == ntohl(NRF_WIFI_MAGIC_NUM_RAWTX)) {
408+
LOG_DBG("%s: raw_hdr.magic_num=0x%x, pkt_len=%d",
409+
__func__, ntohl(raw_hdr.magic_num), net_pkt_get_len(pkt));
410+
if (ntohl(raw_hdr.magic_num) == NRF_WIFI_MAGIC_NUM_RAWTX ||
411+
ntohl(raw_hdr.magic_num) == ntohl(NRF_WIFI_MAGIC_NUM_RAWTX)) {
402412
if (vif_ctx_zep->if_carr_state != NRF_WIFI_FMAC_IF_CARR_STATE_ON) {
413+
LOG_ERR("%s: Carrier state is not ON, dropping raw packet",
414+
__func__);;
403415
goto drop;
404416
}
405417
LOG_DBG("%s: Sending raw packet: len=%d, vif_idx=%d",
@@ -754,7 +766,6 @@ int nrf_wifi_if_start_zep(const struct device *dev)
754766
fmac_dev_added = true;
755767
LOG_DBG("%s: FMAC device added", __func__);
756768
}
757-
758769
fmac_dev_ctx = rpu_ctx_zep->rpu_ctx;
759770

760771
memset(&add_vif_info,

modules/nrf_wifi/bus/ipc_if.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static void event_recv(void *data, void *priv)
4343
hal_dev_ctx = (struct nrf_wifi_hal_dev_ctx *) bal_dev_ctx->hal_dev_ctx;
4444

4545
hal_dev_ctx->ipc_msg = data;
46+
LOG_DBG("Received event data: %p", data);
4647
callback_func(priv);
4748
}
4849

modules/nrf_wifi/os/shim.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,22 @@ static void zep_shim_qspi_cpy_to(void *priv, unsigned long addr, const void *src
119119
dev->write(addr, src, count_aligned);
120120
}
121121
#endif /* !CONFIG_NRF71_ON_IPC */
122+
struct zep_shim_spinlock {
123+
struct k_spinlock lock;
124+
k_spinlock_key_t key;
125+
};
122126

123127
static void *zep_shim_spinlock_alloc(void)
124128
{
125-
struct k_mutex *lock = NULL;
129+
struct zep_shim_spinlock *slock = NULL;
126130

127-
lock = k_malloc(sizeof(*lock));
131+
slock = k_calloc(sizeof(*slock), sizeof(char));
128132

129-
if (!lock) {
133+
if (!slock) {
130134
LOG_ERR("%s: Unable to allocate memory for spinlock", __func__);
131135
}
132136

133-
return lock;
137+
return slock;
134138
}
135139

136140
static void zep_shim_spinlock_free(void *lock)
@@ -140,29 +144,34 @@ static void zep_shim_spinlock_free(void *lock)
140144

141145
static void zep_shim_spinlock_init(void *lock)
142146
{
143-
k_mutex_init(lock);
147+
/* No explicit initialization needed for k_spinlock_t */
148+
ARG_UNUSED(lock);
144149
}
145150

146151
static void zep_shim_spinlock_take(void *lock)
147152
{
148-
k_mutex_lock(lock, K_FOREVER);
153+
struct zep_shim_spinlock *slock = (struct zep_shim_spinlock *)lock;
154+
slock->key = k_spin_lock(&slock->lock);
149155
}
150156

151157
static void zep_shim_spinlock_rel(void *lock)
152158
{
153-
k_mutex_unlock(lock);
159+
struct zep_shim_spinlock *slock = (struct zep_shim_spinlock *)lock;
160+
k_spin_unlock(&slock->lock, slock->key);
154161
}
155162

156163
static void zep_shim_spinlock_irq_take(void *lock, unsigned long *flags)
157164
{
165+
struct zep_shim_spinlock *slock = (struct zep_shim_spinlock *)lock;
158166
ARG_UNUSED(flags);
159-
k_mutex_lock(lock, K_FOREVER);
167+
slock->key = k_spin_lock(&slock->lock);
160168
}
161169

162170
static void zep_shim_spinlock_irq_rel(void *lock, unsigned long *flags)
163171
{
172+
struct zep_shim_spinlock *slock = (struct zep_shim_spinlock *)lock;
164173
ARG_UNUSED(flags);
165-
k_mutex_unlock(lock);
174+
k_spin_unlock(&slock->lock, slock->key);
166175
}
167176

168177
static int zep_shim_pr_dbg(const char *fmt, va_list args)
@@ -618,7 +627,7 @@ static void zep_shim_work_kill(void *item)
618627

619628
static unsigned long zep_shim_time_get_curr_us(void)
620629
{
621-
return k_uptime_get() * USEC_PER_MSEC;
630+
return k_ticks_to_us_floor64(k_uptime_ticks());
622631
}
623632

624633
static unsigned int zep_shim_time_elapsed_us(unsigned long start_time_us)

samples/net/zperf/overlay-loopback.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CONFIG_NET_LOOPBACK_SIMULATE_PACKET_DROP=y
66

77
CONFIG_NET_BUF_DATA_SIZE=1100
88
# Optimized networking settings for performance
9-
CONFIG_NET_PKT_RX_COUNT=32
9+
CONFIG_NET_PKT_RX_COUNT=24
1010
CONFIG_NET_PKT_TX_COUNT=48
11-
CONFIG_NET_BUF_RX_COUNT=32
11+
CONFIG_NET_BUF_RX_COUNT=24
1212
CONFIG_NET_BUF_TX_COUNT=96

samples/subsys/ipc/ipc_service/icmsg/src/main.c

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,16 @@ static void ep_bound(void *priv)
4242

4343
static void ep_recv(const void *data, size_t len, void *priv)
4444
{
45-
#if defined(CONFIG_ASSERT)
46-
struct data_packet *packet = (struct data_packet *)data;
4745

48-
__ASSERT(packet->data[0] == expected_message, "Unexpected message. Expected %c, got %c",
49-
expected_message, packet->data[0]);
50-
__ASSERT(len == expected_len, "Unexpected length. Expected %zu, got %zu",
51-
expected_len, len);
52-
#endif
53-
54-
#ifndef CONFIG_MULTITHREADING
55-
recv_sem = 0;
56-
#endif
5746

5847
received += len;
59-
expected_message++;
60-
expected_len++;
6148

62-
if (expected_message > 'Z') {
63-
expected_message = 'A';
64-
}
65-
66-
if (expected_len > sizeof(struct data_packet)) {
67-
expected_len = PACKET_SIZE_START;
68-
}
6949
}
7050

7151
static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms)
7252
{
7353
struct data_packet msg = {.data[0] = 'a'};
74-
size_t mlen = PACKET_SIZE_START;
54+
size_t mlen = sizeof(msg);
7555
size_t bytes_sent = 0;
7656
int ret = 0;
7757

@@ -101,11 +81,13 @@ static int send_for_time(struct ipc_ept *ep, const int64_t sending_time_ms)
10181
}
10282

10383
bytes_sent += mlen;
84+
#if 0
10485
mlen++;
10586

10687
if (mlen > sizeof(struct data_packet)) {
10788
mlen = PACKET_SIZE_START;
10889
}
90+
#endif
10991

11092
#if defined(CONFIG_MULTITHREADING)
11193
k_usleep(1);
@@ -160,20 +142,17 @@ int main(void)
160142
while (bound_sem != 0) {
161143
};
162144
#endif
163-
145+
#if 0
164146
ret = send_for_time(&ep, SENDING_TIME_MS);
165147
if (ret < 0) {
166148
LOG_ERR("send_for_time() failure");
167149
return ret;
168150
}
169-
170-
LOG_INF("Wait 500ms. Let remote core finish its sends");
171-
#if defined(CONFIG_MULTITHREADING)
172-
k_msleep(500);
173151
#else
174-
k_busy_wait(500000);
152+
LOG_INF("Wait till remote Tx is done");
153+
k_msleep(SENDING_TIME_MS);
175154
#endif
176-
155+
177156
LOG_INF("Received %zu [Bytes] in total", received);
178157

179158
#if defined(CONFIG_SOC_NRF5340_CPUAPP)

0 commit comments

Comments
 (0)