Lines Matching +full:retain +full:- +full:state +full:- +full:shutdown
1 // SPDX-License-Identifier: GPL-2.0
14 struct efc_node *node = rnode->node; in efc_remote_node_cb()
17 spin_lock_irqsave(&efc->lock, flags); in efc_remote_node_cb()
19 spin_unlock_irqrestore(&efc->lock, flags); in efc_remote_node_cb()
28 return xa_load(&nport->lookup, port_id); in efc_node_find()
35 struct efc *efc = node->efc; in _efc_node_free()
38 dma = &node->sparm_dma_buf; in _efc_node_free()
39 dma_pool_free(efc->node_dma_pool, dma->virt, dma->phys); in _efc_node_free()
41 mempool_free(node, efc->node_pool); in _efc_node_free()
49 struct efc *efc = nport->efc; in efc_node_alloc()
52 if (nport->shutting_down) { in efc_node_alloc()
58 node = mempool_alloc(efc->node_pool, GFP_ATOMIC); in efc_node_alloc()
65 dma = &node->sparm_dma_buf; in efc_node_alloc()
66 dma->size = NODE_SPARAMS_SIZE; in efc_node_alloc()
67 dma->virt = dma_pool_zalloc(efc->node_dma_pool, GFP_ATOMIC, &dma->phys); in efc_node_alloc()
68 if (!dma->virt) { in efc_node_alloc()
72 node->rnode.indicator = U32_MAX; in efc_node_alloc()
73 node->nport = nport; in efc_node_alloc()
75 node->efc = efc; in efc_node_alloc()
76 node->init = init; in efc_node_alloc()
77 node->targ = targ; in efc_node_alloc()
79 spin_lock_init(&node->pend_frames_lock); in efc_node_alloc()
80 INIT_LIST_HEAD(&node->pend_frames); in efc_node_alloc()
81 spin_lock_init(&node->els_ios_lock); in efc_node_alloc()
82 INIT_LIST_HEAD(&node->els_ios_list); in efc_node_alloc()
83 node->els_io_enabled = true; in efc_node_alloc()
85 rc = efc_cmd_node_alloc(efc, &node->rnode, port_id, nport); in efc_node_alloc()
91 node->rnode.node = node; in efc_node_alloc()
92 node->sm.app = node; in efc_node_alloc()
93 node->evtdepth = 0; in efc_node_alloc()
97 rc = xa_err(xa_store(&nport->lookup, port_id, node, GFP_ATOMIC)); in efc_node_alloc()
104 kref_init(&node->ref); in efc_node_alloc()
105 node->release = _efc_node_free; in efc_node_alloc()
106 kref_get(&nport->ref); in efc_node_alloc()
111 efc_node_free_resources(efc, &node->rnode); in efc_node_alloc()
113 dma_pool_free(efc->node_dma_pool, dma->virt, dma->phys); in efc_node_alloc()
115 mempool_free(node, efc->node_pool); in efc_node_alloc()
127 nport = node->nport; in efc_node_free()
128 efc = node->efc; in efc_node_free()
132 if (node->refound) { in efc_node_free()
137 ns = efc_node_find(node->nport, FC_FID_DIR_SERV); in efc_node_free()
140 if (!node->nport) { in efc_node_free()
146 rc = efc_node_free_resources(efc, &node->rnode); in efc_node_free()
151 if (timer_pending(&node->gidpt_delay_timer)) in efc_node_free()
152 del_timer(&node->gidpt_delay_timer); in efc_node_free()
154 xa_erase(&nport->lookup, node->rnode.fc_id); in efc_node_free()
162 if (xa_empty(&nport->lookup)) in efc_node_free()
163 efc_sm_post_event(&nport->sm, EFC_EVT_ALL_CHILD_NODES_FREE, in efc_node_free()
166 node->nport = NULL; in efc_node_free()
167 node->sm.current_state = NULL; in efc_node_free()
169 kref_put(&nport->ref, nport->release); in efc_node_free()
170 kref_put(&node->ref, node->release); in efc_node_free()
184 if (buffer_length > dma->size) in efc_dma_copy_in()
185 buffer_length = dma->size; in efc_dma_copy_in()
187 memcpy(dma->virt, buffer, buffer_length); in efc_dma_copy_in()
188 dma->len = buffer_length; in efc_dma_copy_in()
195 struct efc_nport *nport = node->nport; in efc_node_attach()
196 struct efc_domain *domain = nport->domain; in efc_node_attach()
197 struct efc *efc = node->efc; in efc_node_attach()
199 if (!domain->attached) { in efc_node_attach()
201 return -EIO; in efc_node_attach()
203 /* Update node->wwpn/wwnn */ in efc_node_attach()
205 efc_node_build_eui_name(node->wwpn, sizeof(node->wwpn), in efc_node_attach()
207 efc_node_build_eui_name(node->wwnn, sizeof(node->wwnn), in efc_node_attach()
210 efc_dma_copy_in(&node->sparm_dma_buf, node->service_params + 4, in efc_node_attach()
211 sizeof(node->service_params) - 4); in efc_node_attach()
213 /* take lock to protect node->rnode.attached */ in efc_node_attach()
214 rc = efc_cmd_node_attach(efc, &node->rnode, &node->sparm_dma_buf); in efc_node_attach()
248 u32 port_id = node->rnode.fc_id; in efc_node_update_display_name()
249 struct efc_nport *nport = node->nport; in efc_node_update_display_name()
254 snprintf(node->display_name, sizeof(node->display_name), "%s.%s", in efc_node_update_display_name()
255 nport->display_name, portid_display); in efc_node_update_display_name()
261 if (node->send_ls_acc != EFC_NODE_SEND_LS_ACC_NONE) { in efc_node_send_ls_io_cleanup()
262 efc_log_debug(node->efc, "[%s] cleaning up LS_ACC oxid=0x%x\n", in efc_node_send_ls_io_cleanup()
263 node->display_name, node->ls_acc_oxid); in efc_node_send_ls_io_cleanup()
265 node->send_ls_acc = EFC_NODE_SEND_LS_ACC_NONE; in efc_node_send_ls_io_cleanup()
266 node->ls_acc_io = NULL; in efc_node_send_ls_io_cleanup()
279 WARN_ON(node->send_ls_acc != EFC_NODE_SEND_LS_ACC_PLOGI); in efc_node_handle_implicit_logo()
280 node_printf(node, "Reason: implicit logout, re-authenticate\n"); in efc_node_handle_implicit_logo()
282 /* Re-attach node with the same HW node resources */ in efc_node_handle_implicit_logo()
283 node->req_free = false; in efc_node_handle_implicit_logo()
286 node->els_io_enabled = true; in efc_node_handle_implicit_logo()
300 spin_lock_irqsave(&node->pend_frames_lock, flags); in efc_node_handle_explicit_logo()
301 pend_frames_empty = list_empty(&node->pend_frames); in efc_node_handle_explicit_logo()
302 spin_unlock_irqrestore(&node->pend_frames_lock, flags); in efc_node_handle_explicit_logo()
310 * a target and we need to re-authenticate in efc_node_handle_explicit_logo()
312 node_printf(node, "Shutdown: explicit logo pend=%d ", !pend_frames_empty); in efc_node_handle_explicit_logo()
314 node->nport->enable_ini, node->targ); in efc_node_handle_explicit_logo()
315 if (!pend_frames_empty || (node->nport->enable_ini && node->targ)) { in efc_node_handle_explicit_logo()
318 if (node->nport->enable_ini && node->targ) { in efc_node_handle_explicit_logo()
322 * we'll need to re-authenticate in in efc_node_handle_explicit_logo()
323 * initial state in efc_node_handle_explicit_logo()
330 * (will retain HW node resources) in efc_node_handle_explicit_logo()
332 node->els_io_enabled = true; in efc_node_handle_explicit_logo()
333 node->req_free = false; in efc_node_handle_explicit_logo()
336 * either pending frames exist or we are re-authenticating in efc_node_handle_explicit_logo()
338 * state in efc_node_handle_explicit_logo()
342 /* else: let node shutdown occur */ in efc_node_handle_explicit_logo()
348 struct efc *efc = node->efc; in efc_node_purge_pending()
352 spin_lock_irqsave(&node->pend_frames_lock, flags); in efc_node_purge_pending()
354 list_for_each_entry_safe(frame, next, &node->pend_frames, list_entry) { in efc_node_purge_pending()
355 list_del(&frame->list_entry); in efc_node_purge_pending()
356 efc->tt.hw_seq_free(efc, frame); in efc_node_purge_pending()
359 spin_unlock_irqrestore(&node->pend_frames_lock, flags); in efc_node_purge_pending()
366 struct efc_node *node = ctx->app; in __efc_node_shutdown()
375 WARN_ON(!efc_els_io_list_empty(node, &node->els_ios_list)); in __efc_node_shutdown()
377 node->req_free = true; in __efc_node_shutdown()
379 switch (node->shutdown_reason) { in __efc_node_shutdown()
381 /* Node shutdown b/c of PLOGI received when node in __efc_node_shutdown()
397 * shutdown due to link down, in __efc_node_shutdown()
399 * nport shutdown, purge pending and in __efc_node_shutdown()
407 "Shutdown reason: default, purge pending\n"); in __efc_node_shutdown()
428 if (node->els_req_cnt == 0 && node->els_cmpl_cnt == 0 && in efc_node_check_els_quiesced()
429 efc_els_io_list_empty(node, &node->els_ios_list)) { in efc_node_check_els_quiesced()
430 if (!node->attached) { in efc_node_check_els_quiesced()
454 * if ELS's have already been quiesced, will move to next state in efc_node_initiate_cleanup()
468 struct efc_node *node = ctx->app; in __efc_node_wait_els_shutdown()
473 /* Node state machine: Wait for all ELSs to complete */ in __efc_node_wait_els_shutdown()
477 if (efc_els_io_list_empty(node, &node->els_ios_list)) { in __efc_node_wait_els_shutdown()
490 if (WARN_ON(!node->els_req_cnt)) in __efc_node_wait_els_shutdown()
492 node->els_req_cnt--; in __efc_node_wait_els_shutdown()
498 if (WARN_ON(!node->els_cmpl_cnt)) in __efc_node_wait_els_shutdown()
500 node->els_cmpl_cnt--; in __efc_node_wait_els_shutdown()
507 WARN_ON(!efc_els_io_list_empty(node, &node->els_ios_list)); in __efc_node_wait_els_shutdown()
519 /* ignore shutdown events as we're already in shutdown path */ in __efc_node_wait_els_shutdown()
521 /* have default shutdown event take precedence */ in __efc_node_wait_els_shutdown()
522 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT; in __efc_node_wait_els_shutdown()
542 struct efc_node *node = ctx->app; in __efc_node_wait_node_free()
559 node->attached = false; in __efc_node_wait_node_free()
572 /* ignore shutdown events as we're already in shutdown path */ in __efc_node_wait_node_free()
574 /* have default shutdown event take precedence */ in __efc_node_wait_node_free()
575 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT; in __efc_node_wait_node_free()
591 struct efc_node *node = ctx->app; in __efc_node_wait_ios_shutdown()
592 struct efc *efc = node->efc; in __efc_node_wait_ios_shutdown()
603 if (efc_els_io_list_empty(node, &node->els_ios_list)) in __efc_node_wait_ios_shutdown()
610 if (efc_els_io_list_empty(node, &node->els_ios_list)) in __efc_node_wait_ios_shutdown()
620 if (WARN_ON(!node->els_req_cnt)) in __efc_node_wait_ios_shutdown()
622 node->els_req_cnt--; in __efc_node_wait_ios_shutdown()
625 /* ignore shutdown events as we're already in shutdown path */ in __efc_node_wait_ios_shutdown()
627 /* have default shutdown event take precedence */ in __efc_node_wait_ios_shutdown()
628 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT; in __efc_node_wait_ios_shutdown()
633 efc_log_debug(efc, "[%s] %-20s\n", node->display_name, in __efc_node_wait_ios_shutdown()
652 node = ctx->app; in __efc_node_common()
653 efc = node->efc; in __efc_node_common()
665 node->refound = true; in __efc_node_common()
669 * node->attached must be set appropriately in __efc_node_common()
673 node->attached = true; in __efc_node_common()
678 node->attached = false; in __efc_node_common()
688 if (WARN_ON(!node->els_cmpl_cnt)) in __efc_node_common()
690 node->els_cmpl_cnt--; in __efc_node_common()
702 if (WARN_ON(!node->els_req_cnt)) in __efc_node_common()
704 node->els_req_cnt--; in __efc_node_common()
708 struct fc_frame_header *hdr = cbdata->header->dma.virt; in __efc_node_common()
716 node->display_name, funcname, in __efc_node_common()
717 ((u8 *)cbdata->payload->dma.virt)[0]); in __efc_node_common()
719 efc_send_ls_rjt(node, be16_to_cpu(hdr->fh_ox_id), in __efc_node_common()
734 struct fc_frame_header *hdr = cbdata->header->dma.virt; in __efc_node_common()
738 node->display_name, funcname, in __efc_node_common()
740 /* if we didn't catch this in a state, send generic LS_RJT */ in __efc_node_common()
741 efc_send_ls_rjt(node, be16_to_cpu(hdr->fh_ox_id), in __efc_node_common()
747 node->display_name, funcname, in __efc_node_common()
751 efc_send_bls_acc(node, cbdata->header->dma.virt); in __efc_node_common()
756 efc_log_debug(node->efc, "[%s] %-20s %-20s not handled\n", in __efc_node_common()
757 node->display_name, funcname, in __efc_node_common()
765 memcpy(node->service_params, payload, sizeof(node->service_params)); in efc_node_save_sparms()
774 node->evtdepth++; in efc_node_post_event()
776 efc_sm_post_event(&node->sm, evt, arg); in efc_node_post_event()
784 if (!node->hold_frames && node->evtdepth == 1) in efc_node_post_event()
787 node->evtdepth--; in efc_node_post_event()
793 if (node->evtdepth == 0 && node->req_free) in efc_node_post_event()
802 void (*state)(struct efc_sm_ctx *, in efc_node_transition()
805 struct efc_sm_ctx *ctx = &node->sm; in efc_node_transition()
807 if (ctx->current_state == state) { in efc_node_transition()
811 ctx->current_state = state; in efc_node_transition()
828 (struct fc_els_flogi *)node->service_params; in efc_node_get_wwpn()
830 return be64_to_cpu(sp->fl_wwpn); in efc_node_get_wwpn()
837 (struct fc_els_flogi *)node->service_params; in efc_node_get_wwnn()
839 return be64_to_cpu(sp->fl_wwnn); in efc_node_get_wwnn()
866 spin_lock_irqsave(&node->els_ios_lock, flags); in efc_els_io_list_empty()
868 spin_unlock_irqrestore(&node->els_ios_lock, flags); in efc_els_io_list_empty()
874 void (*state)(struct efc_sm_ctx *, in efc_node_pause()
878 node->nodedb_state = state; in efc_node_pause()
886 struct efc_node *node = ctx->app; in __efc_node_paused()
893 * This state is entered when a state is "paused". When resumed, the in __efc_node_paused()
894 * node is transitioned to a previously saved state (node->ndoedb_state) in __efc_node_paused()
905 pf = node->nodedb_state; in __efc_node_paused()
907 node->nodedb_state = NULL; in __efc_node_paused()
916 node->req_free = true; in __efc_node_paused()
946 u8 *buf = seq->payload->dma.virt; in efc_node_recv_els_frame()
951 cbdata.header = seq->header; in efc_node_recv_els_frame()
952 cbdata.payload = seq->payload; in efc_node_recv_els_frame()
969 struct fc_ct_hdr *iu = seq->payload->dma.virt; in efc_node_recv_ct_frame()
970 struct fc_frame_header *hdr = seq->header->dma.virt; in efc_node_recv_ct_frame()
971 struct efc *efc = node->efc; in efc_node_recv_ct_frame()
972 u16 gscmd = be16_to_cpu(iu->ct_cmd); in efc_node_recv_ct_frame()
975 node->display_name, gscmd); in efc_node_recv_ct_frame()
976 efc_send_ct_rsp(efc, node, be16_to_cpu(hdr->fh_ox_id), iu, in efc_node_recv_ct_frame()
986 cbdata.header = seq->header; in efc_node_recv_fcp_cmd()
987 cbdata.payload = seq->payload; in efc_node_recv_fcp_cmd()
995 struct efc *efc = node->efc; in efc_process_node_pending()
1003 * to a state that holds frames in efc_process_node_pending()
1005 if (node->hold_frames) in efc_process_node_pending()
1010 spin_lock_irqsave(&node->pend_frames_lock, flags); in efc_process_node_pending()
1012 if (!list_empty(&node->pend_frames)) { in efc_process_node_pending()
1013 seq = list_first_entry(&node->pend_frames, in efc_process_node_pending()
1015 list_del(&seq->list_entry); in efc_process_node_pending()
1017 spin_unlock_irqrestore(&node->pend_frames_lock, flags); in efc_process_node_pending()
1020 pend_frames_processed = node->pend_frames_processed; in efc_process_node_pending()
1021 node->pend_frames_processed = 0; in efc_process_node_pending()
1024 node->pend_frames_processed++; in efc_process_node_pending()
1028 efc->tt.hw_seq_free(efc, seq); in efc_process_node_pending()
1041 struct efc *efc = node->efc; in efc_scsi_sess_reg_complete()
1046 spin_lock_irqsave(&efc->lock, flags); in efc_scsi_sess_reg_complete()
1049 spin_unlock_irqrestore(&efc->lock, flags); in efc_scsi_sess_reg_complete()
1057 spin_lock_irqsave(&efc->lock, flags); in efc_scsi_del_initiator_complete()
1060 spin_unlock_irqrestore(&efc->lock, flags); in efc_scsi_del_initiator_complete()
1068 spin_lock_irqsave(&efc->lock, flags); in efc_scsi_del_target_complete()
1071 spin_unlock_irqrestore(&efc->lock, flags); in efc_scsi_del_target_complete()
1079 spin_lock_irqsave(&efc->lock, flags); in efc_scsi_io_list_empty()
1081 spin_unlock_irqrestore(&efc->lock, flags); in efc_scsi_io_list_empty()
1086 struct efc *efc = node->efc; in efc_node_post_els_resp()
1089 spin_lock_irqsave(&efc->lock, flags); in efc_node_post_els_resp()
1091 spin_unlock_irqrestore(&efc->lock, flags); in efc_node_post_els_resp()
1097 struct efc *efc = node->efc; in efc_node_post_shutdown()
1099 spin_lock_irqsave(&efc->lock, flags); in efc_node_post_shutdown()
1101 spin_unlock_irqrestore(&efc->lock, flags); in efc_node_post_shutdown()