blob: 1cf6c236ad3468287d36fbb673df517abac804f8 [file] [log] [blame]
/*
* bcm_pcie_sw_queue.h
*
* Created on: 31 Jan 2017
* Author: igort
*/
#ifndef _BCM_PCIE_SW_QUEUE_H_
#define _BCM_PCIE_SW_QUEUE_H_
#include <bcmos_system.h>
#include <bcmtr_pcie.h>
/* Message priority */
typedef enum
{
BCMTR_PCIE_PRTY_URGENT = 0,
BCMTR_PCIE_PRTY_NORMAL = 1,
BCMTR_PCIE_PRTY__NUM_OF
} bcmtr_pcie_prty;
/* First urgent channel id */
#define BCMTR_SWQ_FIRST_URGENT_CHANNEL 30
/** Initialize PCI software queue module
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_init(void);
/* Cleanup software queue module
*/
void bcmtr_swq_exit(void);
/** Initialize PCI software queue module for a device
* \param[in] device Maple device index
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_device_init(uint8_t device);
/* Cleanup software queue module for a device
* \param[in] device Maple device index
*/
void bcmtr_swq_device_exit(uint8_t device);
/** Configure TX queue.
* \param[in] device Maple device index
* \param[in] prty Priority
* \param[in] hardq_size Max number of buffers that can be submitted to the h/w queue.
* 0=unlimited.
* \param[in] softq_size Max number of buffers to be queued. 0=unlimited.
* \returns: 0 in case of success or error code < 0
* BCM_ERR_OVERFLOW - max_softq_size buffer is waiting to be handling by the receiver
*/
bcmos_errno bcmtr_swq_tx_queue_cfg(uint8_t device, bcmtr_pcie_prty prty, uint32_t hardq_size, uint32_t softq_size);
/** Send buffer to the peer
* \param[in] device Maple device index
* \param[in] prty Priority
* \param[in] channel Channel id
* \param[in] buf Buffer to be transferred
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_send(uint8_t device, uint8_t channel, bcmos_buf *buf);
/** Receive packet from device
* \param[in] device Maple device index
* \param[in] prty Priority
* \param[out] channel message channel from the BD
* \param[out] buf pointer to network buffer containing the
* received packet
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_receive(uint8_t device, bcmtr_pcie_prty prty, uint8_t *channel, bcmos_buf **buf);
/** data_received callback enables callback-based receive buffer delivery
* instead of / in addition to bcmtr_swq_receive() function.
* This callback takes buffer ownership
*/
typedef void (*bcmtr_swq_rx_cb)(uint8_t device, uint8_t channel, bcmos_buf *buf);
/** Register for "data received" indication"
* \param[in] device Maple device index
* \param[in] prty Priority
* \param[in] cb Callback pointer
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_rx_cb_register(uint8_t device, bcmtr_pcie_prty prty, bcmtr_swq_rx_cb rx_cb);
/** Unregister "data received indication" callback
* \param[in] device Maple device index
* \param[in] prty Priority
* \returns: 0 in case of success or error code < 0
*/
bcmos_errno bcmtr_swq_rx_cb_unregister(uint8_t device, bcmtr_pcie_prty prty);
/** Fetch data from the hw to the sw queue.
*
* It is expected that this function should be triggered by RX interrupt
*
* \param[in] device Maple device index
* \param[out] nbuf Per priority array with number of buffers
*/
void bcmtr_swq_rx_poll(uint8_t device, uint32_t nbuf[]);
/** Submit data from the sw TX queue to the h/w
*
* It is expected that this function should be triggered by TX
* completion interrupt
*
* \param[in] device Maple device index
*/
void bcmtr_swq_tx_submit(uint8_t device);
#endif /* _BCM_PCIE_SW_QUEUE_H_ */