BAL and Maple Release 2.2

Signed-off-by: Shad Ansari <developer@Carbon.local>
diff --git a/bcm68620_release/release/host_driver/api/Makefile b/bcm68620_release/release/host_driver/api/Makefile
new file mode 100644
index 0000000..fc035d1
--- /dev/null
+++ b/bcm68620_release/release/host_driver/api/Makefile
@@ -0,0 +1,13 @@
+# Common API
+#
+MOD_NAME = common_api
+MOD_TYPE = lib
+MOD_DEPS = utils dev_log
+
+srcs = bcmolt_msg.c
+
+MOD_INC_DIRS = $(SRC_DIR) $(MODEL_OUT_DIR)
+ifeq ("$(RELEASE_BUILD)", "y")
+    MOD_INC_DIRS += $(SRC_DIR)/../transport
+    srcs += bcmolt_api.c
+endif
diff --git a/bcm68620_release/release/host_driver/api/bcmolt_api.c b/bcm68620_release/release/host_driver/api/bcmolt_api.c
new file mode 100644
index 0000000..f15f7e5
--- /dev/null
+++ b/bcm68620_release/release/host_driver/api/bcmolt_api.c
@@ -0,0 +1,291 @@
+/*
+<: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.
+
+:>
+ */
+
+#include <bcmtr_interface.h>
+#include "bcmolt_api.h"
+#include "bcmolt_msg_pack.h"
+
+system_mode_change_cb sm_change_cb;
+
+/** Set configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_cfg_set(bcmolt_devid dev, bcmolt_cfg *cfg)
+{
+    bcmos_errno err;
+    bcmolt_presence_mask ro_mask;
+
+    cfg->hdr.type = BCMOLT_MSG_TYPE_SET;
+    /* Make sure that no attemp is made to set read-only property */
+    err = bcmolt_get_prop_readonly_mask(cfg->hdr.obj_type, &ro_mask);
+    if (err)
+    {
+        return err;
+    }
+    if ((ro_mask & cfg->hdr.presence_mask))
+    {
+        cfg->hdr.dir = BCMOLT_MSG_DIR_RESPONSE;
+        cfg->hdr.err = BCM_ERR_READ_ONLY;
+        strncpy(cfg->hdr.err_text, "Read-only fields cannot be set", BCMOLT_MAX_ERR_TEXT_LENGTH);
+        return cfg->hdr.err;
+    }
+    err = bcmtr_call(dev, &cfg->hdr);
+    if ((cfg->hdr.err == BCM_ERR_OK) &&
+        (cfg->hdr.obj_type == BCMOLT_OBJ_ID_DEVICE) &&
+        (BCMOLT_CFG_PROP_IS_SET((bcmolt_device_cfg*)cfg, device, system_mode)))
+    {
+        bcmolt_system_mode_set(dev, ((bcmolt_device_cfg*)cfg)->data.system_mode);
+        if (NULL != sm_change_cb)
+        {
+            sm_change_cb(dev);
+        }
+    }
+    return err;
+}
+
+/** Get configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_cfg_get(bcmolt_devid dev, bcmolt_cfg *cfg)
+{
+    cfg->hdr.type = BCMOLT_MSG_TYPE_GET;
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Clear configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_cfg_clear(bcmolt_devid dev, bcmolt_cfg *cfg)
+{
+    cfg->hdr.presence_mask = BCMOLT_PRESENCE_MASK_ALL; /* clear is always object-wide */
+    cfg->hdr.type = BCMOLT_MSG_TYPE_CLEAR;
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Get statistics
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   stat    Configuration
+ * \param[in]   flags   Flags
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_get(bcmolt_devid dev, bcmolt_stat *stat, bcmolt_stat_flags flags)
+{
+    stat->hdr.type = BCMOLT_MSG_TYPE_GET;
+    if ((flags & BCMOLT_STAT_FLAGS_CLEAR_ON_READ))
+    {
+        stat->hdr.type |= BCMOLT_MSG_TYPE_CLEAR;
+    }
+    return bcmtr_call(dev, &stat->hdr);
+}
+
+/** Get statistics configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_cfg_get(bcmolt_devid dev, bcmolt_stat_cfg *cfg)
+{
+    cfg->hdr.type = BCMOLT_MSG_TYPE_GET;
+    cfg->hdr.presence_mask = BCMOLT_PRESENCE_MASK_ALL;
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Set statistics configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_cfg_set(bcmolt_devid dev, bcmolt_stat_cfg *cfg)
+{
+    cfg->hdr.type = BCMOLT_MSG_TYPE_SET;
+    cfg->hdr.presence_mask = BCMOLT_PRESENCE_MASK_ALL;
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Get indication configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_auto_cfg_get(bcmolt_devid dev, bcmolt_auto_cfg *cfg)
+{
+    cfg->hdr.type = BCMOLT_MSG_TYPE_GET;
+    if (cfg->hdr.presence_mask == 0)
+    {
+        cfg->hdr.presence_mask = BCMOLT_PRESENCE_MASK_ALL;
+    }
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Set indication configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_auto_cfg_set(bcmolt_devid dev, bcmolt_auto_cfg *cfg)
+{
+    cfg->hdr.type = BCMOLT_MSG_TYPE_SET;
+    return bcmtr_call(dev, &cfg->hdr);
+}
+
+/** Invoke operation
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   oper    Operation
+ * \returns error code
+ */
+bcmos_errno bcmolt_oper_submit(bcmolt_devid dev, bcmolt_oper *oper)
+{
+    oper->hdr.type = BCMOLT_MSG_TYPE_SET;
+    return bcmtr_call(dev, &oper->hdr);
+}
+
+/** Send message to ONU
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   msg     Message to be sent
+ * \returns error code
+ */
+bcmos_errno bcmolt_proxy_send(bcmolt_devid dev, bcmolt_proxy *msg)
+{
+    msg->hdr.type = BCMOLT_MSG_TYPE_SET;
+    return bcmtr_call(dev, &msg->hdr);
+}
+
+
+/* (Un)Register auto/proxy message */
+static bcmos_errno bcmolt_rx_cb_set(bcmolt_devid device, bcmolt_mgt_group group, bcmolt_rx_cfg *rx_cfg)
+{
+    bcmtr_handler_parm tparm = {
+        .group = group,
+        .subgroup = BCMOLT_SUBGROUP_ANY,
+    };
+    bcmos_errno rc = BCM_ERR_OK;
+    int i;
+
+    if (!rx_cfg)
+        return BCM_ERR_PARM;
+
+    tparm.object = rx_cfg->obj_type;
+    tparm.app_cb = rx_cfg->rx_cb;
+    tparm.flags = rx_cfg->flags;
+    if (rx_cfg->flags == BCMOLT_AUTO_FLAGS_DISPATCH)
+        tparm.module = rx_cfg->module;
+
+    for (i = 0; i < BCMTR_MAX_INSTANCES && !rc; i++)
+    {
+        /* Skip interfaces that are not present in the default mask */
+        if (rx_cfg->pon_ni_mask && 0 == (rx_cfg->pon_ni_mask & (1 << i)))
+            continue;
+
+        tparm.instance = i;
+        if (rx_cfg->rx_cb)
+        {
+            /* If registration of specific object - unregister the old handler first */
+            if (rx_cfg->obj_type != BCMOLT_OBJECT_ANY)
+                bcmtr_msg_handler_unregister(device, &tparm);
+            rc = bcmtr_msg_handler_register(device, &tparm);
+        }
+        else
+        {
+            rc = bcmtr_msg_handler_unregister(device, &tparm);
+        }
+    }
+    return rc;
+}
+
+/* (Un)Register autonomous indication message handler
+ *
+ * \param[in]   dev             Device id
+ * \param[in]   rx_cfg          Receive handler configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_auto_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg)
+{
+    return bcmolt_rx_cb_set(device, BCMOLT_MGT_GROUP_AUTO, rx_cfg);
+}
+
+/* (Un)Register proxy message handler
+ *
+ * \param[in]   dev             Device id
+ * \param[in]   rx_cfg          Receive handler configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_proxy_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg)
+{
+    return bcmolt_rx_cb_set(device, BCMOLT_MGT_GROUP_PROXY_RX, rx_cfg);
+}
+
+/* Get configuration of multiple objects */
+bcmos_errno bcmolt_cfg_get_multi(bcmolt_devid dev, bcmolt_cfg *filter,
+    bcmolt_filter_flags filter_flags, bcmolt_msg_set *msg_set)
+{
+    int i;
+
+    /* If message set already includes messages received on previous iteration - release them */
+    for (i=0; i < msg_set->num_instances; i++)
+    {
+        if (msg_set->msg[i])
+        {
+            bcmolt_msg_free(msg_set->msg[i]);
+            msg_set->msg[i] = NULL;
+        }
+    }
+
+    msg_set->filter_flags = filter_flags;
+    msg_set->num_instances = 0;
+    msg_set->more = BCMOS_FALSE;
+
+    /* Set msg_set in filter message and submit request*/
+    filter->hdr.msg_set = msg_set;
+    filter->hdr.type = BCMOLT_MSG_TYPE_GET_MULTI;
+
+    return bcmtr_call(dev, &filter->hdr);
+}
diff --git a/bcm68620_release/release/host_driver/api/bcmolt_api.h b/bcm68620_release/release/host_driver/api/bcmolt_api.h
new file mode 100644
index 0000000..f18bac9
--- /dev/null
+++ b/bcm68620_release/release/host_driver/api/bcmolt_api.h
@@ -0,0 +1,521 @@
+/*
+<: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 BCMOLT_API_H_
+#define BCMOLT_API_H_
+
+#include <bcmos_system.h>
+#include <bcmolt_msg.h>
+
+/** \defgroup api BCM6862x Host API
+ *
+ * Data Types, functions and macros that should be used for BCM6862x device management.
+ * @{
+ */
+
+/** \defgroup api_macros Message Access Macros
+ * @{
+ */
+
+/*
+ * Message Initialization Macros
+ */
+
+/* Initialize request. Internal macro
+ * \param[in]   _h      Message header
+ * \param[in]   _obj    Object type
+ * \param[in]   _grp    message type
+ * \param[in]   _subgrp message subgroup
+ */
+#define _BCMOLT_REQ_INIT(_h, _obj, _grp, _subgrp) \
+    (_h)->hdr.dir = BCMOLT_MSG_DIR_REQUEST;\
+    (_h)->hdr.err = BCM_ERR_OK;\
+    (_h)->hdr.presence_mask = 0;\
+    (_h)->hdr.obj_type = bcmolt_obj_id_ ## _obj;\
+    (_h)->hdr.group = _grp;\
+    (_h)->hdr.subgroup = (uint16_t)_subgrp;\
+    (_h)->hdr.corr_tag = 0
+
+/** Initialize configuration structure
+ * \param[in]   _s      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_CFG_INIT(_s, _obj, _key) \
+    do {\
+        bcmolt_ ## _obj ## _cfg *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_CFG, 0);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize statistics structure
+ * \param[in]   _s      Statistics structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_STAT_INIT(_s, _obj, _key) \
+    do {\
+        bcmolt_ ## _obj ## _stat *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_STAT, 0);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize statistic configuration structure
+ * \param[in]   _s      Statistics configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _stat   Statistic counter name
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_STAT_CFG_INIT(_s, _obj, _stat, _key) \
+    do {\
+        bcmolt_ ## _obj ## _stat_cfg *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_STAT_CFG, bcmolt_ ## _obj ## _stat_id_ ## _stat);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize indication configuration structure
+ * \param[in]   _s      Indication configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_AUTO_CFG_INIT(_s, _obj, _key) \
+    do {\
+        bcmolt_ ## _obj ## _auto_cfg *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_AUTO_CFG, 0);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize operation structure
+ * \param[in]   _s      Operation structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _op     Operation type
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_OPER_INIT(_s, _obj, _op, _key) \
+    do {\
+        bcmolt_ ## _obj ## _ ## _op *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_OPER, bcmolt_ ## _obj ## _oper_id_ ## _op);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize proxy message structure
+ * \param[in]   _s      Operation structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _m      Proxy message type
+ * \param[in]   _key    Object key
+ */
+#define BCMOLT_PROXY_INIT(_s, _obj, _m, _key) \
+    do {\
+        bcmolt_ ## _obj ## _ ## _m *_x_ = _s;\
+        memset(_x_, 0, sizeof(*_x_));\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_PROXY, bcmolt_ ## _obj ## _proxy_id_ ## _m);\
+        (_x_)->key = _key;\
+    } while (0)
+
+/** Initialize autonomous indication structure
+ * \param[in]   _s      Autonomous indication structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _au     Autonomous indication type
+ */
+#define BCMOLT_AUTO_INIT(_s, _obj, _au) \
+    do {\
+        bcmolt_ ## _obj ## _ ## _au *_x_ = _s;\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_AUTO, bcmolt_ ## _obj ## _auto_id_ ## _au);\
+        _x_->hdr.hdr.subch = 0;\
+        _x_->hdr.hdr.presence_mask = (1ULL << (uint64_t)bcmolt_ ## _obj ## _ ## _au ## _id_all_properties) - 1;\
+    } while (0)
+
+/** Initialize proxy_rx structure
+ * \param[in]   _s      Proxy rx message structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _pr     Proxy message type
+ */
+#define BCMOLT_PROXY_RX_INIT(_s, _obj, _pr) \
+    do {\
+        bcmolt_ ## _obj ## _ ## _pr *_x_ = _s;\
+        _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_PROXY_RX, bcmolt_ ## _obj ## _proxy_rx_id_ ## _pr);\
+        _x_->hdr.hdr.subch = 0;\
+        _x_->hdr.hdr.presence_mask = (1ULL << (uint64_t)bcmolt_ ## _obj ## _ ## _pr ## _id_all_properties) - 1;\
+    } while (0)
+
+/** Set the memory buffer to use for variable-sized lists within a cfg get
+* \param[in]   _s      Configuration structure
+* \param[in]   _obj    Object type
+* \param[in]   _buf    Pointer to a location in memory in which to store the lists
+* \param[in]   _len    Length of the buffer pointed to by _buf
+*/
+#define BCMOLT_CFG_LIST_BUF_SET(_s, _obj, _buf, _len) \
+    do {\
+        bcmolt_ ## _obj ## _cfg *_x_ = _s;\
+        _x_->hdr.hdr.list_buf = _buf;\
+        _x_->hdr.hdr.list_buf_size = _len;\
+    } while (0)
+
+/* Internal macro: Get a bitmask given a property ID enum */
+#define BCMOLT_PROP_MASK_GET(_obj, _grp, _p) \
+    (bcmolt_ ## _obj ## _grp ## _id_ ## _p == bcmolt_ ## _obj ## _grp ## _id_all_properties ? \
+        ((1ULL << (uint64_t)bcmolt_ ## _obj ## _grp ## _id_ ## _p) - 1) : \
+        (1ULL << (uint64_t)bcmolt_ ## _obj ## _grp ## _id_ ## _p))
+
+/* Internal macro: Indicate that configuration property is present */
+#define _BCMOLT_PROP_SET_PRESENT(_m, _obj, _grp, _p) \
+    do { \
+        (_m)->hdr.hdr.presence_mask |= BCMOLT_PROP_MASK_GET(_obj, _grp, _p);\
+    } while (0)
+
+/* Internal macro: check if property is present */
+#define _BCMOLT_PROP_IS_PRESENT(_m, _obj, _grp, _p) \
+    (((_m)->hdr.hdr.presence_mask & BCMOLT_PROP_MASK_GET(_obj, _grp, _p)) ? \
+        BCMOS_TRUE : BCMOS_FALSE)
+
+/** Set configuration property in message structure
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ * \param[in]   _v      Property value
+ */
+#define BCMOLT_CFG_PROP_SET(_m, _obj, _p, _v) \
+    do { \
+        _BCMOLT_PROP_SET_PRESENT(_m, _obj, _cfg, _p);\
+        (_m)->data._p = (_v);\
+    } while (0)
+
+/** Indicate that configuration property should be read
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_CFG_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _cfg, _p)
+
+/** Check if configuration property is set in message structure
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_CFG_PROP_IS_SET(_m, _obj, _p)    _BCMOLT_PROP_IS_PRESENT(_m, _obj, _cfg, _p)
+
+/** Indicate that statistic property should be read
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_STAT_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _stat, _p)
+
+/** Check if statistic property is set in message structure
+ * \param[in]   _m      Statistic structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_STAT_PROP_IS_SET(_m, _obj, _p)    _BCMOLT_PROP_IS_PRESENT(_m, _obj, _stat, _p)
+
+/** Set operation property in message structure
+ * \param[in]   _m      Operation structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _op     Operation
+ * \param[in]   _p      Property name
+ * \param[in]   _v      Property value
+ */
+#define BCMOLT_OPER_PROP_SET(_m, _obj, _op, _p, _v) \
+    do { \
+        _BCMOLT_PROP_SET_PRESENT(_m, _obj, _ ## _op, _p);\
+        (_m)->data._p = (_v);\
+    } while (0)
+
+/** Check if operation property is set in message structure
+* \param[in]   _m      Operation structure
+* \param[in]   _obj    Object type
+* \param[in]   _op     Operation
+* \param[in]   _p      Property name
+*/
+#define BCMOLT_OPER_PROP_IS_SET(_m, _obj, _op, _p)    _BCMOLT_PROP_IS_PRESENT(_m, _obj, _op, _p)
+
+/** Indicate that autonomous message configuration property should be read
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_AUTO_CFG_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _auto_cfg, _p)
+
+/** Set autonomous message configuration property in message structure
+ * \param[in]   _m      Operation structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ * \param[in]   _v      Property value
+ */
+#define BCMOLT_AUTO_CFG_PROP_SET(_m, _obj, _p, _v) \
+    do { \
+        _BCMOLT_PROP_SET_PRESENT(_m, _obj, _auto_cfg, _p);\
+        (_m)->data._p = (_v);\
+    } while (0)
+
+/** Check if autonomous message configuration property is set in message structure
+* \param[in]   _m      Configuration structure
+* \param[in]   _obj    Object type
+* \param[in]   _p      Property name
+*/
+#define BCMOLT_AUTO_CFG_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _auto_cfg, _p)
+
+/** Set statistic configuration property in message structure
+* \param[in]   _m      Configuration structure
+* \param[in]   _obj    Object type
+* \param[in]   _p      Property name
+* \param[in]   _v      Property value
+*/
+#define BCMOLT_STAT_CFG_PROP_SET(_m, _obj, _p, _v) \
+    do { \
+        _BCMOLT_PROP_SET_PRESENT(_m, _obj, _stat_cfg, _p);\
+        (_m)->data._p = (_v);\
+    } while (0)
+
+/** Check if statistic configuration property is set in message structure
+* \param[in]   _m      Configuration structure
+* \param[in]   _obj    Object type
+* \param[in]   _p      Property name
+*/
+#define BCMOLT_STAT_CFG_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _stat_cfg, _p)
+
+/** Set proxy message property in message structure
+ * \param[in]   _m      Configuration structure
+ * \param[in]   _obj    Object type
+ * \param[in]   _grp    Proxy message type
+ * \param[in]   _p      Property name
+ * \param[in]   _v      Property value
+ */
+#define BCMOLT_PROXY_PROP_SET(_m, _obj, _grp, _p, _v) \
+    do { \
+        _BCMOLT_PROP_SET_PRESENT(_m, _obj, _ ## _grp, _p);\
+        (_m)->data._p = (_v);\
+    } while (0)
+
+/** \defgroup multi_api_func Multi-object property access macros
+ * @{
+ */
+
+/*
+ * Macros for multi-object configuration and statistics retrieval
+ */
+
+/* Internal macro: Indicate that configuration property is present */
+#define _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _grp, _p) \
+    do { \
+        (_set)->presence_mask |= BCMOLT_PROP_MASK_GET(_obj, _grp, _p);\
+    } while (0)
+
+/* Internal macro: check if property is present */
+#define _BCMOLT_MSGSET_PROP_IS_PRESENT(_set, _obj, _grp, _p) \
+    (((_set)->presence_mask & BCMOLT_PROP_MASK_GET(_obj, _grp, _p)) ? \
+        BCMOS_TRUE : BCMOS_FALSE)
+
+/** Indicate that configuration property should be read
+ * \param[in]   _set    Message set
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_MSGSET_CFG_PROP_GET(_set, _obj, _p)  _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _cfg, _p)
+
+/** Check if configuration property is set in message set
+ * \param[in]   _set    Message set
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_MSGSET_CFG_PROP_IS_SET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_IS_PRESENT(_set, _obj, _cfg, _p)
+
+/** Indicate that statistic should be read
+ * \param[in]   _set    Message set
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_MSGSET_STAT_PROP_GET(_set, _obj, _p)  _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _stat, _p)
+
+/** Check if statistic property is set in message set
+ * \param[in]   _set    Message set
+ * \param[in]   _obj    Object type
+ * \param[in]   _p      Property name
+ */
+#define BCMOLT_MSGSET_STAT_PROP_IS_SET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_IS_PRESENT(_m, _obj, _stat, _p)
+
+/** @} */
+
+/** @} */
+
+/** \defgroup api_func API Functions
+ * @{
+ */
+
+/*
+ * API
+ */
+
+typedef void (*system_mode_change_cb)(bcmolt_devid dev);
+
+extern system_mode_change_cb sm_change_cb;
+
+/** Set Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_cfg_set(bcmolt_devid dev, bcmolt_cfg *cfg);
+
+/** Get Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_cfg_get(bcmolt_devid dev, bcmolt_cfg *cfg);
+
+/** Clear Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_cfg_clear(bcmolt_devid dev, bcmolt_cfg *cfg);
+
+/** Get Statistics
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   stat    Configuration
+ * \param[in]   flags   Flags
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_get(bcmolt_devid dev, bcmolt_stat *stat, bcmolt_stat_flags flags);
+
+/** Get Statistics Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_cfg_get(bcmolt_devid dev, bcmolt_stat_cfg *cfg);
+
+/** Set Statistics Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_stat_cfg_set(bcmolt_devid dev, bcmolt_stat_cfg *cfg);
+
+/** Get Indication Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_auto_cfg_get(bcmolt_devid dev, bcmolt_auto_cfg *cfg);
+
+/** Set Indication Configuration
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   cfg     Configuration
+ * \returns error code
+ * The error code can indicate local or remote failure
+ */
+bcmos_errno bcmolt_auto_cfg_set(bcmolt_devid dev, bcmolt_auto_cfg *cfg);
+
+/** Submit Operation
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   oper    Operation
+ * \returns error code
+ */
+bcmos_errno bcmolt_oper_submit(bcmolt_devid dev, bcmolt_oper *oper);
+
+/** Send Message to ONU
+ *
+ * \param[in]   dev     Device id
+ * \param[in]   msg     Message to be sent
+ * \returns error code
+ */
+bcmos_errno bcmolt_proxy_send(bcmolt_devid dev, bcmolt_proxy *msg);
+
+/** Receive callback registration parameters */
+typedef struct bcmolt_rx_cfg
+{
+    bcmolt_obj_id obj_type;     /**< Object type. Can be \ref BCMOLT_OBJECT_ANY */
+    f_bcmolt_msg_handler rx_cb; /**< Receive callback. NULL=unregister */
+    bcmolt_auto_flags flags;    /**< Dispatch flags. Receive callback function can be called
+                                     in the context of rx task or application task,
+                                     depending on the flags */
+    bcmos_module_id module;     /**< Target module id.
+                                     Relevant only if flags == BCMOLT_AUTO_FLAGS_DISPATCH */
+    uint32_t pon_ni_mask;       /**< Bitmask of pon_ni interfaces the registration applies to.
+                                     0=all interfaces. Each interface is identified by (1 << pon_ni) bit */
+} bcmolt_rx_cfg;
+
+/* (Un)Register Autonomous Indication Message Handler
+ *
+ * \param[in]   dev             Device id
+ * \param[in]   rx_cfg          Receive handler configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_auto_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg);
+
+/* (Un)Register Proxy Message Handler
+ *
+ * \param[in]   dev             Device id
+ * \param[in]   rx_cfg          Receive handler configuration
+ * \returns error code
+ */
+bcmos_errno bcmolt_proxy_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg);
+
+/** \defgroup multi_api_func Multi-object API Functions
+ * @{
+ */
+
+/* Get configuration of multiple objects
+ * \param[in]           olt             Device id
+ * \param[in]           filter          Object filter. Header of generated bcmolt_xx_cfg structure
+ * \param[in]           filter_flags    Optional filtering flags
+ * \param[in,out]       msg_set         Message set
+ */
+bcmos_errno bcmolt_cfg_get_multi(bcmolt_devid olt, bcmolt_cfg *filter,
+    bcmolt_filter_flags filter_flags, bcmolt_msg_set *msg_set);
+
+/** @} */
+
+/** @} */
+
+/** @} */
+
+#endif /* BCMOLT_API_H_ */
diff --git a/bcm68620_release/release/host_driver/api/bcmolt_msg.c b/bcm68620_release/release/host_driver/api/bcmolt_msg.c
new file mode 100644
index 0000000..56e3961
--- /dev/null
+++ b/bcm68620_release/release/host_driver/api/bcmolt_msg.c
@@ -0,0 +1,55 @@
+/*
+<: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.
+
+:>
+ */
+#include <bcmos_system.h>
+#include <bcm_dev_log.h>
+#include "bcmolt_msg.h"
+
+bcmos_errno bcmolt_msg_err(bcmolt_msg *msg, dev_log_id log_id, bcmos_errno err, uint16_t err_field_idx, const char *fmt, ...)
+{
+    msg->err = err;
+    msg->err_field_idx = err_field_idx;
+    if (fmt)
+    {
+        va_list args;
+
+        va_start(args, fmt);
+        vsnprintf(msg->err_text, sizeof(msg->err_text) - 1, fmt, args);
+        va_end(args);
+        strncat(msg->err_text, "\n", 1);
+#ifdef ENABLE_LOG
+        if (log_id && log_id != DEV_LOG_INVALID_ID)
+            bcm_dev_log_log(log_id, DEV_LOG_LEVEL_ERROR, BCM_LOG_FLAG_CALLER_FMT, "%s", msg->err_text);
+#endif
+    }
+    else
+    {
+        msg->err_text[0] = 0;
+    }
+    return err;
+}
diff --git a/bcm68620_release/release/host_driver/api/bcmolt_msg.h b/bcm68620_release/release/host_driver/api/bcmolt_msg.h
new file mode 100644
index 0000000..5f24b26
--- /dev/null
+++ b/bcm68620_release/release/host_driver/api/bcmolt_msg.h
@@ -0,0 +1,385 @@
+/*
+<: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 BCMOLT_MSG_H_
+#define BCMOLT_MSG_H_
+
+#include "bcmos_system.h"
+#include "bcmolt_buf.h"
+#include "bcmolt_model_ids.h"
+#include "bcm_dev_log_task.h"
+
+/** \defgroup \api_data_types Data Types
+ * \ingroup api
+ * @{
+ */
+
+/** Device ID */
+typedef uint8_t bcmolt_devid;
+
+/** Bitmask of fields that are present in a message */
+typedef uint64_t bcmolt_presence_mask;
+
+/** Presence mask indicating all fields present */
+#define BCMOLT_PRESENCE_MASK_ALL ((bcmolt_presence_mask)0xFFFFFFFFFFFFFFFF)
+
+/** Message direction - request or response */
+typedef enum bcmolt_msg_dir
+{
+    BCMOLT_MSG_DIR_REQUEST,
+    BCMOLT_MSG_DIR_RESPONSE
+} bcmolt_msg_dir;
+
+/** Message type. Can be a combination of flags */
+typedef enum bcmolt_msg_type
+{
+    BCMOLT_MSG_TYPE_GET  = 0x01,        /**< Get: configuration or statistics */
+    BCMOLT_MSG_TYPE_SET  = 0x02,        /**< Set: Configuration, Statistics, Auto, Proxy */
+    BCMOLT_MSG_TYPE_CLEAR= 0x04,        /**< Clear: configuration */
+    BCMOLT_MSG_TYPE_MULTI= 0x08,        /**< Multi-object: configuration, statistics */
+
+    BCMOLT_MSG_TYPE_GET_MULTI = BCMOLT_MSG_TYPE_GET | BCMOLT_MSG_TYPE_MULTI,
+} bcmolt_msg_type;
+
+/** Management group - key, config, operation, etc */
+typedef enum bcmolt_mgt_group
+{
+    BCMOLT_MGT_GROUP_KEY,               /**< key that uniquely identifies object instance */
+    BCMOLT_MGT_GROUP_CFG,               /**< Configuration */
+    BCMOLT_MGT_GROUP_STAT,              /**< Statistics */
+    BCMOLT_MGT_GROUP_STAT_CFG,          /**< Statistics threshold configuration */
+    BCMOLT_MGT_GROUP_AUTO,              /**< Autonomous indications */
+    BCMOLT_MGT_GROUP_AUTO_CFG,          /**< Autonomous indication configuration */
+    BCMOLT_MGT_GROUP_OPER,              /**< Operations */
+    BCMOLT_MGT_GROUP_PROXY,             /**< Messages to ONU */
+    BCMOLT_MGT_GROUP_PROXY_RX,          /**< Messages from ONU */
+    BCMOLT_MGT_GROUP__NUM_OF
+} bcmolt_mgt_group;
+
+/** Any object */
+#define BCMOLT_OBJECT_ANY       (bcmolt_obj_id)0xffff
+
+/** Any group */
+#define BCMOLT_MGT_GROUP_ANY    (bcmolt_mgt_group)0xffff
+
+/** Any subgroup */
+#define BCMOLT_SUBGROUP_ANY     0xffff
+
+/** Indicator that no fields contained errors */
+#define BCMOLT_ERR_FIELD_NONE   0xffff
+
+/** Max error text length */
+#define BCMOLT_MAX_ERR_TEXT_LENGTH      256
+
+/* Transport sub-channel handle */
+typedef uint16_t bcmolt_subchannel;
+
+/** Message set - for multi-instance APIs */
+typedef struct bcmolt_msg_set bcmolt_msg_set;
+
+/** Common message header */
+typedef struct bcmolt_msg
+{
+    bcmolt_obj_id        obj_type;      /**< Object type */
+    bcmolt_mgt_group     group;         /**< Management group */
+    uint16_t             subgroup;      /**< Subgroup: for operations, autonomous messages, proxy */
+    bcmolt_msg_type      type;          /**< Set, Get, Clear */
+    bcmolt_msg_dir       dir;           /**< Request/autonomous or Response */
+    bcmos_errno          err;           /**< Remote error code */
+    uint16_t             err_field_idx; /**< If not BCMOLT_ERR_FIELD_NONE, index of erroneous field within struct */
+    uint16_t             corr_tag;      /**< Correlation tag */
+    bcmolt_presence_mask presence_mask; /**< Indicates which parameters are present */
+    char                 err_text[BCMOLT_MAX_ERR_TEXT_LENGTH];  /**< Error text - if err != 0 */
+    /* The following fields are internal. They are not sent on the line */
+    bcmolt_subchannel    subch;         /*   Transport sub-channel via which the message arrived */
+    bcmos_msg            os_msg;        /*   Internal OS message for easy task routing */
+    void                *list_buf;      /*   Memory buffer in which to store variable-sized lists when unpacking */
+    uint32_t             list_buf_size; /*   Number of bytes in the variable-sized list buffer */
+    bcmolt_msg_set      *msg_set;       /* Message set the message belongs to */
+} bcmolt_msg;
+
+/** Configuration group message header */
+typedef struct bcmolt_cfg
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_cfg;
+
+/** Statistic flags */
+typedef enum
+{
+    BCMOLT_STAT_FLAGS_NONE          = 0x0000, /**< No statistics options set (no clear on read, etc) */
+    BCMOLT_STAT_FLAGS_CLEAR_ON_READ = 0x0001, /**< Clear the requested statistics as part of the read operation */
+} bcmolt_stat_flags;
+
+/** Statistics group message header */
+typedef struct bcmolt_stat
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_stat;
+
+/** Statistics configuration message header */
+typedef struct bcmolt_stat_cfg
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_stat_cfg;
+
+/** Operation group message header */
+typedef struct bcmolt_oper
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_oper;
+
+/** Autonomous message header */
+typedef struct bcmolt_auto
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_auto;
+
+/** Autonomous message configuration header */
+typedef struct bcmolt_auto_cfg
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_auto_cfg;
+
+/** Message handler */
+typedef void (*f_bcmolt_msg_handler)(bcmolt_devid olt, bcmolt_msg *msg);
+
+/** Autonomous message flags */
+typedef enum
+{
+    BCMOLT_AUTO_FLAGS_NONE      = 0,            /**< Invoke callback in context of RX task */
+    BCMOLT_AUTO_FLAGS_DISPATCH  = 0x0001,       /**< Dispatch message to application module */
+} bcmolt_auto_flags;
+
+/** Proxy message header */
+typedef struct bcmolt_proxy
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_proxy;
+
+/** Proxy RX message header */
+typedef struct bcmolt_proxy_rx
+{
+    bcmolt_msg hdr;             /** Common header */
+} bcmolt_proxy_rx;
+
+/** Filter flags */
+typedef enum
+{
+    BCMOLT_FILTER_FLAGS_NONE = 0,
+    BCMOLT_FILTER_FLAGS_INVERT_SELECTION = 0x00000001    /** Return objects NOT selected by filter */
+} bcmolt_filter_flags;
+
+/* Message set */
+struct bcmolt_msg_set
+{
+    uint16_t max_instances;     /**< Max number of instances in the set. Set when set is created and doesn't change */
+    bcmolt_mgt_group group;     /**< Management group */
+    bcmolt_presence_mask presence_mask; /**< Indicates which parameters should be fetched */
+    bcmolt_filter_flags filter_flags;   /**< Filter flags */
+
+    /* Multi-msg API output */
+    uint16_t num_instances;     /**< Number of instances in the set. */
+    bcmos_bool more;            /**< BCMOS_TRUE if not all instances have been retrieved by the last
+                                     bcmolt_get_multi() call. */
+    void *next_key;             /**< Key of the next object instance after those that were returned.  Only valid if
+                                     'more' is BCMOS_FALSE.  Treat this as a pointer to the object's key struct.  This
+                                     can be used for subsequent invocations of bcmolt_cfg_get_multiple() by copying this
+                                     into the filter's key field. */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /**< Check whether C99 is supported */
+    bcmolt_msg *msg[];          /**< Set of API objects returned by bcmolt_cfg_get_multiple(). */
+#else
+    bcmolt_msg *msg[0];          /**< Set of API objects returned by bcmolt_cfg_get_multiple(). */
+#endif
+};
+
+/** @} */
+
+
+/*lint -ecall(633, bcmolt_msg_err) - 4th argument will be a specific enum type, but must be treated as a uint16. */
+/** Set message error. Cannot be static inline, as it uses variable argument list. */
+bcmos_errno bcmolt_msg_err(bcmolt_msg *msg, dev_log_id log_id, bcmos_errno err, uint16_t err_field_idx, const char *fmt, ...)__attribute__((format(__printf__, 5, 6)));
+
+/** Whether we pack the entire structure of a message */
+static inline bcmos_bool bcmolt_msg_should_pack_data(const bcmolt_msg *msg)
+{
+    switch (msg->group)
+    {
+        case BCMOLT_MGT_GROUP_CFG:
+        case BCMOLT_MGT_GROUP_STAT:
+        case BCMOLT_MGT_GROUP_STAT_CFG:
+        case BCMOLT_MGT_GROUP_AUTO_CFG:
+            if ((msg->type & BCMOLT_MSG_TYPE_GET))
+            {
+                bcmos_bool should_pack = (msg->dir == BCMOLT_MSG_DIR_RESPONSE);
+                /* For multi-message get request should_pack must be inverted because the 1st part
+                 * of multi-object request is filter
+                 */
+                return (msg->type & BCMOLT_MSG_TYPE_MULTI) ? !should_pack : should_pack;
+            }
+            else if ((msg->type & BCMOLT_MSG_TYPE_SET))
+            {
+                return (msg->dir == BCMOLT_MSG_DIR_REQUEST);
+            }
+            else
+            {
+                return BCMOS_FALSE;
+            }
+
+        case BCMOLT_MGT_GROUP_OPER:
+        case BCMOLT_MGT_GROUP_PROXY:
+            return (msg->dir == BCMOLT_MSG_DIR_REQUEST);
+
+        default:
+            return BCMOS_TRUE;
+    }
+}
+
+/** Get the length of the header portion of a message */
+static inline int32_t bcmolt_msg_hdr_get_packed_length(const bcmolt_msg *msg)
+{
+    return 18 + (msg->err ? strlen(msg->err_text) + 2 : 0);
+}
+
+/** Pack a message header to a byte stream */
+static inline bcmos_errno bcmolt_msg_hdr_pack(const bcmolt_msg *msg, bcmolt_buf *buf)
+{
+    bcmos_bool ret;
+
+    ret =        bcmolt_buf_write_u8(buf, (uint8_t)msg->obj_type);
+    ret = ret && bcmolt_buf_write_u8(buf, (uint8_t)msg->group);
+    ret = ret && bcmolt_buf_write_u16(buf, msg->subgroup);
+    ret = ret && bcmolt_buf_write_u8(buf, (uint8_t)msg->type);
+    ret = ret && bcmolt_buf_write_u8(buf, (uint8_t)msg->dir);
+    ret = ret && bcmolt_buf_write_s16(buf, (int16_t)msg->err);
+    ret = ret && bcmolt_buf_write_u64(buf, (uint64_t)msg->presence_mask);
+    ret = ret && bcmolt_buf_write_u16(buf, msg->err_field_idx);
+    if (msg->err)
+    {
+        uint16_t len = strlen(msg->err_text);
+        ret = ret && bcmolt_buf_write_u16(buf, len);
+        ret = ret && bcmolt_buf_write(buf, msg->err_text, len);
+    }
+
+    return ret ? BCM_ERR_OK : BCM_ERR_OVERFLOW;
+}
+
+/** Unpack a message header from a byte stream */
+static inline bcmos_errno bcmolt_msg_hdr_unpack(bcmolt_msg *msg, bcmolt_buf *buf)
+{
+    uint8_t    obj_type;
+    uint8_t    group;
+    uint16_t   subgroup;
+    uint8_t    type;
+    uint8_t    dir;
+    int16_t    err = 0;
+    uint64_t   presence_mask;
+    uint16_t   err_field_idx;
+    bcmos_bool ret;
+
+    ret =        bcmolt_buf_read_u8(buf, &obj_type);
+    ret = ret && bcmolt_buf_read_u8(buf, &group);
+    ret = ret && bcmolt_buf_read_u16(buf, &subgroup);
+    ret = ret && bcmolt_buf_read_u8(buf, &type);
+    ret = ret && bcmolt_buf_read_u8(buf, &dir);
+    ret = ret && bcmolt_buf_read_s16(buf, &err);
+    ret = ret && bcmolt_buf_read_u64(buf, &presence_mask);
+    ret = ret && bcmolt_buf_read_u16(buf, &err_field_idx);
+    if (err)
+    {
+        uint16_t len = 0;
+        ret = ret && bcmolt_buf_read_u16(buf, &len);
+        if (len >= sizeof(msg->err_text))
+            len = sizeof(msg->err_text) - 1;
+        ret = ret && bcmolt_buf_read(buf, msg->err_text, len);
+        msg->err_text[len] = 0;
+    }
+    else
+    {
+        msg->err_text[0] = 0;
+    }
+
+    if (ret)
+    {
+        msg->obj_type = (bcmolt_obj_id)obj_type;
+        msg->group = (bcmolt_mgt_group)group;
+        msg->subgroup = subgroup;
+        msg->type = (bcmolt_msg_type)type;
+        msg->dir = (bcmolt_msg_dir)dir;
+        msg->err = (bcmos_errno)err;
+        msg->presence_mask = (bcmolt_presence_mask)presence_mask;
+        msg->err_field_idx = err_field_idx;
+        msg->msg_set = NULL;
+    }
+
+    return ret ? BCM_ERR_OK : BCM_ERR_OVERFLOW;
+}
+
+/* Create message set
+ *
+ * \param[in]   obj             Object id
+ * \param[in]   group           Management group
+ * \param[in]   max_instances   Max number of objects returned by a single API call
+ * \param[out]  msg_set         Message set
+ * \returns error code
+ */
+bcmos_errno bcmolt_msg_set_alloc(bcmolt_obj_id obj, bcmolt_mgt_group group,
+    uint32_t max_instances, bcmolt_msg_set **msg_set);
+
+/* Release message set
+ * \param[in]   msg_set
+ */
+void bcmolt_msg_set_free(bcmolt_msg_set *msg_set);
+
+/* Release dynamically allocated message.
+ */
+static inline void bcmolt_msg_free(bcmolt_msg *msg)
+{
+    if (msg->msg_set)
+    {
+        bcmolt_msg_set_free(msg->msg_set);
+    }
+    bcmos_free(msg);
+}
+
+static inline void bcmolt_os_msg_release_cb(bcmos_msg *os_msg)
+{
+    bcmolt_msg *msg = os_msg->data;
+
+    /* We can be here if target module or transport queue overflows.
+       Release the message
+    */
+    bcmolt_msg_free(msg);
+}
+
+static inline bcmos_module_id bcmos_module_id_for_device(bcmos_module_id module, bcmolt_devid devid)
+{
+    return module + (bcmos_module_id)devid;
+}
+#endif