Date:2011-09-25 11:58:49 (11 years 10 days ago)
Author:Stefan Schmidt
Commit:d8f39e8418e18f9fe0d595aba440e6ea63135164
Message:ieee802154/at86rf230.c: Prepare driver for auto ACK support

Implement the filter function to update short address, pan id and ieee
address on change. Allowing for hardware address filtering needed for
auto ACK. Switch state machine to use auto ACK states for rx.

Currently wrapped in ugly ifdef's until automatic re-transmit is also in place.
Testing for auto ACK showed no problems so far.

Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
Files: drivers/ieee802154/at86rf230.c (7 diffs)

Change Details

drivers/ieee802154/at86rf230.c
3939
4040#include "at86rf230.h"
4141
42//#define ENABLE_AACK
4243
4344struct at86rf230_local {
4445    struct spi_device *spi;
...... 
322323
323324    if (val == desired_status)
324325        return 0;
326#ifdef ENABLE_AACK
327    if (state == STATE_RX_AACK_ON && val == STATE_BUSY_RX_AACK)
328#else
325329    if (state == STATE_RX_ON && val == STATE_BUSY_RX)
330#endif
326331        return 0;
327332
328333    pr_err("%s unexpected state change: %d, asked for %d\n", __func__,
...... 
343348    rc = at86rf230_write_subreg(lp, SR_RX_SAFE_MODE, 1);
344349    if (rc)
345350        return rc;
351#ifdef ENABLE_AACK
352    return at86rf230_state(dev, STATE_RX_AACK_ON);
353#else
346354    return at86rf230_state(dev, STATE_RX_ON);
355#endif
347356}
348357
349358static void
...... 
478487    return -EINVAL;
479488}
480489
490#ifdef ENABLE_AACK
491static int
492at86rf230_set_hw_addr_filt(struct ieee802154_dev *dev,
493                        struct ieee802154_hw_addr_filt *filt,
494                        unsigned long changed)
495{
496    struct at86rf230_local *lp = dev->priv;
497
498    might_sleep();
499
500    at86rf230_stop(dev);
501
502    msleep(10);
503
504    if (changed & IEEE802515_SADDR_CHANGED) {
505        dev_info(&lp->spi->dev, "at86rf230_set_hw_addr_filt called for saddr\n");
506        __at86rf230_write(lp, RG_SHORT_ADDR_0, filt->short_addr & 0xff); /* LSB */
507        __at86rf230_write(lp, RG_SHORT_ADDR_1, (filt->short_addr >> 8) & 0xff); /* MSB */
508    }
509
510    if (changed & IEEE802515_PANID_CHANGED) {
511        dev_info(&lp->spi->dev, "at86rf230_set_hw_addr_filt called for pan id\n");
512        __at86rf230_write(lp, RG_PAN_ID_0, filt->pan_id & 0xff); /* LSB */
513        __at86rf230_write(lp, RG_PAN_ID_1, (filt->pan_id >> 8) & 0xff); /* MSB */
514    }
515
516    if (changed & IEEE802515_IEEEADDR_CHANGED) {
517        dev_info(&lp->spi->dev, "at86rf230_set_hw_addr_filt called ieee addr\n");
518        // Make sure order MSB to LSB is correct
519        at86rf230_write_subreg(lp, SR_IEEE_ADDR_0, filt->ieee_addr[7]);
520        at86rf230_write_subreg(lp, SR_IEEE_ADDR_1, filt->ieee_addr[6]);
521        at86rf230_write_subreg(lp, SR_IEEE_ADDR_2, filt->ieee_addr[5]);
522        at86rf230_write_subreg(lp, SR_IEEE_ADDR_3, filt->ieee_addr[4]);
523        at86rf230_write_subreg(lp, SR_IEEE_ADDR_4, filt->ieee_addr[3]);
524        at86rf230_write_subreg(lp, SR_IEEE_ADDR_5, filt->ieee_addr[2]);
525        at86rf230_write_subreg(lp, SR_IEEE_ADDR_6, filt->ieee_addr[1]);
526        at86rf230_write_subreg(lp, SR_IEEE_ADDR_7, filt->ieee_addr[0]);
527    }
528
529    if (changed & IEEE802515_PANC_CHANGED) {
530        dev_info(&lp->spi->dev, "at86rf230_set_hw_addr_filt called panc change\n");
531        if (filt->pan_coord)
532            at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
533        else
534            at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 0);
535    }
536
537    at86rf230_start(dev);
538
539    return 0;
540}
541#endif
481542static struct ieee802154_ops at86rf230_ops = {
482543    .owner = THIS_MODULE,
483544    .xmit = at86rf230_xmit,
...... 
485546    .set_channel = at86rf230_channel,
486547    .start = at86rf230_start,
487548    .stop = at86rf230_stop,
549#ifdef ENABLE_AACK
550    .set_hw_addr_filt = at86rf230_set_hw_addr_filt,
551#endif
488552};
489553
490554static void at86rf230_irqwork(struct work_struct *work)
...... 
531595    return IRQ_HANDLED;
532596}
533597
534
535598static int at86rf230_hw_init(struct at86rf230_local *lp)
536599{
537600    u8 status;
...... 
694757    dev->extra_tx_headroom = 0;
695758    /* We do support only 2.4 Ghz */
696759    dev->phy->channels_supported[0] = 0x7FFF800;
760#ifdef ENABLE_AACK
761    dev->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK;
762#else
697763    dev->flags = IEEE802154_HW_OMIT_CKSUM;
764#endif
698765
699766    mutex_init(&lp->bmux);
700767    INIT_WORK(&lp->irqwork, at86rf230_irqwork);

Archive Download the corresponding diff file



interactive