blob: 82d3dd24fb37ba4f8550129375a933759b270282 [file] [log] [blame]
/*
<:copyright-BRCM:2016:DUAL/GPL:standard
Broadcom Proprietary and Confidential.(c) 2016 Broadcom
All Rights Reserved
Unless you and Broadcom execute a separate written software license
agreement governing use of this software, this software is licensed
to you under the terms of the GNU General Public License version 2
(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
with the following added to such license:
As a special exception, the copyright holders of this software give
you permission to link this software with independent modules, and
to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent
module, the terms and conditions of the license of that module.
An independent module is a module which is not derived from this
software. The special exception does not apply to any modifications
of the software.
Not withstanding the above, under no circumstances may you combine
this software in any way with any other Broadcom software provided
under a license other than the GPL, without Broadcom's express prior
written consent.
:>
*/
#ifndef BCMTR_PLUGIN_H_
#define BCMTR_PLUGIN_H_
#include <bcmolt_buf.h>
#include <bcmolt_msg.h>
#include <bcmtr_interface.h>
#include <bcmtr_header.h>
/** Message transport type */
typedef enum
{
BCMTR_TYPE_UDP, /**< UDP transport */
BCMTR_TYPE_RAW /**< Raw transport */
} bcmtr_transport_type;
/** UDP configuration */
typedef struct
{
uint32_t my_ip; /**< Local IP address in host format */
uint32_t remote_ip; /**< Remote IP address in host format */
uint16_t my_port; /**< Local UDP port in host format. INADDR_ANY is acceptable */
uint16_t remote_port; /**< Remote UDP port in host format */
} bcmtr_udp_cfg;
/** Transport configuration parameters */
typedef struct
{
bcmtr_transport_type type; /**< Transport type */
/** Type-specific configuration */
union
{
/** UDP Plugin parameters */
bcmtr_udp_cfg udp;
/* Raw task forwarder plugin parameters */
struct
{
bcmtr_udp_cfg udp; /**< UDP configuration - for UDP-based raw driver */
uint32_t max_txq_size; /**< Max transmit queue/pool size */
bcmos_task_priority tx_pri; /**< Tx task priority */
} forwarder;
} x;
uint32_t headroom; /**< Additional headroom length that should be reserved for plugin use */
} bcmtr_plugin_cfg;
/** Plugin channel */
typedef unsigned long bcmtr_plugin_channel;
/** Transport driver */
typedef struct {
/** Open communication channel, establish communication */
bcmos_errno (*open)(int device, bcmtr_plugin_cfg *cfg, bcmtr_plugin_channel *ch);
/** Close communication channel */
bcmos_errno (*close)(bcmtr_plugin_channel ch);
/** Send data. It doesn't have to release the tx buffer, but if it does - it must
* clear buf->start to prevent double release */
bcmos_errno (*send)(bcmtr_plugin_channel ch, bcmolt_subchannel subch, bcmolt_buf *buf, bcmtr_send_flags flags);
/** Receive data. It is responsible for receive buffer allocation */
bcmos_errno (*recv)(bcmtr_plugin_channel ch, bcmolt_subchannel *subch, bcmolt_buf *buf);
} bcmtr_driver;
/** Initialize plugin callbacks
* \param[in] cfg Plugin configuration
* \param[in,out] driver Transport plugin driver structure
* \return error code
*/
bcmos_errno bcmtr_plugin_init(bcmtr_plugin_cfg *cfg, bcmtr_driver *driver);
/* UDP comm parameters */
#ifdef BCMTR_UDP_SUPPORT
extern uint32_t bcmtr_host_ip;
extern uint16_t bcmtr_host_udp_port;
extern uint32_t bcmtr_olt_ip[BCMTR_MAX_OLTS];
extern uint16_t bcmtr_olt_udp_port[BCMTR_MAX_OLTS];
#endif
void using_inband_set(bcmos_bool using_inband);
bcmos_bool using_inband_get(void);
#endif /* BCMTR_PLUGIN_H_ */