Lines Matching refs:node

14 	struct efc_node *node = rnode->node;
18 efc_node_post_event(node, event, NULL);
27 /* Find an FC node structure given the FC port ID */
34 struct efc_node *node = container_of(arg, struct efc_node, ref);
35 struct efc *efc = node->efc;
38 dma = &node->sparm_dma_buf;
41 mempool_free(node, efc->node_pool);
48 struct efc_node *node = NULL;
53 efc_log_debug(efc, "node allocation when shutting down %06x",
58 node = mempool_alloc(efc->node_pool, GFP_ATOMIC);
59 if (!node) {
60 efc_log_err(efc, "node allocation failed %06x", port_id);
63 memset(node, 0, sizeof(*node));
65 dma = &node->sparm_dma_buf;
69 efc_log_err(efc, "node dma alloc failed\n");
72 node->rnode.indicator = U32_MAX;
73 node->nport = nport;
75 node->efc = efc;
76 node->init = init;
77 node->targ = targ;
79 spin_lock_init(&node->pend_frames_lock);
80 INIT_LIST_HEAD(&node->pend_frames);
81 spin_lock_init(&node->els_ios_lock);
82 INIT_LIST_HEAD(&node->els_ios_list);
83 node->els_io_enabled = true;
85 rc = efc_cmd_node_alloc(efc, &node->rnode, port_id, nport);
91 node->rnode.node = node;
92 node->sm.app = node;
93 node->evtdepth = 0;
95 efc_node_update_display_name(node);
97 rc = xa_err(xa_store(&nport->lookup, port_id, node, GFP_ATOMIC));
104 kref_init(&node->ref);
105 node->release = _efc_node_free;
108 return node;
111 efc_node_free_resources(efc, &node->rnode);
115 mempool_free(node, efc->node_pool);
120 efc_node_free(struct efc_node *node)
127 nport = node->nport;
128 efc = node->efc;
130 node_printf(node, "Free'd\n");
132 if (node->refound) {
134 * Save the name server node. We will send fake RSCN event at
135 * the end to handle ignored RSCN event during node deletion
137 ns = efc_node_find(node->nport, FC_FID_DIR_SERV);
140 if (!node->nport) {
146 rc = efc_node_free_resources(efc, &node->rnode);
151 if (timer_pending(&node->gidpt_delay_timer))
152 del_timer(&node->gidpt_delay_timer);
154 xa_erase(&nport->lookup, node->rnode.fc_id);
166 node->nport = NULL;
167 node->sm.current_state = NULL;
170 kref_put(&node->ref, node->release);
173 /* sending fake RSCN event to name server node */
192 efc_node_attach(struct efc_node *node)
195 struct efc_nport *nport = node->nport;
197 struct efc *efc = node->efc;
203 /* Update node->wwpn/wwnn */
205 efc_node_build_eui_name(node->wwpn, sizeof(node->wwpn),
206 efc_node_get_wwpn(node));
207 efc_node_build_eui_name(node->wwnn, sizeof(node->wwnn),
208 efc_node_get_wwnn(node));
210 efc_dma_copy_in(&node->sparm_dma_buf, node->service_params + 4,
211 sizeof(node->service_params) - 4);
213 /* take lock to protect node->rnode.attached */
214 rc = efc_cmd_node_attach(efc, &node->rnode, &node->sparm_dma_buf);
246 efc_node_update_display_name(struct efc_node *node)
248 u32 port_id = node->rnode.fc_id;
249 struct efc_nport *nport = node->nport;
254 snprintf(node->display_name, sizeof(node->display_name), "%s.%s",
259 efc_node_send_ls_io_cleanup(struct efc_node *node)
261 if (node->send_ls_acc != EFC_NODE_SEND_LS_ACC_NONE) {
262 efc_log_debug(node->efc, "[%s] cleaning up LS_ACC oxid=0x%x\n",
263 node->display_name, node->ls_acc_oxid);
265 node->send_ls_acc = EFC_NODE_SEND_LS_ACC_NONE;
266 node->ls_acc_io = NULL;
270 static void efc_node_handle_implicit_logo(struct efc_node *node)
276 * recvd. Thus, node's ELS IO pending list won't be
279 WARN_ON(node->send_ls_acc != EFC_NODE_SEND_LS_ACC_PLOGI);
280 node_printf(node, "Reason: implicit logout, re-authenticate\n");
282 /* Re-attach node with the same HW node resources */
283 node->req_free = false;
284 rc = efc_node_attach(node);
285 efc_node_transition(node, __efc_d_wait_node_attach, NULL);
286 node->els_io_enabled = true;
289 efc_node_post_event(node, EFC_EVT_NODE_ATTACH_FAIL, NULL);
292 static void efc_node_handle_explicit_logo(struct efc_node *node)
298 efc_node_send_ls_io_cleanup(node);
300 spin_lock_irqsave(&node->pend_frames_lock, flags);
301 pend_frames_empty = list_empty(&node->pend_frames);
302 spin_unlock_irqrestore(&node->pend_frames_lock, flags);
306 * this node alive:
309 * 2. we're an initiator and the remote node is
312 node_printf(node, "Shutdown: explicit logo pend=%d ", !pend_frames_empty);
313 node_printf(node, "nport.ini=%d node.tgt=%d\n",
314 node->nport->enable_ini, node->targ);
315 if (!pend_frames_empty || (node->nport->enable_ini && node->targ)) {
318 if (node->nport->enable_ini && node->targ) {
321 * node shutting down is a target;
330 * (will retain HW node resources)
332 node->els_io_enabled = true;
333 node->req_free = false;
340 efc_node_init_device(node, send_plogi);
342 /* else: let node shutdown occur */
346 efc_node_purge_pending(struct efc_node *node)
348 struct efc *efc = node->efc;
352 spin_lock_irqsave(&node->pend_frames_lock, flags);
354 list_for_each_entry_safe(frame, next, &node->pend_frames, list_entry) {
359 spin_unlock_irqrestore(&node->pend_frames_lock, flags);
366 struct efc_node *node = ctx->app;
374 efc_node_hold_frames(node);
375 WARN_ON(!efc_els_io_list_empty(node, &node->els_ios_list));
376 /* by default, we will be freeing node after we unwind */
377 node->req_free = true;
379 switch (node->shutdown_reason) {
381 /* Node shutdown b/c of PLOGI received when node
383 * parameters, so submit node attach; we won't be
384 * freeing this node
387 efc_node_handle_implicit_logo(node);
391 efc_node_handle_explicit_logo(node);
398 * node going away (xport event) or
400 * proceed to cleanup node
404 efc_node_send_ls_io_cleanup(node);
406 node_printf(node,
408 efc_node_purge_pending(node);
416 efc_node_accept_frames(node);
425 efc_node_check_els_quiesced(struct efc_node *node)
428 if (node->els_req_cnt == 0 && node->els_cmpl_cnt == 0 &&
429 efc_els_io_list_empty(node, &node->els_ios_list)) {
430 if (!node->attached) {
431 /* hw node detach already completed, proceed */
432 node_printf(node, "HW node not attached\n");
433 efc_node_transition(node,
438 * hw node detach hasn't completed,
441 node_printf(node, "HW node still attached\n");
442 efc_node_transition(node, __efc_node_wait_node_free,
451 efc_node_initiate_cleanup(struct efc_node *node)
457 if (!efc_node_check_els_quiesced(node)) {
458 efc_node_hold_frames(node);
459 efc_node_transition(node, __efc_node_wait_els_shutdown, NULL);
468 struct efc_node *node = ctx->app;
476 efc_node_hold_frames(node);
477 if (efc_els_io_list_empty(node, &node->els_ios_list)) {
478 node_printf(node, "All ELS IOs complete\n");
483 efc_node_accept_frames(node);
490 if (WARN_ON(!node->els_req_cnt))
492 node->els_req_cnt--;
498 if (WARN_ON(!node->els_cmpl_cnt))
500 node->els_cmpl_cnt--;
506 node_printf(node, "All ELS IOs complete\n");
507 WARN_ON(!efc_els_io_list_empty(node, &node->els_ios_list));
522 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT;
527 node_printf(node, "%s received\n", efc_sm_event_name(evt));
535 efc_node_check_els_quiesced(node);
542 struct efc_node *node = ctx->app;
550 efc_node_hold_frames(node);
554 efc_node_accept_frames(node);
558 /* node is officially no longer attached */
559 node->attached = false;
560 efc_node_transition(node, __efc_node_wait_ios_shutdown, NULL);
575 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT;
580 node_printf(node, "%s received\n", efc_sm_event_name(evt));
591 struct efc_node *node = ctx->app;
592 struct efc *efc = node->efc;
600 efc_node_hold_frames(node);
603 if (efc_els_io_list_empty(node, &node->els_ios_list))
605 efc_node_transition(node, __efc_node_shutdown, NULL);
610 if (efc_els_io_list_empty(node, &node->els_ios_list))
611 efc_node_transition(node, __efc_node_shutdown, NULL);
615 efc_node_accept_frames(node);
620 if (WARN_ON(!node->els_req_cnt))
622 node->els_req_cnt--;
628 node->shutdown_reason = EFC_NODE_SHUTDOWN_DEFAULT;
633 efc_log_debug(efc, "[%s] %-20s\n", node->display_name,
648 struct efc_node *node = NULL;
652 node = ctx->app;
653 efc = node->efc;
665 node->refound = true;
669 * node->attached must be set appropriately
670 * for all node attach/detach events
673 node->attached = true;
678 node->attached = false;
688 if (WARN_ON(!node->els_cmpl_cnt))
690 node->els_cmpl_cnt--;
702 if (WARN_ON(!node->els_req_cnt))
704 node->els_req_cnt--;
716 node->display_name, funcname,
719 efc_send_ls_rjt(node, be16_to_cpu(hdr->fh_ox_id),
738 node->display_name, funcname,
741 efc_send_ls_rjt(node, be16_to_cpu(hdr->fh_ox_id),
747 node->display_name, funcname,
751 efc_send_bls_acc(node, cbdata->header->dma.virt);
756 efc_log_debug(node->efc, "[%s] %-20s %-20s not handled\n",
757 node->display_name, funcname,
763 efc_node_save_sparms(struct efc_node *node, void *payload)
765 memcpy(node->service_params, payload, sizeof(node->service_params));
769 efc_node_post_event(struct efc_node *node,
774 node->evtdepth++;
776 efc_sm_post_event(&node->sm, evt, arg);
784 if (!node->hold_frames && node->evtdepth == 1)
785 efc_process_node_pending(node);
787 node->evtdepth--;
790 * Free the node object if so requested,
793 if (node->evtdepth == 0 && node->req_free)
797 efc_node_free(node);
801 efc_node_transition(struct efc_node *node,
805 struct efc_sm_ctx *ctx = &node->sm;
808 efc_node_post_event(node, EFC_EVT_REENTER, data);
810 efc_node_post_event(node, EFC_EVT_EXIT, data);
812 efc_node_post_event(node, EFC_EVT_ENTER, data);
825 efc_node_get_wwpn(struct efc_node *node)
828 (struct fc_els_flogi *)node->service_params;
834 efc_node_get_wwnn(struct efc_node *node)
837 (struct fc_els_flogi *)node->service_params;
861 efc_els_io_list_empty(struct efc_node *node, struct list_head *list)
866 spin_lock_irqsave(&node->els_ios_lock, flags);
868 spin_unlock_irqrestore(&node->els_ios_lock, flags);
873 efc_node_pause(struct efc_node *node,
878 node->nodedb_state = state;
879 efc_node_transition(node, __efc_node_paused, NULL);
886 struct efc_node *node = ctx->app;
894 * node is transitioned to a previously saved state (node->ndoedb_state)
898 node_printf(node, "Paused\n");
905 pf = node->nodedb_state;
907 node->nodedb_state = NULL;
908 efc_node_transition(node, pf, NULL);
916 node->req_free = true;
925 efc_node_recv_els_frame(struct efc_node *node,
962 efc_node_post_event(node, evt, &cbdata);
966 efc_node_recv_ct_frame(struct efc_node *node,
971 struct efc *efc = node->efc;
975 node->display_name, gscmd);
976 efc_send_ct_rsp(efc, node, be16_to_cpu(hdr->fh_ox_id), iu,
981 efc_node_recv_fcp_cmd(struct efc_node *node, struct efc_hw_sequence *seq)
989 efc_node_post_event(node, EFC_EVT_FCP_CMD_RCVD, &cbdata);
993 efc_process_node_pending(struct efc_node *node)
995 struct efc *efc = node->efc;
1005 if (node->hold_frames)
1010 spin_lock_irqsave(&node->pend_frames_lock, flags);
1012 if (!list_empty(&node->pend_frames)) {
1013 seq = list_first_entry(&node->pend_frames,
1017 spin_unlock_irqrestore(&node->pend_frames_lock, flags);
1020 pend_frames_processed = node->pend_frames_processed;
1021 node->pend_frames_processed = 0;
1024 node->pend_frames_processed++;
1027 efc_node_dispatch_frame(node, seq);
1032 efc_log_debug(efc, "%u node frames held and processed\n",
1037 efc_scsi_sess_reg_complete(struct efc_node *node, u32 status)
1041 struct efc *efc = node->efc;
1047 /* Notify the node to resume */
1048 efc_node_post_event(node, evt, NULL);
1053 efc_scsi_del_initiator_complete(struct efc *efc, struct efc_node *node)
1058 /* Notify the node to resume */
1059 efc_node_post_event(node, EFC_EVT_NODE_DEL_INI_COMPLETE, NULL);
1064 efc_scsi_del_target_complete(struct efc *efc, struct efc_node *node)
1069 /* Notify the node to resume */
1070 efc_node_post_event(node, EFC_EVT_NODE_DEL_TGT_COMPLETE, NULL);
1075 efc_scsi_io_list_empty(struct efc *efc, struct efc_node *node)
1080 efc_node_post_event(node, EFC_EVT_NODE_ACTIVE_IO_LIST_EMPTY, NULL);
1084 void efc_node_post_els_resp(struct efc_node *node, u32 evt, void *arg)
1086 struct efc *efc = node->efc;
1090 efc_node_post_event(node, evt, arg);
1094 void efc_node_post_shutdown(struct efc_node *node, void *arg)
1097 struct efc *efc = node->efc;
1100 efc_node_post_event(node, EFC_EVT_SHUTDOWN, arg);