mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
6loWPAN: Changes to use new MAC interfaces. Incomplete and needs some clean-up of dangling, unused definitions.
This commit is contained in:
@@ -102,8 +102,8 @@ struct lo_driver_s
|
||||
uint16_t lo_panid; /* Fake PAN ID for testing */
|
||||
WDOG_ID lo_polldog; /* TX poll timer */
|
||||
struct work_s lo_work; /* For deferring poll work to the work queue */
|
||||
FAR struct iob_s *head; /* Head of IOBs queued for loopback */
|
||||
FAR struct iob_s *tail; /* Tail of IOBs queued for loopback */
|
||||
FAR struct iob_s *lo_head; /* Head of IOBs queued for loopback */
|
||||
FAR struct iob_s *lo_tail; /* Tail of IOBs queued for loopback */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -145,9 +145,9 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
#endif
|
||||
static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta);
|
||||
FAR const struct ieee802154_frame_meta_s *meta);
|
||||
static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
FAR const struct ieee802154_frame_meta_s *meta,
|
||||
FAR struct iob_s *frames);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -177,43 +177,15 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
static int lo_loopback(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
|
||||
FAR struct iob_s *head;
|
||||
FAR struct iob_s *tail;
|
||||
FAR struct iob_s *iob;
|
||||
int ret;
|
||||
|
||||
if (dev->d_len > 0 || priv->lo_ieee.i_framelist != NULL)
|
||||
{
|
||||
ninfo("d_len: %u i_framelist: %p\n",
|
||||
dev->d_len, priv->lo_ieee.i_framelist);
|
||||
|
||||
/* The only two valid settings are:
|
||||
*
|
||||
* 1. Nothing to send:
|
||||
* dev->d_len == 0 && priv->lo_ieee.i_framelist == NULL
|
||||
* 2. Outgoing packet has been converted to IEEE802.15.4 frames:
|
||||
* dev->d_len == 0 && priv->lo_ieee.i_framelist != NULL
|
||||
*/
|
||||
|
||||
DEBUGASSERT(dev->d_len == 0 && priv->lo_ieee.i_framelist != NULL);
|
||||
}
|
||||
|
||||
/* Remove the queued IOBs from driver structure */
|
||||
|
||||
head = priv->lo_ieee.i_framelist;
|
||||
|
||||
/* Find the tail of the IOB queue */
|
||||
|
||||
for (tail = NULL, iob = head;
|
||||
iob != NULL;
|
||||
tail = iob, iob = iob->io_flink);
|
||||
|
||||
/* Loop while there frames to be sent, i.e., while the IOB list is not
|
||||
* emtpy. Sending, of course, just means relaying back through the network
|
||||
/* Loop while there frames to be sent, i.e., while the freme list is not
|
||||
* emtpy. Sending, of course, just means relaying back through the network
|
||||
* for this driver.
|
||||
*/
|
||||
|
||||
while (head != NULL)
|
||||
while (priv->lo_head != NULL)
|
||||
{
|
||||
/* Increment statistics */
|
||||
|
||||
@@ -221,24 +193,23 @@ static int lo_loopback(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Remove the IOB from the queue */
|
||||
|
||||
iob = head;
|
||||
head = iob->io_flink;
|
||||
iob = priv->lo_head;
|
||||
priv->lo_head = iob->io_flink;
|
||||
iob->io_flink = NULL;
|
||||
|
||||
/* Is the queue now empty? */
|
||||
/* Did the framelist become empty? */
|
||||
|
||||
if (head == NULL)
|
||||
if (priv->lo_head == NULL)
|
||||
{
|
||||
tail = NULL;
|
||||
priv->lo_tail = NULL;
|
||||
}
|
||||
|
||||
/* Return the next frame to the network */
|
||||
|
||||
iob->io_flink = NULL;
|
||||
priv->lo_ieee.i_framelist = iob;
|
||||
ninfo("Send frame %p to the network: Offset=%u Length=%u\n",
|
||||
iob, iob->io_offset, iob->io_len);
|
||||
|
||||
ninfo("Send frame %p to the network. Length=%u\n", iob, iob->io_len);
|
||||
ret = sixlowpan_input(&priv->lo_ieee);
|
||||
ret = sixlowpan_input(&priv->lo_ieee, iob);
|
||||
|
||||
/* Increment statistics */
|
||||
|
||||
@@ -250,33 +221,6 @@ static int lo_loopback(FAR struct net_driver_s *dev)
|
||||
NETDEV_TXERRORS(&priv->lo_ieee.i_dev);
|
||||
NETDEV_ERRORS(&priv->lo_ieee.i_dev);
|
||||
}
|
||||
|
||||
/* What if the network responds with more frames to send? */
|
||||
|
||||
if (priv->lo_ieee.i_framelist != NULL)
|
||||
{
|
||||
/* Append the new list to the tail of the queue */
|
||||
|
||||
iob = priv->lo_ieee.i_framelist;
|
||||
priv->lo_ieee.i_framelist = NULL;
|
||||
|
||||
if (tail == NULL)
|
||||
{
|
||||
head = iob;
|
||||
}
|
||||
else
|
||||
{
|
||||
tail->io_flink = iob;
|
||||
}
|
||||
|
||||
/* Find the new tail of the IOB queue */
|
||||
|
||||
for (tail = iob, iob = iob->io_flink;
|
||||
iob != NULL;
|
||||
tail = iob, iob = iob->io_flink);
|
||||
}
|
||||
|
||||
priv->lo_txdone = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -693,7 +637,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta)
|
||||
FAR const struct ieee802154_frame_meta_s *meta)
|
||||
{
|
||||
return MAC_HDRLEN;
|
||||
}
|
||||
@@ -710,13 +654,14 @@ static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
FAR const struct ieee802154_frame_meta_s *meta,
|
||||
FAR struct iob_s *frames)
|
||||
{
|
||||
FAR struct lo_driver_s *priv;
|
||||
FAR struct iob_s *iob;
|
||||
|
||||
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL && iob != NULL);
|
||||
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL &&
|
||||
frames != NULL);
|
||||
priv = (FAR struct lo_driver_s *)netdev->i_dev.d_private;
|
||||
|
||||
/* Add the incoming list of frames to queue of frames to loopback */
|
||||
@@ -737,22 +682,18 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
DEBUGASSERT(iob->io_offset == MAC_HDRLEN);
|
||||
memset(iob->io_data, 0, MAC_HDRLEN);
|
||||
|
||||
/* Add the IOB to the tail of teh queue of frames to be looped back */
|
||||
/* Add the IOB to the tail of the queue of frames to be looped back */
|
||||
|
||||
if (priv->tail == NULL)
|
||||
if (priv->lo_tail == NULL)
|
||||
{
|
||||
priv->head = iob;
|
||||
priv->lo_head = iob;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->tail->io_flink = iob;
|
||||
priv->lo_tail->io_flink = iob;
|
||||
}
|
||||
|
||||
/* Find the new tail of the IOB queue */
|
||||
|
||||
for (priv->tail = iob, iob = iob->io_flink;
|
||||
iob != NULL;
|
||||
priv->tail = iob, iob = iob->io_flink);
|
||||
priv->lo_tail = iob;
|
||||
}
|
||||
|
||||
/* Is our single work structure available? It may not be if there are
|
||||
@@ -821,10 +762,6 @@ int ieee8021514_loopback(void)
|
||||
dev->d_buf = g_iobuffer; /* Attach the IO buffer */
|
||||
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
|
||||
|
||||
/* Initialize the DSN to a "random" value */
|
||||
|
||||
ieee->i_dsn = 42;
|
||||
|
||||
/* Initialize the Network frame-related callbacks */
|
||||
|
||||
ieee->i_get_mhrlen = lo_get_mhrlen; /* Get MAC header length */
|
||||
|
||||
@@ -140,16 +140,6 @@ struct macnet_driver_s
|
||||
WDOG_ID md_txtimeout; /* TX timeout timer */
|
||||
struct work_s md_irqwork; /* Defer interupt work to the work queue */
|
||||
struct work_s md_pollwork; /* Defer poll work to the work queue */
|
||||
|
||||
/* This is queue of outgoing, ready-to-send frames that will be sent
|
||||
* indirectly. This list should only be used by a MAC acting as a
|
||||
* coordinator. These transactions will stay here until the data is
|
||||
* extracted by the destination device sending a Data Request MAC
|
||||
* command or if too much time passes.
|
||||
*/
|
||||
|
||||
FAR volatile struct iob_s *md_head;
|
||||
FAR volatile struct iob_s *md_tail;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -258,9 +248,9 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
#endif
|
||||
static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta);
|
||||
FAR const struct ieee802154_frame_meta_s *meta);
|
||||
static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
FAR const struct ieee802154_frame_meta_s *meta,
|
||||
FAR struct iob_s *frames);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -654,57 +644,6 @@ static int macnet_transmit(FAR struct macnet_driver_s *priv)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_txqueue
|
||||
*
|
||||
* Description:
|
||||
* Add new frames from the network to the list of outgoing frames.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - Reference to the NuttX driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; a negated errno on failure
|
||||
*
|
||||
* Assumptions:
|
||||
* May or may not be called from an interrupt handler. In either case,
|
||||
* the network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void macnet_txqueue(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Check if there is a new list of outgoing frames from the network. */
|
||||
|
||||
if (priv->lo_ieee.i_framelist != NULL)
|
||||
{
|
||||
/* Yes.. Remove the frame list from the driver structure */
|
||||
|
||||
iob = priv->lo_ieee.i_framelist;
|
||||
priv->lo_ieee.i_framelist = NULL;
|
||||
|
||||
/* Append the new list to the tail of the queue of outgoing frames. */
|
||||
|
||||
if (priv->md_tail == NULL)
|
||||
{
|
||||
priv->md_head = iob;
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->md_tail->io_flink = iob;
|
||||
}
|
||||
|
||||
/* Find the new tail of the outgoing frame queue */
|
||||
|
||||
for (priv->md_tail = iob, iob = iob->io_flink;
|
||||
iob != NULL;
|
||||
priv->md_tail = iob, iob = iob->io_flink);
|
||||
|
||||
/* Notify the radio driver that there is data available */
|
||||
#warning Missing logic
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_txpoll
|
||||
*
|
||||
@@ -724,30 +663,12 @@ static void macnet_txqueue(FAR struct net_driver_s *dev)
|
||||
* OK on success; a negated errno on failure
|
||||
*
|
||||
* Assumptions:
|
||||
* May or may not be called from an interrupt handler. In either case,
|
||||
* the network is locked.
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_txpoll(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv =
|
||||
(FAR struct macnet_driver_s *)dev->d_private;
|
||||
FAR struct iob_s *iob;
|
||||
|
||||
/* If the polling resulted in data that should be sent out, the field
|
||||
* i_framelist will set to a new, outgoing list of frames.
|
||||
*/
|
||||
|
||||
if (priv->lo_ieee.i_framelist != NULL)
|
||||
{
|
||||
/* Remove the frame list from the driver structure and append it to
|
||||
* the tail of the ist of outgoing frames.
|
||||
*/
|
||||
|
||||
macnet_txqueue(priv);
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
* been examined.
|
||||
*/
|
||||
@@ -781,6 +702,7 @@ static void macnet_receive(FAR struct macnet_driver_s *priv)
|
||||
|
||||
net_lock();
|
||||
iob = iob_alloc(false);
|
||||
#warning Allocated by radio layer, right?
|
||||
if (iob == NULL)
|
||||
{
|
||||
nerr("ERROR: Failed to allocate an IOB\n")
|
||||
@@ -796,22 +718,7 @@ static void macnet_receive(FAR struct macnet_driver_s *priv)
|
||||
|
||||
/* Transfer the frame to the network logic */
|
||||
|
||||
priv->md_dev.framelist = iob;
|
||||
sixlowpan_input(&priv->md_dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be sent
|
||||
* out, the field i_framelist will have been set to a new, outgoing list
|
||||
* of frames.
|
||||
*/
|
||||
|
||||
if (priv->md_dev.i_framelist != NULL)
|
||||
{
|
||||
/* Remove the frame list from the driver structure and append it to
|
||||
* the tail of the ist of outgoing frames.
|
||||
*/
|
||||
|
||||
macnet_txqueue(priv);
|
||||
}
|
||||
sixlowpan_input(&priv->md_dev, iob);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1508,7 +1415,7 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta)
|
||||
FAR const struct ieee802154_frame_meta_s *meta)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv;
|
||||
|
||||
@@ -1530,7 +1437,7 @@ static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
FAR const struct ieee802154_frame_meta_s *meta,
|
||||
FAR struct iob_s *frames)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv;
|
||||
|
||||
Reference in New Issue
Block a user