2016-06-14 16:52:57 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-06-14 16:52:57 +08:00
|
|
|
*/
|
|
|
|
|
2016-11-12 06:13:24 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Public IEEE 802.15.4 Radio API
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IEEE802154_RADIO_H__
|
|
|
|
#define __IEEE802154_RADIO_H__
|
|
|
|
|
|
|
|
#include <device.h>
|
|
|
|
#include <net/net_if.h>
|
|
|
|
|
|
|
|
struct ieee802154_radio_api {
|
|
|
|
/**
|
|
|
|
* Mandatory to get in first position.
|
|
|
|
* A network device should indeed provide a pointer on such
|
|
|
|
* net_if_api structure. So we make current structure pointer
|
|
|
|
* that can be casted to a net_if_api structure pointer.
|
|
|
|
*/
|
|
|
|
struct net_if_api iface_api;
|
|
|
|
|
|
|
|
/** Clear Channel Assesment - Check channel's activity */
|
|
|
|
int (*cca)(struct device *dev);
|
|
|
|
|
|
|
|
/** Set current channel */
|
|
|
|
int (*set_channel)(struct device *dev, uint16_t channel);
|
|
|
|
|
|
|
|
/** Set current PAN id */
|
|
|
|
int (*set_pan_id)(struct device *dev, uint16_t pan_id);
|
|
|
|
|
|
|
|
/** Set current device's short address */
|
|
|
|
int (*set_short_addr)(struct device *dev, uint16_t short_addr);
|
|
|
|
|
|
|
|
/** Set current devices's full length address */
|
|
|
|
int (*set_ieee_addr)(struct device *dev, const uint8_t *ieee_addr);
|
|
|
|
|
|
|
|
/** Set TX power level in dbm */
|
|
|
|
int (*set_txpower)(struct device *dev, int16_t dbm);
|
|
|
|
|
2017-04-05 14:37:44 +08:00
|
|
|
/** Transmit a packet fragment */
|
net/ieee802154: Modify radio TX function signature
The cause for this change is TCP. Until now, the radio strategy driver
(ALOHA or CSMA) was providing the actual nbuf, and not the buffer
fragment, counting on the fact that the loop was using
net_buf_frag_del() which made so, iteration after iteration, buffer
framgent to be always buf->frags. The problem with this logic is loosing
the fragments that might be still referenced by TCP, in case the whole
buffer did not make it so TCP can retry later and so on.
Instead, TX now takes the nbuf and the actual frag to send. It could
have been working with just a pointer on the data, and the whole length
of the frame. But it has been avoided due to possible future devices,
that will be smarter and run CSMA directly in the hw, thus it will
require to access the whole buffer list through the nbuf.
Change-Id: I8d77b1e13b648c0ec3645cb2d55d1910d00381ea
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-26 21:31:30 +08:00
|
|
|
int (*tx)(struct device *dev,
|
2017-04-05 14:37:44 +08:00
|
|
|
struct net_pkt *pkt,
|
net/ieee802154: Modify radio TX function signature
The cause for this change is TCP. Until now, the radio strategy driver
(ALOHA or CSMA) was providing the actual nbuf, and not the buffer
fragment, counting on the fact that the loop was using
net_buf_frag_del() which made so, iteration after iteration, buffer
framgent to be always buf->frags. The problem with this logic is loosing
the fragments that might be still referenced by TCP, in case the whole
buffer did not make it so TCP can retry later and so on.
Instead, TX now takes the nbuf and the actual frag to send. It could
have been working with just a pointer on the data, and the whole length
of the frame. But it has been avoided due to possible future devices,
that will be smarter and run CSMA directly in the hw, thus it will
require to access the whole buffer list through the nbuf.
Change-Id: I8d77b1e13b648c0ec3645cb2d55d1910d00381ea
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-26 21:31:30 +08:00
|
|
|
struct net_buf *frag);
|
2016-11-12 06:13:24 +08:00
|
|
|
|
|
|
|
/** Start the device */
|
|
|
|
int (*start)(struct device *dev);
|
|
|
|
|
|
|
|
/** Stop the device */
|
|
|
|
int (*stop)(struct device *dev);
|
|
|
|
|
|
|
|
/** Get latest Link Quality Information */
|
|
|
|
uint8_t (*get_lqi)(struct device *dev);
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Radio driver sending function that hw drivers should use
|
|
|
|
*
|
|
|
|
* @details This function should be used to fill in struct net_if's send pointer.
|
|
|
|
*
|
|
|
|
* @param iface A valid pointer on a network interface to send from
|
2017-04-05 14:37:44 +08:00
|
|
|
* @param pkt A valid pointer on a packet to send
|
2016-11-12 06:13:24 +08:00
|
|
|
*
|
|
|
|
* @return 0 on success, negative value otherwise
|
|
|
|
*/
|
|
|
|
extern int ieee802154_radio_send(struct net_if *iface,
|
2017-04-05 14:37:44 +08:00
|
|
|
struct net_pkt *pkt);
|
2016-11-12 06:13:24 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Radio driver ACK handling function that hw drivers should use
|
|
|
|
*
|
|
|
|
* @details ACK handling requires fast handling and thus such function
|
|
|
|
* helps to hook direcly the hw drivers to the radio driver.
|
|
|
|
*
|
|
|
|
* @param iface A valid pointer on a network interface that received the packet
|
2017-04-05 14:37:44 +08:00
|
|
|
* @param pkt A valid pointer on a packet to check
|
2016-11-12 06:13:24 +08:00
|
|
|
*
|
|
|
|
* @return NET_OK if it was handled, NET_CONTINUE otherwise
|
|
|
|
*/
|
|
|
|
extern enum net_verdict ieee802154_radio_handle_ack(struct net_if *iface,
|
2017-04-05 14:37:44 +08:00
|
|
|
struct net_pkt *pkt);
|
2016-11-12 06:13:24 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialize L2 stack for a given interface
|
|
|
|
*
|
|
|
|
* @param iface A valid pointer on a network interface
|
|
|
|
*/
|
|
|
|
void ieee802154_init(struct net_if *iface);
|
|
|
|
|
|
|
|
#endif /* __IEEE802154_RADIO_H__ */
|