net: ieee802154_radio: Allow to specify TX mode

Even though radio driver can report in its capabilities that it does
support CSMA CA, there's no way in the driver to select how the frame
should be transmitted (with CSMA or without). As layers above radio
driver (Thread, Zigbee) can expect that both TX modes are available, we
need to extend the API to allow either of these modes.

This commits extends the API `tx` function with an extra parameter,
`ieee802154_tx_mode`, which informs the driver how the packet should be
transmitted. Currently, the following modes are specified:
* direct (regular tx, no cca, just how it worked so far),
* CCA before transmission,
* CSMA CA before transmission,
* delayed TX,
* delayed TX with CCA

Assume that radios that reported CSMA CA capability transmit in CSMA CA
mode by default, all others will support direct mode.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-02-28 13:57:49 +01:00 committed by Jukka Rissanen
commit 1fb418df4c
17 changed files with 94 additions and 17 deletions

View file

@ -36,7 +36,8 @@ enum ieee802154_hw_caps {
IEEE802154_HW_2_4_GHZ = BIT(4), /* 2.4Ghz radio supported */
IEEE802154_HW_TX_RX_ACK = BIT(5), /* Handles ACK request on TX */
IEEE802154_HW_SUB_GHZ = BIT(6), /* Sub-GHz radio supported */
IEEE802154_HW_ENERGY_SCAN = BIT(7) /* Energy scan supported */
IEEE802154_HW_ENERGY_SCAN = BIT(7), /* Energy scan supported */
IEEE802154_HW_TXTIME = BIT(8), /* TX at specified time supported */
};
enum ieee802154_filter_type {
@ -57,6 +58,24 @@ struct ieee802154_filter {
/* @endcond */
};
/** IEEE802.15.4 Transmission mode. */
enum ieee802154_tx_mode {
/** Transmit packet immediately, no CCA. */
IEEE802154_TX_MODE_DIRECT,
/** Perform CCA before packet transmission. */
IEEE802154_TX_MODE_CCA,
/** Perform full CSMA CA procedure before packet transmission. */
IEEE802154_TX_MODE_CSMA_CA,
/** Transmit packet in the future, at specified time, no CCA. */
IEEE802154_TX_MODE_TXTIME,
/** Transmit packet in the future, perform CCA before transmission. */
IEEE802154_TX_MODE_TXTIME_CCA,
};
/** IEEE802.15.4 driver configuration types. */
enum ieee802154_config_type {
/** Indicates how radio driver should set Frame Pending bit in ACK
@ -137,9 +156,8 @@ struct ieee802154_radio_api {
int (*set_txpower)(struct device *dev, s16_t dbm);
/** Transmit a packet fragment */
int (*tx)(struct device *dev,
struct net_pkt *pkt,
struct net_buf *frag);
int (*tx)(struct device *dev, enum ieee802154_tx_mode mode,
struct net_pkt *pkt, struct net_buf *frag);
/** Start the device */
int (*start)(struct device *dev);