Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 2 | |
| 3 | Redistribution and use in source and binary forms, with or without |
| 4 | modification, are permitted provided that the following conditions are |
| 5 | met: |
| 6 | * Redistributions of source code must retain the above copyright |
| 7 | notice, this list of conditions and the following disclaimer. |
| 8 | * Redistributions in binary form must reproduce the above |
| 9 | copyright notice, this list of conditions and the following |
| 10 | disclaimer in the documentation and/or other materials provided |
| 11 | with the distribution. |
| 12 | * Neither the name of The Linux Foundation nor the names of its |
| 13 | contributors may be used to endorse or promote products derived |
| 14 | from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | |
| 30 | /*=========================================================================== |
| 31 | INCLUDE FILES |
| 32 | ===========================================================================*/ |
| 33 | |
| 34 | #include "glink_os_utils.h" |
| 35 | #include "glink.h" |
| 36 | #include "glink_internal.h" |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 37 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 38 | #define FEATURE_CH_MIGRATION_FREE |
| 39 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 40 | /*=========================================================================== |
| 41 | GLOBAL FUNCTION DECLARATIONS |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 42 | ===========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 43 | /*=========================================================================== |
| 44 | LOCAL FUNCTION DEFINITIONS |
| 45 | ===========================================================================*/ |
| 46 | /*=========================================================================== |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 47 | FUNCTION glink_process_negotiation_complete |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 48 | ===========================================================================*/ |
| 49 | /** |
| 50 | |
| 51 | This is called when negotiation is complete. |
| 52 | It will set the version and call link up callback to notify |
| 53 | |
| 54 | |
| 55 | @param[in] xport_ctx transport context |
| 56 | |
| 57 | @param[in] if_ptr Pointer to interface instance; must be unique |
| 58 | for each edge |
| 59 | |
| 60 | @param[in] version negotiated version |
| 61 | |
| 62 | @param[in] features negotiated with local side |
| 63 | |
| 64 | @return None |
| 65 | @sideeffects None. |
| 66 | @dependencies None. |
| 67 | */ |
| 68 | /*=========================================================================*/ |
| 69 | static void glink_process_negotiation_complete |
| 70 | ( |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 71 | glink_transport_if_type *if_ptr, |
| 72 | uint32 version, |
| 73 | uint32 features |
| 74 | ) |
| 75 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 76 | glink_core_xport_ctx_type *xport_ctx = if_ptr->glink_core_priv; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 77 | /* Version/Feautre can be negotiated both in ver_req and ver_ack |
| 78 | * Only go through process once in case they are negotiated |
| 79 | * in ver_req before receiving ver_ack */ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 80 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 81 | if (glinki_xport_linkup(if_ptr)) |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 82 | { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | /* setup core based on transport capabilities*/ |
| 87 | xport_ctx->xport_capabilities = if_ptr->set_version( if_ptr, |
| 88 | version, |
| 89 | features ); |
| 90 | glink_core_setup(if_ptr); |
| 91 | |
| 92 | /* transport is ready to open channels */ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 93 | glink_os_cs_acquire( &xport_ctx->status_cs ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 94 | if_ptr->glink_core_priv->status = GLINK_XPORT_LINK_UP; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 95 | glink_os_cs_release(&xport_ctx->status_cs); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 96 | |
| 97 | /* Scan the notification list to check is we have to let any registered |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 98 | * clients know that link came online */ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 99 | glinki_scan_notif_list_and_notify(if_ptr, GLINK_LINK_STATE_UP); |
| 100 | } |
| 101 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 102 | /*=========================================================================== |
| 103 | FUNCTION glink_clean_channel_ctx |
| 104 | ===========================================================================*/ |
| 105 | /** |
| 106 | |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 107 | This is called when channel is fully closed. |
| 108 | Clean up the context and redeem channel id if possible. |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 109 | |
| 110 | @param[in] xport_ctx transport context |
| 111 | @param[in] channel_ctx channel context |
| 112 | |
| 113 | |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 114 | @return None. |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 115 | @sideeffects None. |
| 116 | @dependencies This function needs to be called in safe context |
| 117 | which is critical sections locked - channel_q_cs |
| 118 | */ |
| 119 | /*=========================================================================*/ |
| 120 | static void glink_clean_channel_ctx |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 121 | ( |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 122 | glink_core_xport_ctx_type *xport_ctx, |
| 123 | glink_channel_ctx_type *channel_ctx |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 124 | ) |
| 125 | { |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 126 | /* If logging was enabled for this channel reset the logging filter */ |
| 127 | glinki_update_logging_filter(channel_ctx, TRUE); |
| 128 | |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 129 | smem_list_delete(&xport_ctx->open_list, channel_ctx); |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 130 | |
| 131 | if( channel_ctx->lcid == ( xport_ctx->free_lcid - 1 ) ) |
| 132 | { |
| 133 | /* If channel being closed is the last opened channel |
| 134 | re-use the lcid of this channel for any new channels */ |
| 135 | xport_ctx->free_lcid--; |
| 136 | } |
| 137 | |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 138 | xport_ctx->channel_cleanup(channel_ctx); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /*=========================================================================== |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 142 | FUNCTION glink_get_current_version |
| 143 | ===========================================================================*/ |
| 144 | /** |
| 145 | |
| 146 | Get current version/feature. This is necessarily highest version. |
| 147 | |
| 148 | @param[in] xport_ctx transport context |
| 149 | |
| 150 | @return pointer to version/feature if available. |
| 151 | NULL otherwise. |
| 152 | |
| 153 | @sideeffects None. |
| 154 | @dependencies None. |
| 155 | */ |
| 156 | /*=========================================================================*/ |
| 157 | static const glink_core_version_type *glink_get_current_version |
| 158 | ( |
| 159 | glink_core_xport_ctx_type *xport_ctx |
| 160 | ) |
| 161 | { |
Steven Cahail | a136c10 | 2015-08-21 13:29:10 -0600 | [diff] [blame] | 162 | const glink_core_version_type *ver; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 163 | |
Steven Cahail | a136c10 | 2015-08-21 13:29:10 -0600 | [diff] [blame] | 164 | ver = &xport_ctx->version_array[xport_ctx->version_indx]; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 165 | ASSERT(ver); |
| 166 | |
| 167 | return ver; |
| 168 | } |
| 169 | |
| 170 | /*=========================================================================== |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 171 | FUNCTION glink_is_local_ch_closed |
| 172 | ===========================================================================*/ |
| 173 | /** |
| 174 | |
| 175 | Check if local channel is fully closed |
| 176 | |
| 177 | @param[in] local_state local channel state |
| 178 | |
| 179 | @return TRUE, if local channel is closed |
| 180 | |
| 181 | @sideeffects None. |
| 182 | @dependencies None. |
| 183 | */ |
| 184 | /*=========================================================================*/ |
| 185 | static boolean glink_is_local_ch_closed |
| 186 | ( |
| 187 | glink_local_state_type local_state |
| 188 | ) |
| 189 | { |
| 190 | return local_state == GLINK_LOCAL_CH_INIT || |
| 191 | local_state == GLINK_LOCAL_CH_CLOSED; |
| 192 | } |
| 193 | |
| 194 | /*=========================================================================== |
| 195 | FUNCTION glink_is_remote_ch_closed |
| 196 | ===========================================================================*/ |
| 197 | /** |
| 198 | |
| 199 | Check if remote channel is fully closed. |
| 200 | This doesn't chek GLINK_REMOTE_CH_CLEANUP state as channel ctx shouldn't be |
| 201 | destroyed yet |
| 202 | |
| 203 | @param[in] ch_ctx channel ctx |
| 204 | |
| 205 | @return TRUE, if remote channel is closed |
| 206 | |
| 207 | @sideeffects None. |
| 208 | @dependencies None. |
| 209 | */ |
| 210 | /*=========================================================================*/ |
| 211 | static boolean glink_is_remote_ch_closed |
| 212 | ( |
| 213 | glink_remote_state_type remote_state |
| 214 | ) |
| 215 | { |
| 216 | return remote_state == GLINK_REMOTE_CH_INIT || |
| 217 | remote_state == GLINK_REMOTE_CH_CLOSED || |
| 218 | remote_state == GLINK_REMOTE_CH_SSR_RESET; |
| 219 | } |
| 220 | |
| 221 | /*=========================================================================== |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 222 | EXTERNAL FUNCTION DEFINITIONS |
| 223 | ===========================================================================*/ |
| 224 | /*=========================================================================== |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 225 | FUNCTION glink_link_up |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 226 | ===========================================================================*/ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 227 | /** |
| 228 | Indicates that transport is now ready to start negotiation |
| 229 | using the v0 configuration |
| 230 | |
| 231 | @param[in] if_ptr Pointer to interface instance; must be unique |
| 232 | for each edge |
| 233 | |
| 234 | @return None |
| 235 | @sideeffects None. |
| 236 | @dependencies None. |
| 237 | */ |
| 238 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 239 | void glink_link_up |
| 240 | ( |
| 241 | glink_transport_if_type *if_ptr |
| 242 | ) |
| 243 | { |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 244 | glink_core_xport_ctx_type *xport_ctx; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 245 | const glink_core_version_type *version_array; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 246 | |
| 247 | xport_ctx = if_ptr->glink_core_priv; |
| 248 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 249 | version_array = glink_get_current_version(xport_ctx); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 250 | |
| 251 | /* Update the transport state */ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 252 | glink_os_cs_acquire(&if_ptr->glink_core_priv->status_cs); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 253 | if_ptr->glink_core_priv->status = GLINK_XPORT_NEGOTIATING; |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 254 | glink_os_cs_release(&if_ptr->glink_core_priv->status_cs); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 255 | |
| 256 | /* Start the negtiation */ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 257 | if_ptr->tx_cmd_version(if_ptr, |
| 258 | version_array->version, |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 259 | version_array->features); |
| 260 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 261 | GLINK_LOG_EVENT_NO_FILTER( GLINK_EVENT_LINK_UP, "", |
| 262 | xport_ctx->xport, |
| 263 | xport_ctx->remote_ss, |
| 264 | GLINK_STATUS_SUCCESS); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /*=========================================================================== |
| 268 | FUNCTION glink_rx_cmd_version |
| 269 | |
| 270 | DESCRIPTION Receive transport version for remote-initiated version |
| 271 | negotiation |
| 272 | |
| 273 | ARGUMENTS *if_ptr Pointer to interface instance; must be unique |
| 274 | for each edge |
| 275 | |
| 276 | version Remote Version |
| 277 | |
| 278 | features Remote Features |
| 279 | |
| 280 | RETURN VALUE None. |
| 281 | |
| 282 | SIDE EFFECTS None |
| 283 | ===========================================================================*/ |
| 284 | void glink_rx_cmd_version |
| 285 | ( |
| 286 | glink_transport_if_type *if_ptr, |
| 287 | uint32 version, |
| 288 | uint32 features |
| 289 | ) |
| 290 | { |
| 291 | const glink_core_version_type *ver; |
| 292 | uint32 negotiated_features; |
| 293 | glink_core_xport_ctx_type *xport_ctx; |
| 294 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 295 | xport_ctx = if_ptr->glink_core_priv; |
| 296 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 297 | ver = glink_get_current_version(xport_ctx); |
| 298 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 299 | /* The version to use must be a subset of supported version and features |
| 300 | * on this host and remote host */ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 301 | if (version == ver->version) |
| 302 | { |
| 303 | /* Call the transport's negotiation function */ |
| 304 | negotiated_features = ver->negotiate_features(if_ptr, ver, features); |
| 305 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 306 | if_ptr->tx_cmd_version_ack(if_ptr, version, negotiated_features); |
| 307 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 308 | /* If negotiated features match the provided features, version nogetiation |
| 309 | * is complete */ |
| 310 | if(negotiated_features == features) |
| 311 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 312 | glink_process_negotiation_complete( if_ptr, version, features ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | else |
| 316 | { |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 317 | /* Versions don't match, return ACK with the feature set that we support */ |
| 318 | if_ptr->tx_cmd_version_ack(if_ptr, ver->version, ver->features); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /*=========================================================================== |
| 323 | FUNCTION glink_rx_cmd_version_ack |
| 324 | |
| 325 | DESCRIPTION Receive ACK to previous glink_transport_if::tx_cmd_version |
| 326 | command |
| 327 | |
| 328 | ARGUMENTS *if_ptr Pointer to interface instance; must be unique |
| 329 | for each edge |
| 330 | |
| 331 | version Remote Version |
| 332 | |
| 333 | features Remote Features |
| 334 | |
| 335 | RETURN VALUE None. |
| 336 | |
| 337 | SIDE EFFECTS None |
| 338 | ===========================================================================*/ |
| 339 | void glink_rx_cmd_version_ack |
| 340 | ( |
| 341 | glink_transport_if_type *if_ptr, |
| 342 | uint32 version, |
| 343 | uint32 features |
| 344 | ) |
| 345 | { |
| 346 | const glink_core_version_type* ver; |
| 347 | uint32 negotiated_features; |
| 348 | glink_core_xport_ctx_type *xport_ctx; |
| 349 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 350 | xport_ctx = if_ptr->glink_core_priv; |
| 351 | |
| 352 | /* Check to see if version returned by remote end is supported by |
| 353 | * this host. Remote side would have acked only when the version/features |
| 354 | * sent by this host did not match the remote */ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 355 | ver = glink_get_current_version(xport_ctx); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 356 | |
| 357 | if (ver->version == version) |
| 358 | { |
| 359 | /* Call the transport's negotiation function */ |
| 360 | negotiated_features = ver->negotiate_features(if_ptr, ver, features); |
| 361 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 362 | if(negotiated_features == features) |
| 363 | { |
| 364 | glink_process_negotiation_complete( if_ptr, version, features ); |
| 365 | } |
| 366 | else |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 367 | { |
| 368 | /* Continue negotiating */ |
| 369 | if_ptr->tx_cmd_version(if_ptr, version, negotiated_features); |
| 370 | } |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 371 | } |
| 372 | else |
| 373 | { |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 374 | while (ver->version > version && xport_ctx->version_indx > 0) |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 375 | { |
| 376 | /* Next time use older version */ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 377 | xport_ctx->version_indx--; |
| 378 | ver = &xport_ctx->version_array[xport_ctx->version_indx]; |
| 379 | } |
| 380 | |
| 381 | /* Versions don't match, return ACK with the feature set that we support */ |
| 382 | if_ptr->tx_cmd_version(if_ptr, ver->version, ver->features); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /*=========================================================================== |
| 387 | FUNCTION glink_rx_cmd_ch_remote_open |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 388 | ===========================================================================*/ |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 389 | /** |
| 390 | * Receive remote channel open request; |
| 391 | * Calls glink_transport_if:: tx_cmd_ch_remote_open_ack as a result |
| 392 | * |
| 393 | * @param[in] if_ptr Pointer to interface instance; must be unique |
| 394 | for each edge |
| 395 | * @param[in] rcid Remote Channel ID |
| 396 | * @param[in] name String name for logical channel |
| 397 | * @param[in] priority xport priority requested by remote side |
| 398 | * |
| 399 | * @return None |
| 400 | * |
| 401 | * @sideeffects NONE |
| 402 | */ |
| 403 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 404 | void glink_rx_cmd_ch_remote_open |
| 405 | ( |
| 406 | glink_transport_if_type *if_ptr, |
| 407 | uint32 rcid, |
| 408 | const char *name, |
| 409 | glink_xport_priority priority |
| 410 | ) |
| 411 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 412 | glink_channel_ctx_type *remote_ch_ctx = NULL; |
| 413 | glink_channel_ctx_type *allocated_ch_ctx; |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 414 | glink_err_type status; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 415 | |
Steven Cahail | a136c10 | 2015-08-21 13:29:10 -0600 | [diff] [blame] | 416 | GLINK_OS_UNREFERENCED_PARAM( priority ); |
| 417 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 418 | /* Allocate and initialize channel info structure */ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 419 | remote_ch_ctx = glink_os_calloc( sizeof( glink_channel_ctx_type ) ); |
| 420 | if(remote_ch_ctx == NULL) |
| 421 | { |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 422 | GLINK_LOG_ERROR_EVENT( GLINK_EVENT_RM_CH_OPEN, |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 423 | name, |
| 424 | if_ptr->glink_core_priv->xport, |
| 425 | if_ptr->glink_core_priv->remote_ss, |
| 426 | GLINK_STATUS_OUT_OF_RESOURCES ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 427 | ASSERT(0); |
| 428 | } |
| 429 | |
| 430 | /* Fill in the channel info structure */ |
| 431 | glink_os_string_copy(remote_ch_ctx->name, name, sizeof(remote_ch_ctx->name)); |
| 432 | remote_ch_ctx->rcid = rcid; |
| 433 | |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 434 | status = glinki_add_ch_to_xport( if_ptr, |
| 435 | remote_ch_ctx, |
| 436 | &allocated_ch_ctx, |
| 437 | FALSE, |
| 438 | if_ptr->glink_priority ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 439 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 440 | GLINK_LOG_EVENT( allocated_ch_ctx, |
| 441 | GLINK_EVENT_RM_CH_OPEN, |
Steven Cahail | ba780a8 | 2015-08-19 17:57:09 -0600 | [diff] [blame] | 442 | name, |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 443 | if_ptr->glink_core_priv->xport, |
| 444 | if_ptr->glink_core_priv->remote_ss, |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 445 | status ); |
| 446 | |
| 447 | ASSERT(GLINK_STATUS_SUCCESS == status); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | /*=========================================================================== |
| 451 | FUNCTION glink_rx_cmd_ch_open_ack |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 452 | ===========================================================================*/ |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 453 | /** |
| 454 | * This function is invoked by the transport |
| 455 | * in response to glink_transport_if:: tx_cmd_ch_open |
| 456 | * |
| 457 | * @param[in] if_ptr Pointer to interface instance; must be unique |
| 458 | * for each edge |
| 459 | * @param[in] lcid Local Channel ID |
| 460 | * @param[in] migrated_ch_prio Negotiated xport priority from remote side |
| 461 | * |
| 462 | * @return None |
| 463 | * |
| 464 | * @sideeffects NONE |
| 465 | */ |
| 466 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 467 | void glink_rx_cmd_ch_open_ack |
| 468 | ( |
| 469 | glink_transport_if_type *if_ptr, |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 470 | uint32 lcid, |
| 471 | glink_xport_priority migrated_ch_prio |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 472 | ) |
| 473 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 474 | glink_channel_ctx_type *open_ch_ctx; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 475 | glink_core_xport_ctx_type *xport_ctx; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 476 | glink_remote_state_type remote_state; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 477 | |
Steven Cahail | a136c10 | 2015-08-21 13:29:10 -0600 | [diff] [blame] | 478 | GLINK_OS_UNREFERENCED_PARAM( migrated_ch_prio ); |
| 479 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 480 | xport_ctx = if_ptr->glink_core_priv; |
| 481 | |
| 482 | /* Move to closed state. Implies we clean up the channel from the |
| 483 | * open list */ |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 484 | glink_os_cs_acquire(&xport_ctx->channel_q_cs); |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 485 | |
| 486 | open_ch_ctx = glinki_find_ch_ctx_by_lcid(xport_ctx, lcid); |
| 487 | |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 488 | if( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSING ) |
| 489 | { |
| 490 | /* Client called glink_close before gettng open ack. |
| 491 | * Ignore open ack and go for closing sequence */ |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 492 | glink_os_cs_release( &xport_ctx->channel_q_cs ); |
| 493 | return; |
| 494 | } |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 495 | |
Steven Cahail | 40d2f51 | 2015-08-24 18:02:08 -0600 | [diff] [blame] | 496 | ASSERT(open_ch_ctx->local_state == GLINK_LOCAL_CH_OPENING); |
| 497 | |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 498 | open_ch_ctx->local_state = GLINK_LOCAL_CH_OPENED; |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 499 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 500 | remote_state = open_ch_ctx->remote_state; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 501 | glink_os_cs_release(&xport_ctx->channel_q_cs); |
| 502 | |
| 503 | if (remote_state == GLINK_REMOTE_CH_OPENED) |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 504 | { |
| 505 | /* remote channel is open on same xport as current xport. |
| 506 | * change channel state to GLINK_CH_STATE_OPEN and notify client */ |
Steven Cahail | 89c6dc8 | 2015-08-20 14:36:56 -0600 | [diff] [blame] | 507 | open_ch_ctx->notify_state( open_ch_ctx, |
| 508 | open_ch_ctx->priv, |
| 509 | GLINK_CONNECTED ); |
| 510 | } |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 511 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 512 | GLINK_LOG_EVENT( open_ch_ctx, |
| 513 | GLINK_EVENT_CH_OPEN_ACK, |
| 514 | open_ch_ctx->name, |
| 515 | xport_ctx->xport, |
| 516 | xport_ctx->remote_ss, |
| 517 | lcid ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | /*=========================================================================== |
| 521 | FUNCTION glink_rx_cmd_ch_close_ack |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 522 | ===========================================================================*/ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 523 | /** |
| 524 | * This function is invoked by the transport in response to |
| 525 | * glink_transport_if_type:: tx_cmd_ch_close |
| 526 | * |
| 527 | * @param[in] if_ptr Pointer to interface instance; must be unique |
| 528 | * for each edge |
| 529 | * @param[in] lcid Local Channel ID |
| 530 | * |
| 531 | * @return None |
| 532 | * |
| 533 | * @sideeffects NONE |
| 534 | */ |
| 535 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 536 | void glink_rx_cmd_ch_close_ack |
| 537 | ( |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 538 | glink_transport_if_type *if_ptr, |
| 539 | uint32 lcid |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 540 | ) |
| 541 | { |
| 542 | glink_channel_ctx_type *open_ch_ctx; |
| 543 | glink_core_xport_ctx_type *xport_ctx; |
| 544 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 545 | xport_ctx = if_ptr->glink_core_priv; |
| 546 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 547 | glink_os_cs_acquire(&xport_ctx->channel_q_cs); |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 548 | |
| 549 | open_ch_ctx = glinki_find_ch_ctx_by_lcid(xport_ctx, lcid); |
| 550 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 551 | GLINK_LOG_EVENT( open_ch_ctx, |
| 552 | GLINK_EVENT_CH_CLOSE_ACK, |
| 553 | open_ch_ctx->name, |
| 554 | xport_ctx->xport, |
| 555 | xport_ctx->remote_ss, |
| 556 | lcid); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 557 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 558 | ASSERT( open_ch_ctx->local_state == GLINK_LOCAL_CH_CLOSING ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 559 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 560 | open_ch_ctx->local_state = GLINK_LOCAL_CH_CLOSED; |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 561 | open_ch_ctx->lcid = GLINK_INVALID_CID; |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 562 | |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 563 | if ( glink_is_remote_ch_closed( open_ch_ctx->remote_state ) ) |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 564 | { |
| 565 | glink_clean_channel_ctx( xport_ctx, open_ch_ctx ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | glink_os_cs_release(&xport_ctx->channel_q_cs); |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 569 | |
| 570 | open_ch_ctx->notify_state( open_ch_ctx, |
| 571 | open_ch_ctx->priv, |
| 572 | GLINK_LOCAL_DISCONNECTED ); |
| 573 | |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 574 | if ( glink_is_remote_ch_closed( open_ch_ctx->remote_state ) ) |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 575 | { |
| 576 | glink_os_free( open_ch_ctx ); |
| 577 | } |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | /*=========================================================================== |
| 581 | FUNCTION glink_rx_cmd_ch_remote_close |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 582 | ===========================================================================*/ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 583 | /** |
| 584 | * Remote channel close request; will result in sending |
| 585 | * glink_transport_if_type:: tx_cmd_ch_remote_close_ack |
| 586 | * |
| 587 | * @param[in] if_ptr Pointer to interface instance; must be unique |
| 588 | * for each edge |
| 589 | * @param[in] rcid Remote Channel ID |
| 590 | * |
| 591 | * @return None. |
| 592 | * |
| 593 | * @sideeffects None. |
| 594 | */ |
| 595 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 596 | void glink_rx_cmd_ch_remote_close |
| 597 | ( |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 598 | glink_transport_if_type *if_ptr, |
| 599 | uint32 rcid |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 600 | ) |
| 601 | { |
| 602 | glink_channel_ctx_type *open_ch_ctx; |
| 603 | glink_core_xport_ctx_type *xport_ctx; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 604 | glink_remote_state_type remote_state; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 605 | |
| 606 | xport_ctx = if_ptr->glink_core_priv; |
| 607 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 608 | glink_os_cs_acquire( &xport_ctx->channel_q_cs ); |
| 609 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 610 | open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid); |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 611 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 612 | GLINK_LOG_EVENT( open_ch_ctx, |
| 613 | GLINK_EVENT_CH_REMOTE_CLOSE, |
| 614 | open_ch_ctx->name, |
| 615 | xport_ctx->xport, |
| 616 | xport_ctx->remote_ss, |
| 617 | rcid ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 618 | |
Steven Cahail | 19f044e | 2015-08-24 17:36:25 -0600 | [diff] [blame] | 619 | /* It is possible that the remote subsystem sending close might crash |
| 620 | before we handle the close request from it */ |
| 621 | if (open_ch_ctx->remote_state == GLINK_REMOTE_CH_SSR_RESET) |
| 622 | { |
| 623 | glink_os_cs_release(&xport_ctx->channel_q_cs); |
| 624 | return; |
| 625 | } |
| 626 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 627 | ASSERT( open_ch_ctx->remote_state == GLINK_REMOTE_CH_OPENED ); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 628 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 629 | open_ch_ctx->remote_state = GLINK_REMOTE_CH_CLOSED; |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 630 | open_ch_ctx->rcid = GLINK_INVALID_CID; |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 631 | |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 632 | if ( glink_is_local_ch_closed( open_ch_ctx->local_state ) ) |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 633 | { |
| 634 | /* Local side never opened the channel OR it opened it but closed it */ |
| 635 | /* Free channel resources */ |
| 636 | glink_clean_channel_ctx( xport_ctx, open_ch_ctx ); |
| 637 | } |
| 638 | |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 639 | remote_state = open_ch_ctx->remote_state; |
| 640 | |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 641 | glink_os_cs_release(&xport_ctx->channel_q_cs); |
| 642 | |
| 643 | /* Send the remote close ACK back to the other side */ |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 644 | if_ptr->tx_cmd_ch_remote_close_ack(if_ptr, rcid); |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 645 | |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 646 | if ( glink_is_local_ch_closed( open_ch_ctx->local_state ) ) |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 647 | { |
Steven Cahail | 338e2f2 | 2015-08-24 15:11:53 -0600 | [diff] [blame] | 648 | /* Destroy channel context only if there isn't any pending intents */ |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 649 | if (remote_state != GLINK_REMOTE_CH_CLEANUP) |
| 650 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 651 | glink_os_free(open_ch_ctx); |
| 652 | } |
Steven Cahail | 7978335 | 2015-08-20 15:24:04 -0600 | [diff] [blame] | 653 | } |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 654 | else |
| 655 | { |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 656 | /* Inform the client */ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 657 | open_ch_ctx->notify_state(open_ch_ctx, |
| 658 | open_ch_ctx->priv, |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 659 | GLINK_REMOTE_DISCONNECTED); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 660 | } |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | /*=========================================================================== |
| 664 | FUNCTION glink_rx_put_pkt_ctx |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 665 | ===========================================================================*/ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 666 | /** |
| 667 | * Transport invokes this call to receive a packet fragment (must |
| 668 | * have previously received an rx_cmd_rx_data packet) |
| 669 | * |
| 670 | * @param[in] if_ptr Pointer to interface instance; must be unique |
| 671 | * for each edge |
| 672 | * @param[in] rcid Remote Channel ID |
| 673 | * @param[in] intent_ptr Pointer to the intent fragment |
| 674 | * @param[in] complete True if pkt is complete |
| 675 | * |
| 676 | * @return None. |
| 677 | * |
| 678 | * @sideeffects None. |
| 679 | */ |
| 680 | /*=========================================================================*/ |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 681 | void glink_rx_put_pkt_ctx |
| 682 | ( |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 683 | glink_transport_if_type *if_ptr, |
| 684 | uint32 rcid, |
| 685 | glink_rx_intent_type *intent_ptr, |
| 686 | boolean complete |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 687 | ) |
| 688 | { |
| 689 | glink_channel_ctx_type *open_ch_ctx; |
| 690 | glink_core_xport_ctx_type *xport_ctx; |
| 691 | |
Steven Cahail | a136c10 | 2015-08-21 13:29:10 -0600 | [diff] [blame] | 692 | GLINK_OS_UNREFERENCED_PARAM( complete ); |
| 693 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 694 | ASSERT(intent_ptr); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 695 | |
| 696 | xport_ctx = if_ptr->glink_core_priv; |
| 697 | |
| 698 | /* Find channel in the open_list */ |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 699 | glink_os_cs_acquire(&xport_ctx->channel_q_cs); |
| 700 | open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid); |
| 701 | glink_os_cs_release(&xport_ctx->channel_q_cs); |
| 702 | |
Steven Cahail | b850bb6 | 2015-08-21 14:39:38 -0600 | [diff] [blame] | 703 | GLINK_LOG_EVENT( open_ch_ctx, |
| 704 | GLINK_EVENT_CH_PUT_PKT_CTX, |
| 705 | open_ch_ctx->name, |
| 706 | xport_ctx->xport, |
| 707 | xport_ctx->remote_ss, |
| 708 | intent_ptr->iid); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 709 | |
| 710 | xport_ctx->channel_receive_pkt(open_ch_ctx, intent_ptr); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | /*=========================================================================== |
| 714 | FUNCTION glink_rx_cmd_remote_sigs |
| 715 | |
| 716 | DESCRIPTION Transport invokes this call to inform GLink of remote side |
| 717 | changing its control signals |
| 718 | |
| 719 | ARGUMENTS *if_ptr Pointer to interface instance; must be unique |
| 720 | for each edge |
| 721 | |
| 722 | rcid Remote Channel ID |
| 723 | |
| 724 | remote_sigs Remote signal state. |
| 725 | |
| 726 | RETURN VALUE None. |
| 727 | |
| 728 | SIDE EFFECTS None |
| 729 | ===========================================================================*/ |
| 730 | void glink_rx_cmd_remote_sigs |
| 731 | ( |
| 732 | glink_transport_if_type *if_ptr, /* Pointer to the interface instance */ |
| 733 | uint32 rcid, /* Remote channel ID */ |
| 734 | uint32 remote_sigs /* Remote control signals */ |
| 735 | ) |
| 736 | { |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 737 | glink_core_xport_ctx_type *xport_ctx; |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 738 | glink_channel_ctx_type *open_ch_ctx; |
| 739 | uint32 prev_sigs; |
| 740 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 741 | xport_ctx = if_ptr->glink_core_priv; |
Steven Cahail | ba780a8 | 2015-08-19 17:57:09 -0600 | [diff] [blame] | 742 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 743 | glink_os_cs_acquire(&xport_ctx->channel_q_cs); |
| 744 | open_ch_ctx = glinki_find_ch_ctx_by_rcid(xport_ctx, rcid); |
| 745 | glink_os_cs_release( &xport_ctx->channel_q_cs ); |
Steven Cahail | ba780a8 | 2015-08-19 17:57:09 -0600 | [diff] [blame] | 746 | |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 747 | if (!glinki_channel_fully_opened(open_ch_ctx)) |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 748 | { |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 749 | ASSERT(0); |
Sridhar Parasuram | 3b05812 | 2015-05-11 16:15:03 -0700 | [diff] [blame] | 750 | } |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 751 | |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 752 | /* Found channel, let client know of new remote signal state */ |
| 753 | prev_sigs = open_ch_ctx->remote_sigs; |
| 754 | open_ch_ctx->remote_sigs = remote_sigs; |
Steven Cahail | 964ff2f | 2015-08-20 19:01:56 -0600 | [diff] [blame] | 755 | open_ch_ctx->notify_rx_sigs(open_ch_ctx, |
| 756 | open_ch_ctx->priv, |
| 757 | prev_sigs, |
| 758 | remote_sigs); |
Sridhar Parasuram | bf39132 | 2015-01-23 09:29:07 -0800 | [diff] [blame] | 759 | } |
| 760 | |