Merge "target: msm8909: change the logic for adding command line params"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 759bc22..07f87e5 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -93,12 +93,13 @@
 extern void platform_uninit(void);
 extern void target_uninit(void);
 extern int get_target_boot_params(const char *cmdline, const char *part,
-				  char *buf, int buflen);
+				  char **buf);
 
 void *info_buf;
 void write_device_info_mmc(device_info *dev);
 void write_device_info_flash(device_info *dev);
 static int aboot_save_boot_hash_mmc(uint32_t image_addr, uint32_t image_size);
+static int aboot_frp_unlock(char *pname, void *data, unsigned sz);
 
 /* fastboot command function pointer */
 typedef void (*fastboot_cmd_fn) (const char *, void *, unsigned);
@@ -164,7 +165,7 @@
 static unsigned page_mask = 0;
 static char ffbm_mode_string[FFBM_MODE_BUF_SIZE];
 static bool boot_into_ffbm;
-static char target_boot_params[64];
+static char *target_boot_params = NULL;
 static bool boot_reason_alarm;
 static bool devinfo_present = true;
 
@@ -302,8 +303,7 @@
 
 	if (get_target_boot_params(cmdline, boot_into_recovery ? "recoveryfs" :
 								 "system",
-				   target_boot_params,
-				   sizeof(target_boot_params)) == 0) {
+						&target_boot_params) == 0) {
 		have_target_boot_params = 1;
 		cmdline_len += strlen(target_boot_params);
 	}
@@ -516,6 +516,7 @@
 			if (have_cmdline) --dst;
 			src = target_boot_params;
 			while ((*dst++ = *src++));
+			free(target_boot_params);
 		}
 	}
 
@@ -2176,6 +2177,14 @@
 		cmd_erase_nand(arg, data, sz);
 }
 
+static uint32_t aboot_get_secret_key()
+{
+	/* 0 is invalid secret key, update this implementation to return
+	 * device specific unique secret key
+	 */
+	return 0;
+}
+
 void cmd_flash_mmc_img(const char *arg, void *data, unsigned sz)
 {
 	unsigned long long ptn = 0;
@@ -2199,6 +2208,19 @@
 
 	if (pname)
 	{
+		if (!strncmp(pname, "frp-unlock", strlen("frp-unlock")))
+		{
+			if (!aboot_frp_unlock(pname, data, sz))
+			{
+				fastboot_info("FRP unlock successful");
+				fastboot_okay("");
+			}
+			else
+				fastboot_fail("Secret key is invalid, please update the bootloader with secret key");
+
+			return;
+		}
+
 		if (!strcmp(pname, "partition"))
 		{
 			dprintf(INFO, "Attempt to write partition image.\n");
@@ -2818,6 +2840,26 @@
 	fastboot_okay("");
 }
 
+static int aboot_frp_unlock(char *pname, void *data, unsigned sz)
+{
+	int ret = 1;
+	uint32_t secret_key;
+	char seckey_buffer[MAX_RSP_SIZE];
+
+	secret_key = aboot_get_secret_key();
+	if (secret_key)
+	{
+		snprintf((char *) seckey_buffer, MAX_RSP_SIZE, "%x", secret_key);
+		if (!memcmp((void *)data, (void *)seckey_buffer, sz))
+		{
+			is_allow_unlock = true;
+			write_allow_oem_unlock(is_allow_unlock);
+			ret = 0;
+		}
+	}
+	return ret;
+}
+
 void cmd_oem_lock(const char *arg, void *data, unsigned sz)
 {
 	/* TODO: Wipe user data */
diff --git a/platform/init.c b/platform/init.c
index 9919b22..e6f0f66 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -111,7 +111,7 @@
 }
 
 __WEAK int get_target_boot_params(const char *cmdline, const char *part,
-				  char *buf, int buflen)
+				  char **buf)
 {
 	return -1;
 }
diff --git a/platform/msm_shared/glink/glink_api.c b/platform/msm_shared/glink/glink_api.c
index fe5fd92..f2bdae6 100644
--- a/platform/msm_shared/glink/glink_api.c
+++ b/platform/msm_shared/glink/glink_api.c
@@ -35,9 +35,10 @@
 #include <glink_os_utils.h>
 #include <glink_internal.h>
 #include <glink_vector.h>
-#include <glink_channel_migration.h>
-#include <smem_list.h>
-#include <smem_type.h>
+
+#ifdef FEATURE_TRACER_PACKET
+#include "glink_tracer.h"
+#endif
 
 #define GLINK_NOT_INITIALIZED 0
 #define GLINK_INITIALIZED     1
@@ -45,276 +46,9 @@
 /*===========================================================================
                         GLOBAL DATA DECLARATIONS
 ===========================================================================*/
-int glink_core_status = GLINK_NOT_INITIALIZED;
-
-os_cs_type *glink_transport_q_cs;
-os_cs_type *glink_mem_log_cs;
-
-glink_mem_log_entry_type glink_mem_log_arr[GLINK_MEM_LOG_SIZE];
-uint32 glink_mem_log_idx = 0;
-
-/* Keep a list of registered transport for each edge allowed for this host */
-smem_list_type glink_registered_transports[GLINK_NUM_HOSTS];
-
-smem_list_type glink_link_notif_list;
-
-/* List of supported hosts */
-const char* glink_hosts_supported[]   = { "apss",
-                                          "mpss",
-                                          "lpass",
-                                          "dsps",
-                                          "wcnss",
-                                          "tz",
-                                          "rpm",
-                                        };
-
-/* Forward function declarations */
-void glinki_free_intents(glink_channel_ctx_type *open_ch_ctx);
-
 /*===========================================================================
                     LOCAL FUNCTION DEFINITIONS
 ===========================================================================*/
-/*===========================================================================
-  FUNCTION      glinki_add_ch_to_xport
-===========================================================================*/
-/**
- * Add remote/local channel context to xport open channel queue
- *
- * @param[in]    if_ptr            Pointer to xport if on which channel is to
- *                                 be opened
- * @param[in]    req_if_ptr        Pointer to xport if on which channel
- *                                 actually wants to open
- * @param[in]    ch_ctx            channel context
- * @param[out]   allocated_ch_ctx  Pointer to channel context pointer
- * @param[in]    local_open        flag to determine if channel is opened
- *                                 locally or remotely
- * @param[in]    prio              negotiated xport priority
- *                                 (used to send priority via remote_open_ack to
- *                                  remote side)
- *
- * @return       pointer to glink_transport_if_type struct
- *
- * @sideeffects  NONE
- */
-/*=========================================================================*/
-glink_err_type glinki_add_ch_to_xport
-(
-  glink_transport_if_type  *if_ptr,
-  glink_transport_if_type  *req_if_ptr,
-  glink_channel_ctx_type   *ch_ctx,
-  glink_channel_ctx_type  **allocated_ch_ctx,
-  unsigned int              local_open,
-  glink_xport_priority      migrated_ch_prio
-)
-{
-  glink_err_type             status;
-  glink_channel_ctx_type     *open_ch_ctx;
-  glink_core_xport_ctx_type  *xport_ctx = if_ptr->glink_core_priv;
-
-  /* See if channel already exists in open_list */
-  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-
-  for( open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
-       open_ch_ctx;
-       open_ch_ctx = smem_list_next(open_ch_ctx) )
-  {
-    if( 0 != glink_os_string_compare( open_ch_ctx->name, ch_ctx->name ) )
-    {
-      continue;
-    }
-    /* grab lock to avoid race condition for channel state change */
-    glink_os_cs_acquire(&open_ch_ctx->ch_state_cs);
-
-    if( local_open )
-    {
-      /* LOCAL OPEN REQUEST */
-      ASSERT( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSED );
-
-      glink_os_cs_init( &ch_ctx->tx_cs );
-      glink_os_cs_init( &ch_ctx->ch_state_cs );
-
-      ch_ctx->rcid        = open_ch_ctx->rcid;
-      ch_ctx->lcid        = open_ch_ctx->lcid;
-      ch_ctx->pintents    = open_ch_ctx->pintents;
-      ch_ctx->if_ptr      = open_ch_ctx->if_ptr;
-      ch_ctx->req_if_ptr  = req_if_ptr;
-
-      ch_ctx->remote_state = open_ch_ctx->remote_state;
-      ch_ctx->local_state  = GLINK_LOCAL_CH_OPENING;
-
-      /* release lock before context switch otherwise it is causing
-       * deadlock */
-      smem_list_delete( &xport_ctx->open_list, open_ch_ctx );
-      smem_list_append( &xport_ctx->open_list, ch_ctx );
-
-      glink_os_cs_release(&open_ch_ctx->ch_state_cs);
-      glink_os_cs_release(&xport_ctx->channel_q_cs);
-
-      glink_os_free( open_ch_ctx );
-      *allocated_ch_ctx = ch_ctx;
-      /* Send open cmd to transport */
-      status = if_ptr->tx_cmd_ch_open( if_ptr,
-                                       ch_ctx->lcid,
-                                       ch_ctx->name,
-                                       ch_ctx->req_if_ptr->glink_priority );
-    }
-    else
-    {
-      /* REMOTE OPEN REQUEST */
-
-      if( open_ch_ctx->remote_state == GLINK_REMOTE_CH_SSR_RESET )
-      {/* During SSR previous channel ctx needs to be destroyed
-        * new remote/local open request will create new context */
-        glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-        continue;
-      }
-
-      ASSERT( open_ch_ctx->remote_state == GLINK_REMOTE_CH_CLOSED );
-
-      open_ch_ctx->rcid = ch_ctx->rcid;
-      *allocated_ch_ctx = open_ch_ctx;
-      status = xport_ctx->channel_init(open_ch_ctx);
-
-      if( status == GLINK_STATUS_SUCCESS )
-      {
-        open_ch_ctx->remote_state = GLINK_REMOTE_CH_OPENED;
-      }
-
-      /* release lock before context switch otherwise it is causing deadlock */
-      glink_os_cs_release(&open_ch_ctx->ch_state_cs);
-      glink_os_cs_release(&xport_ctx->channel_q_cs);
-
-
-      if ( status == GLINK_STATUS_SUCCESS )
-      {
-        /* Send ACK to transport */
-        if_ptr->tx_cmd_ch_remote_open_ack( if_ptr,
-                                           open_ch_ctx->rcid,
-                                           migrated_ch_prio );
-
-        /* Inform the client */
-        if( open_ch_ctx->local_state == GLINK_LOCAL_CH_OPENED )
-        {
-          open_ch_ctx->notify_state( open_ch_ctx,
-                                     open_ch_ctx->priv,
-                                     GLINK_CONNECTED );
-        }
-      }
-
-      glink_os_free(ch_ctx);
-    } /* end If - else (local_open) */
-
-    return status;
-  } /* end for */
-
-  ASSERT( open_ch_ctx == NULL );
-
-  /* Channel not in the list - it was not previously opened */
-  ch_ctx->if_ptr = if_ptr;
-  *allocated_ch_ctx = ch_ctx;
-
-  /* Set channel state */
-  if (local_open)
-  {
-    /* This is a local open */
-    ch_ctx->local_state = GLINK_LOCAL_CH_OPENING;
-    ch_ctx->req_if_ptr  = req_if_ptr;
-  }
-  else
-  {
-    ch_ctx->remote_state = GLINK_REMOTE_CH_OPENED;
-  }
-
-  glink_os_cs_init(&ch_ctx->tx_cs);
-  glink_os_cs_init(&ch_ctx->ch_state_cs);
-
-  /* Append the channel to the transport interface's open_list */
-  ch_ctx->lcid = xport_ctx->free_lcid;
-  xport_ctx->free_lcid++;
-  smem_list_append(&if_ptr->glink_core_priv->open_list, ch_ctx);
-
-  /* release lock before context switch otherwise it is causing deadlock */
-  glink_os_cs_release(&xport_ctx->channel_q_cs);
-
-  /* Send the OPEN command to transport */
-  if ( local_open )
-  {
-    status = if_ptr->tx_cmd_ch_open( if_ptr, ch_ctx->lcid,
-                                     ch_ctx->name,
-                                     ch_ctx->req_if_ptr->glink_priority );
-  }
-  else
-  {
-    /* initialize channel resources */
-    status = xport_ctx->channel_init(ch_ctx);
-
-    /* ACK the transport for remote open */
-    if (status == GLINK_STATUS_SUCCESS)
-    {
-      if_ptr->tx_cmd_ch_remote_open_ack( if_ptr, ch_ctx->rcid,
-                                         migrated_ch_prio );
-    }
-  }
-
-  if (status != GLINK_STATUS_SUCCESS)
-  {
-    /* Remove the channel from the transport interface's open_list */
-    xport_ctx->free_lcid--;
-    glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-    smem_list_delete(&if_ptr->glink_core_priv->open_list, ch_ctx);
-    glink_os_cs_release(&xport_ctx->channel_q_cs);
-
-    /* free the ch_ctx structure and return */
-    xport_ctx->channel_cleanup(ch_ctx);
-    glink_os_free(ch_ctx);
-  }
-
-  return status;
-}
-
-/*===========================================================================
-  FUNCTION      glink_is_channel_fully_opened
-===========================================================================*/
-/**
- * Check whether this channel is fully opened or not (local & remote)
- * This also checks transport status
- *
- * @param[in]  handle        glink channel handle
- * @param[in]  xport_ctx     glink transport core private
- *
- * @return     TRUE,  if channel is fully opened
- *             FASLE, otherwise
- *
- * @sideeffects  NONE
- */
-/*=========================================================================*/
-static boolean glink_is_channel_fully_opened
-(
-  glink_handle_type          handle,
-  glink_core_xport_ctx_type *xport_ctx
-)
-{
-  boolean ch_fully_opened = TRUE;
-
-  glink_os_cs_acquire( &handle->ch_state_cs );
-
-  if( handle->local_state != GLINK_LOCAL_CH_OPENED ||
-      handle->remote_state != GLINK_REMOTE_CH_OPENED )
-  {
-    ch_fully_opened = FALSE;
-  }
-
-  glink_os_cs_acquire( &xport_ctx->status_cs );
-  if( xport_ctx->status != GLINK_XPORT_LINK_UP )
-  {
-    ch_fully_opened = FALSE;
-  }
-
-  glink_os_cs_release( &xport_ctx->status_cs );
-  glink_os_cs_release( &handle->ch_state_cs );
-
-  return ch_fully_opened;
-}
 
 /** Default implementation of optional callbacks */
 static void glink_default_notify_rx_sigs
@@ -325,507 +59,16 @@
   uint32             curr
 )
 {
+  GLINK_OS_UNREFERENCED_PARAM( handle );
+  GLINK_OS_UNREFERENCED_PARAM( priv );
+  GLINK_OS_UNREFERENCED_PARAM( prev );
+  GLINK_OS_UNREFERENCED_PARAM( curr );
   return;
 }
 
-static void glinki_call_link_notifier
-(
-  glink_link_notif_data_type *link_notif_data,
-  glink_core_xport_ctx_type  *xport_ctx,
-  glink_link_state_type      state
-)
-{
-  glink_link_info_type link_info;
-
-  ASSERT(xport_ctx);
-  ASSERT(link_notif_data);
-
-  link_info.xport = xport_ctx->xport;
-  link_info.remote_ss = xport_ctx->remote_ss;
-  link_info.link_state = state;
-  link_notif_data->link_notifier(&link_info, link_notif_data->priv);
-}
-
-uint32 glinki_find_remote_host
-(
-  const char *remote_ss
-)
-{
-  uint32 remote_host;
-  ASSERT(remote_ss);
-
-  for(remote_host = 0; remote_host < GLINK_NUM_HOSTS; remote_host++)
-  {
-    if( 0 == glink_os_string_compare( glink_hosts_supported[remote_host],
-                                      remote_ss ) )
-    {
-      /* Match found, break out of loop */
-      break;
-    }
-  }
-  return remote_host;
-}
-
-static void glinki_check_xport_and_notify
-(
-  glink_link_notif_data_type *link_notif_data,
-  glink_core_xport_ctx_type  *xport_ctx,
-  glink_link_state_type      state
-)
-{
-  ASSERT(xport_ctx);
-  ASSERT(link_notif_data);
-
-  if( link_notif_data->xport == NULL ||
-      0 == glink_os_string_compare( xport_ctx->xport, link_notif_data->xport ) )
-  {
-    /* xport not specified, or it is specified and matches the current xport */
-    /* Invoke registered callback */
-    glinki_call_link_notifier(link_notif_data, xport_ctx, state);
-  }
-}
-
-static void glinki_scan_xports_and_notify
-(
-  glink_link_notif_data_type *link_notif_data
-)
-{
-  unsigned int remote_host;
-  glink_transport_if_type *if_ptr;
-  glink_core_xport_ctx_type  *xport_ctx;
-
-  ASSERT(link_notif_data);
-
-  /* Find matching subsystem */
-  for(remote_host = 0;
-      remote_host < sizeof(glink_hosts_supported)/sizeof(char *);
-      remote_host++)
-  {
-    if ( link_notif_data->remote_ss != NULL &&
-         0 != glink_os_string_compare( glink_hosts_supported[remote_host],
-                                       link_notif_data->remote_ss ) )
-    {
-      /* client is not interested in this remote SS */
-      continue;
-    }
-
-    /* Find the xport and give link UP notification */
-    for (if_ptr = smem_list_first(&glink_registered_transports[remote_host]);
-         if_ptr != NULL;
-         if_ptr = smem_list_next(if_ptr))
-    {
-      xport_ctx = if_ptr->glink_core_priv;
-
-      if (xport_ctx->status == GLINK_XPORT_LINK_UP)
-      {
-        /* Invoke registered callback */
-        glinki_check_xport_and_notify( link_notif_data, xport_ctx,
-                                       GLINK_LINK_STATE_UP );
-      }
-    }
-  } /* end for remote_host */
-} /* glinki_scan_xports_and_notify */
-
-void glinki_scan_notif_list_and_notify
-(
-  glink_transport_if_type *if_ptr,
-  glink_link_state_type state
-)
-{
-  glink_link_notif_data_type *link_notif_data;
-  glink_core_xport_ctx_type  *xport_ctx = if_ptr->glink_core_priv;
-
-  for (link_notif_data = smem_list_first(&glink_link_notif_list);
-       link_notif_data != NULL;
-       link_notif_data = smem_list_next(link_notif_data))
-  {
-    if( link_notif_data->remote_ss == NULL ||
-        0 == glink_os_string_compare( xport_ctx->remote_ss,
-                                      link_notif_data->remote_ss ) )
-    {
-      glinki_check_xport_and_notify(link_notif_data, xport_ctx, state);
-    }
-  }
-} /* glinki_scan_notif_list_and_notify */
-
-void glinki_scan_channels_and_notify_discon
-(
-  glink_transport_if_type *if_ptr
-)
-{
-  glink_channel_ctx_type     *open_ch_ctx, *dummy_open_ch_ctx;
-  glink_core_xport_ctx_type  *xport_ctx;
-
-  ASSERT(if_ptr != NULL);
-
-  xport_ctx = if_ptr->glink_core_priv;
-
-  /* Find channel in the open_list */
-  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-  open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
-  while( open_ch_ctx )
-  {
-    glink_os_cs_acquire( &open_ch_ctx->ch_state_cs );
-    open_ch_ctx->remote_state = GLINK_REMOTE_CH_SSR_RESET;
-    glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-
-    dummy_open_ch_ctx = smem_list_next( open_ch_ctx );
-
-    switch( open_ch_ctx->local_state )
-    {
-      case GLINK_LOCAL_CH_OPENED:
-      case GLINK_LOCAL_CH_OPENING:
-        /* local channel has called open at the moment. */
-        open_ch_ctx->notify_state( open_ch_ctx,
-                                   open_ch_ctx->priv,
-                                   GLINK_REMOTE_DISCONNECTED );
-        break;
-
-      case GLINK_LOCAL_CH_CLOSING:
-        /* Case when local client already closed channel
-         * but has not received ack yet */
-        if_ptr->glink_core_if_ptr->rx_cmd_ch_close_ack( if_ptr,
-                                                        open_ch_ctx->lcid );
-        break;
-
-      case GLINK_LOCAL_CH_CLOSED:
-        /* Channel fully closed - local, remote */
-        xport_ctx->channel_cleanup(open_ch_ctx);
-        smem_list_delete(&if_ptr->glink_core_priv->open_list, open_ch_ctx);
-        glink_os_free(open_ch_ctx);
-        break;
-
-      default:
-        /* invalid local channel state */
-        ASSERT(0);
-    }
-
-    open_ch_ctx = dummy_open_ch_ctx;
-
-  } /* end while */
-  glink_os_cs_release(&xport_ctx->channel_q_cs);
-}
-
-void glink_ssr(const char* remote_ss)
-{
-  unsigned int remote_host;
-  glink_transport_if_type *if_ptr;
-
-  remote_host = glinki_find_remote_host(remote_ss);
-
-  /* Scan through the registered interfaces with the crashing ss
-     and let the clients know about the crash via LINK_DOWN
-     notification followed by REMOTE_DISCONNECT */
-  if_ptr = smem_list_first(&glink_registered_transports[remote_host]);
-
-  while(if_ptr != NULL)
-  {
-    /* xport is down. change the xport state */
-    glink_os_cs_acquire(&if_ptr->glink_core_priv->status_cs);
-    if_ptr->glink_core_priv->status = GLINK_XPORT_REGISTERED;
-
-    /* Let the xport know about ssr */
-    if_ptr->ssr( if_ptr );
-
-    /* Invoke LINK_DOWN notification for any registered notifiers */
-    glinki_scan_notif_list_and_notify(if_ptr, GLINK_LINK_STATE_DOWN);
-
-    /* Invoke REMOTE_DISCONNECT for all channels associated with if_ptr */
-    glinki_scan_channels_and_notify_discon(if_ptr);
-
-    glink_os_cs_release(&if_ptr->glink_core_priv->status_cs);
-
-    if_ptr = smem_list_next(if_ptr);
-  }
-}
-
-
 /*===========================================================================
                     EXTERNAL FUNCTION DEFINITIONS
 ===========================================================================*/
-/*===========================================================================
-FUNCTION      glink_init
-
-DESCRIPTION   Initializes the GLink core library.
-
-ARGUMENTS     None
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glink_init(void)
-{
-  uint32 i;
-
-  glink_mem_log_cs = glink_os_cs_create();
-
-  glink_core_status = GLINK_INITIALIZED;
-
-  /* Create/Initalize crtitical sections */
-  glink_transport_q_cs = glink_os_cs_create();
-  if(glink_transport_q_cs == NULL) {
-    return;
-  }
-
-  glink_os_cs_acquire(glink_transport_q_cs);
-  for(i= 0; i < sizeof(glink_registered_transports)/sizeof(smem_list_type);
-      i++)
-  {
-    smem_list_init(&glink_registered_transports[i]);
-  }
-  glink_os_cs_release(glink_transport_q_cs);
-}
-
-/*===========================================================================
-FUNCTION      glink_core_register_transport
-
-DESCRIPTION   Transport calls this API to register its interface with GLINK
-              Core
-
-ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
-                      for each edge
-
-            *cfg      Pointer to transport configuration structure.
-
-RETURN VALUE  Standard GLINK error codes.
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_err_type glink_core_register_transport
-(
-  glink_transport_if_type       *if_ptr,
-  glink_core_transport_cfg_type *cfg
-)
-{
-  unsigned int remote_host = 0;
-  glink_core_xport_ctx_type *xport_ctx;
-  /* Param validation */
-  if(if_ptr == NULL || cfg == NULL)
-  {
-    GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, "", "",
-        GLINK_STATUS_INVALID_PARAM);
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-  if(cfg->name == NULL       ||
-     cfg->remote_ss == NULL  ||
-     cfg->version == NULL    ||
-     cfg->version_count == 0 ||
-     cfg->max_cid == 0)
-  {
-    GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, "", "",
-        GLINK_STATUS_INVALID_PARAM);
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-
-  if(if_ptr->tx_cmd_version == NULL             ||
-     if_ptr->tx_cmd_version_ack == NULL         ||
-     if_ptr->set_version == NULL                ||
-     if_ptr->tx_cmd_ch_open == NULL             ||
-     if_ptr->tx_cmd_ch_close == NULL            ||
-     if_ptr->tx_cmd_ch_remote_open_ack == NULL  ||
-     if_ptr->tx_cmd_ch_remote_close_ack == NULL ||
-     if_ptr->tx_cmd_set_sigs  == NULL           ||
-     if_ptr->ssr  == NULL)
-  {
-    GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, cfg->name,
-        cfg->remote_ss, GLINK_STATUS_INVALID_PARAM);
-    return GLINK_STATUS_INVALID_PARAM;;
-  }
-
-  remote_host = glinki_find_remote_host(cfg->remote_ss);
-
-  if(remote_host == GLINK_NUM_HOSTS ) {
-    /* Unknown transport name trying to register with GLink */
-    GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, cfg->name,
-           cfg->remote_ss, GLINK_STATUS_INVALID_PARAM);
-
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-  /* Set the glink_core_if_ptr to point to the default interface */
-  if_ptr->glink_core_if_ptr = glink_core_get_default_interface();
-
-  /* Allocate/fill out the GLink private context data */
-  {
-     xport_ctx = glink_os_calloc(sizeof(glink_core_xport_ctx_type));
-    if(xport_ctx == NULL) {
-      /* Free previously allocated memory */
-      glink_os_free(if_ptr->glink_core_if_ptr);
-
-      GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, cfg->name,
-          cfg->remote_ss, GLINK_STATUS_OUT_OF_RESOURCES);
-
-      return GLINK_STATUS_OUT_OF_RESOURCES;
-    }
-
-    xport_ctx->xport = cfg->name;
-    xport_ctx->remote_ss = cfg->remote_ss;
-    xport_ctx->free_lcid = 1; /* lcid 0 is reserved for invalid channel */
-    xport_ctx->version_array = cfg->version;
-    xport_ctx->version_indx = cfg->version_count - 1;
-
-    glink_os_cs_init(&xport_ctx->channel_q_cs);
-    glink_os_cs_init(&xport_ctx->liid_cs);
-    glink_os_cs_init(&xport_ctx->status_cs);
-
-    glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-    smem_list_init(&xport_ctx->open_list);
-    glink_os_cs_release(&xport_ctx->channel_q_cs);
-
-    /* Set the glink_core_if_ptr to point to the allocated structure */
-    if_ptr->glink_core_priv = xport_ctx;
-    xport_ctx->status = GLINK_XPORT_REGISTERED;
-  }
-
-  /* Push the transport interface into appropriate queue */
-  glink_os_cs_acquire(glink_transport_q_cs);
-  smem_list_append(&glink_registered_transports[remote_host], if_ptr);
-  glink_os_cs_release(glink_transport_q_cs);
-
-  GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, NULL, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
-
-  return GLINK_STATUS_SUCCESS;
-}
-
-/**
- * Regsiters a client specified callback to be invoked when the specified
- * transport (link) is up/down.
- *
- * @param[in]    link_id  Pointer to the configuration structure for the
- *                        xport(link) to be monitored. See glink.h
- * @param[in]    priv     Callback data returned to client when callback
- *                        is invoked.
- *
- * @return       Standard GLink error codes
- *
- * @sideeffects  Puts the callback in a queue which gets scanned when a
- *               transport(link) comes up OR an SSR happnes.
- */
-glink_err_type glink_register_link_state_cb
-(
-  glink_link_id_type *link_id,
-  void*              priv
-)
-{
-  glink_link_notif_data_type* link_notif_data;
-  unsigned int remote_host;
-
-  /* Input validation */
-  ASSERT(link_id != NULL);
-
-  /* Make sure client provided us with the correct version of the input
-   * structure */
-  if(link_id->version != GLINK_LINK_ID_VER || link_id->link_notifier == NULL) {
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-  /* Save the callback on the notification list */
-  if((link_notif_data = glink_os_malloc(sizeof(glink_link_notif_data_type)))
-       == NULL) {
-    return GLINK_STATUS_OUT_OF_RESOURCES;
-  }
-
-  /* Check for remote_ss validity */
-  if(link_id->remote_ss != NULL) {
-    remote_host = glinki_find_remote_host(link_id->remote_ss);
-
-    if(remote_host == sizeof(glink_hosts_supported)/sizeof(char *)) {
-      glink_os_free(link_notif_data);
-      return GLINK_STATUS_INVALID_PARAM;
-    }
-  }
-
-  link_notif_data->xport = link_id->xport;
-  link_notif_data->remote_ss = link_id->remote_ss;
-  link_notif_data->link_notifier = link_id->link_notifier;
-  link_notif_data->priv = priv; /* private client data */
-
-  /* Append the request to the list for link UP/DOWN notifications */
-  smem_list_append(&glink_link_notif_list, link_notif_data);
-
-  link_id->handle = (glink_link_handle_type)link_notif_data;
-
-  /* Scan the list of available transport to see if this link is already up */
-  glinki_scan_xports_and_notify(link_notif_data);
-
-  return GLINK_STATUS_SUCCESS;
-}
-
-/**
- * Degsiter the link UP/DOWN notification callback associated with the
- * provided handle.
- *
- * @param[in]    handle  Callback handler returned by
- *                       glink_register_link_state_cb
- *
- * @return       Standard GLink error codes
- *
- * @sideeffects  Removes the callback in a queue which gets scanned when a
- *               transport(link) comes up OR an SSR happnes.
- */
-glink_err_type glink_deregister_link_state_cb
-(
-  glink_link_handle_type handle
-)
-{
-  /* check if glink handle is NULL and return appropriate
-     return code  */
-  if(handle == NULL)
-  {
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-  smem_list_delete(&glink_link_notif_list,
-                   (glink_link_notif_data_type*)handle);
-
-  glink_os_free(handle);
-
-  return GLINK_STATUS_SUCCESS;
-}
-
-/**
- * This function gives best available transport for give edge
- *
- * @param[in]    remote_host  Index into glink_registered_transports array of
- *                            registered transports list per edge
- *
- * @return       pointer to glink_transport_if_type
- *
- * @sideeffects  NONE
- */
-glink_transport_if_type* glink_get_best_xport
-(
-  unsigned int remote_host
-)
-{
-  glink_transport_if_type   *if_ptr    = NULL, *best_if_ptr = NULL;
-  glink_xport_priority       priority  = GLINK_MIN_PRIORITY;
-  glink_core_xport_ctx_type *xport_ctx = NULL;
-
-  best_if_ptr = if_ptr = smem_list_first(
-                          &glink_registered_transports[remote_host]);
-
-  while(if_ptr != NULL)
-  {
-    xport_ctx = if_ptr->glink_core_priv;
-    /* check if priority of current transport is higher than
-     * current highest priority (0 = highest priority)
-     */
-    if( xport_ctx->status == GLINK_XPORT_LINK_UP &&
-        if_ptr->glink_priority < priority )
-    {
-      best_if_ptr = if_ptr;
-      priority    = if_ptr->glink_priority;
-    }
-    if_ptr = smem_list_next(if_ptr);
-  } /* end while() */
-
-  return best_if_ptr;
-}
 
 /**
  * Opens a logical GLink based on the specified config params
@@ -845,23 +88,20 @@
   glink_handle_type      *handle
 )
 {
-  glink_transport_if_type *if_ptr, *req_if_ptr;
+  glink_transport_if_type *if_ptr;
   glink_channel_ctx_type  *ch_ctx;
   unsigned int            remote_host;
+  glink_xport_priority     suggested_priority;
+  glink_channel_ctx_type  *allocated_ch_ctx;
+  glink_err_type           status;
 
   /* Param validation */
-  if(cfg_ptr == NULL)
-  {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN, NULL, "", "",
-        GLINK_STATUS_INVALID_PARAM);
-    return GLINK_STATUS_INVALID_PARAM;
-  }
-
-  if(cfg_ptr->remote_ss == NULL             ||
+  if(cfg_ptr == NULL            ||
+     cfg_ptr->remote_ss == NULL ||
      cfg_ptr->name == NULL                  ||
      cfg_ptr->notify_state == NULL)
   {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN, NULL, "", "",
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_OPEN, "", "", "", 
         GLINK_STATUS_INVALID_PARAM);
     return GLINK_STATUS_INVALID_PARAM;
   }
@@ -869,19 +109,24 @@
   /* Evaluate the equivalent edge name->enum for future use */
   remote_host = glinki_find_remote_host(cfg_ptr->remote_ss);
 
-  if(remote_host == GLINK_NUM_HOSTS ) {
+  if (remote_host == GLINK_NUM_HOSTS)
+  {
     /* Unknown transport name trying to register with GLink */
-    GLINK_LOG_EVENT(GLINK_EVENT_REGISTER_XPORT, cfg_ptr->name, "",
-        cfg_ptr->remote_ss, GLINK_STATUS_INVALID_PARAM);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_REGISTER_XPORT, 
+                           cfg_ptr->name, "", 
+                           cfg_ptr->remote_ss, 
+                           GLINK_STATUS_INVALID_PARAM );    
 
     return GLINK_STATUS_INVALID_PARAM;
   }
 
   /* Allocate and initialize channel info structure */
   ch_ctx = glink_os_calloc(sizeof(glink_channel_ctx_type));
-  if(ch_ctx == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN, cfg_ptr->name, "",
-        "", GLINK_STATUS_OUT_OF_RESOURCES);
+  if(ch_ctx == NULL) 
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_OPEN, 
+                           cfg_ptr->name, "", "",
+                           GLINK_STATUS_OUT_OF_RESOURCES );
     return GLINK_STATUS_OUT_OF_RESOURCES;
   }
 
@@ -899,80 +144,60 @@
   ch_ctx->notify_rx_abort = cfg_ptr->notify_rx_abort;
   ch_ctx->notify_tx_abort = cfg_ptr->notify_tx_abort;
 
-  if (ch_ctx->notify_rx_sigs == NULL) {
+  if (ch_ctx->notify_rx_sigs == NULL)
+  {
     /* set default callback */
     ch_ctx->notify_rx_sigs = glink_default_notify_rx_sigs;
   }
 
-  glink_os_cs_acquire(glink_transport_q_cs);
+  if_ptr = glinki_find_requested_xport( cfg_ptr->transport, 
+                                       cfg_ptr->remote_ss,
+                                        cfg_ptr->options,
+                                        &suggested_priority );
 
-  /* Check to see if requested transport is available */
-  for (if_ptr = smem_list_first(&glink_registered_transports[remote_host]);
-       if_ptr != NULL;
-       if_ptr = smem_list_next(if_ptr))
-  {
-    glink_core_xport_ctx_type *xport_ctx = if_ptr->glink_core_priv;
-    glink_channel_ctx_type    *allocated_ch_ctx;
-
-    if (xport_ctx->status == GLINK_XPORT_LINK_UP &&
-        (cfg_ptr->transport == NULL ||
-         0 == strcmp(cfg_ptr->transport, xport_ctx->xport)) &&
-        xport_ctx->verify_open_cfg(ch_ctx))
+  if( !if_ptr )
     {
-      glink_err_type status;
-
-      if(cfg_ptr->transport == NULL)
-      {
-        /* get best available transport */
-        if_ptr = req_if_ptr = glink_get_best_xport(remote_host);
+    /* Code gets here if we are not able to find reqeusted transport */
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_OPEN,
+                     cfg_ptr->name,
+                     cfg_ptr->transport,
+                     cfg_ptr->remote_ss,
+                     GLINK_STATUS_NO_TRANSPORT );
+    glink_os_free(ch_ctx);
+    return GLINK_STATUS_NO_TRANSPORT;
       }
-      else
-      {
-        if(cfg_ptr->options & GLINK_OPT_INITIAL_XPORT)
-        {
-          /* xport suggested by client is optional.
-           * get best available xport */
-          req_if_ptr = glink_get_best_xport(remote_host);
-        }
-        else
-        {
-          req_if_ptr = if_ptr;
-        }
-      }
-      /* Xport match found */
+  
       status = glinki_add_ch_to_xport( if_ptr,
-                                       req_if_ptr,
                                        ch_ctx,
                                        &allocated_ch_ctx,
                                        TRUE,
-                                       if_ptr->glink_priority );
+                                   suggested_priority );
 
       if( status == GLINK_STATUS_SUCCESS )
       {
         /* Set the handle and return */
         *handle = allocated_ch_ctx;
+    GLINK_LOG_EVENT( *handle,
+                     GLINK_EVENT_CH_OPEN,
+                     cfg_ptr->name,
+                     cfg_ptr->transport,
+                     cfg_ptr->remote_ss,
+                     status );
       }
       else
       {
         *handle = NULL;
-      }
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_OPEN,
+                   cfg_ptr->name,
+                   cfg_ptr->transport,
+                   cfg_ptr->remote_ss,
+                   status );
+  }
 
-      glink_os_cs_release(glink_transport_q_cs);
+  
 
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN, ch_ctx->name, xport_ctx->xport,
-        xport_ctx->remote_ss, status);
       return status;
     }
-  } /* end for() */
-
-  glink_os_cs_release(glink_transport_q_cs);
-
-  /* Code gets here if we are not able to find reqeusted transport */
-  GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN, cfg_ptr->name, cfg_ptr->transport,
-      cfg_ptr->remote_ss, GLINK_STATUS_NO_TRANSPORT);
-  glink_os_free(ch_ctx);
-  return GLINK_STATUS_NO_TRANSPORT;
-}
 
 /**
  * Closes the GLink logical channel specified by the handle.
@@ -989,43 +214,45 @@
 )
 {
   glink_err_type status;
-  glink_core_xport_ctx_type *xport_ctx = NULL;
+  glink_core_xport_ctx_type *xport_ctx; 
 
   if(handle == NULL)
   {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_CLOSE, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_CLOSE, "", "", "",
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
   /* get xport context after NULL check */
-  xport_ctx = handle->if_ptr->glink_core_priv;
-
+  xport_ctx = handle->if_ptr->glink_core_priv;  
+  
+  ASSERT( xport_ctx != NULL );
+  
   /* grab lock to change/check channel state atomically */
-  glink_os_cs_acquire( &handle->ch_state_cs );
+  glink_os_cs_acquire( &xport_ctx->channel_q_cs );
 
   /* Check to see if closed called again for same channel */
-  if ( handle->local_state == GLINK_LOCAL_CH_CLOSING ||
-       handle->local_state == GLINK_LOCAL_CH_CLOSED )
+  if (handle->local_state != GLINK_LOCAL_CH_OPENED &&
+      handle->local_state != GLINK_LOCAL_CH_OPENING)
   {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_CLOSE, handle->name, xport_ctx->xport,
-      xport_ctx->remote_ss, handle->local_state);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_CLOSE, 
+                           handle->name, 
+                           xport_ctx->xport,
+                           xport_ctx->remote_ss, 
+                           handle->local_state );
 
-    glink_os_cs_release(&handle->ch_state_cs);
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
 
-    return GLINK_STATUS_FAILURE;
+    return GLINK_STATUS_CH_ALREADY_CLOSED;
   }
 
   handle->local_state = GLINK_LOCAL_CH_CLOSING;
 
-  glink_os_cs_acquire( &xport_ctx->status_cs );
-
-  if( GLINK_XPORT_LINK_UP != xport_ctx->status ||
-      handle->remote_state == GLINK_REMOTE_CH_SSR_RESET )
+  if (handle->remote_state == GLINK_REMOTE_CH_SSR_RESET ||
+      glinki_xport_linkup(handle->if_ptr) == FALSE)
   {
-    /* SSR happened on remote-SS. Fake close_ack from here */
-    glink_os_cs_release( &xport_ctx->status_cs );
-    glink_os_cs_release( &handle->ch_state_cs );
+    /* SSR happened on remote-SS OR XPORT link is down. Fake close_ack from here */
+    glink_os_cs_release( &xport_ctx->channel_q_cs);
 
     handle->if_ptr->glink_core_if_ptr->rx_cmd_ch_close_ack( handle->if_ptr,
                                                             handle->lcid );
@@ -1034,13 +261,16 @@
   }
   else
   {
-    glink_os_cs_release( &xport_ctx->status_cs );
-    glink_os_cs_release( &handle->ch_state_cs );
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
 
     status = handle->if_ptr->tx_cmd_ch_close(handle->if_ptr, handle->lcid);
 
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_CLOSE, handle->name, xport_ctx->xport,
-        xport_ctx->remote_ss, status);
+    GLINK_LOG_EVENT( handle,
+                     GLINK_EVENT_CH_CLOSE, 
+                     handle->name, 
+                     xport_ctx->xport,
+                     xport_ctx->remote_ss, 
+                     status );
   }
 
   return status;
@@ -1119,31 +349,34 @@
 
   /* Input validation */
   if(handle == NULL || iovec == NULL || size == 0 ||
-     (vprovider == NULL && pprovider == NULL)) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_TX, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+     (vprovider == NULL && pprovider == NULL))
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_TX, "", "", "",
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
   xport_ctx = handle->if_ptr->glink_core_priv;
 
-  if( !glink_is_channel_fully_opened( handle, xport_ctx ) )
+  if (!glinki_channel_fully_opened(handle))
   {
-    GLINK_LOG_EVENT( GLINK_EVENT_CH_TX,
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_TX, 
                      handle->name,
                      xport_ctx->xport,
                      xport_ctx->remote_ss,
-                     GLINK_STATUS_FAILURE );
-
-    return GLINK_STATUS_FAILURE;
+                           GLINK_STATUS_CH_NOT_FULLY_OPENED );
+    return GLINK_STATUS_CH_NOT_FULLY_OPENED;
   }
 
   pctx = glink_os_calloc( sizeof( glink_core_tx_pkt_type ) );
 
   if (pctx == NULL)
   {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_CLOSE, handle->name, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_OUT_OF_RESOURCES);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_TX, 
+                           handle->name, 
+                           xport_ctx->xport,
+                           xport_ctx->remote_ss, 
+                           GLINK_STATUS_OUT_OF_RESOURCES );
     return GLINK_STATUS_OUT_OF_RESOURCES;
   }
 
@@ -1168,11 +401,25 @@
     pctx->iovec = iovec;
   }
 
+#ifdef FEATURE_TRACER_PACKET
+  pctx->tracer_pkt = options & GLINK_TX_TRACER_PKT ? TRUE : FALSE;
+  if( pctx->tracer_pkt )
+  {
+    glink_tracer_packet_log_pctx_pkt( pctx, GLINK_CORE_TX );
+  }
+#endif
 
   status = xport_ctx->channel_submit_pkt(handle, pctx, req_intent);
 
-  GLINK_LOG_EVENT(GLINK_EVENT_CH_TX, handle->name, xport_ctx->xport,
-      xport_ctx->remote_ss, status);
+  /*Update the channel stats*/
+  GLINK_UPDATE_CHANNEL_STATS( handle->ch_stats, tx_request, size);
+  
+  GLINK_LOG_EVENT( handle,
+                   GLINK_EVENT_CH_TX, 
+                   handle->name, 
+                   xport_ctx->xport,
+                   xport_ctx->remote_ss, 
+                   status);
 
   glink_os_cs_release(&handle->tx_cs);
   return status;
@@ -1200,75 +447,89 @@
 {
   glink_err_type         status;
   glink_rx_intent_type   *lc_intent;
-  glink_core_xport_ctx_type *xport_ctx = handle->if_ptr->glink_core_priv;
+  glink_core_xport_ctx_type *xport_ctx; 
   size_t tmp;
 
   /* Input validation */
-  if(handle == NULL || size == 0) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_Q_RX_INTENT, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+  if(handle == NULL || size == 0)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_Q_RX_INTENT, "", "", "", 
+                           GLINK_STATUS_INVALID_PARAM);
     return GLINK_STATUS_INVALID_PARAM;
   }
 
+  xport_ctx = handle->if_ptr->glink_core_priv;
+  
   /* short circuit for intentless mode */
-  if(xport_ctx->xport_capabilities & GLINK_CAPABILITY_INTENTLESS) {
-    return GLINK_STATUS_FAILURE;
+  if(xport_ctx->xport_capabilities & GLINK_CAPABILITY_INTENTLESS)
+  {
+    return GLINK_STATUS_API_NOT_SUPPORTED;
   }
 
-  if( !glink_is_channel_fully_opened( handle, xport_ctx ) )
+  if (!glinki_channel_fully_opened(handle))
   {
-    GLINK_LOG_EVENT( GLINK_EVENT_CH_Q_RX_INTENT,
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_Q_RX_INTENT, 
                      handle->name,
                      xport_ctx->xport,
                      xport_ctx->remote_ss,
-                     GLINK_STATUS_FAILURE );
-
-    return GLINK_STATUS_FAILURE;
+                           GLINK_STATUS_CH_NOT_FULLY_OPENED );
+    return GLINK_STATUS_CH_NOT_FULLY_OPENED;
   }
 
   /* Allocate an intent structure */
   lc_intent = glink_os_calloc(sizeof(glink_rx_intent_type));
-  if(lc_intent == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_Q_RX_INTENT, handle->name, xport_ctx->xport,
-        xport_ctx->remote_ss, GLINK_STATUS_OUT_OF_RESOURCES);
+  if(lc_intent == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_Q_RX_INTENT, 
+                           handle->name, 
+                           xport_ctx->xport,
+                           xport_ctx->remote_ss, 
+                           GLINK_STATUS_OUT_OF_RESOURCES );
     return GLINK_STATUS_OUT_OF_RESOURCES;
   }
 
-  glink_os_cs_acquire(&handle->if_ptr->glink_core_priv->liid_cs);
-
   /* Call transport API to allocate rx intent buffer */
   status = handle->if_ptr->allocate_rx_intent(handle->if_ptr, size, lc_intent);
-  if(status != GLINK_STATUS_SUCCESS) {
+  if(status != GLINK_STATUS_SUCCESS)
+  {
     glink_os_free(lc_intent);
-    glink_os_cs_release(&handle->if_ptr->glink_core_priv->liid_cs);
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_Q_RX_INTENT, handle->name, xport_ctx->xport,
-        xport_ctx->remote_ss, status);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_Q_RX_INTENT, 
+                           handle->name, 
+                           xport_ctx->xport,
+                           xport_ctx->remote_ss, 
+                           status );
     return status;
   }
 
   if (handle->notify_rxv == NULL &&
-     (lc_intent->vprovider(lc_intent->iovec, 0, &tmp) == NULL || tmp < size)) {
+     (lc_intent->vprovider(lc_intent->iovec, 0, &tmp) == NULL || tmp < size))
+  {
     /* Allocate bounce buffer for non-vectored Rx */
     lc_intent->data = glink_os_malloc(size);
 
-    if(lc_intent->data == NULL) {
+    if(lc_intent->data == NULL)
+    {
       handle->if_ptr->deallocate_rx_intent(handle->if_ptr, lc_intent);
       glink_os_free(lc_intent);
-      glink_os_cs_release(&handle->if_ptr->glink_core_priv->liid_cs);
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_Q_RX_INTENT, handle->name,
-        xport_ctx->xport, xport_ctx->remote_ss, GLINK_STATUS_OUT_OF_RESOURCES);
+      GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_Q_RX_INTENT, 
+                             handle->name, 
+                             xport_ctx->xport, 
+                             xport_ctx->remote_ss, 
+                             GLINK_STATUS_OUT_OF_RESOURCES );
       return GLINK_STATUS_OUT_OF_RESOURCES;
     }
   }
 
+  glink_os_cs_acquire(&handle->if_ptr->glink_core_priv->liid_cs);
+  
   /* push the intent on local queue. Do this before calling tx cmd
      as transport may try to read data into the newly queued rx_buffer */
   lc_intent->iid = handle->if_ptr->glink_core_priv->liid;
   lc_intent->size = size;
   lc_intent->pkt_priv = pkt_priv;
-  glink_os_cs_acquire(&handle->pintents->intent_q_cs);
-  smem_list_append(&handle->pintents->local_intent_q, lc_intent);
-  glink_os_cs_release(&handle->pintents->intent_q_cs);
+  glinki_enqueue_item(&handle->pintents->local_intent_q,
+                      lc_intent,
+                      &handle->pintents->intent_q_cs);
 
   /* Call transport API to queue rx intent */
   /* Increment the local intent ID counter associated with this channel */
@@ -1276,11 +537,12 @@
 
   status = handle->if_ptr->tx_cmd_local_rx_intent(handle->if_ptr,
               handle->lcid, size, lc_intent->iid);
-  if(status != GLINK_STATUS_SUCCESS) {
+  if(status != GLINK_STATUS_SUCCESS)
+  {
     /* Failure */
-    glink_os_cs_acquire(&handle->pintents->intent_q_cs);
-    smem_list_delete(&handle->pintents->local_intent_q, lc_intent);
-    glink_os_cs_release(&handle->pintents->intent_q_cs);
+    glinki_dequeue_item(&handle->pintents->local_intent_q,
+                        lc_intent,
+                        &handle->pintents->intent_q_cs);
 
     handle->if_ptr->deallocate_rx_intent(handle->if_ptr, lc_intent);
     glink_os_free(lc_intent->data);
@@ -1288,8 +550,12 @@
   }
   glink_os_cs_release(&handle->if_ptr->glink_core_priv->liid_cs);
 
-  GLINK_LOG_EVENT(GLINK_EVENT_CH_Q_RX_INTENT, handle->name, xport_ctx->xport,
-      xport_ctx->remote_ss, status);
+  GLINK_LOG_EVENT( handle,
+                   GLINK_EVENT_CH_Q_RX_INTENT, 
+                   handle->name, 
+                   xport_ctx->xport,
+                   xport_ctx->remote_ss, 
+                   status );
   return status;
 }
 
@@ -1319,59 +585,66 @@
   glink_core_xport_ctx_type *xport_ctx = handle->if_ptr->glink_core_priv;
 
   /* Input validation */
-  if(handle == NULL || ptr == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_RX_DONE, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+  if(handle == NULL || ptr == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_RX_DONE, "", "", "", 
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
   /* short circuit for intentless mode */
-  if(xport_ctx->xport_capabilities & GLINK_CAPABILITY_INTENTLESS) {
-    return GLINK_STATUS_SUCCESS;
+  if (xport_ctx->xport_capabilities & GLINK_CAPABILITY_INTENTLESS)
+  {
+    return GLINK_STATUS_API_NOT_SUPPORTED;
   }
 
-  if( !glink_is_channel_fully_opened( handle, xport_ctx ) )
+  if (!glinki_channel_fully_opened(handle))
   {
-    GLINK_LOG_EVENT( GLINK_EVENT_CH_RX_DONE,
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_RX_DONE, 
                      handle->name,
                      xport_ctx->xport,
                      xport_ctx->remote_ss,
-                     GLINK_STATUS_FAILURE );
-
-    return GLINK_STATUS_FAILURE;
+			   GLINK_STATUS_CH_NOT_FULLY_OPENED );
+    return GLINK_STATUS_CH_NOT_FULLY_OPENED;
   }
 
   /* Free the intent */
   lc_intent = smem_list_first(&handle->pintents->local_intent_client_q);
-  while(lc_intent != NULL) {
+  while(lc_intent != NULL)
+  {
     size_t tmp;
 
     if(lc_intent->iovec == ptr || (handle->notify_rxv == NULL &&
        (lc_intent->data == ptr ||
-       ptr == lc_intent->vprovider(lc_intent->iovec, 0, &tmp)))) {
+       ptr == lc_intent->vprovider(lc_intent->iovec, 0, &tmp))))
+    {
 
       uint32 iid;
 
       /* Found intent, delete it */
-      glink_os_cs_acquire(&handle->pintents->intent_q_cs);
-      smem_list_delete(&handle->pintents->local_intent_client_q, lc_intent);
-      glink_os_cs_release(&handle->pintents->intent_q_cs);
+      glinki_dequeue_item(&handle->pintents->local_intent_client_q,
+                          lc_intent,
+                          &handle->pintents->intent_q_cs);
 
       iid = lc_intent->iid;
 
+      GLINK_UPDATE_CHANNEL_STATS( handle->ch_stats, rx_done, lc_intent->pkt_sz);
+
       if (reuse)
       {
         lc_intent->used = 0;
 
-        glink_os_cs_acquire(&handle->pintents->intent_q_cs);
-        smem_list_append(&handle->pintents->local_intent_q, lc_intent);
-        glink_os_cs_release(&handle->pintents->intent_q_cs);
+        glinki_enqueue_item(&handle->pintents->local_intent_q,
+                            lc_intent,
+                            &handle->pintents->intent_q_cs);
+        
       }
       else
       {
         /* Free the intent */
         handle->if_ptr->deallocate_rx_intent(handle->if_ptr, lc_intent);
-        if(lc_intent->data) {
+        if(lc_intent->data)
+        {
           /* Free the bounce buffer if we had allocated one */
           glink_os_free(lc_intent->data);
         }
@@ -1381,18 +654,28 @@
       /* Note that the actual buffer, lc_intent->data, was allocated by the
       * transport and should be freed by the xport. We should not touch it */
       /* Let the xport know we are done with the buffer */
-      handle->if_ptr->tx_cmd_local_rx_done(handle->if_ptr, handle->lcid,
-                                           iid, reuse);
+      handle->if_ptr->tx_cmd_local_rx_done(handle->if_ptr,
+                                           handle->lcid,
+                                           iid,
+                                           reuse);
 
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_RX_DONE, handle->name, xport_ctx->xport,
-          xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
+      GLINK_LOG_EVENT( handle,
+                       GLINK_EVENT_CH_RX_DONE, 
+                       handle->name, 
+                       xport_ctx->xport,
+                       xport_ctx->remote_ss, 
+                       GLINK_STATUS_SUCCESS );
+
       return GLINK_STATUS_SUCCESS;
     }
     lc_intent = smem_list_next(lc_intent);
   }
 
-  GLINK_LOG_EVENT(GLINK_EVENT_CH_RX_DONE, handle->name, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_INVALID_PARAM);
+  GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_RX_DONE, 
+                         handle->name, 
+                         xport_ctx->xport,
+                         xport_ctx->remote_ss, 
+                         GLINK_STATUS_INVALID_PARAM );
   return GLINK_STATUS_INVALID_PARAM;
 }
 
@@ -1415,32 +698,37 @@
   uint32            sig_value
 )
 {
-  glink_core_xport_ctx_type *xport_ctx;
+  glink_core_xport_ctx_type *xport_ctx; 
   glink_err_type status;
 
   /* Input validation */
-  if(handle == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_SIG_SET, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+  if(handle == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_SIG_SET, "", "", "", 
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
-  xport_ctx = handle->if_ptr->glink_core_priv;
+	xport_ctx = handle->if_ptr->glink_core_priv;
 
-  if( !glink_is_channel_fully_opened( handle, xport_ctx ) )
+	ASSERT( xport_ctx != NULL );
+
+  if (!glinki_channel_fully_opened(handle))
   {
-    GLINK_LOG_EVENT( GLINK_EVENT_CH_SIG_SET,
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_SIG_SET, 
                      handle->name,
                      xport_ctx->xport,
                      xport_ctx->remote_ss,
-                     GLINK_STATUS_FAILURE );
+                           GLINK_STATUS_CH_NOT_FULLY_OPENED );
 
-    return GLINK_STATUS_FAILURE;
+    return GLINK_STATUS_CH_NOT_FULLY_OPENED;
   }
 
-  status = handle->if_ptr->tx_cmd_set_sigs(handle->if_ptr, handle->lcid,
+  status = handle->if_ptr->tx_cmd_set_sigs(handle->if_ptr,
+                                           handle->lcid,
                                            sig_value);
-  if(GLINK_STATUS_SUCCESS == status) {
+  if(GLINK_STATUS_SUCCESS == status)
+  {
     /* Update local copy of local control signal state */
     handle->local_sigs = sig_value;
   }
@@ -1466,9 +754,10 @@
 )
 {
   /* Input validation */
-  if(handle == NULL || sig_value == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_SIG_L_GET, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+  if(handle == NULL || sig_value == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_SIG_L_GET, "", "", "", 
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
@@ -1495,9 +784,10 @@
 )
 {
   /* Input validation */
-  if(handle == NULL || sig_value == NULL) {
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_SIG_R_GET, NULL, "",
-        "", GLINK_STATUS_INVALID_PARAM);
+  if(handle == NULL || sig_value == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_CH_SIG_R_GET, "", "", "", 
+                           GLINK_STATUS_INVALID_PARAM );
     return GLINK_STATUS_INVALID_PARAM;
   }
 
@@ -1506,6 +796,100 @@
   return GLINK_STATUS_SUCCESS;
 }
 
+/** 
+ * Regsiters a client specified callback to be invoked when the specified
+ * transport (link) is up/down.
+ *
+ * @param[in]    link_id  Pointer to the configuration structure for the
+ *                        xport(link) to be monitored. See glink.h
+ * @param[in]    priv     Callback data returned to client when callback
+ *                        is invoked.
+ *
+ * @return       Standard GLink error codes
+ *
+ * @sideeffects  Puts the callback in a queue which gets scanned when a 
+ *               transport(link) comes up OR an SSR happnes.
+ */
+glink_err_type glink_register_link_state_cb
+(
+  glink_link_id_type *link_id,
+  void*              priv
+)
+{
+  glink_link_notif_data_type* link_notif_data;
+  unsigned int remote_host;
+
+  /* Input validation */
+  if (link_id == NULL ||
+      link_id->version != GLINK_LINK_ID_VER ||
+      link_id->link_notifier == NULL)
+  {
+    return GLINK_STATUS_INVALID_PARAM;
+  }
+
+  /* Check for remote_ss validity */
+  if (link_id->remote_ss != NULL)
+  {
+    remote_host = glinki_find_remote_host(link_id->remote_ss);
+    if (remote_host == GLINK_NUM_HOSTS)
+    {
+      return GLINK_STATUS_INVALID_PARAM;
+    }
+  }
+  
+  /* Save the callback on the notification list */
+  if((link_notif_data = glink_os_calloc(sizeof(glink_link_notif_data_type)))
+       == NULL)
+  {
+    return GLINK_STATUS_OUT_OF_RESOURCES;
+  }
+
+  link_notif_data->xport = link_id->xport;
+  link_notif_data->remote_ss = link_id->remote_ss;
+  link_notif_data->link_notifier = link_id->link_notifier;
+  link_notif_data->priv = priv; /* private client data */
+
+  /* Append the request to the list for link UP/DOWN notifications */
+  glinki_register_link_notif_data(link_notif_data);
+  link_id->handle = (glink_link_handle_type)link_notif_data;
+  
+  /* Scan the list of available transport to see if this link is already up */
+  glinki_scan_xports_and_notify(link_notif_data);
+
+  return GLINK_STATUS_SUCCESS;
+}
+
+/** 
+ * Degsiter the link UP/DOWN notification callback associated with the
+ * provided handle.
+ *
+ * @param[in]    handle  Callback handler returned by 
+ *                       glink_register_link_state_cb
+ *
+ * @return       Standard GLink error codes
+ *
+ * @sideeffects  Removes the callback in a queue which gets scanned when a 
+ *               transport(link) comes up OR an SSR happnes.
+ */
+glink_err_type glink_deregister_link_state_cb
+(
+  glink_link_handle_type handle
+)
+{
+  /* check if glink handle is NULL and return appropriate
+     return code  */
+  if(handle == NULL) 
+  {
+    return GLINK_STATUS_INVALID_PARAM;
+  }
+
+  glinki_deregister_link_notif_data((glink_link_notif_data_type *)handle);
+  
+  glink_os_free(handle);
+
+  return GLINK_STATUS_SUCCESS;
+}
+
 /*================= RESTRICTED API ==========================*/
 
 /**
@@ -1524,12 +908,15 @@
   glink_handle_type handle
 )
 {
-  ASSERT(handle);
+  if (!handle)
+  {
+    return GLINK_STATUS_INVALID_PARAM;
+  }
 
   if(handle->if_ptr->poll) {
     return handle->if_ptr->poll(handle->if_ptr);
   }
-  return GLINK_STATUS_FAILURE;
+  return GLINK_STATUS_API_NOT_SUPPORTED;
 }
 
 /**
@@ -1553,12 +940,15 @@
   void              *platform_struct
 )
 {
-  ASSERT(handle);
+  if (!handle)
+  {
+    return GLINK_STATUS_INVALID_PARAM;
+  }
 
   if(handle->if_ptr->mask_rx_irq) {
     return handle->if_ptr->mask_rx_irq(handle->if_ptr, mask);
   }
-  return GLINK_STATUS_FAILURE;
+  return GLINK_STATUS_API_NOT_SUPPORTED;
 }
 
 /**
@@ -1580,20 +970,3 @@
   return handle->if_ptr->wait_link_down(handle->if_ptr) ?
          GLINK_STATUS_SUCCESS : GLINK_STATUS_FAILURE;
 }
-
-/* ============ Internal Logging API ================ */
-void glink_mem_log
-(
-  const char *func,
-  uint32 line,
-  glink_log_event_type type,
-  const char *msg,
-  const char *xport,
-  const char *remote_ss,
-  uint32 param
-)
-{
-#ifdef DEBUG_GLINK
-  dprintf(INFO, "%s:%u, event:%d, msg:%s, xport:%s, remote_ss:%s, param:%u\n", func, line, type, msg, xport, remote_ss, param);
-#endif
-}
diff --git a/platform/msm_shared/glink/glink_core_if.c b/platform/msm_shared/glink/glink_core_if.c
index 5e3abd5..5b56c65 100644
--- a/platform/msm_shared/glink/glink_core_if.c
+++ b/platform/msm_shared/glink/glink_core_if.c
@@ -34,21 +34,12 @@
 #include "glink_os_utils.h"
 #include "glink.h"
 #include "glink_internal.h"
-#include "smem_list.h"
-#include "glink_channel_migration.h"
 
 #define FEATURE_CH_MIGRATION_FREE
 
 /*===========================================================================
                         GLOBAL FUNCTION DECLARATIONS
-==========================================================================*/
-extern void glinki_scan_notif_list_and_notify
-(
-  glink_transport_if_type *if_ptr,
-  glink_link_state_type state
-);
-
-
+===========================================================================*/
 /*===========================================================================
                      LOCAL FUNCTION DEFINITIONS
 ===========================================================================*/
@@ -87,16 +78,11 @@
    * Only go through process once in case they are negotiated
    * in ver_req before receiving ver_ack */
 
-  glink_os_cs_acquire( &xport_ctx->status_cs );
-
-  if( xport_ctx->status == GLINK_XPORT_LINK_UP )
+  if (glinki_xport_linkup(if_ptr))
   {
-    glink_os_cs_release( &xport_ctx->status_cs );
     return;
   }
 
-  glink_os_cs_release(&if_ptr->glink_core_priv->status_cs);
-
   /* setup core based on transport capabilities*/
   xport_ctx->xport_capabilities = if_ptr->set_version( if_ptr,
                                                        version,
@@ -106,27 +92,26 @@
   /* transport is ready to open channels */
   glink_os_cs_acquire( &xport_ctx->status_cs );
   if_ptr->glink_core_priv->status = GLINK_XPORT_LINK_UP;
-  glink_os_cs_release(&if_ptr->glink_core_priv->status_cs);
+  glink_os_cs_release(&xport_ctx->status_cs);
 
   /* Scan the notification list to check is we have to let any registered
    * clients know that link came online */
   glinki_scan_notif_list_and_notify(if_ptr, GLINK_LINK_STATE_UP);
 }
 
-
 /*===========================================================================
   FUNCTION      glink_clean_channel_ctx
 ===========================================================================*/
 /**
 
-  This is called when channel is fully closed
-  Clean up the context and redeem channel id if possible
+  This is called when channel is fully closed.
+  Clean up the context and redeem channel id if possible.
 
   @param[in]    xport_ctx    transport context
   @param[in]    channel_ctx  channel context
 
 
-  @return        None
+  @return        None.
   @sideeffects   None.
   @dependencies  This function needs to be called in safe context
                  which is critical sections locked - channel_q_cs
@@ -138,7 +123,10 @@
   glink_channel_ctx_type    *channel_ctx
 )
 {
-  xport_ctx->channel_cleanup( channel_ctx );
+  /* If logging was enabled for this channel reset the logging filter */
+  glinki_update_logging_filter(channel_ctx, TRUE);
+  
+  smem_list_delete(&xport_ctx->open_list, channel_ctx);
 
   if( channel_ctx->lcid == ( xport_ctx->free_lcid - 1 ) )
   {
@@ -147,7 +135,87 @@
     xport_ctx->free_lcid--;
   }
 
-  smem_list_delete(&xport_ctx->open_list, channel_ctx);
+  xport_ctx->channel_cleanup(channel_ctx);
+}
+
+/*===========================================================================
+  FUNCTION      glink_get_current_version
+===========================================================================*/
+/**
+
+  Get current version/feature. This is necessarily highest version.
+
+  @param[in]     xport_ctx    transport context
+  
+  @return        pointer to version/feature if available.
+                 NULL otherwise.
+  
+  @sideeffects   None.
+  @dependencies  None.
+*/
+/*=========================================================================*/
+static const glink_core_version_type *glink_get_current_version
+(
+  glink_core_xport_ctx_type *xport_ctx
+)
+{
+  const glink_core_version_type *ver;
+  
+  ver = &xport_ctx->version_array[xport_ctx->version_indx];
+  ASSERT(ver);
+  
+  return ver;
+}
+
+/*===========================================================================
+  FUNCTION      glink_is_local_ch_closed
+===========================================================================*/
+/**
+
+  Check if local channel is fully closed
+  
+  @param[in]     local_state local channel state
+  
+  @return        TRUE, if local channel is closed
+  
+  @sideeffects   None.
+  @dependencies  None.
+*/
+/*=========================================================================*/
+static boolean glink_is_local_ch_closed
+(
+  glink_local_state_type local_state
+)
+{
+  return local_state == GLINK_LOCAL_CH_INIT ||
+         local_state == GLINK_LOCAL_CH_CLOSED;
+}
+
+/*===========================================================================
+  FUNCTION      glink_is_remote_ch_closed
+===========================================================================*/
+/**
+
+  Check if remote channel is fully closed.
+  This doesn't chek GLINK_REMOTE_CH_CLEANUP state as channel ctx shouldn't be
+  destroyed yet
+  
+  @param[in]     ch_ctx  channel ctx
+  
+  @return        TRUE, if remote channel is closed
+  
+  @sideeffects   None.
+  @dependencies  None.
+*/
+/*=========================================================================*/
+static boolean glink_is_remote_ch_closed
+(
+    glink_remote_state_type remote_state
+)
+{
+  return remote_state == GLINK_REMOTE_CH_INIT ||
+         remote_state == GLINK_REMOTE_CH_CLOSED ||
+         remote_state == GLINK_REMOTE_CH_SSR_RESET;
 }
 
 /*===========================================================================
@@ -173,14 +241,12 @@
   glink_transport_if_type *if_ptr
 )
 {
-  const glink_core_version_type *version_array;
   glink_core_xport_ctx_type *xport_ctx;
-
-  ASSERT(if_ptr != NULL);
+  const glink_core_version_type *version_array;
 
   xport_ctx = if_ptr->glink_core_priv;
 
-  version_array = xport_ctx->version_array;
+  version_array = glink_get_current_version(xport_ctx);
 
   /* Update the transport state */
   glink_os_cs_acquire(&if_ptr->glink_core_priv->status_cs);
@@ -188,12 +254,14 @@
   glink_os_cs_release(&if_ptr->glink_core_priv->status_cs);
 
   /* Start the negtiation */
-  if_ptr->tx_cmd_version(if_ptr, version_array->version,
+  if_ptr->tx_cmd_version(if_ptr,
+                         version_array->version,
       version_array->features);
 
-  GLINK_LOG_EVENT(GLINK_EVENT_LINK_UP, NULL, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
-
+  GLINK_LOG_EVENT_NO_FILTER( GLINK_EVENT_LINK_UP, "", 
+                             xport_ctx->xport, 
+                             xport_ctx->remote_ss, 
+                             GLINK_STATUS_SUCCESS);
 }
 
 /*===========================================================================
@@ -224,40 +292,28 @@
   uint32 negotiated_features;
   glink_core_xport_ctx_type *xport_ctx;
 
-  ASSERT(if_ptr != NULL);
-
   xport_ctx = if_ptr->glink_core_priv;
 
+  ver = glink_get_current_version(xport_ctx);
+  
   /* The version to use must be a subset of supported version and features
    * on this host and remote host */
-  ver = &xport_ctx->version_array[xport_ctx->version_indx];
-  ASSERT(ver);
-
   if (version == ver->version)
   {
     /* Call the transport's negotiation function */
     negotiated_features = ver->negotiate_features(if_ptr, ver, features);
 
+    if_ptr->tx_cmd_version_ack(if_ptr, version, negotiated_features);
+    
     /* If negotiated features match the provided features, version nogetiation
      * is complete */
     if(negotiated_features == features)
     {
-      /* send version ack before allowing to open channels */
-      if_ptr->tx_cmd_version_ack(if_ptr, version, features);
-
       glink_process_negotiation_complete( if_ptr, version, features );
-      return;
-    }
-    else
-    {
-      if_ptr->tx_cmd_version_ack(if_ptr, version, negotiated_features);
     }
   }
   else
   {
-    /* Next time use older version */
-    ver = &xport_ctx->version_array[xport_ctx->version_indx];
-
     /* Versions don't match, return ACK with the feature set that we support */
     if_ptr->tx_cmd_version_ack(if_ptr, ver->version, ver->features);
   }
@@ -291,38 +347,33 @@
   uint32 negotiated_features;
   glink_core_xport_ctx_type *xport_ctx;
 
-  ASSERT(if_ptr != NULL);
-
   xport_ctx = if_ptr->glink_core_priv;
 
   /* Check to see if version returned by remote end is supported by
    * this host. Remote side would have acked only when the version/features
    * sent by this host did not match the remote */
-
-  ver = &xport_ctx->version_array[xport_ctx->version_indx];
-  ASSERT(ver);
+  ver = glink_get_current_version(xport_ctx);
 
   if (ver->version == version)
   {
     /* Call the transport's negotiation function */
     negotiated_features = ver->negotiate_features(if_ptr, ver, features);
 
-    if(negotiated_features != features)
+    if(negotiated_features == features)
+    {
+      glink_process_negotiation_complete( if_ptr, version, features );
+    }
+    else
     {
       /* Continue negotiating */
       if_ptr->tx_cmd_version(if_ptr, version, negotiated_features);
     }
-    else
-    {
-      glink_process_negotiation_complete( if_ptr, version, features );
-    }
   }
   else
   {
-    while (ver->version > version)
+    while (ver->version > version && xport_ctx->version_indx > 0)
     {
       /* Next time use older version */
-      ASSERT(xport_ctx->version_indx > 0);
       xport_ctx->version_indx--;
       ver = &xport_ctx->version_array[xport_ctx->version_indx];
     }
@@ -334,23 +385,22 @@
 
 /*===========================================================================
 FUNCTION      glink_rx_cmd_ch_remote_open
-
-DESCRIPTION   Receive remote channel open request; Calls
-              glink_transport_if:: tx_cmd_ch_remote_open_ack as a result
-
-ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
-                      for each edge
-
-            rcid     Remote Channel ID
-
-            *name    String name for logical channel
-
-            prio     xport priority requested by remote side
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
 ===========================================================================*/
+/** 
+ * Receive remote channel open request; 
+ * Calls glink_transport_if:: tx_cmd_ch_remote_open_ack as a result
+ *
+ * @param[in]    if_ptr    Pointer to interface instance; must be unique
+                           for each edge
+ * @param[in]    rcid      Remote Channel ID
+ * @param[in]    name      String name for logical channel
+ * @param[in]    priority  xport priority requested by remote side
+ *
+ * @return       None
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
 void glink_rx_cmd_ch_remote_open
 (
   glink_transport_if_type *if_ptr,
@@ -361,22 +411,19 @@
 {
   glink_channel_ctx_type     *remote_ch_ctx  = NULL;
   glink_channel_ctx_type     *allocated_ch_ctx;
-
-  glink_xport_priority        negotiated_xport_priority;
-  glink_core_xport_ctx_type  *xport_ctx;
   glink_err_type              status;
 
-  ASSERT( if_ptr != NULL );
-  ASSERT( name != NULL );
-
-  xport_ctx = if_ptr->glink_core_priv;
-
+  GLINK_OS_UNREFERENCED_PARAM( priority );
+  
   /* Allocate and initialize channel info structure */
   remote_ch_ctx = glink_os_calloc( sizeof( glink_channel_ctx_type ) );
   if(remote_ch_ctx == NULL)
   {
-    GLINK_LOG_EVENT(GLINK_EVENT_RM_CH_OPEN, name, xport_ctx->xport,
-        xport_ctx->remote_ss, GLINK_STATUS_OUT_OF_RESOURCES);
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_RM_CH_OPEN,
+                     name,
+                     if_ptr->glink_core_priv->xport,
+                     if_ptr->glink_core_priv->remote_ss,
+                     GLINK_STATUS_OUT_OF_RESOURCES );
     ASSERT(0);
   }
 
@@ -384,132 +431,39 @@
   glink_os_string_copy(remote_ch_ctx->name, name, sizeof(remote_ch_ctx->name));
   remote_ch_ctx->rcid = rcid;
 
-#ifndef FEATURE_CH_MIGRATION_FREE
-  glink_channel_ctx_type     *present_ch_ctx = NULL;
-  glink_transport_if_type    *negotiated_xport;
-  glink_channel_ctx_type     *dummy_ch_ctx;
+	status = glinki_add_ch_to_xport( if_ptr,
+																	 remote_ch_ctx,
+																	 &allocated_ch_ctx,
+																	 FALSE,
+																	 if_ptr->glink_priority );
 
-  /* search if channel with given name exists locally */
+  GLINK_LOG_EVENT( allocated_ch_ctx,
+                   GLINK_EVENT_RM_CH_OPEN,
+                     name,
+                   if_ptr->glink_core_priv->xport,
+                   if_ptr->glink_core_priv->remote_ss,
+                   status );
 
-  glink_os_cs_acquire( &xport_ctx->channel_q_cs );
-  present_ch_ctx = glinki_local_channel_exists( if_ptr, name );
-
-  if( !present_ch_ctx )
-  {
-    // channel doesn't exists yet and migration will not happen here
-    status = glinki_add_ch_to_xport( if_ptr,
-                                     if_ptr,
-                                     remote_ch_ctx,
-                                     &allocated_ch_ctx,
-                                     FALSE,
-                                     if_ptr->glink_priority );
-    ASSERT(status == GLINK_STATUS_SUCCESS);
-
-    GLINK_LOG_EVENT(GLINK_EVENT_RM_CH_OPEN, name, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
-
-    glink_os_cs_release( &xport_ctx->channel_q_cs );
-    return;
-  }
-
-  glink_os_cs_release( &xport_ctx->channel_q_cs );
-
-  present_ch_ctx->rcid = rcid;
-
-  if( present_ch_ctx->tag_ch_for_close )
-  {
-    // Migration already started.
-    GLINK_LOG_EVENT(GLINK_EVENT_CH_MIGRATION_IN_PROGRESS, name, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
-
-    return;
-  }
-
-  /* Negotiate the priority for migration if needed */
-  if( priority < present_ch_ctx->req_if_ptr->glink_priority )
-  {
-    negotiated_xport_priority = present_ch_ctx->req_if_ptr->glink_priority;
-  }
-  else
-  {
-    negotiated_xport_priority = priority;
-  }
-
-  negotiated_xport =  glinki_get_xport_from_prio( negotiated_xport_priority,
-                                                  xport_ctx->remote_ss );
-
-  if( if_ptr == negotiated_xport )
-  {
-    /* Current transport is best one. No need to migrate */
-
-    status = glinki_add_ch_to_xport( if_ptr,
-                                     if_ptr,
-                                     remote_ch_ctx,
-                                     &allocated_ch_ctx,
-                                     FALSE,
-                                     negotiated_xport_priority );
-
-    ASSERT(status == GLINK_STATUS_SUCCESS);
-    GLINK_LOG_EVENT( GLINK_EVENT_CH_NO_MIGRATION, name, xport_ctx->xport,
-      xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
-
-    return;
-  }
-
-  /* Need to migrate to new transport */
-  if_ptr->tx_cmd_ch_remote_open_ack( if_ptr,
-                                     rcid,
-                                     negotiated_xport_priority );
-
-  glink_create_dummy_ch_ctx( &dummy_ch_ctx, present_ch_ctx );
-  glink_close_dummy_ch_for_migration( if_ptr, dummy_ch_ctx );
-  glink_init_ch_migrate_candidate( present_ch_ctx );
-
-  status = glinki_add_ch_to_xport( negotiated_xport,
-                                   negotiated_xport,
-                                   present_ch_ctx,
-                                   &allocated_ch_ctx,
-                                   TRUE,
-                                   negotiated_xport_priority );
-
-  ASSERT( status == GLINK_STATUS_SUCCESS );
-
-  glink_os_free( remote_ch_ctx );
-
-#else
-  negotiated_xport_priority = if_ptr->glink_priority;
-
-  status = glinki_add_ch_to_xport( if_ptr,
-                                   NULL,
-                                   remote_ch_ctx,
-                                   &allocated_ch_ctx,
-                                   FALSE,
-                                   negotiated_xport_priority );
-
-  ASSERT(status == GLINK_STATUS_SUCCESS);
-#endif
-
-  GLINK_LOG_EVENT(GLINK_EVENT_RM_CH_OPEN, name, xport_ctx->xport,
-    xport_ctx->remote_ss, GLINK_STATUS_SUCCESS);
+  ASSERT(GLINK_STATUS_SUCCESS == status);
 }
 
 /*===========================================================================
 FUNCTION      glink_rx_cmd_ch_open_ack
-
-DESCRIPTION   This function is invoked by the transport in response to
-              glink_transport_if:: tx_cmd_ch_open
-
-ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
-                      for each edge
-
-            lcid     Local Channel ID
-
-            prio     Negotiated xport priority from remote side
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
 ===========================================================================*/
+/** 
+ * This function is invoked by the transport
+ * in response to glink_transport_if:: tx_cmd_ch_open
+ *
+ * @param[in]    if_ptr            Pointer to interface instance; must be unique
+ *                                 for each edge
+ * @param[in]    lcid              Local Channel ID
+ * @param[in]    migrated_ch_prio  Negotiated xport priority from remote side
+ *
+ * @return       None
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
 void glink_rx_cmd_ch_open_ack
 (
   glink_transport_if_type *if_ptr,
@@ -519,312 +473,241 @@
 {
   glink_channel_ctx_type     *open_ch_ctx;
   glink_core_xport_ctx_type  *xport_ctx;
+  glink_remote_state_type    remote_state;
 
-  ASSERT(if_ptr != NULL);
-
+  GLINK_OS_UNREFERENCED_PARAM( migrated_ch_prio );
+  
   xport_ctx = if_ptr->glink_core_priv;
 
   /* Move to closed state. Implies we clean up the channel from the
    * open list */
   glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-  /* Find channel in the open_list */
-  open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
-  while(open_ch_ctx != NULL)
-  {
-    if(open_ch_ctx->lcid == lcid)
-    {
-#ifndef FEATURE_CH_MIGRATION_FREE
-      glink_transport_if_type    *negotiated_xport = NULL;
-      negotiated_xport = glinki_get_xport_from_prio( migrated_ch_prio,
-                                                     xport_ctx->remote_ss );
+  
+  open_ch_ctx = glinki_find_ch_ctx_by_lcid(xport_ctx, lcid);
+  
+			if( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSING )
+			{
+			/* Client called glink_close before gettng open ack. 
+			 * Ignore open ack and go for closing sequence */
+				glink_os_cs_release( &xport_ctx->channel_q_cs );
+				return;
+			}
 
-      if( negotiated_xport != if_ptr &&
-          !open_ch_ctx->tag_ch_for_close &&
-          ( open_ch_ctx->ch_open_options & GLINK_OPT_INITIAL_XPORT ) )
-      {
-        glink_channel_ctx_type *dummy_ch_ctx;
-        glink_err_type          status;
+  ASSERT(open_ch_ctx->local_state == GLINK_LOCAL_CH_OPENING);
+  
+			open_ch_ctx->local_state = GLINK_LOCAL_CH_OPENED;
 
-        glink_create_dummy_ch_ctx( &dummy_ch_ctx, open_ch_ctx );
-        glink_close_dummy_ch_for_migration( if_ptr, dummy_ch_ctx );
-
-        glink_init_ch_migrate_candidate( open_ch_ctx );
-        dummy_ch_ctx = NULL;
-
-        status = glinki_add_ch_to_xport( negotiated_xport,
-                                         negotiated_xport,
-                                         open_ch_ctx,
-                                         &dummy_ch_ctx,
-                                         TRUE,
-                                         negotiated_xport->glink_priority );
-
-        ASSERT( status == GLINK_STATUS_SUCCESS );
-      }
-      else
-      {
-        glink_os_cs_acquire( &open_ch_ctx->ch_state_cs );
-
-        if( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSING )
-        {
-          /* Local client called glink_close
-           * before local channel is fully opened */
-          glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-          glink_os_cs_release( &xport_ctx->channel_q_cs );
-          return;
-        }
-
-        open_ch_ctx->local_state = GLINK_LOCAL_CH_OPENED;
-
-        if( open_ch_ctx->remote_state == GLINK_REMOTE_CH_OPENED )
-        {
-          glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-          open_ch_ctx->notify_state( open_ch_ctx,
-                                     open_ch_ctx->priv,
-                                     GLINK_CONNECTED );
-        }
-        else
-        {
-          glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-        }
-      }
-
-#else
-      /* This is same code as above. once core capability code is done copy
-       * issue should be resolved */
-      glink_os_cs_acquire( &open_ch_ctx->ch_state_cs );
-      open_ch_ctx->local_state = GLINK_LOCAL_CH_OPENED;
-      if( open_ch_ctx->remote_state == GLINK_REMOTE_CH_OPENED )
-      {
-        /* remote channel is open on same xport as current xport.
-         * change channel state to GLINK_CH_STATE_OPEN and notify client */
-        glink_os_cs_release( &open_ch_ctx->ch_state_cs );
-        open_ch_ctx->notify_state( open_ch_ctx,
-                                   open_ch_ctx->priv,
-                                   GLINK_CONNECTED);
-      }
-#endif
-
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_OPEN_ACK, open_ch_ctx->name,
-          xport_ctx->xport, xport_ctx->remote_ss, lcid);
-      glink_os_cs_release(&xport_ctx->channel_q_cs);
-      return;
-    }
-    open_ch_ctx = smem_list_next(open_ch_ctx);
-  }
+  remote_state = open_ch_ctx->remote_state;
   glink_os_cs_release(&xport_ctx->channel_q_cs);
-  /* We are here in case we could not find the channel in the open list. */
-  ASSERT(0);
+  
+  if (remote_state == GLINK_REMOTE_CH_OPENED)
+			{
+			/* remote channel is open on same xport as current xport.
+			 * change channel state to GLINK_CH_STATE_OPEN and notify client */
+				open_ch_ctx->notify_state( open_ch_ctx,
+																	 open_ch_ctx->priv,
+																	 GLINK_CONNECTED );
+			}
+
+  GLINK_LOG_EVENT( open_ch_ctx, 
+                   GLINK_EVENT_CH_OPEN_ACK, 
+                   open_ch_ctx->name, 
+                   xport_ctx->xport, 
+                   xport_ctx->remote_ss, 
+                   lcid );
 }
 
 /*===========================================================================
 FUNCTION      glink_rx_cmd_ch_close_ack
-
-DESCRIPTION   This function is invoked by the transport in response to
-              glink_transport_if_type:: tx_cmd_ch_close
-
-ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
-                      for each edge
-
-            lcid      Local Channel ID
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
 ===========================================================================*/
+/** 
+ * This function is invoked by the transport in response to 
+ * glink_transport_if_type:: tx_cmd_ch_close
+ *
+ * @param[in]    if_ptr            Pointer to interface instance; must be unique
+ *                                 for each edge
+ * @param[in]    lcid              Local Channel ID
+ *
+ * @return       None
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
 void glink_rx_cmd_ch_close_ack
 (
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  lcid     /* Local channel ID */
+  glink_transport_if_type *if_ptr,
+  uint32                   lcid
 )
 {
   glink_channel_ctx_type *open_ch_ctx;
   glink_core_xport_ctx_type  *xport_ctx;
 
-  ASSERT(if_ptr != NULL);
-
   xport_ctx = if_ptr->glink_core_priv;
 
-  /* Move to closed state. Implies we clean up the channel from the
-   * open list */
-
-  /* Find channel in the open_list */
   glink_os_cs_acquire(&xport_ctx->channel_q_cs);
-  open_ch_ctx = smem_list_first(&xport_ctx->open_list);
-  while( open_ch_ctx )
-  {
-    if( open_ch_ctx->lcid == lcid )
-    {
-      /* Found channel */
-      glink_os_cs_acquire( &open_ch_ctx->ch_state_cs );
-
-
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_CLOSE_ACK, open_ch_ctx->name,
-          xport_ctx->xport, xport_ctx->remote_ss, lcid);
+  
+  open_ch_ctx = glinki_find_ch_ctx_by_lcid(xport_ctx, lcid);
+  
+  GLINK_LOG_EVENT( open_ch_ctx, 
+                   GLINK_EVENT_CH_CLOSE_ACK, 
+                   open_ch_ctx->name,
+                   xport_ctx->xport, 
+                   xport_ctx->remote_ss, 
+                   lcid);
 
       ASSERT( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSING );
 
       open_ch_ctx->local_state = GLINK_LOCAL_CH_CLOSED;
+  open_ch_ctx->lcid        = GLINK_INVALID_CID;
 
-      if( open_ch_ctx->remote_state == GLINK_REMOTE_CH_CLOSED ||
-          open_ch_ctx->remote_state == GLINK_REMOTE_CH_SSR_RESET )
+  if ( glink_is_remote_ch_closed( open_ch_ctx->remote_state ) )
       {
         glink_clean_channel_ctx( xport_ctx, open_ch_ctx );
       }
 
-      glink_os_cs_release(&open_ch_ctx->ch_state_cs);
       glink_os_cs_release(&xport_ctx->channel_q_cs);
 
       open_ch_ctx->notify_state( open_ch_ctx,
                                  open_ch_ctx->priv,
                                  GLINK_LOCAL_DISCONNECTED );
 
-      if( open_ch_ctx->remote_state == GLINK_REMOTE_CH_CLOSED ||
-          open_ch_ctx->remote_state == GLINK_REMOTE_CH_SSR_RESET )
+  if ( glink_is_remote_ch_closed( open_ch_ctx->remote_state ) )
       {
         glink_os_free( open_ch_ctx );
       }
-
-      return;
-    }
-    open_ch_ctx = smem_list_next(open_ch_ctx);
-  }/* end while */
-
-  glink_os_cs_release(&xport_ctx->channel_q_cs);
-  /* We are here in case we could not find the channel in the open list. */
-  ASSERT(0);
 }
 
 /*===========================================================================
 FUNCTION      glink_rx_cmd_ch_remote_close
-
-DESCRIPTION   Remote channel close request; will result in sending
-              glink_transport_if_type:: tx_cmd_ch_remote_close_ack
-
-ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
-                      for each edge
-
-            rcid      Remote Channel ID
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
 ===========================================================================*/
+/** 
+ * Remote channel close request; will result in sending 
+ * glink_transport_if_type:: tx_cmd_ch_remote_close_ack
+ *
+ * @param[in]    if_ptr            Pointer to interface instance; must be unique
+ *                                 for each edge
+ * @param[in]    rcid              Remote Channel ID
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
 void glink_rx_cmd_ch_remote_close
 (
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  rcid     /* Remote channel ID */
+  glink_transport_if_type *if_ptr,
+  uint32                   rcid
 )
 {
   glink_channel_ctx_type *open_ch_ctx;
   glink_core_xport_ctx_type  *xport_ctx;
-
-  ASSERT(if_ptr != NULL);
+  glink_remote_state_type    remote_state;
 
   xport_ctx = if_ptr->glink_core_priv;
 
-  /* Find channel in the open_list */
   glink_os_cs_acquire( &xport_ctx->channel_q_cs );
 
-  open_ch_ctx = smem_list_first( &if_ptr->glink_core_priv->open_list );
-  while(open_ch_ctx != NULL)
-  {
-    if( open_ch_ctx->rcid == rcid )
-    {
-      GLINK_LOG_EVENT( GLINK_EVENT_CH_REMOTE_CLOSE, open_ch_ctx->name,
-                       xport_ctx->xport, xport_ctx->remote_ss, rcid);
-      /* Found channel, transition to appropriate state based on current state
-       * grab lock to perform channel state related operations */
-      glink_os_cs_acquire(&open_ch_ctx->ch_state_cs);
+  open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid);
 
+  GLINK_LOG_EVENT( open_ch_ctx, 
+                   GLINK_EVENT_CH_REMOTE_CLOSE, 
+                   open_ch_ctx->name, 
+                   xport_ctx->xport, 
+                   xport_ctx->remote_ss, 
+                   rcid );
+
+  /* It is possible that the remote subsystem sending close might crash 
+     before we handle the close request from it */
+  if (open_ch_ctx->remote_state == GLINK_REMOTE_CH_SSR_RESET)
+  {
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+    return;
+  }
+                   
       ASSERT( open_ch_ctx->remote_state == GLINK_REMOTE_CH_OPENED );
 
       open_ch_ctx->remote_state = GLINK_REMOTE_CH_CLOSED;
+  open_ch_ctx->rcid         = GLINK_INVALID_CID;
 
-      if( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSED )
+  if ( glink_is_local_ch_closed( open_ch_ctx->local_state ) )
       {
         /* Local side never opened the channel OR it opened it but closed it */
         /* Free channel resources */
         glink_clean_channel_ctx( xport_ctx, open_ch_ctx );
       }
 
-      glink_os_cs_release(&open_ch_ctx->ch_state_cs);
+      remote_state = open_ch_ctx->remote_state;
+
       glink_os_cs_release(&xport_ctx->channel_q_cs);
 
       /* Send the remote close ACK back to the other side */
-      if_ptr->tx_cmd_ch_remote_close_ack(if_ptr, open_ch_ctx->rcid);
+  if_ptr->tx_cmd_ch_remote_close_ack(if_ptr, rcid);
 
-      if( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSED )
+  if ( glink_is_local_ch_closed( open_ch_ctx->local_state ) )
       {
+    /* Destroy channel context only if there isn't any pending intents */
+        if (remote_state != GLINK_REMOTE_CH_CLEANUP)
+        {
         glink_os_free(open_ch_ctx);
       }
+      }
       else
       {
         /* Inform the client */
-        open_ch_ctx->notify_state( open_ch_ctx, open_ch_ctx->priv,
+    open_ch_ctx->notify_state(open_ch_ctx,
+                              open_ch_ctx->priv,
                                    GLINK_REMOTE_DISCONNECTED);
       }
-
-      return;
-    }
-    open_ch_ctx = smem_list_next(open_ch_ctx);
-  }/* end while */
-
-  glink_os_cs_release( &xport_ctx->channel_q_cs );
-  ASSERT(0);
 }
 
 /*===========================================================================
 FUNCTION      glink_rx_put_pkt_ctx
-
-DESCRIPTION   Transport invokes this call to receive a packet fragment (must
-              have previously received an rx_cmd_rx_data packet)
-
-ARGUMENTS   *if_ptr      Pointer to interface instance; must be unique
-                         for each edge
-
-            rcid         Remote Channel ID
-
-            *intent_ptr  Pointer to the intent fragment
-
-            complete     True if pkt is complete
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
 ===========================================================================*/
+/** 
+ * Transport invokes this call to receive a packet fragment (must 
+ * have previously received an rx_cmd_rx_data packet)
+ *
+ * @param[in]    if_ptr       Pointer to interface instance; must be unique
+ *                            for each edge
+ * @param[in]    rcid         Remote Channel ID
+ * @param[in]    intent_ptr   Pointer to the intent fragment
+ * @param[in]    complete     True if pkt is complete
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
 void glink_rx_put_pkt_ctx
 (
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  rcid,    /* Remote channel ID */
-  glink_rx_intent_type    *intent_ptr, /* Fragment ptr */
-  boolean                 complete     /* True if pkt is complete */
+  glink_transport_if_type *if_ptr,
+  uint32                   rcid,
+  glink_rx_intent_type    *intent_ptr,
+  boolean                  complete
 )
 {
   glink_channel_ctx_type *open_ch_ctx;
   glink_core_xport_ctx_type  *xport_ctx;
 
-  ASSERT(if_ptr != NULL && intent_ptr != NULL);
+  GLINK_OS_UNREFERENCED_PARAM( complete );
+  
+  ASSERT(intent_ptr);
 
   xport_ctx = if_ptr->glink_core_priv;
 
   /* Find channel in the open_list */
-  open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
-  while(open_ch_ctx != NULL)
-  {
-    if(open_ch_ctx->rcid == rcid) {
-      /* Found channel */
-      GLINK_LOG_EVENT(GLINK_EVENT_CH_PUT_PKT_CTX, open_ch_ctx->name,
-          xport_ctx->xport, xport_ctx->remote_ss, intent_ptr->iid);
+  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+  open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid);
+  glink_os_cs_release(&xport_ctx->channel_q_cs);
+  
+  GLINK_LOG_EVENT( open_ch_ctx,
+                   GLINK_EVENT_CH_PUT_PKT_CTX, 
+                   open_ch_ctx->name,
+                   xport_ctx->xport, 
+                   xport_ctx->remote_ss, 
+                   intent_ptr->iid);
 
       xport_ctx->channel_receive_pkt(open_ch_ctx, intent_ptr);
-
-      return;
-    }
-    open_ch_ctx = smem_list_next(open_ch_ctx);
-  }/* end while */
-
-  /* We end up here if we don't find the channel */
-  ASSERT(0);
 }
 
 /*===========================================================================
@@ -851,59 +734,27 @@
   uint32                  remote_sigs /* Remote control signals */
 )
 {
+  glink_core_xport_ctx_type *xport_ctx;
   glink_channel_ctx_type *open_ch_ctx;
   uint32 prev_sigs;
 
-  ASSERT(if_ptr != NULL);
-
-  /* Find channel in the open_list */
-  open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
-  while(open_ch_ctx != NULL)
-  {
-    if(open_ch_ctx->rcid == rcid ) {
-      glink_os_cs_acquire( &open_ch_ctx->ch_state_cs );
-      if( open_ch_ctx->local_state != GLINK_LOCAL_CH_OPENED &&
-          open_ch_ctx->remote_state != GLINK_REMOTE_CH_OPENED )
+  xport_ctx = if_ptr->glink_core_priv;
+      
+  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+  open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid);
+  glink_os_cs_release( &xport_ctx->channel_q_cs );
+      
+  if (!glinki_channel_fully_opened(open_ch_ctx))
       {
-        glink_os_cs_release( &open_ch_ctx->ch_state_cs );
         ASSERT(0);
-        return;
       }
-      glink_os_cs_release( &open_ch_ctx->ch_state_cs );
+  
       /* Found channel, let client know of new remote signal state */
       prev_sigs = open_ch_ctx->remote_sigs;
       open_ch_ctx->remote_sigs = remote_sigs;
-      open_ch_ctx->notify_rx_sigs(open_ch_ctx, open_ch_ctx->priv,
-                                  prev_sigs, remote_sigs);
-      return;
-    }
-    open_ch_ctx = smem_list_next(open_ch_ctx);
+  open_ch_ctx->notify_rx_sigs(open_ch_ctx,
+                              open_ch_ctx->priv,
+                              prev_sigs,
+                              remote_sigs);
   }
 
-  /* We end up here if we don't find the channel */
-  ASSERT(0);
-}
-
-
-/*===========================================================================
-FUNCTION      glink_set_core_version
-
-DESCRIPTION   Sets the core version used by the transport; called after
-              completing negotiation.
-
-ARGUMENTS   *if_ptr    Pointer to interface instance; must be unique
-                       for each edge
-
-             version   Negotiated transport version
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glink_set_core_version
-(
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  version  /* Version */
-)
-{
-}
diff --git a/platform/msm_shared/glink/glink_core_intentless_xport.c b/platform/msm_shared/glink/glink_core_intentless_xport.c
index 98ced24..2feba42 100644
--- a/platform/msm_shared/glink/glink_core_intentless_xport.c
+++ b/platform/msm_shared/glink/glink_core_intentless_xport.c
@@ -42,9 +42,6 @@
   glink_rx_cmd_version,
   /** Receive ACK to previous glink_transport_if_type::tx_cmd_version command */
   glink_rx_cmd_version_ack,
-  /** Sets the core version used by the transport; called after completing
-   *  negotiation.*/
-  glink_set_core_version,
   /** Receive remote channel open request; expected response is
    *  glink_transport_if_type:: tx_cmd_ch_remote_open_ack */
   glink_rx_cmd_ch_remote_open,
@@ -178,6 +175,7 @@
   glink_transport_if_type *if_ptr = open_ch_ctx->if_ptr;
   glink_err_type status = if_ptr->tx(if_ptr, open_ch_ctx->lcid, pctx);
 
+  GLINK_OS_UNREFERENCED_PARAM( req_intent );
   glink_os_free(pctx);
 
   return status;
diff --git a/platform/msm_shared/glink/glink_core_internal.c b/platform/msm_shared/glink/glink_core_internal.c
new file mode 100644
index 0000000..8a87b0a
--- /dev/null
+++ b/platform/msm_shared/glink/glink_core_internal.c
@@ -0,0 +1,1576 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+/*===========================================================================
+                        INCLUDE FILES
+===========================================================================*/
+#include <glink_internal.h>
+
+#ifdef FEATURE_TRACER_PACKET
+#include "glink_tracer.h"
+#endif
+/*===========================================================================
+  MACRO DEFINITION
+===========================================================================*/
+/*===========================================================================
+  GLOBAL DATA DECLARATIONS
+===========================================================================*/
+static os_cs_type glink_transport_q_cs[GLINK_NUM_HOSTS];
+
+#if defined(GLINK_OS_DEFINED_LOGGING) || defined(GLINK_MEMORY_LOGGING)
+/* glink_log_filter_status indicates if channel filtering is enabled or not */
+glink_logging_filter_cfg_type log_filter_cfg = { 
+    FALSE,      /* Filter Disabled */
+    "",         /* Filter channel name */
+    0x0,        /* Filter lcid - will be updated dynamically */
+    0x0,        /* Filter rcid - will be updated dynamically */
+    0xFFFFFFFF, /* remote host ID */
+    0x0,        /* Channel Context */
+    0xFFFFFFFF, /* All xports are enabled */
+   };
+#endif
+
+/* Keep a list of registered transport for each edge allowed for this host 
+ * ***IMPORTANT*** 
+ * it should be safe to traverse this list without taking locks */
+static smem_list_type glink_registered_transports[GLINK_NUM_HOSTS];
+
+/* List of supported hosts */
+const char* glink_hosts_supported[] = { "apss",
+                                        "mpss",
+                                        "lpass",
+                                        "dsps",
+                                        "wcnss",
+                                        "tz",
+                                        "rpm",
+                                      };
+
+#if defined(GLINK_MEMORY_LOGGING)
+static glink_mem_log_entry_type glink_mem_log_arr[GLINK_MEM_LOG_SIZE];
+static uint32 glink_mem_log_idx = 0;
+static os_cs_type glink_mem_log_cs;
+#endif
+
+static smem_list_type  glink_link_notif_list;
+static os_cs_type      glink_link_notif_list_cs;
+
+/*===========================================================================
+  GLOBAL FUNCTION DECLARATION
+===========================================================================*/
+/*===========================================================================
+  LOCAL FUNCTION DEFINITIONS
+===========================================================================*/
+/*===========================================================================
+  FUNCTION      glinki_scan_channels_and_notify_discon
+===========================================================================*/
+/** 
+ * Close all the channels belong to this transport
+ * This is helper function for glink_ssr
+ *
+ * @param[in]    if_ptr  pointer to transport interface
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+static void glinki_scan_channels_and_notify_discon
+(
+  glink_transport_if_type *if_ptr
+)
+{
+  glink_channel_ctx_type     *open_ch_ctx, *dummy_open_ch_ctx;
+  glink_core_xport_ctx_type  *xport_ctx;
+  glink_remote_state_type     remote_state;
+  
+  xport_ctx = if_ptr->glink_core_priv;
+
+  /* Find channel in the open_list */
+  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+  open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
+  glink_os_cs_release(&xport_ctx->channel_q_cs);
+  
+  while(open_ch_ctx)
+  {
+    glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+    open_ch_ctx->remote_state = GLINK_REMOTE_CH_SSR_RESET;
+    
+    dummy_open_ch_ctx = smem_list_next(open_ch_ctx);
+    
+    switch (open_ch_ctx->local_state)
+    {
+      case GLINK_LOCAL_CH_OPENED:
+      case GLINK_LOCAL_CH_OPENING:
+        glink_os_cs_release(&xport_ctx->channel_q_cs);
+        /* local channel has called open at the moment. */
+        open_ch_ctx->notify_state(open_ch_ctx, 
+                                  open_ch_ctx->priv, 
+                                  GLINK_REMOTE_DISCONNECTED);
+        break;
+        
+      case GLINK_LOCAL_CH_CLOSING:
+        /* Case when local client already closed channel 
+         * but has not received ack yet */
+        if_ptr->glink_core_if_ptr->rx_cmd_ch_close_ack(if_ptr, 
+                                                       open_ch_ctx->lcid);
+       glink_os_cs_release(&xport_ctx->channel_q_cs);
+        break;
+        
+      case GLINK_LOCAL_CH_CLOSED:  /* Channel fully closed - local, remote */
+      case GLINK_LOCAL_CH_INIT:    /* We had only remote open and waiting for local open */
+        xport_ctx->channel_cleanup(open_ch_ctx);
+        smem_list_delete(&if_ptr->glink_core_priv->open_list, open_ch_ctx);
+        remote_state = open_ch_ctx->remote_state;
+
+        if (remote_state != GLINK_REMOTE_CH_CLEANUP)
+        {
+          glink_os_free(open_ch_ctx);
+        }
+        glink_os_cs_release(&xport_ctx->channel_q_cs);
+        break;
+        
+      default:
+        glink_os_cs_release(&xport_ctx->channel_q_cs);
+        /* invalid local channel state */
+        ASSERT(0);
+    }
+    
+    open_ch_ctx = dummy_open_ch_ctx;
+  } /* end while */
+}
+
+/*===========================================================================
+  FUNCTION      glinki_xport_priority_comp
+===========================================================================*/
+/** 
+ * Helper function for glinki_get_xport_from_prio. This will be provided to
+ * glinki_xports_find function.
+ * Return true if given transport has same priority
+ *
+ * @param[in]    if_ptr     transport interface pointer
+ * @param[in]    cond1      unused
+ * @param[in]    priority   glink transport priority to find
+ *
+ * @return       TRUE   if if_ptr priority matches
+ *               FALSE  otherwise
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static boolean glinki_xport_priority_comp
+(
+  glink_transport_if_type *if_ptr,
+  void                    *cond1,
+  uint32                   priority,
+  void                   **out
+)
+{
+  GLINK_OS_UNREFERENCED_PARAM( cond1 );
+  GLINK_OS_UNREFERENCED_PARAM( out );
+
+  return if_ptr->glink_priority == (glink_xport_priority)priority;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_client_requested_xport_check
+===========================================================================*/
+/**
+ * check whether this is client requested xport or not
+ *
+ * @param[in]    if_ptr     transport interface pointer
+ * @param[in]    xport_name transport name to find
+ * @param[in]    cond2      unused
+ * @param[in]    out        unused
+ * 
+ * @return       TRUE   if transport name
+ *               FALSE  otherwise
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static boolean glinki_client_requested_xport_check
+(
+  glink_transport_if_type *if_ptr,
+  void                    *xport_name,
+  uint32                   cond2,
+  void                   **out
+)
+{
+  GLINK_OS_UNREFERENCED_PARAM( cond2 );
+  GLINK_OS_UNREFERENCED_PARAM( out );
+  
+  if (!glinki_xport_linkup(if_ptr))
+  {
+    return FALSE;
+  }
+  
+  return 0 == glink_os_string_compare(if_ptr->glink_core_priv->xport,
+                                      (const char *)xport_name);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_update_best_xport
+===========================================================================*/
+/** 
+ * Check whether given transport (if_ptr) has higher priority than
+ * priority user wants to check and update if it is true.
+ *
+ * @param[in]    if_ptr          transport interface pointer
+ * @param[in]    priority_param  xport priority to compare
+ * @param[in]    param2          unused
+ * @param[out]   best_xport      pointer to result xport
+ * 
+ * @return       FALSE  all the time since this needs to iterate all transports
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static void glinki_update_best_xport
+(
+  glink_transport_if_type  *if_ptr,
+  void                     *priority_param,
+  uint32                    param2,
+  void                    **best_xport
+)
+{
+  glink_xport_priority *priority;
+  
+  GLINK_OS_UNREFERENCED_PARAM( param2 );
+
+  ASSERT(best_xport && priority_param);
+  
+  priority = (glink_xport_priority*)priority_param;
+  
+  if (!glinki_xport_linkup(if_ptr))
+  {
+    return;
+  }
+  
+  /* Given xport is best one if comparing xport doesn't exist */ 
+  if (if_ptr->glink_priority < *priority)
+  {
+    *best_xport = (void*)if_ptr;
+    *priority = if_ptr->glink_priority;
+  }
+}
+
+/*===========================================================================
+  FUNCTION      glinki_notify_xport_ssr
+===========================================================================*/
+/** 
+ * Notify this xport of ssr event and do ssr clean up
+ *
+ * @param[in]    if_ptr         transport interface pointer
+ * @param[in]    priority       priority to check
+ * @param[in]    cond2          unused
+ * @param[out]   updated_xport  pointer to result xport
+ * 
+ * @return       FALSE  all the time since this needs to iterate all transports
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static void glinki_notify_xport_ssr
+(
+  glink_transport_if_type  *if_ptr,
+  void                     *param1,
+  uint32                    param2,
+  void                    **out
+)
+{
+  GLINK_OS_UNREFERENCED_PARAM( param1 );
+  GLINK_OS_UNREFERENCED_PARAM( param2 );
+  GLINK_OS_UNREFERENCED_PARAM( out );
+  /* xport is down. change the xport state */
+  glink_os_cs_acquire(&if_ptr->glink_core_priv->status_cs);
+  if_ptr->glink_core_priv->status = GLINK_XPORT_REGISTERED;
+  
+  /* Let the xport know about ssr */
+  if_ptr->ssr( if_ptr );
+  
+  /* Invoke LINK_DOWN notification for any registered notifiers */
+  glinki_scan_notif_list_and_notify(if_ptr, GLINK_LINK_STATE_DOWN);
+  
+  /* Invoke REMOTE_DISCONNECT for all channels associated with if_ptr */
+  glinki_scan_channels_and_notify_discon(if_ptr);
+  
+  glink_os_cs_release(&if_ptr->glink_core_priv->status_cs);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_check_xport_and_notify
+===========================================================================*/
+/** 
+ * Notify this xport for link state change if applicable
+ *
+ * @param[in]  if_ptr                 transport interface pointer
+ * @param[in]  link_notif_data_param  parameter for link notif data
+ * @param[in]  state                  link state to notify
+ * @param[out] out                    unused
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static void glinki_check_xport_and_notify
+(
+  glink_transport_if_type  *if_ptr,
+  void                     *link_notif_data_param,
+  uint32                    state,
+  void                    **out
+)
+{
+  glink_core_xport_ctx_type  *xport_ctx;
+  glink_link_notif_data_type *link_notif_data;
+  glink_link_info_type        link_info;
+  
+  GLINK_OS_UNREFERENCED_PARAM( out );
+  
+  ASSERT(link_notif_data_param && if_ptr->glink_core_priv);
+  
+  link_notif_data = (glink_link_notif_data_type *)link_notif_data_param;
+  xport_ctx = if_ptr->glink_core_priv;
+  
+  if (link_notif_data->xport == NULL ||
+      0 == glink_os_string_compare(xport_ctx->xport, link_notif_data->xport))
+  {
+    /* xport not specified, or it is specified and matches the current xport */
+    /* Invoke registered callback */
+    link_info.xport = xport_ctx->xport;
+    link_info.remote_ss = xport_ctx->remote_ss;
+    link_info.link_state = (glink_link_state_type)state;
+    
+    link_notif_data->link_notifier(&link_info, link_notif_data->priv);
+  }
+}
+
+/*===========================================================================
+  FUNCTION      glinki_check_xport_link_up_and_notify
+===========================================================================*/
+/** 
+ * Notify this xport for link state change if applicable
+ *
+ * @param[in]  if_ptr                 transport interface pointer
+ * @param[in]  link_notif_data_param  parameter for link notif data
+ * @param[in]  state                  link state to notify
+ * @param[out] out                    unused. but just passed as parameter
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+static void glinki_check_xport_link_up_and_notify
+(
+  glink_transport_if_type  *if_ptr,
+  void                     *link_notif_data_param,
+  uint32                    state,
+  void                    **out
+)
+{
+  if (!glinki_xport_linkup(if_ptr))
+  {
+    return;
+  }
+  
+  glinki_check_xport_and_notify(if_ptr, link_notif_data_param, state, out);
+}
+
+/*===========================================================================
+  EXTERNAL FUNCTION DEFINITIONS
+===========================================================================*/
+/*===========================================================================
+FUNCTION      glink_init
+
+DESCRIPTION   Initializes the GLink core library.
+
+ARGUMENTS     None
+
+RETURN VALUE  None
+
+SIDE EFFECTS  None
+===========================================================================*/
+void glink_init(void)
+{
+  uint32 i;
+  boolean cs_created = FALSE;
+
+#if defined(GLINK_MEMORY_LOGGING)
+  cs_created = glink_os_cs_init(&glink_mem_log_cs);
+  ASSERT(cs_created);
+#elif defined(GLINK_OS_DEFINED_LOGGING)
+  OS_LOG_INIT();
+#endif
+  
+  smem_list_init(&glink_link_notif_list);
+  cs_created = glink_os_cs_init(&glink_link_notif_list_cs);
+  ASSERT(cs_created);
+  
+  /* Create/Initalize crtitical sections */
+  for (i = 0; i < GLINK_NUM_HOSTS; ++i)
+  {
+    cs_created = glink_os_cs_init(&glink_transport_q_cs[i]);
+    ASSERT(cs_created);
+    smem_list_init(&glink_registered_transports[i]);
+  }
+}
+
+/*===========================================================================
+  FUNCTION      glinki_add_ch_to_xport
+===========================================================================*/
+/** 
+ * Add remote/local channel context to xport open channel queue
+ *
+ * @param[in]    if_ptr            Pointer to xport if on which channel is to
+ *                                 be opened
+ * @param[in]    req_if_ptr        Pointer to xport if on which channel 
+ *                                 actually wants to open
+ * @param[in]    ch_ctx            channel context
+ * @param[out]   allocated_ch_ctx  Pointer to channel context pointer
+ * @param[in]    local_open        flag to determine if channel is opened 
+ *                                 locally or remotely
+ * @param[in]    migrated_ch_prio  negotiated xport priority
+ *                                 (used to send priority via remote_open_ack to 
+ *                                  remote side)
+ *
+ * @return       G-Link standard error type
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_err_type glinki_add_ch_to_xport
+(
+  glink_transport_if_type  *if_ptr,
+  glink_channel_ctx_type   *ch_ctx,
+  glink_channel_ctx_type  **allocated_ch_ctx,
+  unsigned int              local_open,
+  glink_xport_priority      migrated_ch_prio
+)
+{
+  glink_err_type              status;
+  glink_channel_ctx_type     *open_ch_ctx;
+  glink_core_xport_ctx_type  *xport_ctx;
+  boolean                     valid_open_call;
+
+  if ( if_ptr == NULL          ||
+       ch_ctx->name[0] == '\0' ||
+       allocated_ch_ctx == NULL )
+  {
+    return GLINK_STATUS_INVALID_PARAM;
+  }
+  
+  xport_ctx = if_ptr->glink_core_priv;
+  
+  /* See if channel already exists in open_list */
+  glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+  
+  open_ch_ctx = glinki_find_ch_ctx_by_name(xport_ctx,
+                                           ch_ctx->name,
+                                           (boolean)local_open,
+                                           &valid_open_call);
+  
+  if ( !valid_open_call )
+  {
+    glink_os_free(ch_ctx);
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+    return GLINK_STATUS_FAILURE;
+  }
+  
+  if (!open_ch_ctx)
+  {
+    /* check if a new channel can be added */
+    if ((uint32)smem_list_count(&xport_ctx->open_list) >= xport_ctx->max_lcid)
+    {
+      glink_os_cs_release(&xport_ctx->channel_q_cs);
+      glink_os_free(ch_ctx);
+      return GLINK_STATUS_OUT_OF_RESOURCES;
+    }
+    
+    /* Channel not in the list - it was not previously opened */
+    ch_ctx->if_ptr = if_ptr;
+    *allocated_ch_ctx = ch_ctx;
+
+    /* Set channel state */
+    if (local_open)
+    {
+      /* This is a local open */
+      ch_ctx->local_state = GLINK_LOCAL_CH_OPENING;
+    }
+    else
+    {
+      ch_ctx->remote_state = GLINK_REMOTE_CH_OPENED;
+    }
+
+    glink_os_cs_init(&ch_ctx->tx_cs);
+    glink_os_cs_init(&ch_ctx->qos_cs);
+
+    /* make sure next LCID is not used in currently open channels */
+    open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
+
+    while (open_ch_ctx)
+    {
+      if (open_ch_ctx->lcid == xport_ctx->free_lcid)
+      {
+        xport_ctx->free_lcid++;
+        
+        if (xport_ctx->free_lcid >= xport_ctx->max_lcid)
+        {
+          xport_ctx->free_lcid = 1;
+        }
+
+        open_ch_ctx = smem_list_first(&if_ptr->glink_core_priv->open_list);
+        continue;
+      }
+
+      open_ch_ctx = smem_list_next(open_ch_ctx);
+    }
+
+    ch_ctx->lcid = xport_ctx->free_lcid;
+
+    /* Append the channel to the transport interface's open_list */
+    smem_list_append(&if_ptr->glink_core_priv->open_list, ch_ctx);
+
+    /* release lock before context switch otherwise it is causing deadlock */
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+    
+    /* Send the OPEN command to transport */
+    if (local_open)
+    {
+      status = if_ptr->tx_cmd_ch_open(if_ptr, ch_ctx->lcid,
+                                      ch_ctx->name,
+                                      migrated_ch_prio);
+    }
+    else
+    {
+      /* initialize channel resources */
+      status = xport_ctx->channel_init(ch_ctx);
+
+      if_ptr->tx_cmd_ch_remote_open_ack(if_ptr, ch_ctx->rcid, migrated_ch_prio);
+    }
+
+    if (status != GLINK_STATUS_SUCCESS)
+    {
+      /* Remove the channel from the transport interface's open_list */
+      xport_ctx->free_lcid--;
+      glinki_dequeue_item(&if_ptr->glink_core_priv->open_list,
+                          ch_ctx,
+                          &xport_ctx->channel_q_cs);
+      
+      /* free the ch_ctx structure and return */
+      xport_ctx->channel_cleanup(ch_ctx);
+      glink_os_free(ch_ctx);
+    }
+    else
+    {
+      //Update the Filter
+      glinki_update_logging_filter(*allocated_ch_ctx, FALSE);
+    }
+
+    return status;
+  }
+  
+  if (local_open)
+  {
+    /* LOCAL OPEN REQUEST */
+    
+    ch_ctx->rcid     = open_ch_ctx->rcid;
+    ch_ctx->lcid     = open_ch_ctx->lcid;
+    ch_ctx->pintents = open_ch_ctx->pintents;
+    ch_ctx->if_ptr   = open_ch_ctx->if_ptr;
+
+    if (ch_ctx->pintents != NULL)
+    {
+      ch_ctx->pintents->ch_ctx = ch_ctx;
+    }
+
+    ch_ctx->remote_state = open_ch_ctx->remote_state;
+    ch_ctx->local_state  = GLINK_LOCAL_CH_OPENING;
+    
+    /* release lock before context switch otherwise it is causing
+     * deadlock */
+    smem_list_delete(&xport_ctx->open_list, open_ch_ctx);
+    smem_list_append(&xport_ctx->open_list, ch_ctx);
+
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+
+    glink_os_free(open_ch_ctx);
+    *allocated_ch_ctx = ch_ctx;
+    
+    /* Send open cmd to transport */
+    status = if_ptr->tx_cmd_ch_open(if_ptr, 
+                                    ch_ctx->lcid,
+                                    ch_ctx->name,
+                                    migrated_ch_prio);
+  }
+  else
+  { 
+    /* REMOTE OPEN REQUEST */
+    open_ch_ctx->rcid = ch_ctx->rcid;
+    *allocated_ch_ctx = open_ch_ctx;
+    status = xport_ctx->channel_init(open_ch_ctx);
+
+    if (status == GLINK_STATUS_SUCCESS)
+    {
+      open_ch_ctx->remote_state = GLINK_REMOTE_CH_OPENED;
+    }
+    
+    /* release lock before context switch otherwise it is causing deadlock */
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+    
+    /* Send ACK to transport */
+    if_ptr->tx_cmd_ch_remote_open_ack(if_ptr,
+                                      open_ch_ctx->rcid,
+                                      migrated_ch_prio);
+    
+    if (status == GLINK_STATUS_SUCCESS)
+    {
+      /* Inform the client */
+      if (open_ch_ctx->local_state == GLINK_LOCAL_CH_OPENED)
+      {
+        open_ch_ctx->notify_state(open_ch_ctx, 
+                                  open_ch_ctx->priv, 
+                                  GLINK_CONNECTED);
+      }
+    }
+
+    glink_os_free(ch_ctx);
+  } /* end If - else (local_open) */
+  
+  /* If the channel was added to be closed later by channel migration
+     do not update the filter */
+  if ( status == GLINK_STATUS_SUCCESS )
+  {
+    //Update the Filter - Reset Boolean=FALSE
+    glinki_update_logging_filter( *allocated_ch_ctx, FALSE );
+  }
+  
+  return status;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_channel_fully_opened
+===========================================================================*/
+/** 
+ * Check whether this channel is fully opened or not (local & remote)
+ * This also checks transport status
+ *
+ * @param[in]  handle        glink channel handle
+ *
+ * @return     TRUE,  if channel is fully opened
+ *             FASLE, otherwise
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+boolean glinki_channel_fully_opened
+(
+  glink_handle_type          handle
+)
+{
+  boolean ch_fully_opened = TRUE;
+
+  if (!glinki_xport_linkup(handle->if_ptr))
+  {
+    return FALSE;
+  }
+  
+  glink_os_cs_acquire( &handle->if_ptr->glink_core_priv->channel_q_cs );
+  
+  if (handle->local_state != GLINK_LOCAL_CH_OPENED ||
+      handle->remote_state != GLINK_REMOTE_CH_OPENED)
+  {
+    ch_fully_opened = FALSE;
+  }
+
+  glink_os_cs_release( &handle->if_ptr->glink_core_priv->channel_q_cs );
+  
+  return ch_fully_opened;
+}
+
+/*===========================================================================
+FUNCTION      glink_core_register_transport
+
+DESCRIPTION   Transport calls this API to register its interface with GLINK 
+              Core
+
+ARGUMENTS   *if_ptr   Pointer to interface instance; must be unique
+                      for each edge
+                         
+            *cfg      Pointer to transport configuration structure.
+
+RETURN VALUE  Standard GLINK error codes.
+
+SIDE EFFECTS  None
+===========================================================================*/
+glink_err_type glink_core_register_transport
+(
+  glink_transport_if_type       *if_ptr,
+  glink_core_transport_cfg_type *cfg
+)
+{
+  unsigned int remote_host = 0;
+  glink_core_xport_ctx_type *xport_ctx;
+
+  /* Param validation */
+  if (if_ptr == NULL          ||
+      cfg == NULL             ||
+      cfg->name == NULL       ||
+      cfg->remote_ss == NULL  ||
+      cfg->version == NULL    ||
+      cfg->version_count == 0 ||
+      cfg->max_cid == 0)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_REGISTER_XPORT, "", "", "", 
+        GLINK_STATUS_INVALID_PARAM);    
+    return GLINK_STATUS_INVALID_PARAM;
+  }
+
+  if(if_ptr->tx_cmd_version == NULL             ||
+     if_ptr->tx_cmd_version_ack == NULL         ||
+     if_ptr->set_version == NULL                ||
+     if_ptr->tx_cmd_ch_open == NULL             ||
+     if_ptr->tx_cmd_ch_close == NULL            ||
+     if_ptr->tx_cmd_ch_remote_open_ack == NULL  ||
+     if_ptr->tx_cmd_ch_remote_close_ack == NULL ||
+     if_ptr->ssr  == NULL)
+  {
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_REGISTER_XPORT, "", 
+                           cfg->name, 
+                           cfg->remote_ss, 
+                           GLINK_STATUS_INVALID_PARAM );    
+    return GLINK_STATUS_INVALID_PARAM;;
+  }
+
+  remote_host = glinki_find_remote_host(cfg->remote_ss);
+
+  if(remote_host == GLINK_NUM_HOSTS )
+  {
+    /* Unknown transport name trying to register with GLink */
+    GLINK_LOG_ERROR_EVENT( GLINK_EVENT_REGISTER_XPORT, "", 
+                           cfg->name, 
+                           cfg->remote_ss, 
+                           GLINK_STATUS_INVALID_PARAM );
+    return GLINK_STATUS_INVALID_PARAM;
+  }
+
+  /* Set the glink_core_if_ptr to point to the default interface */
+  if_ptr->glink_core_if_ptr = glink_core_get_default_interface();
+
+  /* Allocate/fill out the GLink private context data */
+  {
+     xport_ctx = glink_os_calloc(sizeof(glink_core_xport_ctx_type));
+    if(xport_ctx == NULL)
+    {
+      GLINK_LOG_ERROR_EVENT( GLINK_EVENT_REGISTER_XPORT, "", 
+                             cfg->name, 
+                             cfg->remote_ss, 
+                             GLINK_STATUS_OUT_OF_RESOURCES );
+    
+      return GLINK_STATUS_OUT_OF_RESOURCES;
+    }
+
+    xport_ctx->xport = cfg->name;
+    xport_ctx->remote_ss = cfg->remote_ss;
+    xport_ctx->free_lcid = 1; /* lcid 0 is reserved for invalid channel */
+    xport_ctx->max_lcid = cfg->max_cid; /* Max channel ID supported by transport */
+    xport_ctx->version_array = cfg->version;
+    xport_ctx->version_indx = (int32)cfg->version_count - 1;
+
+    glink_os_cs_init(&xport_ctx->channel_q_cs);
+    glink_os_cs_init(&xport_ctx->liid_cs);
+    glink_os_cs_init(&xport_ctx->status_cs);
+
+    glink_os_cs_acquire(&xport_ctx->channel_q_cs);
+    smem_list_init(&xport_ctx->open_list);
+    glink_os_cs_release(&xport_ctx->channel_q_cs);
+
+    /* Set the glink_core_if_ptr to point to the allocated structure */
+    if_ptr->glink_core_priv = xport_ctx;
+    xport_ctx->status = GLINK_XPORT_REGISTERED;
+  }
+  
+  /* Push the transport interface into appropriate queue */
+  glinki_enqueue_item(&glink_registered_transports[remote_host],
+                      if_ptr,
+                      &glink_transport_q_cs[remote_host]);
+
+  GLINK_LOG_EVENT_NO_FILTER( GLINK_EVENT_REGISTER_XPORT, "", 
+                  xport_ctx->xport,
+                  xport_ctx->remote_ss,
+                  GLINK_STATUS_SUCCESS);
+
+  return GLINK_STATUS_SUCCESS;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_register_link_notif_data
+===========================================================================*/
+/** 
+ * Register link notification data
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_register_link_notif_data
+(
+  glink_link_notif_data_type *link_notif_data
+)
+{
+  glinki_enqueue_item(&glink_link_notif_list,
+                      (void *)link_notif_data,
+                      &glink_link_notif_list_cs);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_deregister_link_notif_data
+===========================================================================*/
+/** 
+ * Deregister link notification data
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_deregister_link_notif_data
+(
+  glink_link_notif_data_type *link_notif_data
+)
+{
+  glinki_dequeue_item(&glink_link_notif_list,
+                      (void *)link_notif_data,
+                      &glink_link_notif_list_cs);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_scan_xports_and_notify
+===========================================================================*/
+/** 
+ * Scan xports and notify link up state event
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_scan_xports_and_notify
+(
+  glink_link_notif_data_type *link_notif_data
+)
+{
+  unsigned int          remote_host;
+  glink_link_state_type link_state = GLINK_LINK_STATE_UP;
+  
+  ASSERT(link_notif_data);
+  
+  /* Find matching subsystem */
+  for (remote_host = 0; remote_host < GLINK_NUM_HOSTS; ++remote_host)
+  {
+    if (link_notif_data->remote_ss != NULL &&
+        0 != glink_os_string_compare(glink_hosts_supported[remote_host],
+                                     link_notif_data->remote_ss))
+    {
+      /* client is not interested in this remote SS */
+      continue;
+    }
+    
+    glinki_xports_for_each(glink_hosts_supported[remote_host],
+                           glinki_check_xport_link_up_and_notify,
+                           link_notif_data,
+                           link_state,
+                           NULL);
+  }
+}
+
+/*===========================================================================
+  FUNCTION      glinki_scan_notif_list_and_notify
+===========================================================================*/
+/** 
+ * Scan registered link notification list and notify of xport link state change
+ *
+ * @param[in]  if_ptr  pointer to xport interface
+ * @param[in]  state   link state to notify
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_scan_notif_list_and_notify
+(
+  glink_transport_if_type *if_ptr,
+  glink_link_state_type    state
+)
+{
+  glink_link_notif_data_type *link_notif_data;
+
+  glink_os_cs_acquire(&glink_link_notif_list_cs);
+  
+  for (link_notif_data = smem_list_first(&glink_link_notif_list);
+       link_notif_data != NULL;
+       link_notif_data = smem_list_next(link_notif_data))
+  {
+    if( link_notif_data->remote_ss == NULL || 
+        0 == glink_os_string_compare( if_ptr->glink_core_priv->remote_ss,
+                                      link_notif_data->remote_ss ) ) 
+    {
+      glinki_check_xport_and_notify(if_ptr,
+                                    link_notif_data,
+                                    (uint32)state,
+                                    NULL);
+    }
+  }
+  
+  glink_os_cs_release(&glink_link_notif_list_cs);
+} /* glinki_scan_notif_list_and_notify */
+
+/*===========================================================================
+  FUNCTION      glinki_ssr
+===========================================================================*/
+/** 
+ * Notify all the xports of ssr event in this edge
+ *
+ * @param[in]    remote_ss name of remote subsystem
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glink_ssr(const char* remote_ss)
+{
+  glinki_xports_for_each(remote_ss,
+                         glinki_notify_xport_ssr,
+                         NULL,
+                         0,
+                         NULL);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_xport_linkup
+===========================================================================*/
+/** 
+ * Check whether this transport is in linkup state or not
+ *
+ * @param[in]    if_ptr     transport interface pointer
+ * 
+ * @return       TRUE   if this xport is in link up state
+ *               FALSE  otherwise
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+boolean glinki_xport_linkup
+(
+  glink_transport_if_type *if_ptr
+)
+{
+  return if_ptr->glink_core_priv->status == GLINK_XPORT_LINK_UP;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_xports_for_each
+===========================================================================*/
+/** 
+ * Scan all the transports in given edge and perform client's function for each
+ * transport
+ *
+ * @param[in]    remote_ss    name of remote subsystem, NULL string not accepted
+ * @param[in]    client_ex_fn client function to perform on each xport
+ * @param[in]    param1       first parameter to use in client_ex_fn
+ * @param[in]    param2       second parameter to use in client_ex_fn
+ * @param[out]   out          value to return in case client wants
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ *
+ * This routine ASSUMES it is safe to traverse the glink_registered_transports 
+ * without a lock. This is only true if the following conditions are met
+ * 1) Only append/traverse operations are allowed on this list (No insert, delete)
+ * 2) Append should make sure at no instance of time we have an uninitialized 
+ * pointer(next) along the list
+ */
+/*=========================================================================*/
+void glinki_xports_for_each
+(
+  const char         *remote_ss,
+  glink_client_ex_fn  client_ex_fn,
+  void               *param1,
+  uint32              param2,
+  void              **out
+)
+{
+  glink_transport_if_type *if_iter_ptr;
+  
+  uint32 remote_host = glinki_find_remote_host(remote_ss);
+  
+  ASSERT(remote_host < GLINK_NUM_HOSTS);
+  
+  
+  for(if_iter_ptr = smem_list_first(&glink_registered_transports[remote_host]);
+      if_iter_ptr != NULL;
+      if_iter_ptr = smem_list_next(if_iter_ptr))
+  {
+    client_ex_fn(if_iter_ptr, param1, param2, out);
+  }
+}
+
+/*===========================================================================
+  FUNCTION      glinki_xports_find
+===========================================================================*/
+/** 
+ * Scan all the transports in given edge and finds transport that satisfy
+ * client's condition
+ *
+ * @param[in]    remote_ss      name of remote subsystem, NULL string not accepted
+ * @param[in]    client_cond_fn client function to check if this transport is 
+ *                              what client is looking for
+ * @param[in]    cond1          first condition to use in client_ex_fn
+ * @param[in]    cond2          second condition to use in client_ex_fn
+ * @param[out]   out            value to return in case client wants
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *               NULL if there isn't any xport matches client's search condition
+ *
+ * @sideeffects  None.
+ *
+ * This routine ASSUMES it is safe to traverse the glink_registered_transports 
+ * without a lock. This is only true if the following conditions are met
+ * 1) Only append/traverse operations are allowed on this list (No insert/delete)
+ * 2) Append should make sure at no instance of time we have an uninitialized 
+ * pointer(next) along the list
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_xports_find
+(
+  const char           *remote_ss,
+  glink_client_cond_fn  client_cond_fn,
+  void                 *cond1,
+  uint32                cond2,
+  void                **out
+)
+{
+  glink_transport_if_type *if_iter_ptr;
+  
+  uint32 remote_host = glinki_find_remote_host(remote_ss);
+  
+  ASSERT(remote_host < GLINK_NUM_HOSTS);
+  
+  for (if_iter_ptr = smem_list_first(&glink_registered_transports[remote_host]);
+       if_iter_ptr != NULL;
+       if_iter_ptr = smem_list_next(if_iter_ptr))
+  {
+    if(client_cond_fn(if_iter_ptr, cond1, cond2, out))
+    {
+      break;
+    }
+  }
+  
+  return if_iter_ptr;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_lcid
+===========================================================================*/
+/** 
+ * Find channel context by lcid
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    lcid       local channel ID
+ *
+ * @return       pointer to glink channel context
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_lcid
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  uint32                     lcid
+)
+{
+  glink_channel_ctx_type *open_ch_ctx;
+  
+  for (open_ch_ctx = smem_list_first(&xport_ctx->open_list);
+       open_ch_ctx;
+       open_ch_ctx = smem_list_next(open_ch_ctx))
+  {
+    if (open_ch_ctx->lcid == lcid)
+    {
+      return open_ch_ctx;
+    }
+  }
+  
+  /* open_ch_ctx will be NULL here. Using this instead of ASSERT(0)
+    to avoid unreachable code warning */
+  ASSERT( open_ch_ctx != NULL );
+  return NULL;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_rcid
+===========================================================================*/
+/** 
+ * Find channel context by rcid
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    rcid       remote channel ID
+ *
+ * @return       pointer to glink channel context
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_rcid
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  uint32                     rcid
+)
+{
+  glink_channel_ctx_type *open_ch_ctx;
+  
+  for (open_ch_ctx = smem_list_first(&xport_ctx->open_list);
+       open_ch_ctx;
+       open_ch_ctx = smem_list_next(open_ch_ctx))
+  {
+    if (open_ch_ctx->rcid == rcid)
+    {
+      return open_ch_ctx;
+    }
+  }
+  
+  /* open_ch_ctx will be NULL here. Using this instead of ASSERT(0)
+    to avoid unreachable code warning */
+  ASSERT( open_ch_ctx != NULL ); 
+  return NULL;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_name
+===========================================================================*/
+/** 
+ * Find channel context by channel name, called by local/remote open function
+ * This function will also indicate (valid_open_call) if this open call would
+ * be valid or not
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    ch_name    channel name
+ * @param[in]    local_open       flag to indicate this is local open call
+ * @param[out]   valid_open_call  tell whether this open call would be valid
+ *                                or not
+ *
+ * @return       pointer to glink channel context
+ *               NULL if channel doesn't exist
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_name
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  const char                *ch_name,
+  boolean                    local_open,
+  boolean                   *valid_open_call
+)
+{
+  glink_channel_ctx_type *open_ch_ctx;
+  glink_channel_ctx_type *ch_ctx_found = NULL;
+  glink_remote_state_type remote_state;
+  glink_local_state_type  local_state;
+  
+  ASSERT( valid_open_call != NULL );
+  *valid_open_call = TRUE;
+  
+  for(open_ch_ctx = smem_list_first(&xport_ctx->open_list);
+        open_ch_ctx != NULL;
+      open_ch_ctx = smem_list_next(open_ch_ctx))
+  {
+    remote_state = open_ch_ctx->remote_state;
+    local_state = open_ch_ctx->local_state;
+    
+    if ( 0 != glink_os_string_compare(open_ch_ctx->name, ch_name) ||
+         remote_state == GLINK_REMOTE_CH_CLEANUP ||
+         remote_state == GLINK_REMOTE_CH_SSR_RESET )
+    {
+      continue;
+    }
+    
+    if ( ( local_open == TRUE && local_state == GLINK_LOCAL_CH_INIT ) || 
+         ( local_open == FALSE && remote_state == GLINK_REMOTE_CH_INIT ) )
+    {
+      /* Local/Remote side already opened channel */
+      ch_ctx_found = open_ch_ctx;
+    }
+    else if ( ( local_open == TRUE && local_state != GLINK_LOCAL_CH_CLOSED ) ||
+              ( local_open == FALSE && remote_state != GLINK_REMOTE_CH_CLOSED ) )
+    {
+      /* Local/Remote side is trying to open channel without closing old one */
+      *valid_open_call = FALSE;
+      break;
+    }
+  }
+  
+  return ch_ctx_found;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_remote_host
+===========================================================================*/
+/** 
+ * return remote subsystem ID based on remote subsystem name
+ *
+ * @param[in]    remote_ss  remote subsystem name
+ *
+ * @return       remote subsystem ID
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+uint32 glinki_find_remote_host
+(
+  const char *remote_ss
+)
+{
+  uint32 remote_host;
+
+  for(remote_host = 0; remote_host < GLINK_NUM_HOSTS; remote_host++) 
+  {
+    if( 0 == glink_os_string_compare(glink_hosts_supported[remote_host],
+                                     remote_ss))
+    {
+      /* Match found, break out of loop */
+      break;
+    }
+  }
+  
+  return remote_host;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_best_xport
+===========================================================================*/
+/** 
+ * This function gives best available transport for give edge
+ *
+ * @param[in]    remote_host  Index into glink_registered_transports array of
+ *                            registered transports list per edge
+ * 
+ * @return       pointer to glink_transport_if_type
+ *               Null, if transport not found
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_best_xport
+(
+  const char *remote_ss
+)
+{
+  glink_transport_if_type *best_if_ptr = NULL;
+  glink_xport_priority priority = GLINK_MIN_PRIORITY;
+  
+  glinki_xports_for_each(remote_ss,
+                         glinki_update_best_xport,
+                         (void *)&priority,
+                         0,
+                         (void **)&best_if_ptr);
+  
+  return best_if_ptr;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_requested_xport
+===========================================================================*/
+/** 
+ * Find requested or best transport depending on client's request
+ *
+ * @param[in]    xport_name         name of transport
+ * @param[in]    remote_ss          remote subsystem name
+ * @param[in]    open_ch_option     option client gave when called glink_open
+ * @param[out]   suggested_priority best xport priority glink suggests
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_requested_xport
+(
+  const char           *xport_name,
+  const char           *remote_ss,
+  uint32                open_ch_option,
+  glink_xport_priority *suggested_priority
+)
+{
+  glink_transport_if_type *best_xport = glinki_find_best_xport(remote_ss);
+  glink_transport_if_type *xport_found = NULL;
+  
+  *suggested_priority = GLINK_INVALID_PRIORITY;
+
+  if (!xport_name)
+  {
+    if (best_xport)
+    {
+      *suggested_priority = best_xport->glink_priority;
+    }
+    
+    return best_xport;
+  }
+  
+  xport_found = glinki_xports_find(remote_ss,
+                                   glinki_client_requested_xport_check,
+                                   (void *)xport_name,
+                                   0,
+                                   NULL);
+  
+  if (!xport_found)
+  {
+    return NULL;
+  }
+  
+  if ((open_ch_option & GLINK_OPT_INITIAL_XPORT) != 0)
+  {
+    *suggested_priority = best_xport->glink_priority;
+  }
+  else
+  {
+    /* Client is not willing to migrate to better transport */
+    *suggested_priority = xport_found->glink_priority;
+  }
+  
+  return xport_found;
+}
+
+/*===========================================================================
+  FUNCTION      glinki_find_xport_by_priority
+===========================================================================*/
+/** 
+ * This function returns glink_transport_if pointer based on transport priority
+ *
+ * @param[in]    prio        glink xport prio
+ * @param[in]    remote_ss   remote subsytem name
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *               NULL, if it's not registered or transport not found with
+ *                     the priority
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_xport_by_priority
+(
+  glink_xport_priority  prio,
+  const char           *remote_ss
+)
+{
+  return glinki_xports_find(remote_ss,
+                            glinki_xport_priority_comp,
+                            NULL,
+                            (uint32)prio,
+                            NULL);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_enqueue_item
+===========================================================================*/
+/** 
+ * Enqueue item to smem list in protected context
+ * 
+ * @param[in]    smem_list  smem list to enqueue
+ * @param[in]    item       item to queue
+ * @param[in]    cs         mutex to protect the list
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+void glinki_enqueue_item
+(
+  smem_list_type *smem_list_ptr,
+  void           *item,
+  os_cs_type     *cs
+)
+{
+  glink_os_cs_acquire(cs);
+  smem_list_append(smem_list_ptr, item);
+  glink_os_cs_release(cs);
+}
+
+/*===========================================================================
+  FUNCTION      glinki_dequeue_item
+===========================================================================*/
+/** 
+ *  Dequeue item from smem list in protected context
+ * 
+ * @param[in]    smem_list  smem list to dequeue from 
+ * @param[in]    item       item to dequeue
+ * @param[in]    cs         mutex to protect the list
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+void glinki_dequeue_item
+(
+  smem_list_type *smem_list_ptr,
+  void           *item,
+  os_cs_type     *cs
+)
+{
+  glink_os_cs_acquire(cs);
+  smem_list_delete(smem_list_ptr, item);
+  glink_os_cs_release(cs);
+}
+
+#if defined(GLINK_MEMORY_LOGGING)
+/* ============ Internal Logging API ================ */
+void glink_mem_log
+(
+  glink_log_event_type type,
+  const char *msg,
+  const char *xport,
+  const char *remote_ss,
+  uint32 param
+)
+{
+#ifdef DEBUG_GLINK
+  dprintf(INFO, "%s:%u, event:%d, msg:%s, xport:%s, remote_ss:%s, param:%u\n", func, line, type, msg, xport, remote_ss, param);
+#endif
+}
+#endif
+
+#ifdef FEATURE_TRACER_PACKET
+/*===========================================================================
+FUNCTION      glink_tracer_packet_log_pctx_pkt
+===========================================================================*/
+/** 
+ * Log tracer packet event. Tracer packet is included in glink_core_tx_pkt
+ * and needs to use vprovider to extract it
+ * 
+ * @param[in]  pctx     pointer to glink_core_tx_pkt_type
+ * @param[in]  event_id event_id
+ * 
+ * @return         None
+ *
+ * @sideeffects    None
+ */
+/*=========================================================================*/
+void glink_tracer_packet_log_pctx_pkt
+(
+  glink_core_tx_pkt_type  *pctx,
+  uint32                   event_id
+)
+{
+  tracer_pkt_result_type  tracer_pkt_log_result;
+  void                   *tracer_pkt_data;
+  size_t                  tracer_pkt_size;
+  
+  tracer_pkt_data = pctx->vprovider(pctx->iovec, 0, &tracer_pkt_size);
+  
+  if (tracer_pkt_size != pctx->size)
+  {
+    GLINK_LOG_EVENT_NO_FILTER( GLINK_EVENT_TXV_INVALID_BUFFER, "", "", "",
+                    tracer_pkt_size);
+  }
+
+  tracer_pkt_log_result = tracer_packet_log_event(tracer_pkt_data, (uint16)event_id);
+  if (tracer_pkt_log_result != TRACER_PKT_STATUS_SUCCESS)
+  {
+    GLINK_LOG_EVENT_NO_FILTER( GLINK_EVENT_TRACER_PKT_FAILURE, "", "", "",
+                    tracer_pkt_log_result);
+  }
+}
+#endif
+
+/*===========================================================================
+  FUNCTION      glinki_update_logging_filter
+===========================================================================*/
+/** 
+ *  Update/Reset the logging filter if the name and remote host of the  
+ *  logging filter matches to that of the passed channel context
+ * 
+ * @param[in]    chnl_ctx   Channel content to match/compare
+ * @param[in]    reset      Indicate Update(FALSE) or Reset(TRUE)
+ *
+ * @return       None.
+ */
+/*=========================================================================*/
+#if defined(GLINK_OS_DEFINED_LOGGING) || defined(GLINK_MEMORY_LOGGING)
+void glinki_update_logging_filter
+(
+  glink_channel_ctx_type  *chnl_ctx, 
+  boolean                 reset
+)
+{
+  if ( ( log_filter_cfg.ch_filter_status == TRUE )  && 
+       ( (chnl_ctx) != NULL )   && 
+       ( glink_os_string_compare( (chnl_ctx)->name,
+                                 log_filter_cfg.ch_name) == 0 ) &&
+       ( log_filter_cfg.remote_host ==
+         glinki_find_remote_host((chnl_ctx)->if_ptr->glink_core_priv->remote_ss) ) 
+     )
+  {
+    if (reset == FALSE) /* Update the Filter */
+    {
+      log_filter_cfg.ch_ctx = (chnl_ctx);
+      log_filter_cfg.ch_lcid = (chnl_ctx)->lcid;
+      log_filter_cfg.ch_rcid = (chnl_ctx)->rcid;
+    }
+    else  /* Reset the Filter */
+    {
+      log_filter_cfg.ch_ctx = NULL;
+      log_filter_cfg.ch_lcid = 0;
+      log_filter_cfg.ch_rcid = 0;
+      log_filter_cfg.remote_host = (uint32)-1;        
+    }
+  }
+}
+
+#else
+void glinki_update_logging_filter(glink_channel_ctx_type *chnl_ctx, boolean reset)
+{
+    GLINK_OS_UNREFERENCED_PARAM( chnl_ctx );
+    GLINK_OS_UNREFERENCED_PARAM( reset );
+}
+#endif
diff --git a/platform/msm_shared/glink/glink_vector.c b/platform/msm_shared/glink/glink_vector.c
index 31f0883..4ca2692 100644
--- a/platform/msm_shared/glink/glink_vector.c
+++ b/platform/msm_shared/glink/glink_vector.c
@@ -109,12 +109,6 @@
     return NULL;
   }
 
-  if (!iovec_l->vlist)
-  {
-    // create vlist and map virtual from physical addresses
-    ASSERT(0);
-  }
-
   if (!iovec_l->vlast || iovec_l->vlast->start_offset > offset)
   {
        iovec_l->vlast = iovec_l->vlist;
@@ -167,12 +161,6 @@
     return NULL;
   }
 
-  if (!iovec_l->plist)
-  {
-    // create plist and get physical addresses from virtual
-    ASSERT(0); // not implemented
-  }
-
   if (!iovec_l->plast || iovec_l->plast->start_offset > offset)
   {
        iovec_l->plast = iovec_l->plist;
diff --git a/platform/msm_shared/glink/xport_rpm.c b/platform/msm_shared/glink/xport_rpm.c
index 68a6c80..31785d2 100644
--- a/platform/msm_shared/glink/xport_rpm.c
+++ b/platform/msm_shared/glink/xport_rpm.c
@@ -49,8 +49,12 @@
 #define XPORT_RPM_NAME "RPM"
 
 #define XPORT_RPM_LOG(msg, remote_host, param) \
-          GLINK_LOG_EVENT(GLINK_EVENT_XPORT_INTERNAL, msg, XPORT_RPM_NAME, \
-            remote_host, (uint32)param)
+	if ((log_filter_cfg.xport_filter_mask &                                     \
+       (1 << GLINK_XPORT_RPM_MASK_BIT)) != 0 )                                \
+  {                                                                           \
+    GLINK_LOG_EVENT_NO_FILTER(GLINK_EVENT_XPORT_INTERNAL, msg, XPORT_RPM_NAME,\
+			       remote_host, (uint32)param);                               \
+  }
 
 #define MSGRAM_READ32(ctx, ind) (*(volatile uint32*)&(ctx)->rx_fifo[ind])
 #define CHECK_INDEX_WRAP_AROUND(ind, size) \
@@ -172,9 +176,9 @@
 )
 {
   /* read out the write index to initiate a bus transaction from MSG RAM */
-  volatile uint32 write_ind = ctx_ptr->tx_desc->write_ind;
 
-  XPORT_RPM_LOG("Send event write ind", ctx_ptr->pcfg->remote_ss, write_ind);
+ 	XPORT_RPM_LOG("Send event write ind", ctx_ptr->pcfg->remote_ss, 
+                (volatile uint32)ctx_ptr->tx_desc->write_ind);
 
   // notify rpm
   dprintf(SPEW, "%s:%d: Notify RPM with IPC interrupt\n", __func__, __LINE__);
diff --git a/platform/msm_shared/include/glink.h b/platform/msm_shared/include/glink.h
index b36fba0..9f1d655 100644
--- a/platform/msm_shared/include/glink.h
+++ b/platform/msm_shared/include/glink.h
@@ -63,14 +63,30 @@
 /** GLink status/return codes */
 typedef enum {
   GLINK_STATUS_SUCCESS = 0,
-  GLINK_STATUS_FAILURE,
-  GLINK_STATUS_INVALID_PARAM,
-  GLINK_STATUS_NOT_INIT,
-  GLINK_STATUS_OUT_OF_RESOURCES,
-  GLINK_STATUS_NO_TRANSPORT
+  GLINK_STATUS_INVALID_PARAM             = -1,
+  GLINK_STATUS_NOT_INIT                  = -2,
+  GLINK_STATUS_OUT_OF_RESOURCES          = -3,
+  /* Failure due to lack of transport */
+  GLINK_STATUS_NO_TRANSPORT              = -4 ,
+  /* TX failure when there is no remote intent queued */
+  GLINK_STATUS_NO_REMOTE_INTENT_FOUND    = -5,
+  /* Failure of a glink_* call when channel is not fully opened yet */
+  GLINK_STATUS_CH_NOT_FULLY_OPENED       = -6,
+  /* Failure due to closing the same channel twice */
+  GLINK_STATUS_CH_ALREADY_CLOSED         = -7,
+  /* Returned when intent APIs are used over an intent less xport */
+  GLINK_STATUS_API_NOT_SUPPORTED         = -8,
+  /* Failure specific to QoS algorithm/implementation */
+  GLINK_STATUS_QOS_FAILURE               = -9,
+  /* Failure due to tx_cmd* calls */
+  GLINK_STATUS_TX_CMD_FAILURE            = -10,
+  /* For other Failures not covered above */
+  GLINK_STATUS_FAILURE                   = -11,
+  /* Failures relating to GLink operation timeout */
+  GLINK_STATUS_TIMEOUT                   = -12
 }glink_err_type;
 
-/** List of possible suvsystems */
+/** List of possible subsystems */
 /**
   "apss"   Application Processor Subsystem
   "mpss"   Modem subsystem
diff --git a/platform/msm_shared/include/glink_core_if.h b/platform/msm_shared/include/glink_core_if.h
index 67cd106..fd4d6be 100644
--- a/platform/msm_shared/include/glink_core_if.h
+++ b/platform/msm_shared/include/glink_core_if.h
@@ -42,7 +42,6 @@
 /*===========================================================================
                         INCLUDE FILES
 ===========================================================================*/
-
 #include "smem_list.h"
 #include "glink.h"
 #include "glink_transport_if.h"
@@ -51,6 +50,17 @@
 /*===========================================================================
                       MACRO DECLARATIONS
 ===========================================================================*/
+/* Limit of the proportion of total QoS requests
+   =GLINK_QOS_RATE_LIMIT_COEFF_N / GLINK_QOS_RATE_LIMIT_COEFF_D
+ */
+#define GLINK_QOS_RATE_LIMIT_COEFF_N 7
+#define GLINK_QOS_RATE_LIMIT_COEFF_D 10
+
+/* Number of QoS tokens given at refill */
+#define GLINK_QOS_TOKENS (10) 
+
+/* Number of QoS buckets */
+#define GLINK_QOS_BUCKETS (1)
 
 /*===========================================================================
                       TYPE DECLARATIONS
@@ -88,11 +98,15 @@
   os_event_type event;   /* Event to signal Tx thread */
   os_cs_type tx_q_cs;    /* Lock to protect Tx queue */
   smem_list_type tx_q;   /* Tx channel queue */
+  uint32 qos_rate_sum;   /* Sum of rates of registered QoS requests */
 } glink_tx_xport_ctx_type;
 
 /** G-Link Local channel states */
 typedef enum
 {
+  /** Initial State before entering channel state machine */
+  GLINK_LOCAL_CH_INIT,
+  
   /** Local G-Link channel is fully closed */
   GLINK_LOCAL_CH_CLOSED,
 
@@ -110,6 +124,9 @@
 /** G-Link Remote channel states */
 typedef enum
 {
+  /** Initial State before entering channel state machine */
+  GLINK_REMOTE_CH_INIT,
+
   /** Remote G-Link channel is closed */
   GLINK_REMOTE_CH_CLOSED,
 
@@ -117,7 +134,12 @@
   GLINK_REMOTE_CH_OPENED,
 
   /* Glink channel state when SSR is received from remote sub-system */
-  GLINK_REMOTE_CH_SSR_RESET
+  GLINK_REMOTE_CH_SSR_RESET,
+
+  /** G-Link channel is pending cleanup. 
+      This state is used for deferred channel cleanup in case 
+      it sits in Tx scheduler queue */
+  GLINK_REMOTE_CH_CLEANUP
 
 }glink_remote_state_type;
 
@@ -144,14 +166,6 @@
   uint32                  features /* Features */
 );
 
-/** Sets the core version used by the transport; called after completing
- *  negotiation.*/
-typedef void (*set_core_version_fn)
-(
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  version  /* Version */
-);
-
 /** Receive remote channel open request; expected response is
  *  glink_transport_if_type:: tx_cmd_ch_remote_open_ack */
 typedef void (*rx_cmd_ch_remote_open_fn)
@@ -307,7 +321,7 @@
   const glink_core_version_type *version_array;
 
   /** Keep track of version array index in use */
-  uint32                        version_indx;
+  int32                         version_indx;
 
   /* Keeps track of the current status of the transport */
   glink_transport_status_type   status;
@@ -319,13 +333,17 @@
   /* Transport's capabilities */
   uint32                        xport_capabilities;
 
+  /* Max lcid */
+  uint32                        max_lcid;
+
   /* Free lcid */
   uint32                        free_lcid;
 
   /* Keeps track of the open channels for this transport/edge combination */
   smem_list_type                open_list;
 
-  /* Critical section to protect access to open_list */
+  /* Critical section to protect access to open_list and channel state of all 
+     channels in that open_list */
   os_cs_type                    channel_q_cs;
 
   /* Local channel intents queued so far. This also helps determining liid
@@ -372,10 +390,6 @@
   /** Receive ACK to previous glink_transport_if_type::tx_cmd_version command */
   rx_cmd_version_ack_fn          rx_cmd_version_ack;
 
-  /** Sets the core version used by the transport; called after completing
-   *  negotiation.*/
-  set_core_version_fn            set_core_version;
-
   /** Receive remote channel open request; expected response is
    *  glink_transport_if_type:: tx_cmd_ch_remote_open_ack */
   rx_cmd_ch_remote_open_fn       rx_cmd_ch_remote_open;
diff --git a/platform/msm_shared/include/glink_internal.h b/platform/msm_shared/include/glink_internal.h
index bdd434c..c753961 100644
--- a/platform/msm_shared/include/glink_internal.h
+++ b/platform/msm_shared/include/glink_internal.h
@@ -36,9 +36,7 @@
 ===========================================================================*/
 
 /*===========================================================================
-
                         INCLUDE FILES
-
 ===========================================================================*/
 #include "smem_list.h"
 #include "glink.h"
@@ -55,15 +53,74 @@
 #define GLINK_VERSION 0
 #define GLINK_FEATURE_FLAGS 0
 #define GLINK_NUM_HOSTS     7
+#define GLINK_INVALID_CID   0
 
 /*===========================================================================
                            MACRO DEFINITIONS
 ===========================================================================*/
-#define GLINK_LOG_EVENT(type, ch_name, xport, remote_ss, param) \
-  glink_mem_log(__FUNCTION__, __LINE__, type, ch_name, xport, remote_ss, param);
 
+/* Macros to enable/select glink logging and stats collection
+ * GLINK_MEMORY_LOGGING     --> Enable memory based logging
+ * GLINK_OS_DEFINED_LOGGING --> Enable OS defined logging (uLog for ADSP/MPSS/SLPI)
+ * These will be selectively defined by the top level Glink Scons file
+ */
+/**** Logging macros GLINK_LOG_* ****/
+#if defined(GLINK_MEMORY_LOGGING)
 #define GLINK_MEM_LOG_SIZE 128
 
+/* Used for xport logging where channel name information is unavaliable */
+#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param) \
+  glink_mem_log(type, ch_name, xport, remote_ss, param);
+
+/* Filtering based on ch_ctx, If ch_ctx is not available we should be using 
+  *_NO_FILTER macro for logging */
+#define GLINK_LOG_EVENT(chnl_ctx, type, ch_name, xport, remote_ss, param)  \
+  if ((log_filter_cfg.ch_filter_status == FALSE) ||                        \
+      ((chnl_ctx) == log_filter_cfg.ch_ctx))                               \
+  {                                                                        \
+    glink_mem_log(type, ch_name, xport, remote_ss, param);                 \
+  }
+
+#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param)      \
+  glink_mem_log(type, ch_name, xport, remote_ss, param);
+
+#elif defined(GLINK_OS_DEFINED_LOGGING)
+
+/* Used for xport logging where channel name information is unavaliable */
+#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param) \
+  OS_LOG_MSG(5, "[%x, %s, %s, %s, %x]" , type, ch_name,                   \
+             xport, remote_ss, param);
+
+/* Filtering based on ch_ctx, If ch_ctx is not available we should be using 
+  *_NO_FILTER macro for logging */
+#define GLINK_LOG_EVENT(chnl_ctx, type, ch_name, xport, remote_ss, param)  \
+  if ((log_filter_cfg.ch_filter_status == FALSE) ||                        \
+      ((chnl_ctx) == log_filter_cfg.ch_ctx))                               \
+  {                                                                        \
+    OS_LOG_MSG(5, "[%x, %s, %s, %s, %x]" , type, ch_name,                  \
+               xport, remote_ss, param);                                   \
+  }
+
+#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param)	 \
+  OS_LOG_ERROR(5, "[%x, %s, %s, %s, %x]" , type, ch_name,                \
+               xport, remote_ss, param);
+#else
+#define GLINK_LOG_EVENT(lcid, type, ch_name, xport, remote_ss, param) 
+#define GLINK_LOG_ERROR_EVENT(type, ch_name, xport, remote_ss, param)
+#define GLINK_LOG_EVENT_NO_FILTER(type, ch_name, xport, remote_ss, param)
+#endif
+
+/**** Macros used for collecting channel stats ****/
+#if defined(GLINK_CHANNEL_STATS_ENABLED)
+#define GLINK_UPDATE_CHANNEL_STATS(ch_stats, var_name, size_in_bytes)               \
+  {                                                                           \
+      (ch_stats).var_name##_count++;                                          \
+      (ch_stats).var_name##_bytes += (size_in_bytes);                         \
+  }
+#else
+#define GLINK_UPDATE_CHANNEL_STATS(ch_stats, var_name, size_in_bytes)
+#endif
+
 /*===========================================================================
                            TYPE DEFINITIONS
 ===========================================================================*/
@@ -95,14 +152,35 @@
   GLINK_EVENT_CH_MIGRATION_IN_PROGRESS,
   GLINK_EVENT_XPORT_INTERNAL,
   GLINK_EVENT_TRACER_PKT_FAILURE,
-  GLINK_EVENT_TXV_INVALID_BUFFER
+  GLINK_EVENT_TXV_INVALID_BUFFER,
+  GLINK_EVENT_CH_QOS_REG,
+  GLINK_EVENT_CH_QOS_CANCEL,
+  GLINK_EVENT_CH_QOS_START,
+  GLINK_EVENT_CH_QOS_STOP,
+  GLINK_EVENT_INVALID_REMOTE_SS,
+  GLINK_EVENT_REGISTER_LINK_STATE_CB,
+  GLINK_EVENT_DEREGISTER_LINK_STATE_CB,
+  GLINK_EVENT_LB_CLIENT,
+  GLINK_EVENT_SSR
 }glink_log_event_type;
 
+/*Bit index of logging mask of differnt xport. The corresponding bit index 
+  in glink_xport_log_filter_mask will disable(0) or enable(1) logging*/
+typedef enum {
+  GLINK_XPORT_RPM_MASK_BIT,
+  GLINK_XPORT_SMEM_MASK_BIT,
+  GLINK_XPORT_SMD_MASK_BIT,
+  GLINK_XPORT_UART_MASK_BIT
+}glink_xport_logging_mask_type;
+
 typedef struct _glink_channel_intents_type {
 
   /* Link for a channel in Tx queue */
   struct _glink_channel_intents_type* next;
 
+  /* Pointer to channel context */
+  glink_channel_ctx_type        *ch_ctx;
+
   /* Critical section to protest access to intent queues */
   os_cs_type                    intent_q_cs;
 
@@ -137,6 +215,85 @@
 
 } glink_channel_intents_type;
 
+
+typedef struct _glink_channel_qos_type {
+  /* qos request count */
+  uint32                        qos_req_count;
+
+  /* qos request packet size */
+  size_t                        qos_pkt_size;
+
+  /* qos request latency */
+  uint32                        qos_latency_us;
+
+  /* qos request rate */
+  uint32                        qos_rate;
+
+  /* qos priority */
+  uint32                        qos_tokens;
+
+  /* qos transport context */
+  void                          *qos_transport_ctx;
+
+  /* qos start time for priority balancing */
+  os_timetick_type              qos_start_priority_time;
+
+} glink_channel_qos_type;
+
+/*This structure holds all the relevant stats per channel used for debugging*/
+typedef struct _glink_channel_stats_type {
+  /* Total number of bytes sent by the client */
+  uint64 tx_request_bytes;
+
+  /* Total number of bytes sent by the client for which we got tx_done */
+  uint64 tx_done_bytes;
+
+  /* Total number of tx requests */
+  uint32 tx_request_count;
+
+  /* total number of tx_done events */
+  uint32 tx_done_count;
+  
+  /* Total number of bytes recieved by the client */
+  uint64 rx_notify_bytes;
+
+  /* Total number of bytes for which we got rx_done */
+  uint64 rx_done_bytes;
+  
+  /* Total number of rx_notify events */
+  uint32 rx_notify_count;
+  
+  /* Total number of rx_done events */
+  uint32 rx_done_count;
+
+} glink_channel_stats_type;
+
+/* Contains the configuration for logging within core and xport */
+typedef struct _glink_logging_filter_cfg {
+    
+  /* GLink channel filter status */
+  boolean ch_filter_status;
+
+  /* channel filter name */
+  char ch_name[GLINK_CH_NAME_LEN];
+  
+  /* corresponding lcid of the filter */
+  uint32 ch_lcid;
+  
+  /* corresponding rcid of the filter*/
+  uint32 ch_rcid;
+  
+  /* corresponding remote host*/
+  uint32 remote_host;
+
+  /* Corresponding channel context */
+  glink_channel_ctx_type *ch_ctx;
+
+  /* xport logging mask */
+  uint32 xport_filter_mask;
+  
+}glink_logging_filter_cfg_type;
+
 struct glink_channel_ctx {
   /* Link needed for use with list APIs.  Must be at the head of the struct */
   smem_list_link_type                 link;
@@ -156,9 +313,6 @@
   /* Remote channel state */
   glink_remote_state_type             remote_state;
 
-  /* Critical section to protect channel states */
-  os_cs_type                          ch_state_cs;
-
   /* Channel local control signal state */
   uint32                              local_sigs;
 
@@ -171,6 +325,15 @@
   /* channel intent collection */
   glink_channel_intents_type          *pintents;
 
+  /* Critical section to protest access to QoS context */
+  os_cs_type                          qos_cs;
+
+  /* qos priority */
+  uint32                              qos_priority;
+
+  /* channel QoS context */
+  glink_channel_qos_type              *qosctx;
+  
   /* Interface pointer with with this channel is registered */
   glink_transport_if_type             *if_ptr;
 
@@ -214,26 +377,16 @@
   *   or local side closed the port. Optional */
   glink_notify_tx_abort_cb            notify_tx_abort;
 
-  /* glink transport if pointer for preferred channel */
-  glink_transport_if_type             *req_if_ptr;
-
-  /* flag to check if channel is marked for deletion
-   * This is workaround to prevent channel migration algorithm from finding channel
-   * which should be closed but has not been closed yet. This case occurs when glink_close
-   * is called for closing channel on initial xport and it is being opened on other xport.
-   * This may lead to remote side opening channel on neogitated xport from which local side
-   * will get remote open again. In this case channel to be closed will be found for negotiation
-   * on initial xport again and channel migration algorithm will be triggered(again)  */
-  boolean                             tag_ch_for_close;
-
   /* save glink open config options */
   uint32                              ch_open_options;
+#if defined(GLINK_CHANNEL_STATS_ENABLED)
+  /* Structure that constains per channel stats */
+  glink_channel_stats_type             ch_stats;
+#endif
 };
 
 
 typedef struct _glink_mem_log_entry_type {
-  const char *func;
-  uint32 line;
   glink_log_event_type type;
   const char *msg;
   const char *xport;
@@ -252,17 +405,37 @@
   void                      *priv;         /* Notification priv ptr */
 } glink_link_notif_data_type;
 
+
+/* Function pointer used to iterate glink registered transports
+ * glink_client_cond_fn is used to find specifc transport client wants
+ * glink_client_ex_fn will execute client's operation on specific/all transports
+ * depends on client's choice */
+typedef boolean (*glink_client_cond_fn)
+(
+  glink_transport_if_type *if_ptr,
+  void                    *cond1,   /* First condition to compare */
+  uint32                   cond2,   /* Second condition to compare */
+  void                   **out      /* Client private return value */
+);
+
+typedef void (*glink_client_ex_fn)
+(
+  glink_transport_if_type *if_ptr,
+  void                    *param1,   /* First parameter */
+  uint32                   param2,   /* Second parameter */
+  void                   **out      /* Client private return value */
+);
+
 /*===========================================================================
                               GLOBAL DATA DECLARATIONS
 ===========================================================================*/
-extern os_cs_type *glink_transport_q_cs;
 extern const char *glink_hosts_supported[GLINK_NUM_HOSTS];
-extern smem_list_type glink_registered_transports[];
 
+/* Used for filtering logs*/
+extern glink_logging_filter_cfg_type log_filter_cfg;
 /*===========================================================================
                     LOCAL FUNCTION DEFINITIONS
 ===========================================================================*/
-
 /*===========================================================================
                     EXTERNAL FUNCTION DEFINITIONS
 ===========================================================================*/
@@ -478,250 +651,6 @@
 );
 
 /*===========================================================================
-FUNCTION      glink_set_core_version
-
-DESCRIPTION   Sets the core version used by the transport; called after
-              completing negotiation.
-
-ARGUMENTS   *if_ptr    Pointer to interface instance; must be unique
-                       for each edge
-
-             version   Negotiated transport version
-
-RETURN VALUE  None.
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glink_set_core_version
-(
-  glink_transport_if_type *if_ptr, /* Pointer to the interface instance */
-  uint32                  version  /* Version */
-);
-
-/*===========================================================================
-                           CHANNEL CONTEXT APIS
-===========================================================================*/
-
-/*===========================================================================
-FUNCTION      glinki_ch_is_fully_opened
-
-DESCRIPTION   Determine if both the local and remote channel state is fully
-              open
-
-ARGUMENTS     *cfg_ptr   - Pointer to channel context
-
-RETURN VALUE  True if fully opened, false otherwise.
-
-SIDE EFFECTS  None
-===========================================================================*/
-boolean glinki_ch_is_fully_opened
-(
-  glink_channel_ctx_type *ctx
-);
-
-
-/*===========================================================================
-FUNCTION      glinki_ch_push_local_rx_intent
-
-DESCRIPTION   Create and push a local receive intent to internal list
-
-ARGUMENTS     *cfg_ptr   - Pointer to channel context
-
-              *pkt_priv  - Client-provided opaque data
-
-              size       - Size of Receive Intent
-
-RETURN VALUE  Pointer to the new intent
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_rx_intent_type* glinki_ch_push_local_rx_intent
-(
-  glink_channel_ctx_type *ctx,
-  const void             *pkt_priv,
-  size_t                 size
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_get_local_rx_intent
-
-DESCRIPTION   Lookup a local receive intent
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              liid        - Local Receive Intent ID
-
-RETURN VALUE  Pointer to the intent or NULL if not match is found.
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_rx_intent_type* glinki_ch_get_local_rx_intent
-(
-  glink_channel_ctx_type *ctx,
-  uint32                 liid
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_remove_local_rx_intent
-
-DESCRIPTION   Removes Local Receive Intent ID
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              liid        - Local Receive Intent ID
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glinki_ch_remove_local_rx_intent
-(
-  glink_channel_ctx_type *ctx,
-  uint32                 liid
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_set_local_rx_intent_notified
-
-DESCRIPTION   Sets the state of the intent as client-notified
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              *intent_ptr - Pointer to the receive intent
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glinki_ch_set_local_rx_intent_notified
-(
-  glink_channel_ctx_type *ctx,
-  glink_rx_intent_type   *intent_ptr
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_get_local_rx_intent_notified
-
-DESCRIPTION   Lookup a Local Receive Intent ID that is in the client-notified
-              state
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              *ptr        - Data pointer of receive buffer from client
-                            (passed in through glink_rx_done)
-
-RETURN VALUE  Pointer to the intent or NULL if not match is found.
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_rx_intent_type* glinki_ch_get_local_rx_intent_notified
-(
-  glink_channel_ctx_type *ctx,
-  void                   *ptr
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_remove_local_rx_intent_notified
-
-DESCRIPTION   Removes the Local Receive Intent
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              *intent_ptr - Pointer to the receive intent
-
-RETURN VALUE  New channel context or NULL
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_channel_ctx_type* glinki_ch_remove_local_rx_intent_notified
-(
-  glink_channel_ctx_type *ctx,
-  glink_rx_intent_type   *intent_ptr
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_push_remote_rx_intent
-
-DESCRIPTION   Adds a new Remote Receive Intent
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              size        - Size of the Remote Receive Intent
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glinki_ch_push_remote_rx_intent
-(
-  glink_channel_ctx_type *ctx,
-  size_t                 size
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_pop_remote_rx_intent
-
-DESCRIPTION   Removes a Remote Receive Intent
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              size        - Size of the Remote Receive Intent
-
-              *riid_ptr   - Pointer to the Remote Receive Intent
-
-RETURN VALUE  Standard GLink Err code.
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_err_type glinki_ch_pop_remote_rx_intent
-(
-  glink_channel_ctx_type *ctx,
-  size_t                size,
-  uint32                *riid_ptr
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_get_tx_pending_remote_done
-
-DESCRIPTION   Lookup packet transmit context for a packet that is waiting for
-              the remote-done notification.
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              riid        - Remote Receive Intent ID
-
-RETURN VALUE  Pointer to the transmit packet context or NULL if not match is
-              found.
-
-SIDE EFFECTS  None
-===========================================================================*/
-glink_core_tx_pkt_type* glinki_ch_get_tx_pending_remote_done
-(
-  glink_channel_ctx_type *ctx,
-  uint32                 riid
-);
-
-/*===========================================================================
-FUNCTION      glinki_ch_remove_tx_pending_remote_done
-
-DESCRIPTION   Removes a packet transmit context for a packet that is waiting
-              for the remote-done notification.
-
-ARGUMENTS     *cfg_ptr    - Pointer to channel context
-
-              *tx_pkt     - Pointer to the packet context to remove
-
-RETURN VALUE  None
-
-SIDE EFFECTS  None
-===========================================================================*/
-void glinki_ch_remove_tx_pending_remote_done
-(
-  glink_channel_ctx_type       *ctx,
-  glink_core_tx_pkt_type       *tx_pkt
-);
-
-/*===========================================================================
   FUNCTION      glinki_add_ch_to_xport
 ===========================================================================*/
 /**
@@ -729,8 +658,6 @@
  *
  * @param[in]    if_ptr            Pointer to xport if on which channel is to
  *                                 be opened
- * @param[in]    req_if_ptr        Pointer to xport if on which channel
- *                                 actually wants to open
  * @param[in]    ch_ctx            channel context
  * @param[out]   allocated_ch_ctx  Pointer to channel context pointer
  * @param[in]    local_open        flag to determine if channel is opened
@@ -747,7 +674,6 @@
 glink_err_type glinki_add_ch_to_xport
 (
   glink_transport_if_type  *if_ptr,
-  glink_transport_if_type  *req_if_ptr,
   glink_channel_ctx_type   *ch_ctx,
   glink_channel_ctx_type  **allocated_ch_ctx,
   unsigned int              local_open,
@@ -756,8 +682,6 @@
 
 void glink_mem_log
 (
-  const char *func,
-  uint32 line,
   glink_log_event_type type,
   const char *msg,
   const char *xport,
@@ -827,4 +751,460 @@
 /*=========================================================================*/
 void glink_core_setup_intentless_xport(glink_transport_if_type *if_ptr);
 
+/*===========================================================================
+  FUNCTION      glink_core_setup_intent_xport
+===========================================================================*/
+/**
+
+  Initializes internal core functions based on the transport capabilities.
+
+  @param[in]  if_ptr   The Pointer to the interface instance.
+
+  @return     None.
+
+  @sideeffects  None.
+*/
+/*=========================================================================*/
+void glink_core_setup_intent_xport(glink_transport_if_type *if_ptr);
+
+/*===========================================================================
+  FUNCTION      glink_core_qos_get_priority
+===========================================================================*/
+/**
+
+  Calculates pinitial priority for QoS request.
+
+  @param[in]  if_ptr   The Pointer to the interface instance.
+  @param[in]  req_rate The requested rate.
+
+  @return     Priority.
+
+  @sideeffects  None.
+*/
+/*=========================================================================*/
+uint32 glink_core_qos_get_priority(glink_transport_if_type *if_ptr, uint32 req_rate);
+
+/*===========================================================================
+  FUNCTION      glinki_channel_fully_opened
+===========================================================================*/
+/** 
+ * Check whether this channel is fully opened or not (local & remote)
+ * This also checks transport status
+ *
+ * @param[in]  handle        glink channel handle
+ *
+ * @return     TRUE,  if channel is fully opened
+ *             FASLE, otherwise
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+boolean glinki_channel_fully_opened
+(
+  glink_handle_type          handle
+);
+
+/*===========================================================================
+  FUNCTION      glink_core_qos_cancel
+===========================================================================*/
+/**
+
+  Releases QoS resources.
+
+  @param[in]  open_ch_ctx  Pointer to the channel context.
+
+  @return     None.
+
+  @sideeffects  None.
+*/
+/*=========================================================================*/
+void glink_core_qos_cancel(glink_channel_ctx_type *open_ch_ctx);
+
+/*===========================================================================
+  FUNCTION      glinki_register_link_notif_data
+===========================================================================*/
+/** 
+ * Register link notification data
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_register_link_notif_data
+(
+  glink_link_notif_data_type *link_notif_data
+);
+
+/*===========================================================================
+  FUNCTION      glinki_deregister_link_notif_data
+===========================================================================*/
+/** 
+ * Deregister link notification data
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_deregister_link_notif_data
+(
+  glink_link_notif_data_type *link_notif_data
+);
+
+/*===========================================================================
+  FUNCTION      glinki_scan_xports_and_notify
+===========================================================================*/
+/** 
+ * Scan xports and notify link up state event
+ *
+ * @param[in]  link_notif_data  parameter for link notif data
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_scan_xports_and_notify
+(
+  glink_link_notif_data_type *link_notif_data
+);
+
+/*===========================================================================
+  FUNCTION      glinki_scan_notif_list_and_notify
+===========================================================================*/
+/** 
+ * Scan registered link notification list and notify of xport link state change
+ *
+ * @param[in]  if_ptr  pointer to xport interface
+ * @param[in]  state   link state to notify
+ * 
+ * @return       NONE
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+void glinki_scan_notif_list_and_notify
+(
+  glink_transport_if_type *if_ptr,
+  glink_link_state_type state
+);
+
+/*===========================================================================
+  FUNCTION      glinki_xport_linkup
+===========================================================================*/
+/** 
+ * Check whether this transport is in linkup state or not
+ *
+ * @param[in]    if_ptr     transport interface pointer
+ * 
+ * @return       TRUE   if this xport is in link up state
+ *               FALSE  otherwise
+ * 
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+boolean glinki_xport_linkup
+(
+  glink_transport_if_type *if_ptr
+);
+
+/*===========================================================================
+  FUNCTION      glinki_xports_for_each
+===========================================================================*/
+/** 
+ * Scan all the transports in given edge and perform client's function for each
+ * transport
+ *
+ * @param[in]    remote_ss    name of remote subsystem, NULL string not accepted
+ * @param[in]    client_ex_fn client function to perform when desired xport is 
+ *                            found
+ * @param[in]    cond1        first condition to use in client_ex_fn
+ * @param[in]    cond2        second condition to use in client_ex_fn
+ * @param[out]   out          value to return in case client wants
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+void glinki_xports_for_each
+(
+  const char         *remote_ss,
+  glink_client_ex_fn  client_ex_fn,
+  void               *param1,
+  uint32              param2,
+  void              **out
+);
+
+/*===========================================================================
+  FUNCTION      glinki_xports_find
+===========================================================================*/
+/** 
+ * Scan all the transports in given edge and finds transport that satisfy
+ * client's condition
+ *
+ * @param[in]    remote_ss      name of remote subsystem, NULL string not accepted
+ * @param[in]    client_cond_fn client function to check if this transport is 
+ *                              what client is looking for
+ * @param[in]    cond1          first condition to use in client_ex_fn
+ * @param[in]    cond2          second condition to use in client_ex_fn
+ * @param[out]   out            value to return in case client wants
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *               NULL if there isn't any xport matches client's search condition
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_xports_find
+(
+  const char           *remote_ss,
+  glink_client_cond_fn  client_cond_fn,
+  void                 *cond1,
+  uint32                cond2,
+  void                **out
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_lcid
+===========================================================================*/
+/** 
+ * Find channel context by lcid
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    lcid       local channel ID
+ *
+ * @return       pointer to glink channel context
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_lcid
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  uint32                     lcid
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_rcid
+===========================================================================*/
+/** 
+ * Find channel context by rcid
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    rcid       remote channel ID
+ *
+ * @return       pointer to glink channel context
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_rcid
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  uint32                     rcid
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_ch_ctx_by_name
+===========================================================================*/
+/** 
+ * Find channel context by channel name, called by local/remote open function
+ * This function will also indicate (valid_open_call) if this open call would
+ * be valid or not
+ *
+ * @param[in]    xport_ctx  Pointer to transport private context
+ * @param[in]    ch_name    channel name
+ * @param[in]    local_open       flag to indicate this is local open call
+ * @param[out]   valid_open_call  tell whether this open call would be valid
+ *                                or not
+ *
+ * @return       pointer to glink channel context
+ *               NULL if channel doesn't exist
+ *
+ * @sideeffects  This function needs to be protected by channel_q_cs
+ *               Caller is responsible grab/release mutex when calling this
+ */
+/*=========================================================================*/
+glink_channel_ctx_type *glinki_find_ch_ctx_by_name
+(
+  glink_core_xport_ctx_type *xport_ctx,
+  const char                *ch_name,
+  boolean                    local_open,
+  boolean                   *valid_open_call
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_remote_host
+===========================================================================*/
+/** 
+ * return remote subsystem ID based on remote subsystem name
+ *
+ * @param[in]    remote_ss  remote subsystem name
+ *
+ * @return       remote subsystem ID
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+uint32 glinki_find_remote_host
+(
+  const char *remote_ss
+);
+
+/*===========================================================================
+  FUNCTION      glink_get_best_xport
+===========================================================================*/
+/** 
+ * This function gives best available transport for give edge
+ *
+ * @param[in]    remote_ss  Name of remote subsystem
+ * 
+ * @return       pointer to glink_transport_if_type
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_best_xport
+(
+  const char *remote_ss
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_requested_xport
+===========================================================================*/
+/** 
+ * Find requested or best transport depending on client's request
+ *
+ * @param[in]    xport_name         name of transport
+ * @param[in]    remote_ss          remote subsystem name
+ * @param[in]    open_ch_option     option client gave when called glink_open
+ * @param[out]   suggested_priority best xport priority glink suggests
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_requested_xport
+(
+  const char           *xport_name,
+  const char           *remote_ss,
+  uint32                open_ch_option,
+  glink_xport_priority *suggested_priority
+);
+
+/*===========================================================================
+  FUNCTION      glinki_find_xport_by_priority
+===========================================================================*/
+/** 
+ * This function returns glink_transport_if pointer based on transport priority
+ *
+ * @param[in]    prio        glink xport prio
+ * @param[in]    remote_ss   remote subsytem name
+ *
+ * @return       pointer to glink_transport_if_type struct
+ *
+ * @sideeffects  NONE
+ */
+/*=========================================================================*/
+glink_transport_if_type *glinki_find_xport_by_priority
+(
+  glink_xport_priority  prio,
+  const char           *remote_ss
+);
+
+/*===========================================================================
+  FUNCTION      glinki_enqueue_item
+===========================================================================*/
+/** 
+ *  Enqueue item to smem list in protected context
+ * 
+ * @param[in]    smem_list  smem list to enqueue
+ * @param[in]    item       item to enqueue
+ * @param[in]    cs         mutex to protect the list
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+void glinki_enqueue_item
+(
+  smem_list_type *smem_list_ptr,
+  void           *item,
+  os_cs_type     *cs
+);
+
+/*===========================================================================
+  FUNCTION      glinki_dequeue_item
+===========================================================================*/
+/** 
+ *  Dequeue item from smem list in protected context
+ * 
+ * @param[in]    smem_list  smem list to dequeue from 
+ * @param[in]    item       item to dequeue
+ * @param[in]    cs         mutex to protect the list
+ *
+ * @return       None.
+ *
+ * @sideeffects  None.
+ */
+/*=========================================================================*/
+void glinki_dequeue_item
+(
+  smem_list_type *smem_list_ptr,
+  void           *item,
+  os_cs_type     *cs
+);
+
+/*===========================================================================
+  FUNCTION      glinki_update_logging_filter
+===========================================================================*/
+/** 
+ *  Update/Reset the logging filter if the name and remote host of the  
+ *  logging filter matches to that of the passed channel context
+ * 
+ * @param[in]    chnl_ctx   Channel content to match/compare
+ * @param[in]    reset      Indicate Update(FALSE) or Reset(TRUE)
+ *
+ * @return       None.
+ */
+/*=========================================================================*/
+void glinki_update_logging_filter
+(
+  glink_channel_ctx_type *chnl_ctx, 
+  boolean reset
+);
+
+#ifdef FEATURE_TRACER_PACKET
+/*===========================================================================
+FUNCTION      glink_tracer_packet_log_pctx_pkt
+===========================================================================*/
+/** 
+ * Log tracer packet event. Tracer packet is included in glink_core_tx_pkt
+ * and needs to use vprovider to extract it
+ * 
+ * @param[in]  pctx     pointer to glink_core_tx_pkt_type
+ * @param[in]  event_id event_id
+ * 
+ * @return         None
+ *
+ * @sideeffects    None
+ */
+/*=========================================================================*/
+void glink_tracer_packet_log_pctx_pkt
+(
+  glink_core_tx_pkt_type  *pctx,
+  uint32                   event_id
+);
+#endif
+
 #endif /* GLINK_INTERNAL_H */
diff --git a/platform/msm_shared/include/glink_os_type.h b/platform/msm_shared/include/glink_os_type.h
index a129372..c904ee4 100644
--- a/platform/msm_shared/include/glink_os_type.h
+++ b/platform/msm_shared/include/glink_os_type.h
@@ -49,6 +49,13 @@
 ===========================================================================*/
 
 #define OS_LOG_INIT( ) glink_os_log_init()
+#define GLINK_OS_SEC_TO_USEC (1000000ULL)
+#define GLINK_OS_SEC_TO_TICK (19200000ULL)
+
+#define GLINK_OS_TICK_TO_USEC(t) ((t)*10ULL/192ULL)
+#define GLINK_OS_USEC_TO_TICK(u) ((u)*192ULL/10ULL)
+
+#define GLINK_OS_UNREFERENCED_PARAM( param ) ( void )param
 
 /*===========================================================================
                         TYPE DEFINITIONS
@@ -88,4 +95,6 @@
   uint32_t irq_out;
 } os_ipc_intr_type;
 
+typedef unsigned long long os_timetick_type;
+
 #endif /* OS_TYPE_H */
diff --git a/platform/msm_shared/include/glink_transport_if.h b/platform/msm_shared/include/glink_transport_if.h
index 84056b0..7ebe1fd 100644
--- a/platform/msm_shared/include/glink_transport_if.h
+++ b/platform/msm_shared/include/glink_transport_if.h
@@ -42,8 +42,8 @@
 /*===========================================================================
                         INCLUDE FILES
 ===========================================================================*/
+#include <glink.h>
 #include <smem_list.h>
-#include <glink_os_utils.h>
 
 /*===========================================================================
                       MACRO DECLARATIONS
@@ -83,7 +83,8 @@
   GLINK_XPORT_RPM = 100,
   GLINK_XPORT_SMD = 200,
   GLINK_XPORT_CP_ENGINE = 300,
-  GLINK_MIN_PRIORITY = GLINK_XPORT_CP_ENGINE,
+  GLINK_XPORT_UART = 400,
+  GLINK_MIN_PRIORITY = 100000,
   GLINK_INVALID_PRIORITY
 } glink_xport_priority;
 
@@ -93,7 +94,6 @@
 
   void       *data;      /* Pointer to the data buffer to be transmitted */
   const void *pkt_priv;  /* Per packet private data */
-  uint32     cid;        /* Local channel ID being used to transmit data */
   uint32     iid;        /* Remote intent ID being used to transmit data */
   size_t     size;       /* Size of data buffer */
   size_t     size_remaining; /* Size left to transmit */
@@ -264,6 +264,76 @@
   glink_transport_if_type *if_ptr   /* Pointer to the interface instance */
 );
 
+/** Provides data rate (tokens/sec) achievable by the transport for given 
+    packet size and latency. */
+typedef uint32 (*get_req_rate_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  uint32                  latency_us, /* latency in us */
+  size_t                  pkt_size    /* Size of the packet */
+);
+
+/** Allocates context structure to use by transport servicing given QoS request. */
+typedef void* (*alloc_req_ctx_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  uint32                  latency_us, /* latency in us */
+  size_t                  pkt_size    /* Size of the packet */
+);
+
+/** Frees context structure used by transport servicing given QoS request. */
+typedef void (*free_req_ctx_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  void                    *qos_ctx    /* Pointer to the transport QoS context */
+);
+
+/** Starts QoS mode. */
+typedef void (*start_req_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  void                    *qos_ctx    /* Pointer to the transport QoS context */
+);
+
+/** Stops QoS mode. */
+typedef void (*stop_req_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  void                    *qos_ctx    /* Pointer to the transport QoS context */
+);
+
+/** Provides ramp up time in microseconds. */
+typedef uint32 (*get_ramp_time_fn)
+(
+  glink_transport_if_type *if_ptr,    /* Pointer to the interface instance */
+  void                    *qos_ctx    /* Pointer to the transport QoS context */
+);
+
+
+/**
+* Data Structure for GLink Core to call into transport QoS API
+*
+* This structure is used by the GLink core to operate transport
+* This set of function pointers to to be filled in by the transport
+* abstraction layer.
+*/
+typedef struct glink_transport_qos_if_s {
+  /** Provides maximum data rate (tokens/sec) associated with transport. */
+  uint32 max_rate;
+  /** Provides data rate achievable by the transport for given request. */
+  get_req_rate_fn  get_req_rate;
+  /** Allocates context structure to use by transport servicing given QoS request. */
+  alloc_req_ctx_fn alloc_req_ctx;
+  /** Frees context structure used by transport servicing given QoS request. */
+  free_req_ctx_fn  free_req_ctx;
+  /** Starts QoS mode. */
+  start_req_fn     start_req;
+  /** Stops QoS mode. */
+  stop_req_fn      stop_req;
+  /** Provides ramp up time in microseconds. */
+  get_ramp_time_fn get_ramp_time;
+
+} glink_transport_qos_if_type;
 
 /**
  * Data Structure for GLink Core to call into transport API
@@ -359,6 +429,9 @@
 
   /* glink transport priority */
   glink_xport_priority                glink_priority;
+
+  /* pointer to glink transport QoS interface */
+  glink_transport_qos_if_type        *qos_functbl;
 };
 
 #endif //GLINK_TRANSPORT_IF_H
diff --git a/platform/msm_shared/include/glink_vector.h b/platform/msm_shared/include/glink_vector.h
index 863c19a..9f705ec 100644
--- a/platform/msm_shared/include/glink_vector.h
+++ b/platform/msm_shared/include/glink_vector.h
@@ -37,9 +37,7 @@
 
 
 /*===========================================================================
-
                         INCLUDE FILES
-
 ===========================================================================*/
 #include "glink.h"
 
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index eb7107d..bffa003 100644
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -55,6 +55,7 @@
 		$(LOCAL_DIR)/rpm-ipc.o \
 		$(LOCAL_DIR)/glink/glink_api.o \
 		$(LOCAL_DIR)/glink/glink_core_if.o \
+		$(LOCAL_DIR)/glink/glink_core_internal.o \
 		$(LOCAL_DIR)/glink/glink_rpmcore_setup.o \
 		$(LOCAL_DIR)/glink/glink_core_intentless_xport.o \
 		$(LOCAL_DIR)/glink/glink_os_utils_dal.o \
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index b174068..a342f86 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -473,6 +473,7 @@
 	HW_PLATFORM_SUBTYPE_DSDA = 7,
 	HW_PLATFORM_SUBTYPE_DSDA2 = 8,
 	HW_PLATFORM_SUBTYPE_SGLTE2 = 9,
+	HW_PLATFORM_SUBTYPE_POLARIS = 64,
 	HW_PLATFORM_SUBTYPE_32BITS = 0x7FFFFFFF
 };
 
diff --git a/target/init.c b/target/init.c
index c3893d3..6eba00e 100644
--- a/target/init.c
+++ b/target/init.c
@@ -239,13 +239,21 @@
 			ret = VIB_ERM_TYPE;
 			break;
 		case MSM8976:
+		case MSM8956:
+		case APQ8056:
 			ret = VIB_LRA_TYPE;
 			break;
+		default:
+			dprintf(CRITICAL,"Unsupported platform id\n");
+			break;
 		}
 		break;
 	case HW_PLATFORM_QRD:
 		ret = VIB_ERM_TYPE;
 		break;
+	default:
+		dprintf(CRITICAL,"Unsupported platform id\n");
+		break;
 	}
 	return ret;
 }
diff --git a/target/msm8952/oem_panel.c b/target/msm8952/oem_panel.c
index 4d448bf..30a56e9 100644
--- a/target/msm8952/oem_panel.c
+++ b/target/msm8952/oem_panel.c
@@ -462,6 +462,7 @@
 {
 	uint32_t hw_id = board_hardware_id();
 	int32_t panel_override_id;
+	uint32_t target_id, plat_hw_ver_major;
 
 	if (panel_name) {
 		panel_override_id = panel_name_to_id(supp_panels,
@@ -495,7 +496,17 @@
 			panel_id = TRULY_1080P_VIDEO_PANEL;
 		break;
 	case HW_PLATFORM_QRD:
-		panel_id = OTM1906C_1080P_CMD_PANEL;
+		target_id = board_target_id();
+		plat_hw_ver_major = ((target_id >> 16) & 0xFF);
+
+		/*
+		 * 8952 SKUM DVT2 - HX8399A 1080p video panel
+		 * 8952 SKUM EVT1/EVT2 - OTM1906C 1080p cmd panel
+		 */
+		if (plat_hw_ver_major >= 4)
+			panel_id = HX8399A_1080P_VIDEO_PANEL;
+		else
+			panel_id = OTM1906C_1080P_CMD_PANEL;
 
 		/* QRD EVT1 uses OTM1906C, and EVT2 uses HX8399A */
 		if (platform_is_msm8956()) {
diff --git a/target/msm8996/include/target/display.h b/target/msm8996/include/target/display.h
index eddc0c8..a8623d2 100644
--- a/target/msm8996/include/target/display.h
+++ b/target/msm8996/include/target/display.h
@@ -66,7 +66,7 @@
 /*---------------------------------------------------------------------------*/
 #define DISPLAY_CMDLINE_PREFIX " mdss_mdp.panel="
 
-#define MIPI_FB_ADDR  0x82400000
+#define MIPI_FB_ADDR  0x83400000
 
 #define MIPI_HSYNC_PULSE_WIDTH       16
 #define MIPI_HSYNC_BACK_PORCH_DCLK   32