summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcdrv/inc/plcdrv.h
blob: a72fe455d216962d87a42e9c3aca68e26ff4d055 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef inc_plcdrv_h
#define inc_plcdrv_h
/* Cleopatre project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    inc/plcdrv.h
 * \brief   Interfaces for plcdrv layer.
 * \ingroup plcdrv
 *
 * Main structure of the PLC driver module and some small modules.
 */

#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/wait.h>
#include <linux/cdev.h>
#include <linux/proc_fs.h>
#include <net/sock.h>
#include <net/seq_check.h>

#include "debug_dump.h"
#include "ipmbox.h"

#include "common/ipmbox/protocol.h"
#include "common/ipmbox/msg.h"

/** Define plc.rom informations. */
#define ROM_VERSION_SIZE 64

/**
 * TX pool size for data.
 */
#define PLCDRV_TX_POOL_DATA (IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_DATA / \
                             IPMBOX_MSG_DATA_WORDS - 1)

/**
 * RX pool size.
 */
#define PLCDRV_RX_POOL (IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_EMPTY_BUF \
                        / IPMBOX_MSG_EMPTY_BUF_WORDS - 1)

/**
 * Watchdog private context.
 */
typedef struct wd_t
{
    /** Set to 1 when WD IT triggered. */
    atomic_t expired;
    /** User space process sleeping on wait queue for WD IT triggering. */
    wait_queue_head_t wq;
} wd_t;

/**
 * PLC private stats.
 */
typedef struct plcdrv_stats_t
{
    /** No headroom in skb to FW, need to re-allocate it. */
    atomic_t skb_to_fw_no_headroom;
} plcdrv_stats_t;

/**
 * Netlink context.
 */
typedef struct netlink_t
{
    /** Socket. */
    struct sock *sock;
    /** PID. */
    uint32_t pid;
} netlink_t;

/**
 * PLC driver private data.
 */
struct plcdrv_t
{
    /** PLC driver net device. */
    struct net_device *dev;
    /** PLC driver net device stats. */
    struct net_device_stats stats;
    /** IPMbox context. */
    ipmbox_ctx_t ipmbox;
    /** NAPI context. */
    struct napi_struct napi;
    /** Data TX pool (buffers given to firmware for transmission to PLC). */
    struct sk_buff_head tx_pool_data;
    /** MME TX pool (buffers given to firmware for transmission to PLC). */
    struct sk_buff_head tx_pool_mme;
    /** RX pool (buffers waiting to be filled by firmware). */
    struct sk_buff_head rx_pool;
    /** Watchdog context. */
    wd_t wd;
    /** PLC driver stats. */
    plcdrv_stats_t plcdrv_stats;
    /** Netlink for PLCd. */
    netlink_t nl_plcd;
    /** Netlink for Managerd. */
    netlink_t nl_managerd;
    /** PLC driver character device. */
    struct cdev cdev;
    /** PLC driver trace character device. */
    struct cdev cdev_trace;
    /** PLC driver global device number. */
    dev_t dev_number;
    /** PLC driver directory in ProcFS. */
    struct proc_dir_entry *proc_dir_plc;
    /** Debug dump context. */
    debug_dump_t debug_dump;
    /** Version of PLC firmware. */
    uint8_t version[ROM_VERSION_SIZE];
#ifdef CONFIG_SEQ_CHECK
    /** Sequence check context. */
    struct seq_check_ctx seq_check_ctx;
#endif
};

#endif /* inc_plcdrv_h */