This patch does multiple things:

 * use RX_AACK_ON instead of RX_ON by default. As a side effect of this
   change, RF212 radios will no longer receive all frames on the
   configured channel/page, but since this is forbidden by the standard
   for non-promiscuous devices and not implemented by other drivers,
   this should not be an issue.
   Set the IEEE802154_HW_AACK for the device to reflect this.
 * enable TX_ARET for frame retransmission limits greater than 0.

Signed-off-by: Phoebe Buckheister <phoebe.buckheis...@itwm.fraunhofer.de>
---
 drivers/net/ieee802154/at86rf230.c |   55 ++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c 
b/drivers/net/ieee802154/at86rf230.c
index 1addfcf..78758ce 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -53,6 +53,7 @@ struct at86rf230_local {
        spinlock_t lock;
        bool irq_busy;
        bool is_tx;
+       bool tx_aret;
 
        int rssi_base_val;
 };
@@ -571,7 +572,11 @@ at86rf230_start(struct ieee802154_dev *dev)
        if (rc)
                return rc;
 
-       return at86rf230_state(dev, STATE_RX_ON);
+       rc = at86rf230_state(dev, STATE_FORCE_TX_ON);
+       if (rc)
+               return rc;
+
+       return at86rf230_state(dev, STATE_RX_AACK_ON);
 }
 
 static void
@@ -675,6 +680,12 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff 
*skb)
        if (rc)
                goto err_rx;
 
+       if (lp->tx_aret) {
+               rc = at86rf230_write_subreg(lp, SR_TRX_CMD, STATE_TX_ARET_ON);
+               if (rc)
+                       goto err_rx;
+       }
+
        rc = at86rf230_write_subreg(lp, SR_TRX_CMD, STATE_BUSY_TX);
        if (rc)
                goto err_rx;
@@ -834,6 +845,44 @@ at86rf212_set_cca_ed_level(struct ieee802154_dev *dev, s32 
level)
        return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, desens_steps);
 }
 
+static int
+at86rf212_set_csma_params(struct ieee802154_dev *dev, u8 min_be, u8 max_be,
+                         u8 retries)
+{
+       struct at86rf230_local *lp = dev->priv;
+       int rc;
+
+       if (min_be > max_be || max_be > 8 || retries > 5)
+               return -EINVAL;
+
+       rc = at86rf230_write_subreg(lp, SR_MIN_BE, min_be);
+       if (rc)
+               return rc;
+
+       rc = at86rf230_write_subreg(lp, SR_MAX_BE, max_be);
+       if (rc)
+               return rc;
+
+       return at86rf230_write_subreg(lp, SR_MAX_CSMA_RETRIES, max_be);
+}
+
+static int
+at86rf212_set_frame_retries(struct ieee802154_dev *dev, s8 retries)
+{
+       struct at86rf230_local *lp = dev->priv;
+       int rc = 0;
+
+       if (retries < -1 || retries > 15)
+               return -EINVAL;
+
+       lp->tx_aret = retries >= 0;
+
+       if (retries >= 0)
+               rc = at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
+
+       return rc;
+}
+
 static struct ieee802154_ops at86rf230_ops = {
        .owner = THIS_MODULE,
        .xmit = at86rf230_xmit,
@@ -856,6 +905,8 @@ static struct ieee802154_ops at86rf212_ops = {
        .set_lbt = at86rf212_set_lbt,
        .set_cca_mode = at86rf212_set_cca_mode,
        .set_cca_ed_level = at86rf212_set_cca_ed_level,
+       .set_csma_params = at86rf212_set_csma_params,
+       .set_frame_retries = at86rf212_set_frame_retries,
 };
 
 static void at86rf230_irqwork(struct work_struct *work)
@@ -1088,7 +1139,7 @@ static int at86rf230_probe(struct spi_device *spi)
 
        dev->parent = &spi->dev;
        dev->extra_tx_headroom = 0;
-       dev->flags = IEEE802154_HW_OMIT_CKSUM;
+       dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
 
        if (pdata->irq_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
                irq_worker = at86rf230_irqwork;
-- 
1.7.9.5


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to