| /* |
| <: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_INTERNAL_H_ |
| #define BCMTR_INTERNAL_H_ |
| |
| #include <bcmos_system.h> |
| #include <bcmolt_buf.h> |
| #include <bcmolt_msg_pack.h> |
| #include <bcmtr_interface.h> |
| #include <bcmtr_plugin.h> |
| #include <bcm_config.h> |
| |
| #include "bcmtr_header.h" |
| |
| /** Transport configuration parameters */ |
| typedef struct |
| { |
| bcmtr_plugin_cfg plugin_cfg; /**< Transport plugin configuration parameters */ |
| |
| /** Limits and timeouts. |
| * If not set, the appropriate BCM_TR_default defined in bcmConfig.h is used |
| */ |
| uint32_t max_retries; /**< Max number of request retransmissions */ |
| uint32_t msg_timeout; /**< Max time to wait for response or next message part (ms) */ |
| uint32_t max_requests; /**< Max number of outstanding requests */ |
| uint32_t max_autos; /**< Max number of multi-part autonomous messages */ |
| uint32_t max_fragments; /**< Max number of multi-part message fragments */ |
| uint32_t msg_wait_timeout; /**< Message waiting timeout (ms) */ |
| uint32_t msg_ready_timeout; /**< Time that transaction is kept after notifying application that it finished (ms) */ |
| uint32_t max_mtu; /**< Max MTU size (bytes) */ |
| |
| int rx_thread_priority; /**< Receive thread priority. If set -1, Rx thread is NOT created */ |
| } bcmtr_cfg; |
| |
| /** Transport connection control block */ |
| typedef struct bcmtr_conn bcmtr_conn; |
| |
| /** Reassemble block */ |
| typedef struct bcmtr_reass |
| { |
| bcmolt_buf *fragments; /** Array of bcmtr_cfg.max_fragments */ |
| uint32_t num_fragments; /** Number of fragments filled in fragments array */ |
| uint32_t max_fragment; /** Max fragment number. Set when last fragment is received */ |
| uint32_t total_size; /** Total size of received fragments */ |
| } bcmtr_reass; |
| |
| /** Transport header list head */ |
| typedef TAILQ_HEAD(bcmtr_msg_list, bcmtr_msg) bcmtr_msg_list; |
| |
| /** Transport transaction control block */ |
| struct bcmtr_msg |
| { |
| bcmolt_buf tx_buf; /**< Transmit buffer info (request only) */ |
| bcmolt_buf rx_buf; /**< Receive buffer info (response or autonomous) */ |
| uint32_t timestamp; /**< Message timestamp. Tx or last Rx */ |
| uint16_t tx_count; /**< Number of times message was transmitted */ |
| bcmtr_hdr hdr; /**< Transport header */ |
| TAILQ_ENTRY(bcmtr_msg) l; /**< Transport message list entry */ |
| bcmtr_reass *segm; /**< Segmentation block */ |
| bcmtr_reass *reass; /**< Reassemble block */ |
| bcmolt_msg *msg; /**< Message reference */ |
| bcmolt_subchannel subch; /**< Sub-channel via which message was received */ |
| bcmos_errno err; /**< Transport status */ |
| |
| /* Transport header is cleared up to this point when released. |
| * "err" field is the last in the section that gets cleared. |
| * Do not move fields below above "err"! |
| */ |
| #define BCMTR_HDR_CLEAR_SIZE (offsetof(bcmtr_msg, err) + sizeof(bcmos_errno)) |
| bcmtr_msg_list *free_list; /**< Free list head reference */ |
| bcmtr_conn *conn; /**< Connection back reference */ |
| bcmos_sem sem; /**< "wait for response" semaphore */ |
| bcmos_msg ipc_hdr; /**< IPC message header */ |
| }; |
| |
| /** Message handler context */ |
| typedef struct bcmtr_handler |
| { |
| f_bcmolt_msg_handler app_cb; /**< Application callback function */ |
| bcmolt_auto_flags flags; /**< Registration flag: call in context of transport rx thread or app module */ |
| bcmos_module_id module; /**< Optional module to dispatch received message to */ |
| } bcmtr_handler; |
| |
| /** Transport connection control block */ |
| struct bcmtr_conn |
| { |
| char name[16]; /**< Transport name */ |
| bcmolt_devid device; /**< Device index */ |
| bcmtr_channel_id channel; /**< Channels served by this transport */ |
| bcmtr_cfg cfg; /**< Transport configuration parameters */ |
| bcmtr_driver driver; /**< Transport driver */ |
| bcmtr_plugin_channel drv_priv; /**< Plugin driver private data */ |
| bcmos_task rx_thread; /**< RX thread handle */ |
| bcmos_mutex mutex; /**< Mutex protecting the transport structure */ |
| uint32_t last_timeout_check; /**< Last timeout check timestamp */ |
| uint32_t timeout_check_period; /**< Time-out check period */ |
| bcmtr_msg_list msg_list; /**< Message list head */ |
| bcmtr_msg_list free_req_list; /**< Free request block list */ |
| bcmtr_msg_list free_auto_list; /**< Free autonomous block list */ |
| bcmtr_msg *tmsg_array; /**< Pre-allocated array of transport headers */ |
| bcmtr_stat stat; /**< Statistics */ |
| bcmos_bool connected; /**< Transport state */ |
| uint16_t num_requests; /**< Number of outstanding requests */ |
| uint16_t num_auto; /**< Number of autonomous messages being reassembled */ |
| uint16_t corr_tag; /**< Last used correlation tag */ |
| bcmos_bool rx_thread_created; /**< TRUE=RX thread was created */ |
| int kill_request; /**< Transport thread is commanded to die */ |
| int kill_done; /**< Transport thread is dead */ |
| }; |
| |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| bcmos_errno bcmtr_cfg_get(bcmolt_devid device, bcmtr_cfg *cfg, bcmtr_driver *driver); |
| |
| bcmos_errno _bcmtr_conn_get(bcmolt_devid device, bcmtr_conn **conn); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* BCMTR_INTERNAL_H_ */ |