Lines Matching refs:path

32  * adapter descriptor heads a linked list of path descriptors.  There is
35 * embedded within a path descriptor). The tokens are used in round robin
45 * - rsmka_remove_path [a path down request is implicit]
50 * treat like path-down for all node paths;
55 * - rsmka_node_alive called after the first cluster path is up
95 * (mutex) path->mutex
96 * protects the path descriptor.
134 extern int rsmipc_send_controlmsg(path_t *path, int msgtype);
239 * In processing the remove path callbacks from the path monitor
312 path_t *path;
353 path = WORK_TOKEN_TO_PATH(work_token, work_opcode -1);
361 "do_deferred_work:up, path = %lx\n", path));
362 error = create_ipc_sendq(path);
363 mutex_enter(&path->mutex);
364 if (path->state != RSMKA_PATH_UP) {
366 * path state has changed, if sendq was created,
369 * using the sendq till path state becomes
373 sendq_handle = path->sendq_token.
375 path->sendq_token.rsmpi_sendq_handle =
377 adapter = path->local_adapter;
378 mutex_exit(&path->mutex);
385 mutex_enter(&path->mutex);
391 * decrement reference count for the path
396 PATH_RELE_NOLOCK(path);
397 mutex_exit(&path->mutex);
405 path->flags &= ~RSMKA_SQCREATE_PENDING;
406 path->state = RSMKA_PATH_ACTIVE;
409 * now that path is active we send the
412 path->procmsg_cnt = 0;
413 path->sendq_token.msgbuf_avail = 0;
419 path->local_incn = (int64_t)tv.tv_sec;
426 * the path to go down anyways, so ignore
429 (void) rsmipc_send_controlmsg(path,
432 path->flags |= RSMKA_WAIT_FOR_SQACK;
442 path->flags |= RSMKA_SQCREATE_PENDING;
449 * decrement reference count for the path
454 PATH_RELE_NOLOCK(path);
455 mutex_exit(&path->mutex);
460 "do_deferred_work:down, path = %lx\n", path));
465 * the state of the path is changed directly to
468 * calls referring this path will just queue up
469 * and will be processed only after the path
472 mutex_enter(&path->mutex);
473 path->state = RSMKA_PATH_DOWN;
475 * clear the WAIT_FOR_SQACK flag since path is down.
477 path->flags &= ~RSMKA_WAIT_FOR_SQACK;
481 * in rsmipc_send to tell it that the path is down
484 cv_broadcast(&path->sendq_token.sendq_cv);
486 mutex_exit(&path->mutex);
489 taskq_wait(path->recv_taskq);
493 * be called after releasing the mutex on the path
496 path_importer_disconnect(path);
500 * decrement reference count for the path
505 mutex_enter(&path->mutex);
512 if (path->msgbuf_cnt != 0)
514 "path=%lx msgbuf_cnt != 0\n",
515 (uintptr_t)path);
523 while (path->sendq_token.ref_cnt != 0)
524 cv_wait(&path->sendq_token.sendq_cv,
525 &path->mutex);
527 sendq_handle = path->sendq_token.rsmpi_sendq_handle;
528 path->sendq_token.rsmpi_sendq_handle = NULL;
532 adapter = path->local_adapter;
538 PATH_RELE_NOLOCK(path);
539 mutex_exit(&path->mutex);
591 * enqueue_work increments the path refcnt to make sure that the path doesn't
592 * go away, callers of cancel_work need to decrement the refcnt of the path to
859 * initialize the path descriptor
861 * initialize and link a sendq token for this path
870 path_t *path;
876 /* allocate new path descriptor */
877 path = kmem_zalloc(sizeof (path_t), KM_SLEEP);
890 * initialize path descriptor
894 mutex_init(&path->mutex, NULL, MUTEX_DEFAULT, NULL);
896 PATH_HOLD(path);
897 path->state = RSMKA_PATH_DOWN;
898 path->remote_node = remote_node;
899 path->remote_hwaddr = remote_hwaddr;
900 path->remote_devinst = rem_adapt_instance;
901 path->local_adapter = adapter;
907 path->recv_taskq = taskq_create_instance(tq_name, adapter_instance,
912 path->msgbuf_queue = (msgbuf_elem_t *)kmem_zalloc(
919 cv_init(&path->sendq_token.sendq_cv, NULL, CV_DEFAULT, NULL);
920 cv_init(&path->hold_cv, NULL, CV_DEFAULT, NULL);
922 /* link path descriptor on adapter path list */
923 link_path(path);
925 /* link the path sendq token on the ipc_info token list */
926 link_sendq_token(&path->sendq_token, remote_node);
931 DBG_PRINTF((category, RSM_DEBUG, "rsmka_add_path: path = %lx\n", path));
934 return ((void *)path);
938 * Wait for the path descriptor reference count to become zero then
939 * directly call path down processing. Finally, unlink the sendq token and
940 * free the path descriptor memory.
942 * Note: lookup_path locks the path and increments the path hold count
948 path_t *path;
953 path = (path_t *)path_cookie;
954 mutex_enter(&path->mutex);
956 path = lookup_path(adapter_name, instance, remote_node,
963 PATH_RELE_NOLOCK(path);
967 "rsmka_remove_path: path = %lx\n", path));
969 while (path->state == RSMKA_PATH_GOING_DOWN)
970 cv_wait(&path->hold_cv, &path->mutex);
974 if (cancel_work(&path->work_token[RSMKA_IPC_UP_INDEX])) {
975 PATH_RELE_NOLOCK(path);
977 if (cancel_work(&path->work_token[RSMKA_IPC_DOWN_INDEX])) {
978 PATH_RELE_NOLOCK(path);
983 * The path descriptor ref cnt was set to 1 initially when
984 * the path was added. So we need to do a decrement here to
987 PATH_RELE_NOLOCK(path);
989 switch (path->state) {
992 path->flags &= ~RSMKA_SQCREATE_PENDING;
993 path->state = RSMKA_PATH_DOWN;
1002 * this code path, the deferred work would
1005 do_path_down(path, 0);
1008 mutex_exit(&path->mutex);
1010 "rsm_remove_path: invalid path state %d\n",
1011 path->state));
1017 * wait for all references to the path to be released. If a thread
1019 * since the path is going down and that will cause the sleeping
1020 * thread to release its hold on the path.
1022 while (path->ref_cnt != 0) {
1023 cv_wait(&path->hold_cv, &path->mutex);
1026 mutex_exit(&path->mutex);
1030 * NOTE: use the remote_node value from the path structure
1034 unlink_sendq_token(&path->sendq_token, path->remote_node);
1036 /* unlink from adapter path list and free path descriptor */
1037 destroy_path(path);
1045 * lookup_path locks the path and increments the path hold count. If the remote
1051 * The path descriptor ref_cnt is incremented here; it will be decremented
1052 * when path up processing is completed in do_path_up or by the work thread
1053 * if the path up is deferred.
1062 path_t *path;
1068 path = (path_t *)path_cookie;
1069 mutex_enter(&path->mutex);
1070 PATH_HOLD_NOLOCK(path);
1072 path = lookup_path(adapter_name, adapter_instance,
1076 while (path->state == RSMKA_PATH_GOING_DOWN)
1077 cv_wait(&path->hold_cv, &path->mutex);
1079 DBG_PRINTF((category, RSM_DEBUG, "rsmka_path_up: path = %lx\n", path));
1080 rval = do_path_up(path, flags);
1081 mutex_exit(&path->mutex);
1090 * lookup_path locks the path and increments the path hold count. If the
1091 * current state is ACTIVE the path lock is release prior to waking up
1097 * The path descriptor ref_cnt is incremented here; it will be decremented
1098 * when path down processing is completed in do_path_down or by the work thread
1099 * if the path down is deferred.
1106 path_t *path;
1112 path = (path_t *)path_cookie;
1113 mutex_enter(&path->mutex);
1114 PATH_HOLD_NOLOCK(path);
1116 path = lookup_path(adapter_devname, instance, remote_node,
1120 while (path->state == RSMKA_PATH_GOING_DOWN)
1121 cv_wait(&path->hold_cv, &path->mutex);
1124 "rsmka_path_down: path = %lx\n", path));
1126 switch (path->state) {
1129 path->flags &= ~RSMKA_SQCREATE_PENDING;
1130 path->state = RSMKA_PATH_GOING_DOWN;
1131 mutex_exit(&path->mutex);
1134 * release path->mutex since enqueued tasks acquire it.
1137 taskq_wait(path->recv_taskq);
1139 mutex_enter(&path->mutex);
1140 path->state = RSMKA_PATH_DOWN;
1141 PATH_RELE_NOLOCK(path);
1144 PATH_RELE_NOLOCK(path);
1147 do_path_down(path, flags);
1149 * Need to release the path refcnt. Either done in do_path_down
1154 PATH_RELE_NOLOCK(path);
1158 "rsm_path_down: invalid path state %d\n", path->state));
1162 mutex_exit(&path->mutex);
1252 * NOTE: This routine is not called from the cluster path interface; the
1253 * rsmka_path_down is called directly for each path.
1259 path_t *path;
1278 path = SQ_TOKEN_TO_PATH(sendq_token);
1279 PATH_HOLD(path);
1280 up_token = &path->work_token[RSMKA_IPC_UP_INDEX];
1281 down_token = &path->work_token[RSMKA_IPC_DOWN_INDEX];
1289 * If the path is active and down work hasn't
1295 if (path->state == RSMKA_PATH_ACTIVE) {
1309 PATH_RELE(path);
1312 PATH_RELE(path);
1334 path = SQ_TOKEN_TO_PATH(sendq_token);
1337 "for path = %x\n",
1338 path));
1340 path, RSMKA_USE_COOKIE);
1354 * Called from rsm_node_alive - if a path to a remote node is in
1359 * The path descriptor ref_cnt is incremented here; it will be decremented
1360 * when path up processing is completed in rsmka_do_path_active or by the work
1361 * thread if the path up is deferred.
1366 path_t *path;
1378 path = SQ_TOKEN_TO_PATH(token);
1379 mutex_enter(&path->mutex);
1380 if (path->state == RSMKA_PATH_UP) {
1381 PATH_HOLD_NOLOCK(path);
1382 (void) rsmka_do_path_active(path, 0);
1384 mutex_exit(&path->mutex);
1401 rsmka_do_path_active(path_t *path, int flags)
1403 work_token_t *up_token = &path->work_token[RSMKA_IPC_UP_INDEX];
1404 work_token_t *down_token = &path->work_token[RSMKA_IPC_DOWN_INDEX];
1414 ASSERT(MUTEX_HELD(&path->mutex));
1421 PATH_RELE_NOLOCK(path);
1425 * If the path is not active and up work hasn't
1431 if (path->state != RSMKA_PATH_ACTIVE) {
1443 PATH_RELE_NOLOCK(path);
1451 * Drop the path lock before calling create_ipc_sendq, shouldn't
1454 mutex_exit(&path->mutex);
1456 error = create_ipc_sendq(path);
1458 mutex_enter(&path->mutex);
1459 if (path->state != RSMKA_PATH_UP) {
1461 * path state has changed, if sendq was created,
1465 sqhdl = path->sendq_token.rsmpi_sendq_handle;
1466 path->sendq_token.rsmpi_sendq_handle = NULL;
1467 adapter = path->local_adapter;
1468 mutex_exit(&path->mutex);
1474 mutex_enter(&path->mutex);
1476 PATH_RELE_NOLOCK(path);
1479 "rsmka_do_path_active done: path=%lx not UP\n",
1480 (uintptr_t)path));
1486 path->flags &= ~RSMKA_SQCREATE_PENDING;
1487 path->state = RSMKA_PATH_ACTIVE;
1489 * now that path is active we send the
1492 path->procmsg_cnt = 0;
1493 path->sendq_token.msgbuf_avail = 0;
1499 path->local_incn = (int64_t)tv.tv_sec;
1505 * will cause the path to go down anyways so ignore
1508 (void) rsmipc_send_controlmsg(path, RSMIPC_MSG_SQREADY);
1510 path->flags |= RSMKA_WAIT_FOR_SQACK;
1523 path->flags |= RSMKA_SQCREATE_PENDING;
1526 PATH_RELE_NOLOCK(path);
1538 * otherwise just transition path state to RSMKA_PATH_UP.
1541 do_path_up(path_t *path, int flags)
1548 ASSERT(MUTEX_HELD(&path->mutex));
1550 /* path moved to ACTIVE by rsm_sqcreateop_callback - just return */
1551 if (path->state == RSMKA_PATH_ACTIVE) {
1554 PATH_RELE_NOLOCK(path);
1558 path->state = RSMKA_PATH_UP;
1561 path->msgbuf_head = 0;
1562 path->msgbuf_tail = RSMIPC_MAX_MESSAGES - 1;
1563 path->msgbuf_cnt = 0;
1564 path->procmsg_cnt = 0;
1567 * correct lock ordering drop the path lock before calling it.
1569 mutex_exit(&path->mutex);
1571 node_alive = rsmka_check_node_alive(path->remote_node);
1573 mutex_enter(&path->mutex);
1575 rval = rsmka_do_path_active(path, flags);
1577 PATH_RELE_NOLOCK(path);
1589 * Destroy the send queue on this path.
1595 do_path_down(path_t *path, int flags)
1597 work_token_t *up_token = &path->work_token[RSMKA_IPC_UP_INDEX];
1598 work_token_t *down_token = &path->work_token[RSMKA_IPC_DOWN_INDEX];
1603 ASSERT(MUTEX_HELD(&path->mutex));
1612 PATH_RELE_NOLOCK(path);
1616 * If the path is active and down work hasn't
1622 if (path->state == RSMKA_PATH_ACTIVE) {
1633 PATH_RELE_NOLOCK(path);
1641 * Change state of the path to RSMKA_PATH_GOING_DOWN and
1642 * release the path mutex. Any other thread referring
1643 * this path would cv_wait till the state of the path
1645 * On completing the path down processing, change the
1646 * state of RSMKA_PATH_DOWN indicating that the path
1649 path->state = RSMKA_PATH_GOING_DOWN;
1652 * clear the WAIT_FOR_SQACK flag since path is going down.
1654 path->flags &= ~RSMKA_WAIT_FOR_SQACK;
1658 * in rsmipc_send to tell it that the path is going down
1660 cv_broadcast(&path->sendq_token.sendq_cv);
1662 mutex_exit(&path->mutex);
1666 * tasks in the taskq_thread acquire the path->mutex
1667 * so we drop the path mutex before taskq_wait.
1669 taskq_wait(path->recv_taskq);
1674 * only after releasing the mutex on the path. This is to
1678 path_importer_disconnect(path);
1681 * Get the path mutex, change the state of the path to
1682 * RSMKA_PATH_DOWN since the path down processing has
1686 * routine with the path lock held by the caller. The
1687 * caller eventually releases the path lock by doing a
1690 mutex_enter(&path->mutex);
1697 if (path->msgbuf_cnt != 0)
1698 cmn_err(CE_NOTE, "path=%lx msgbuf_cnt != 0\n",
1699 (uintptr_t)path);
1701 while (path->sendq_token.ref_cnt != 0)
1702 cv_wait(&path->sendq_token.sendq_cv,
1703 &path->mutex);
1706 if (path->sendq_token.rsmpi_sendq_handle != NULL)
1707 path->local_adapter->rsmpi_ops->rsm_sendq_destroy(
1708 path->sendq_token.rsmpi_sendq_handle);
1710 path->sendq_token.rsmpi_sendq_handle = NULL;
1712 path->state = RSMKA_PATH_DOWN;
1714 cv_signal(&path->hold_cv);
1723 * Search through the list of imported segments for segments using this path
1727 * the path. This is to avoid any recursive mutex panics on the path mutex
1729 * rsmka_get_sendq_token which requires the path mutex.
1733 path_importer_disconnect(path_t *path)
1736 adapter_t *adapter = path->local_adapter;
1737 rsm_node_id_t remote_node = path->remote_node;
2014 * Search the per adapter path list for a match on remote node and
2015 * hwaddr. The path ref_cnt must be greater than zero or the path
2018 * Acquire the path lock and increment the path hold count.
2061 * path. This is used in the interrupt handler routines where nodeid
2113 * Add the path to the head of the (per adapter) list of paths
2116 link_path(path_t *path)
2119 adapter_t *adapter = path->local_adapter;
2129 adapter->next_path = path;
2130 path->next_path = first_path;
2142 * Search the per-adapter list of paths for the specified path, beginning
2143 * at the head of the list. Unlink the path and free the descriptor
2147 destroy_path(path_t *path)
2150 adapter_t *adapter = path->local_adapter;
2157 mutex_enter(&path->local_adapter->listhead->mutex);
2158 ASSERT(path->ref_cnt == 0);
2165 if (path->remote_node == current->remote_node &&
2166 path->remote_hwaddr == current->remote_hwaddr)
2179 path->local_adapter->listhead->path_count--;
2181 mutex_exit(&path->local_adapter->listhead->mutex);
2185 taskq_destroy(path->recv_taskq);
2187 kmem_free(path->msgbuf_queue,
2192 cv_destroy(&path->hold_cv);
2199 rsmka_enqueue_msgbuf(path_t *path, void *data)
2204 ASSERT(MUTEX_HELD(&path->mutex));
2206 ASSERT(path->msgbuf_cnt < RSMIPC_MAX_MESSAGES);
2210 path->msgbuf_cnt++;
2212 if (path->msgbuf_tail == RSMIPC_MAX_MESSAGES - 1) {
2213 path->msgbuf_tail = 0;
2215 path->msgbuf_tail++;
2218 path->msgbuf_queue[path->msgbuf_tail].active = B_TRUE;
2220 bcopy(data, &(path->msgbuf_queue[path->msgbuf_tail].msg),
2233 rsmka_dequeue_msgbuf(path_t *path)
2238 ASSERT(MUTEX_HELD(&path->mutex));
2240 if (path->msgbuf_cnt == 0)
2243 path->msgbuf_cnt--;
2245 path->msgbuf_queue[path->msgbuf_head].active = B_FALSE;
2247 if (path->msgbuf_head == RSMIPC_MAX_MESSAGES - 1) {
2248 path->msgbuf_head = 0;
2250 path->msgbuf_head++;
2259 rsmka_gethead_msgbuf(path_t *path)
2263 ASSERT(MUTEX_HELD(&path->mutex));
2265 if (path->msgbuf_cnt == 0)
2268 head = &path->msgbuf_queue[path->msgbuf_head];
2488 path_t *path = SQ_TOKEN_TO_PATH(token);
2493 ASSERT(path->ref_cnt == 0);
2540 path_t *path;
2544 path = SQ_TOKEN_TO_PATH(token);
2545 mutex_enter(&path->mutex);
2546 PATH_RELE_NOLOCK(path);
2547 SENDQ_TOKEN_RELE(path);
2548 mutex_exit(&path->mutex);
2572 path_t *path;
2595 path = SQ_TOKEN_TO_PATH(token);
2597 "path %lx\n", path));
2598 mutex_enter(&path->mutex);
2599 if (path->state != RSMKA_PATH_ACTIVE ||
2600 path->ref_cnt == 0) {
2601 mutex_exit(&path->mutex);
2607 mutex_exit(&path->mutex);
2614 * if the corresponding path is still up
2617 path = SQ_TOKEN_TO_PATH(prev_used);
2619 "path %lx\n", path));
2620 mutex_enter(&path->mutex);
2621 if (path->state != RSMKA_PATH_ACTIVE ||
2622 path->ref_cnt == 0) {
2623 mutex_exit(&path->mutex);
2636 PATH_HOLD_NOLOCK(path);
2637 SENDQ_TOKEN_HOLD(path);
2643 mutex_exit(&path->mutex);
2662 create_ipc_sendq(path_t *path)
2671 DBG_PRINTF((category, RSM_DEBUG, "create_ipc_sendq: path = %lx\n",
2672 path));
2674 adapter = path->local_adapter;
2675 token = &path->sendq_token;
2677 srvc_offset = path->remote_hwaddr;
2684 path->remote_hwaddr,
2753 * individual adapter and path counts from all the listheads
2800 path_t *path;
2842 /* fill topology from the adapter and path data */
2873 path = adapter->next_path;
2874 while (path != NULL) {
2876 rem_cntlr->remote_nodeid = path->remote_node;
2880 path->remote_devinst);
2881 rem_cntlr->remote_hwaddr = path->remote_hwaddr;
2882 rem_cntlr->connection_state = path->state;
2884 path = path->next_path;