summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcdrv/inc/linux_drv.h
diff options
context:
space:
mode:
authorCyril Jourdan2011-12-09 14:52:11 +0100
committerNicolas Schodet2012-02-10 15:33:49 +0100
commit89328e8cc096f8c9f340a3eb8910d06748a3e572 (patch)
treebc38232bc82f639a80b917d739740b3d9608c03e /cleopatre/devkit/plcdrv/inc/linux_drv.h
parentc0199c330baadc6a8089a1db26b3ec7f76734b2b (diff)
cleo/devkit/plcdrv: remove gidel and move arm dir content to plcdrv, refs #848
Diffstat (limited to 'cleopatre/devkit/plcdrv/inc/linux_drv.h')
-rw-r--r--cleopatre/devkit/plcdrv/inc/linux_drv.h200
1 files changed, 200 insertions, 0 deletions
diff --git a/cleopatre/devkit/plcdrv/inc/linux_drv.h b/cleopatre/devkit/plcdrv/inc/linux_drv.h
new file mode 100644
index 0000000000..71f541a0ad
--- /dev/null
+++ b/cleopatre/devkit/plcdrv/inc/linux_drv.h
@@ -0,0 +1,200 @@
+#ifndef linux_drv_h
+#define linux_drv_h
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file linux_drv.h
+ * \brief interfaces for linux_drv layer
+ * \ingroup Cleopatre - PlcDrv
+ *
+ * this file content interfaces and exported macros, variables... For the
+ * linux_drv layer
+ */
+
+#ifndef __UTESTS__
+#include <linux/netdevice.h>
+#include <net/seq_check.h>
+#else
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
+#include <linux/netdevice.h>
+#endif
+
+#include "common.h"
+#include "hal.h"
+
+/** */
+enum pkt_dest {
+ OTHER = 0,
+ NETLINK_DRV = 1,
+ NETLINK_MME = 2,
+};
+
+/** why do you want to free the buffer */
+enum free_reason {
+ RX_DROP = 0,
+ TX_DROP = 1,
+ TX_COMPLETE = 2,
+};
+
+/** Data direction. */
+enum data_direction {
+ DATA_TO_FW = DMA_TO_DEVICE,
+ DATA_FROM_FW = DMA_FROM_DEVICE,
+ DATA_BIDIR = DMA_BIDIRECTIONAL,
+};
+
+/** Define plc.rom informations */
+#define ROM_INFO_DELIMITER '\n'
+#define ROM_INFO_KEY_DELIMITER ':'
+#define ROM_INFO_MAX_SIZE 1024
+#define ROM_VERSION_SIZE 64
+#define ROM_VERSION_KEY "version"
+
+/** PLC private stats */
+struct plc_stats {
+ uint32_t tx_pool; // number of allocated skbuff for Tx
+ uint32_t rx_pool; // number of allocated skbuff for Rx
+};
+
+/** Select function private data */
+struct plc_select
+{
+ atomic_t plc_error;
+ wait_queue_head_t wq;
+};
+
+/** Driver private data */
+struct net_priv
+{
+ struct plc_select plc_select;
+ uint32_t num_mbx_it;
+ uint32_t num_mbx_it_ack;
+ uint32_t num_mbx_it_wd;
+ uint32_t phys_ring_base_addr;
+ uint32_t virt_ring_base_addr;
+ spinlock_t lock;
+ struct list_head list_head_skbs;
+ struct net_device_stats stats;
+ struct plc_stats plc_stats;
+ struct tasklet_struct tasklet_it_rx;
+ struct halctx *halctx;
+ struct sock *nl_drv_sock;
+ struct sock *nl_mme_sock;
+ uint32_t nl_drv_pid;
+ uint32_t nl_mme_pid;
+ uint8_t firmware_written;
+ uint8_t version[ROM_VERSION_SIZE];
+
+#ifdef CONFIG_SEQ_CHECK
+ struct seq_check_ctx seq_check_ctx;
+#endif
+};
+
+/**
+ * Debug dump buffer length of the buffer received from Cesar by the mailbox.
+ * Set to -1 at initialization and to 0 when there is nothing more to read
+ * from Cesar.
+ */
+extern int debug_dump_buffer_length_received;
+/**
+ * Debug dump buffer location.
+ * When debug dump buffer has been sent to Cesar, this variable is set to
+ * true, otherwise, this is set to false.
+ */
+extern bool debug_dump_waiting_for_buffer;
+/**
+ * Debug dump buffer length allocated by Cleopatra.
+ */
+extern const uint debug_dump_buffer_length;
+/**
+ * Debug dump wait queue shared between the mailbox received and the read
+ * proc from the kernel.
+ */
+extern wait_queue_head_t debug_dump_wait_queue;
+
+/**
+ * Receive a packet.
+ *
+ * \param packet packet pointer.
+ * \param length packet length.
+ * \param dest packet destination.
+ * \return error code.
+ */
+int plcdrv_rx(void *packet, int length, enum pkt_dest dst);
+
+/**
+ * Release a buffer.
+ *
+ * \param packet packet pointer.
+ * \param reason freeing reason.
+ * \return error code.
+ */
+int free_buffer(void *packet, enum free_reason reason);
+
+/**
+ * Allocate a buffer to the pool
+ * and send to the communication layer.
+ *
+ * \param type type of buffer to allocate.
+ * \return error code.
+ */
+int alloc_buffer(enum buffer_type type);
+
+/**
+ * Allocate a debug dump buffer for CESAR and return its.
+ *
+ * \param debug_dump_buffer the debug dump buffer to allocate
+ * \param debug_dump_buffer_length the length of the debug dump buffer
+ * \return error code
+ *
+ * \note the address returned is a virtual one, not a physical one: you need
+ * to convert it before using it.
+ */
+int alloc_debug_dump_buffer(void **debug_dump_buffer,
+ int debug_dump_buffer_length);
+
+/**
+ * Free a debug dump buffer.
+ *
+ * \param debug_dump_buffer the debug dump buffer to free
+ * \param debug_dump_buffer_length the length of the debug dump buffer
+ *
+ * \note the address of debug_dump_buffer should be a virtual one.
+ */
+void free_debug_dump_buffer(void *debug_dump_buffer,
+ int debug_dump_buffer_length);
+
+/**
+ * Changed a virtual address to its corresponding physical address
+ * and manage the cache.
+ *
+ * \param addr buffer virtual address.
+ * \param len buffer length.
+ * \param data_dir data direction.
+ * \return buffer physical address.
+ */
+uint32_t prepare_buffer_to_hw(uint32_t addr, unsigned int len,
+ enum data_direction data_dir);
+
+/**
+ * Changed a physical address to its corresponding virtual address
+ * and manage the cache.
+ *
+ * \param addr buffer physical address.
+ * \param len buffer length.
+ * \param data_dir data direction.
+ * \return buffer virtual address.
+ */
+uint32_t prepare_buffer_from_hw(uint32_t addr, unsigned int len,
+ enum data_direction data_dir);
+
+#endif /* linux_drv_h */
+