summaryrefslogtreecommitdiff
path: root/cesar/mac/common/pb.h
blob: c8339ed69e43f199e2cde58219017f7fc7911859 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef mac_common_pb_h
#define mac_common_pb_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    mac/common/pb.h
 * \brief   MAC PB descriptor.
 * \ingroup mac_common
 *
 * The MAC PB descriptor includes the HAL Phy one and extend it with MAC
 * informations.  The current aim is to make it fit in 16 bytes.
 */
#include "hal/phy/pbdma.h"

/** PB header. */
struct pb_header_t
{
    BITFIELDS_WORD(
    /** Segment sequence number. */
    uint ssn:16;,
    /** MAC frame boundary offset. */
    uint mfbo:9;,
    /** Valid PB flag. */
    bool vpbf:1;,
    /** Management message queue flag. */
    bool mmqf:1;,
    /** MAC frame boundary flag. */
    bool mfbf:1;,
    /** Oldest pending segment flag.
     * Updated by pbproc for TX. */
    bool opsf:1;,
    /** Indicated if the PB has been encrypted (In the rsvd fields) */
    uint spc_encrypted:1;,
    /** Reserved. */
    uint rsvd:2;)
};
typedef struct pb_header_t pb_header_t;

/** MAC PB descriptor. */
union pb_t
{
    /** Common block descriptor. */
    blk_t blk;
    /** Hardware descriptor. */
    phy_pb_t phy_pb;
    struct
    {
        /** Pointer to next descriptor. */
        union pb_t *next;
        /** Pointer to data. */
        u8 *data;
        /** PB header. */
        pb_header_t header;
        /** Expiration date. */
        u32 expiration_ntb;
    };
};
typedef union pb_t pb_t;

/** Derive PB pointer from blk pointer. */
#define PB_FROM_BLK(blkp) PARENT_OF (pb_t, blk, (blkp))

/** Beacon PB descriptor. */
union pb_beacon_t
{
    /** Common block descriptor. */
    blk_t blk;
    /** Hardware descriptor. */
    phy_pb_t phy_pb;
    struct
    {
        /** Pointer to next descriptor. */
        union pb_t *next;
        /** Pointer to data. */
        u8 *data;
        /** First four bytes of the beacon payload. */
        u32 first_data_word;
    };
};
typedef union pb_beacon_t pb_beacon_t;

#endif /* mac_common_pb_h */