-
Notifications
You must be signed in to change notification settings - Fork 2.1k
gnrc_netif: add packet to queue when device is busy #11263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright (C) 2019-20 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @defgroup net_gnrc_netif_pktq Send queue for @ref net_gnrc_netif | ||
* @ingroup net_gnrc_netif | ||
* @brief | ||
* @{ | ||
* | ||
* @file | ||
* @brief @ref net_gnrc_netif_pktq definitions | ||
* | ||
* @author Martine S. Lenders <m.lenders@fu-berlin.de> | ||
*/ | ||
#ifndef NET_GNRC_NETIF_PKTQ_H | ||
#define NET_GNRC_NETIF_PKTQ_H | ||
|
||
#include <assert.h> | ||
#include <stdbool.h> | ||
|
||
#include "net/gnrc/netif.h" | ||
#include "net/gnrc/netif/pktq/type.h" | ||
#include "net/gnrc/pkt.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Puts a packet into the packet send queue of a network interface | ||
* | ||
* @pre `netif != NULL` | ||
* @pre `pkt != NULL` | ||
* | ||
* @param[in] netif A network interface. May not be NULL. | ||
* @param[in] pkt A packet. May not be NULL. | ||
* | ||
* @return 0 on success | ||
* @return -1 when the pool of available gnrc_pktqueue_t entries (of size | ||
* @ref CONFIG_GNRC_NETIF_PKTQ_POOL_SIZE) is depleted | ||
*/ | ||
int gnrc_netif_pktq_put(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt); | ||
|
||
/** | ||
* @brief Gets a packet from the packet send queue of a network interface | ||
* | ||
* @pre `netif != NULL` | ||
* | ||
* @param[in] netif A network interface. May not be NULL. | ||
* | ||
* @return A packet on success | ||
* @return NULL when the queue is empty | ||
*/ | ||
static inline gnrc_pktsnip_t *gnrc_netif_pktq_get(gnrc_netif_t *netif) | ||
{ | ||
#if IS_USED(MODULE_GNRC_NETIF_PKTQ) | ||
assert(netif != NULL); | ||
|
||
gnrc_pktsnip_t *pkt = NULL; | ||
gnrc_pktqueue_t *entry = gnrc_pktqueue_remove_head( | ||
&netif->send_queue.queue | ||
); | ||
|
||
if (entry != NULL) { | ||
pkt = entry->pkt; | ||
entry->pkt = NULL; | ||
} | ||
return pkt; | ||
#else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */ | ||
(void)netif; | ||
return NULL; | ||
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */ | ||
} | ||
|
||
/** | ||
* @brief Schedule a dequeue notification to network interface | ||
* | ||
* The notification will be scheduled in @ref CONFIG_GNRC_NETIF_PKTQ_TIMER_US | ||
* microseconds. | ||
* | ||
* @pre `netif != NULL` | ||
* | ||
* The signaling message can be used to send the next message in | ||
* gnrc_netif_pktq_t::queue. | ||
* | ||
* @param[in] netif A network interface. May not be NULL. | ||
*/ | ||
void gnrc_netif_pktq_sched_get(gnrc_netif_t *netif); | ||
|
||
/** | ||
* @brief Pushes a packet back to the head of the packet send queue of a | ||
* network interface | ||
* | ||
* @pre `netif != NULL` | ||
* @pre `pkt != NULL` | ||
* | ||
* @param[in] netif A network interface. May not be NULL. | ||
* @param[in] pkt A packet. May not be NULL. | ||
* | ||
* @return 0 on success | ||
* @return -1 when the pool of available gnrc_pktqueue_t entries (of size | ||
* @ref CONFIG_GNRC_NETIF_PKTQ_POOL_SIZE) is depleted | ||
*/ | ||
int gnrc_netif_pktq_push_back(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt); | ||
|
||
/** | ||
* @brief Check if a network interface's packet send queue is empty | ||
* | ||
* @pre `netif != NULL` | ||
* | ||
* @param[in] netif A network interface. May not be NULL. | ||
* | ||
* @return true, when the packet send queue of @p netif is empty | ||
* @return false, otherwise | ||
*/ | ||
static inline bool gnrc_netif_pktq_empty(gnrc_netif_t *netif) | ||
{ | ||
#if IS_USED(MODULE_GNRC_NETIF_PKTQ) | ||
assert(netif != NULL); | ||
|
||
return (netif->send_queue.queue == NULL); | ||
#else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */ | ||
(void)netif; | ||
return false; | ||
#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */ | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* NET_GNRC_NETIF_PKTQ_H */ | ||
/** @} */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2019-20 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @addtogroup net_gnrc_netif_pktq | ||
* @brief | ||
* @{ | ||
* | ||
* @file | ||
* @brief @ref net_gnrc_netif_pktq type definitions | ||
* | ||
* Contained in its own file, so the type can be included in | ||
* @ref gnrc_netif_t while the functions in net/gnrc/netif/pktq.h can use | ||
* @ref gnrc_netif_t as operating type. | ||
* | ||
* @author Martine S. Lenders <m.lenders@fu-berlin.de> | ||
*/ | ||
#ifndef NET_GNRC_NETIF_PKTQ_TYPE_H | ||
#define NET_GNRC_NETIF_PKTQ_TYPE_H | ||
|
||
#include "net/gnrc/pktqueue.h" | ||
#include "xtimer.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief A packet queue for @ref net_gnrc_netif with a de-queue timer | ||
*/ | ||
typedef struct { | ||
gnrc_pktqueue_t *queue; /**< the actual packet queue class */ | ||
#if CONFIG_GNRC_NETIF_PKTQ_TIMER_US >= 0 | ||
msg_t dequeue_msg; /**< message for gnrc_netif_pktq_t::dequeue_timer to send */ | ||
xtimer_t dequeue_timer; /**< timer to schedule next sending of | ||
* queued packets */ | ||
#endif | ||
} gnrc_netif_pktq_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* NET_GNRC_NETIF_PKTQ_TYPE_H */ | ||
/** @} */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.