Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | <:copyright-BRCM:2016:DUAL/GPL:standard |
| 3 | |
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Unless you and Broadcom execute a separate written software license |
| 8 | agreement governing use of this software, this software is licensed |
| 9 | to you under the terms of the GNU General Public License version 2 |
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 11 | with the following added to such license: |
| 12 | |
| 13 | As a special exception, the copyright holders of this software give |
| 14 | you permission to link this software with independent modules, and |
| 15 | to copy and distribute the resulting executable under terms of your |
| 16 | choice, provided that you also meet, for each linked independent |
| 17 | module, the terms and conditions of the license of that module. |
| 18 | An independent module is a module which is not derived from this |
| 19 | software. The special exception does not apply to any modifications |
| 20 | of the software. |
| 21 | |
| 22 | Not withstanding the above, under no circumstances may you combine |
| 23 | this software in any way with any other Broadcom software provided |
| 24 | under a license other than the GPL, without Broadcom's express prior |
| 25 | written consent. |
| 26 | |
| 27 | :> |
| 28 | */ |
| 29 | |
| 30 | #ifndef BCMTR_PLUGIN_H_ |
| 31 | #define BCMTR_PLUGIN_H_ |
| 32 | |
| 33 | #include <bcmolt_buf.h> |
| 34 | #include <bcmolt_msg.h> |
| 35 | |
| 36 | #include <bcmtr_interface.h> |
| 37 | #include <bcmtr_header.h> |
| 38 | |
| 39 | /** Message transport type */ |
| 40 | typedef enum |
| 41 | { |
| 42 | BCMTR_TYPE_UDP, /**< UDP transport */ |
| 43 | BCMTR_TYPE_RAW /**< Raw transport */ |
| 44 | } bcmtr_transport_type; |
| 45 | |
| 46 | /** UDP configuration */ |
| 47 | typedef struct |
| 48 | { |
| 49 | uint32_t my_ip; /**< Local IP address in host format */ |
| 50 | uint32_t remote_ip; /**< Remote IP address in host format */ |
| 51 | uint16_t my_port; /**< Local UDP port in host format. INADDR_ANY is acceptable */ |
| 52 | uint16_t remote_port; /**< Remote UDP port in host format */ |
| 53 | } bcmtr_udp_cfg; |
| 54 | |
| 55 | /** Transport configuration parameters */ |
| 56 | typedef struct |
| 57 | { |
| 58 | bcmtr_transport_type type; /**< Transport type */ |
| 59 | |
| 60 | /** Type-specific configuration */ |
| 61 | union |
| 62 | { |
| 63 | /** UDP Plugin parameters */ |
| 64 | bcmtr_udp_cfg udp; |
| 65 | |
| 66 | /* Raw task forwarder plugin parameters */ |
| 67 | struct |
| 68 | { |
| 69 | bcmtr_udp_cfg udp; /**< UDP configuration - for UDP-based raw driver */ |
| 70 | uint32_t max_txq_size; /**< Max transmit queue/pool size */ |
| 71 | bcmos_task_priority tx_pri; /**< Tx task priority */ |
| 72 | } forwarder; |
| 73 | } x; |
| 74 | |
| 75 | uint32_t headroom; /**< Additional headroom length that should be reserved for plugin use */ |
| 76 | |
| 77 | } bcmtr_plugin_cfg; |
| 78 | |
| 79 | /** Plugin channel */ |
| 80 | typedef unsigned long bcmtr_plugin_channel; |
| 81 | |
| 82 | /** Transport driver */ |
| 83 | typedef struct { |
| 84 | /** Open communication channel, establish communication */ |
| 85 | bcmos_errno (*open)(int device, bcmtr_plugin_cfg *cfg, bcmtr_plugin_channel *ch); |
| 86 | /** Close communication channel */ |
| 87 | bcmos_errno (*close)(bcmtr_plugin_channel ch); |
| 88 | /** Send data. It doesn't have to release the tx buffer, but if it does - it must |
| 89 | * clear buf->start to prevent double release */ |
| 90 | bcmos_errno (*send)(bcmtr_plugin_channel ch, bcmolt_subchannel subch, bcmolt_buf *buf, bcmtr_send_flags flags); |
| 91 | /** Receive data. It is responsible for receive buffer allocation */ |
| 92 | bcmos_errno (*recv)(bcmtr_plugin_channel ch, bcmolt_subchannel *subch, bcmolt_buf *buf); |
| 93 | } bcmtr_driver; |
| 94 | |
| 95 | /** Initialize plugin callbacks |
| 96 | * \param[in] cfg Plugin configuration |
| 97 | * \param[in,out] driver Transport plugin driver structure |
| 98 | * \return error code |
| 99 | */ |
| 100 | bcmos_errno bcmtr_plugin_init(bcmtr_plugin_cfg *cfg, bcmtr_driver *driver); |
| 101 | |
| 102 | /* UDP comm parameters */ |
| 103 | #ifdef BCMTR_UDP_SUPPORT |
| 104 | extern uint32_t bcmtr_host_ip; |
| 105 | extern uint16_t bcmtr_host_udp_port; |
| 106 | extern uint32_t bcmtr_olt_ip[BCMTR_MAX_OLTS]; |
| 107 | extern uint16_t bcmtr_olt_udp_port[BCMTR_MAX_OLTS]; |
| 108 | #endif |
| 109 | |
| 110 | void using_inband_set(bcmos_bool using_inband); |
| 111 | bcmos_bool using_inband_get(void); |
| 112 | |
| 113 | #endif /* BCMTR_PLUGIN_H_ */ |