blob: 1cf6c236ad3468287d36fbb673df517abac804f8 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2 * bcm_pcie_sw_queue.h
3 *
4 * Created on: 31 Jan 2017
5 * Author: igort
6 */
7
8#ifndef _BCM_PCIE_SW_QUEUE_H_
9#define _BCM_PCIE_SW_QUEUE_H_
10
11#include <bcmos_system.h>
12#include <bcmtr_pcie.h>
13
14/* Message priority */
15typedef enum
16{
17 BCMTR_PCIE_PRTY_URGENT = 0,
18 BCMTR_PCIE_PRTY_NORMAL = 1,
19
20 BCMTR_PCIE_PRTY__NUM_OF
21} bcmtr_pcie_prty;
22
23/* First urgent channel id */
24#define BCMTR_SWQ_FIRST_URGENT_CHANNEL 30
25
26/** Initialize PCI software queue module
27 * \returns: 0 in case of success or error code < 0
28 */
29bcmos_errno bcmtr_swq_init(void);
30
31/* Cleanup software queue module
32 */
33void bcmtr_swq_exit(void);
34
35/** Initialize PCI software queue module for a device
36 * \param[in] device Maple device index
37 * \returns: 0 in case of success or error code < 0
38 */
39bcmos_errno bcmtr_swq_device_init(uint8_t device);
40
41/* Cleanup software queue module for a device
42 * \param[in] device Maple device index
43 */
44void bcmtr_swq_device_exit(uint8_t device);
45
46/** Configure TX queue.
47 * \param[in] device Maple device index
48 * \param[in] prty Priority
49 * \param[in] hardq_size Max number of buffers that can be submitted to the h/w queue.
50 * 0=unlimited.
51 * \param[in] softq_size Max number of buffers to be queued. 0=unlimited.
52 * \returns: 0 in case of success or error code < 0
53 * BCM_ERR_OVERFLOW - max_softq_size buffer is waiting to be handling by the receiver
54 */
55bcmos_errno bcmtr_swq_tx_queue_cfg(uint8_t device, bcmtr_pcie_prty prty, uint32_t hardq_size, uint32_t softq_size);
56
57/** Send buffer to the peer
58 * \param[in] device Maple device index
59 * \param[in] prty Priority
60 * \param[in] channel Channel id
61 * \param[in] buf Buffer to be transferred
62 * \returns: 0 in case of success or error code < 0
63 */
64bcmos_errno bcmtr_swq_send(uint8_t device, uint8_t channel, bcmos_buf *buf);
65
66/** Receive packet from device
67 * \param[in] device Maple device index
68 * \param[in] prty Priority
69 * \param[out] channel message channel from the BD
70 * \param[out] buf pointer to network buffer containing the
71 * received packet
72 * \returns: 0 in case of success or error code < 0
73 */
74bcmos_errno bcmtr_swq_receive(uint8_t device, bcmtr_pcie_prty prty, uint8_t *channel, bcmos_buf **buf);
75
76/** data_received callback enables callback-based receive buffer delivery
77 * instead of / in addition to bcmtr_swq_receive() function.
78 * This callback takes buffer ownership
79 */
80typedef void (*bcmtr_swq_rx_cb)(uint8_t device, uint8_t channel, bcmos_buf *buf);
81
82/** Register for "data received" indication"
83 * \param[in] device Maple device index
84 * \param[in] prty Priority
85 * \param[in] cb Callback pointer
86 * \returns: 0 in case of success or error code < 0
87 */
88bcmos_errno bcmtr_swq_rx_cb_register(uint8_t device, bcmtr_pcie_prty prty, bcmtr_swq_rx_cb rx_cb);
89
90/** Unregister "data received indication" callback
91 * \param[in] device Maple device index
92 * \param[in] prty Priority
93 * \returns: 0 in case of success or error code < 0
94 */
95bcmos_errno bcmtr_swq_rx_cb_unregister(uint8_t device, bcmtr_pcie_prty prty);
96
97/** Fetch data from the hw to the sw queue.
98 *
99 * It is expected that this function should be triggered by RX interrupt
100 *
101 * \param[in] device Maple device index
102 * \param[out] nbuf Per priority array with number of buffers
103 */
104void bcmtr_swq_rx_poll(uint8_t device, uint32_t nbuf[]);
105
106/** Submit data from the sw TX queue to the h/w
107 *
108 * It is expected that this function should be triggered by TX
109 * completion interrupt
110 *
111 * \param[in] device Maple device index
112 */
113void bcmtr_swq_tx_submit(uint8_t device);
114
115#endif /* _BCM_PCIE_SW_QUEUE_H_ */