#ifndef inc_frame_h #define inc_frame_h /* Cleopatre project {{{ * * Copyright (C) 2012 Spidcom * * <<>> * * }}} */ /** * \file inc/frame.h * \brief Interfaces to send/receive/alloc/free frames for firmware. * \ingroup plcdrv */ #include #include #include #include #include #include #include "plcdrv.h" /** * Max size of an Ethernet frame with double VLAN (size for all buffers). * It must be align on 4 bytes (for Cesar). */ #define PKT_BUF_SZ ALIGN (ETH_FRAME_LEN + 2 * VLAN_HLEN, 4) /** * Allocate buffers and give them to firmware. * \param priv PLC device private context * \return true if all buffers have been allocated, false otherwise */ bool frame_buffer_alloc (plcdrv_t *priv); /** * Free a buffer after being used by firmware. * \param priv PLC device private context * \param buffer buffer to release (physical address) */ void frame_buffer_free (plcdrv_t *priv, uint32_t buffer); /** * Resume device queue if possible. * \param priv PLC device private context */ static inline void frame_wake_queue (plcdrv_t *priv) { if (skb_queue_len (&priv->tx_pool_data) < PLCDRV_TX_POOL_DATA) netif_wake_queue (priv->dev); } /** * Handle a data buffer from firmware. * \param priv PLC device private context * \param data_addr data physical address * \param data_length data length in byte */ void frame_rx_data (plcdrv_t *priv, uint32_t data_addr, uint32_t data_length); /** * Handle a private MME buffer from firmware. * \param priv PLC device private context * \param data_addr data physical address * \param data_length data length in byte */ void frame_rx_mme_priv (plcdrv_t *priv, uint32_t data_addr, uint32_t data_length); /** * Handle a debug dump buffer from firmware. * \param priv PLC device private context * \param data_addr data physical address * \param data_length data length in byte */ void frame_rx_debug_dump (plcdrv_t *priv, uint32_t data_addr, uint32_t data_length); /** * Transmit a data frame to firmware. * \param skb frame structure * \param dev device structure * \return error code */ int frame_tx_data (struct sk_buff *skb, struct net_device *dev); /** * Transmit a private MME frame to firmware. * \param priv PLC device private context * \param skb frame structure */ void frame_tx_mbx_mme_priv (plcdrv_t *priv, struct sk_buff *skb); /** * Transmit a debug dump buffer to firmware. * \param priv PLC device private context * \param buffer debug dump virtual address * \param length debug dump buffer length */ void frame_tx_mbx_debug_dump (plcdrv_t *priv, uint32_t *buffer, unsigned int length); #endif /* inc_frame_h */