feat(802.15.4): support large scale pending table size

This commit is contained in:
zwx 2024-08-23 17:58:23 +08:00
parent ceea71d009
commit 3db6cccffe
2 changed files with 15 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -17,9 +17,11 @@
static ieee802154_pending_table_t ieee802154_pending_table;
#define BIT_SET(mask, pos) ((mask) |= (1UL << (pos)))
#define BIT_CLR(mask, pos) ((mask) &= ~(1UL << (pos)))
#define BIT_IST(mask, pos) ((mask) & (1UL << (pos)))
#define GET_MASK_ITEM_FROM_TABLE(mask, pos) (mask[(pos + 1) / IEEE802154_PENDING_TABLE_MASK_BITS])
#define BIT_SET(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) |= (1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS)))
#define BIT_CLR(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) &= ~(1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS)))
#define BIT_IST(mask, pos) (GET_MASK_ITEM_FROM_TABLE(mask, pos) & (1UL << (pos % IEEE802154_PENDING_TABLE_MASK_BITS)))
static IRAM_ATTR bool ieee802154_addr_in_pending_table(const uint8_t *addr, bool is_short)
{
@ -114,9 +116,9 @@ void ieee802154_reset_pending_table(bool is_short)
{
// Consider this function may be called in ISR, only clear the mask bits for finishing the process quickly.
if (is_short) {
ieee802154_pending_table.short_addr_mask = 0;
memset(ieee802154_pending_table.short_addr_mask, 0, IEEE802154_PENDING_TABLE_MASK_SIZE);
} else {
ieee802154_pending_table.ext_addr_mask = 0;
memset(ieee802154_pending_table.ext_addr_mask, 0, IEEE802154_PENDING_TABLE_MASK_SIZE);
}
}

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -8,6 +8,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "sdkconfig.h"
#include "esp_err.h"
#include "esp_ieee802154_frame.h"
@ -18,11 +19,14 @@ extern "C" {
/**
* @brief The radio pending table, which is utilized to determine whether the received frame should be responded to with pending bit enabled.
*/
#define IEEE802154_PENDING_TABLE_MASK_BITS (8)
#define IEEE802154_PENDING_TABLE_MASK_SIZE ((CONFIG_IEEE802154_PENDING_TABLE_SIZE + 1) / IEEE802154_PENDING_TABLE_MASK_BITS)
typedef struct {
uint8_t short_addr[CONFIG_IEEE802154_PENDING_TABLE_SIZE][IEEE802154_FRAME_SHORT_ADDR_SIZE]; /*!< Short address table */
uint8_t ext_addr[CONFIG_IEEE802154_PENDING_TABLE_SIZE][IEEE802154_FRAME_EXT_ADDR_SIZE]; /*!< Extend address table */
uint32_t short_addr_mask; /*!< The mask which the index of short address table is used */
uint32_t ext_addr_mask; /*!< The mask which the index of extended address table is used */
uint8_t short_addr_mask[IEEE802154_PENDING_TABLE_MASK_SIZE]; /*!< The mask which the index of short address table is used */
uint8_t ext_addr_mask[IEEE802154_PENDING_TABLE_MASK_SIZE]; /*!< The mask which the index of extended address table is used */
} ieee802154_pending_table_t;
/**