gnrc/mac : Move GNRC_MAC_NEIGHBOR_COUNT to 'CONFIG_'
This commit is contained in:
parent
b2550451a1
commit
9ddc9e0633
@ -98,12 +98,12 @@ static inline void gnrc_netif_set_tx_feedback(gnrc_netif_t *netif,
|
||||
/**
|
||||
* @brief Queues the packet into the related transmission packet queue in netdev_t::tx.
|
||||
* Note that, in case the `gnrc_mac_tx_neighbor_t` structure is in used (indicated
|
||||
* by `GNRC_MAC_NEIGHBOR_COUNT != 0`), this function queues the packet to
|
||||
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0`), this function queues the packet to
|
||||
* the queue associated to the pkt's destination neighbor, including a
|
||||
* `broadcast-neighbor` (neighbor id is `0` in netdev_t::tx::neighbors) which
|
||||
* specifically stores broadcasting packets.
|
||||
* On the other hand, if `gnrc_mac_tx_neighbor_t` structure is not in used (indicated
|
||||
* by `GNRC_MAC_NEIGHBOR_COUNT == 0`), this function queues the packet into the single
|
||||
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0`), this function queues the packet into the single
|
||||
* priority TX queue defined in in netdev_t::tx.
|
||||
*
|
||||
* @param[in,out] tx gnrc_mac transmission management object
|
||||
|
||||
@ -65,10 +65,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Count of neighbor nodes in one-hop distance
|
||||
* @brief Count of neighbor nodes in one-hop distance.
|
||||
*/
|
||||
#ifndef GNRC_MAC_NEIGHBOR_COUNT
|
||||
#define GNRC_MAC_NEIGHBOR_COUNT (8U)
|
||||
#ifndef CONFIG_GNRC_MAC_NEIGHBOR_COUNT
|
||||
#define CONFIG_GNRC_MAC_NEIGHBOR_COUNT (8U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@ -115,7 +115,7 @@ typedef struct {
|
||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) && (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || defined(DOXYGEN) */
|
||||
|
||||
#if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief type for storing states of TX neighbor node.
|
||||
*/
|
||||
@ -162,9 +162,9 @@ typedef struct {
|
||||
GNRC_MAC_PHASE_UNINITIALIZED, \
|
||||
}
|
||||
#endif /* (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN) */
|
||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief MAC internal type for storing transmission state parameters and
|
||||
* state machines.
|
||||
@ -173,18 +173,18 @@ typedef struct {
|
||||
* \#ifdef directives when applicable.
|
||||
*/
|
||||
typedef struct {
|
||||
#if (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||
gnrc_mac_tx_neighbor_t neighbors[GNRC_MAC_NEIGHBOR_COUNT + 1]; /**< Neighbor information units for one-hop neighbors.
|
||||
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN)
|
||||
gnrc_mac_tx_neighbor_t neighbors[CONFIG_GNRC_MAC_NEIGHBOR_COUNT + 1]; /**< Neighbor information units for one-hop neighbors.
|
||||
First unit is for broadcast (+1) */
|
||||
gnrc_mac_tx_neighbor_t *current_neighbor; /**< Neighbor information unit of destination node to which
|
||||
the current packet will be sent */
|
||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0) || defined(DOXYGEN) */
|
||||
|
||||
#if (GNRC_MAC_TX_QUEUE_SIZE != 0) || defined(DOXYGEN)
|
||||
#if (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
|
||||
#if (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN)
|
||||
gnrc_priority_pktqueue_t queue; /**< If neighbor queues is not used, define
|
||||
a single queue for managing TX packets. */
|
||||
#endif /* (GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
|
||||
#endif /* (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0) || defined(DOXYGEN) */
|
||||
|
||||
gnrc_priority_pktqueue_node_t _queue_nodes[GNRC_MAC_TX_QUEUE_SIZE]; /**< Shared buffer for TX queue nodes */
|
||||
gnrc_pktsnip_t *packet; /**< currently scheduled packet for sending */
|
||||
@ -219,26 +219,26 @@ typedef struct {
|
||||
/**
|
||||
* @brief Static initializer for gnrc_mac_tx_t.
|
||||
*/
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
#define GNRC_MAC_TX_INIT { \
|
||||
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
||||
NULL, \
|
||||
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
||||
NULL, \
|
||||
}
|
||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
|
||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0)) || defined(DOXYGEN)
|
||||
#define GNRC_MAC_TX_INIT { \
|
||||
PRIORITY_PKTQUEUE_INIT, \
|
||||
{ PRIORITY_PKTQUEUE_NODE_INIT(0, NULL) }, \
|
||||
NULL, \
|
||||
}
|
||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
#elif ((GNRC_MAC_TX_QUEUE_SIZE == 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN)
|
||||
#define GNRC_MAC_TX_INIT { \
|
||||
{ GNRC_MAC_TX_NEIGHBOR_INIT }, \
|
||||
NULL, \
|
||||
}
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) && (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || defined(DOXYGEN) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -90,16 +90,16 @@ typedef struct {
|
||||
*/
|
||||
gnrc_mac_rx_t rx;
|
||||
#endif /* ((GNRC_MAC_RX_QUEUE_SIZE != 0) || (GNRC_MAC_DISPATCH_BUFFER_SIZE != 0)) || DOXYGEN */
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT != 0)) || DOXYGEN
|
||||
#if ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0)) || DOXYGEN
|
||||
/**
|
||||
* @brief MAC internal object which stores transmission parameters, queues, and
|
||||
* state machines.
|
||||
*
|
||||
* @note Only available if @ref GNRC_MAC_TX_QUEUE_SIZE or
|
||||
* @ref GNRC_MAC_NEIGHBOR_COUNT is greater than 0.
|
||||
* @ref CONFIG_GNRC_MAC_NEIGHBOR_COUNT is greater than 0.
|
||||
*/
|
||||
gnrc_mac_tx_t tx;
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_NEIGHBOR_COUNT == 0)) || DOXYGEN */
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0)) || DOXYGEN */
|
||||
|
||||
#if defined(MODULE_GNRC_LWMAC) || defined(MODULE_GNRC_GOMACH)
|
||||
gnrc_mac_prot_t prot;
|
||||
|
||||
@ -1166,11 +1166,11 @@ bool gnrc_gomach_find_next_tx_neighbor(gnrc_netif_t *netif)
|
||||
* thus to be more fair. */
|
||||
uint8_t j = netif->mac.tx.last_tx_neighbor_id + 1;
|
||||
|
||||
if (j >= GNRC_MAC_NEIGHBOR_COUNT) {
|
||||
if (j >= CONFIG_GNRC_MAC_NEIGHBOR_COUNT) {
|
||||
j = 1;
|
||||
}
|
||||
|
||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[j].queue) > 0) {
|
||||
netif->mac.tx.last_tx_neighbor_id = j;
|
||||
next = (int) j;
|
||||
@ -1178,7 +1178,7 @@ bool gnrc_gomach_find_next_tx_neighbor(gnrc_netif_t *netif)
|
||||
}
|
||||
else {
|
||||
j++;
|
||||
if (j >= GNRC_MAC_NEIGHBOR_COUNT) {
|
||||
if (j >= CONFIG_GNRC_MAC_NEIGHBOR_COUNT) {
|
||||
j = 1;
|
||||
}
|
||||
}
|
||||
@ -1388,7 +1388,7 @@ void gnrc_gomach_update_neighbor_phase(gnrc_netif_t *netif)
|
||||
{
|
||||
assert(netif != NULL);
|
||||
|
||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
||||
long int tmp = netif->mac.tx.neighbors[i].cp_phase -
|
||||
netif->mac.prot.gomach.backoff_phase_us;
|
||||
@ -1422,7 +1422,7 @@ void gnrc_gomach_update_neighbor_pubchan(gnrc_netif_t *netif)
|
||||
}
|
||||
|
||||
/* Toggle TX neighbors' current channel. */
|
||||
for (uint8_t i = 1; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (uint8_t i = 1; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (netif->mac.tx.neighbors[i].mac_type == GNRC_GOMACH_TYPE_KNOWN) {
|
||||
if (netif->mac.tx.neighbors[i].pub_chanseq == netif->mac.prot.gomach.pub_channel_1) {
|
||||
netif->mac.tx.neighbors[i].pub_chanseq = netif->mac.prot.gomach.pub_channel_2;
|
||||
|
||||
@ -201,7 +201,7 @@ static gnrc_mac_tx_neighbor_t *_next_tx_neighbor(gnrc_netif_t *netif)
|
||||
gnrc_mac_tx_neighbor_t *next = NULL;
|
||||
uint32_t phase_nearest = GNRC_LWMAC_PHASE_MAX;
|
||||
|
||||
for (unsigned i = 0; i < GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (unsigned i = 0; i < CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (gnrc_priority_pktqueue_length(&netif->mac.tx.neighbors[i].queue) > 0) {
|
||||
/* Unknown destinations are initialized with their phase at the end
|
||||
* of the local interval, so known destinations that still wakeup
|
||||
|
||||
@ -47,7 +47,7 @@ gnrc_priority_pktqueue_node_t *_alloc_pktqueue_node(gnrc_priority_pktqueue_node_
|
||||
#endif /* ((GNRC_MAC_TX_QUEUE_SIZE != 0) || (GNRC_MAC_RX_QUEUE_SIZE != 0)) */
|
||||
|
||||
#if GNRC_MAC_TX_QUEUE_SIZE != 0
|
||||
#if GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||
/* Find the neighbor's id based on the given address */
|
||||
int _gnrc_mac_find_neighbor(gnrc_mac_tx_t *tx, const uint8_t *dst_addr, int addr_len)
|
||||
{
|
||||
@ -59,7 +59,7 @@ int _gnrc_mac_find_neighbor(gnrc_mac_tx_t *tx, const uint8_t *dst_addr, int addr
|
||||
neighbors = tx->neighbors;
|
||||
|
||||
/* Don't attempt to find broadcast neighbor, so start at index 1 */
|
||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (neighbors[i].l2_addr_len == addr_len) {
|
||||
if (memcmp(&(neighbors[i].l2_addr), dst_addr, addr_len) == 0) {
|
||||
return i;
|
||||
@ -78,7 +78,7 @@ int _gnrc_mac_free_neighbor(gnrc_mac_tx_t *tx)
|
||||
neighbors = tx->neighbors;
|
||||
|
||||
/* Don't attempt to free broadcast neighbor, so start at index 1 */
|
||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if ((gnrc_priority_pktqueue_length(&(neighbors[i].queue)) == 0) &&
|
||||
(&neighbors[i] != tx->current_neighbor)) {
|
||||
/* Mark as free */
|
||||
@ -98,7 +98,7 @@ int _gnrc_mac_alloc_neighbor(gnrc_mac_tx_t *tx)
|
||||
neighbors = tx->neighbors;
|
||||
|
||||
/* Don't attempt to allocate broadcast neighbor, so start at index 1 */
|
||||
for (int i = 1; i <= (signed)GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
for (int i = 1; i <= (signed)CONFIG_GNRC_MAC_NEIGHBOR_COUNT; i++) {
|
||||
if (neighbors[i].l2_addr_len == 0) {
|
||||
gnrc_priority_pktqueue_init(&(neighbors[i].queue));
|
||||
return i;
|
||||
@ -118,14 +118,14 @@ void _gnrc_mac_init_neighbor(gnrc_mac_tx_neighbor_t *neighbor, const uint8_t *ad
|
||||
neighbor->phase = GNRC_MAC_PHASE_MAX;
|
||||
memcpy(&(neighbor->l2_addr), addr, len);
|
||||
}
|
||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||
|
||||
bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
assert(tx != NULL);
|
||||
assert(pkt != NULL);
|
||||
|
||||
#if GNRC_MAC_NEIGHBOR_COUNT == 0
|
||||
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0
|
||||
|
||||
gnrc_priority_pktqueue_node_t *node;
|
||||
node = _alloc_pktqueue_node(tx->_queue_nodes, GNRC_MAC_TX_QUEUE_SIZE);
|
||||
@ -177,7 +177,7 @@ bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip
|
||||
/* No neighbor entries left */
|
||||
if (neighbor_id < 0) {
|
||||
DEBUG("[gnrc_mac-int] No neighbor entries left, maybe increase "
|
||||
"GNRC_MAC_NEIGHBOR_COUNT for better performance\n");
|
||||
"CONFIG_GNRC_MAC_NEIGHBOR_COUNT for better performance\n");
|
||||
|
||||
/* Try to free an unused queue */
|
||||
neighbor_id = _gnrc_mac_free_neighbor(tx);
|
||||
@ -210,7 +210,7 @@ bool gnrc_mac_queue_tx_packet(gnrc_mac_tx_t *tx, uint32_t priority, gnrc_pktsnip
|
||||
neighbor_id);
|
||||
return false;
|
||||
|
||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT == 0 */
|
||||
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0 */
|
||||
}
|
||||
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ static void set_up(void)
|
||||
* correctly queue the packet to the corresponded priority packet queue.
|
||||
*
|
||||
* In case when the `gnrc_mac_tx_neighbor_t` structure is in used (indicated by
|
||||
* by `GNRC_MAC_NEIGHBOR_COUNT != 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
||||
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
||||
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
||||
@ -42,7 +42,7 @@ static void set_up(void)
|
||||
* queued to `tx::neighbors[0]::queue`.
|
||||
*
|
||||
* In case when the `gnrc_mac_tx_neighbor_t` structure is not in used (indicated by
|
||||
* by `GNRC_MAC_NEIGHBOR_COUNT == 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||
* by `CONFIG_GNRC_MAC_NEIGHBOR_COUNT == 0`), `test_gnrc_mac_queue_tx_packet()` successively
|
||||
* queues 4 packets, which are pkt1, pkt2, pkt3 and pkt_bcast, into a defined `tx`
|
||||
* (type of `gnrc_mac_tx_t`). Pkt1, pkt2 have the same destination address of "0x76b6",
|
||||
* , pkt3 is heading for "0x447e", while pkt_bcast is for broadcasting.
|
||||
@ -90,7 +90,7 @@ static void test_gnrc_mac_queue_tx_packet(void)
|
||||
LL_APPEND(hdr, pkt3);
|
||||
pkt3 = hdr;
|
||||
|
||||
#if GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0
|
||||
|
||||
gnrc_pktsnip_t *pkt_head;
|
||||
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt1));
|
||||
@ -172,7 +172,7 @@ static void test_gnrc_mac_queue_tx_packet(void)
|
||||
TEST_ASSERT(0 == gnrc_priority_pktqueue_length(&tx.queue));
|
||||
TEST_ASSERT_EQUAL_STRING(TEST_STRING8, pkt_head->next->data);
|
||||
|
||||
#endif /* GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||
#endif /* CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0 */
|
||||
}
|
||||
#endif /* GNRC_MAC_TX_QUEUE_SIZE != 0 */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user