Lines Matching +full:loss +full:- +full:of +full:- +full:lock

2  * This file is part of the Chelsio FCoE driver for Linux.
4 * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
9 * COPYING in the main directory of this source tree, or the
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
51 * csio_reg_rnode - Register a remote port with FC transport.
69 ids.port_id = rn->nport_id; in csio_reg_rnode()
72 if (rn->role & CSIO_RNFR_INITIATOR || rn->role & CSIO_RNFR_TARGET) { in csio_reg_rnode()
73 rport = rn->rport; in csio_reg_rnode()
78 rn->rport = fc_remote_port_add(shost, 0, &ids); in csio_reg_rnode()
79 if (!rn->rport) { in csio_reg_rnode()
81 rn->nport_id); in csio_reg_rnode()
85 ln->num_reg_rnodes++; in csio_reg_rnode()
86 rport = rn->rport; in csio_reg_rnode()
87 spin_lock_irq(shost->host_lock); in csio_reg_rnode()
88 *((struct csio_rnode **)rport->dd_data) = rn; in csio_reg_rnode()
89 spin_unlock_irq(shost->host_lock); in csio_reg_rnode()
91 sp = &rn->rn_sparm; in csio_reg_rnode()
92 rport->maxframe_size = ntohs(sp->csp.sp_bb_data); in csio_reg_rnode()
93 if (ntohs(sp->clsp[2].cp_class) & FC_CPC_VALID) in csio_reg_rnode()
94 rport->supported_classes = FC_COS_CLASS3; in csio_reg_rnode()
96 rport->supported_classes = FC_COS_UNSPECIFIED; in csio_reg_rnode()
98 if (rn->role & CSIO_RNFR_INITIATOR) in csio_reg_rnode()
100 if (rn->role & CSIO_RNFR_TARGET) in csio_reg_rnode()
106 rn->scsi_id = rport->scsi_target_id; in csio_reg_rnode()
109 rn->nport_id, ids.roles); in csio_reg_rnode()
113 * csio_unreg_rnode - Unregister a remote port with FC transport.
124 struct fc_rport *rport = rn->rport; in csio_unreg_rnode()
126 rn->role &= ~(CSIO_RNFR_INITIATOR | CSIO_RNFR_TARGET); in csio_unreg_rnode()
128 ln->num_reg_rnodes--; in csio_unreg_rnode()
130 csio_ln_dbg(ln, "Remote port x%x un-registered\n", rn->nport_id); in csio_unreg_rnode()
134 * csio_lnode_async_event - Async events from local port.
138 * should be made aware of (Eg: RSCN).
145 /* Get payload of rscn from ln */ in csio_lnode_async_event()
177 * csio_fchost_attr_init - Initialize FC transport attributes
191 (csio_lnode_to_hw(ln))->fres_info.max_vnps; in csio_fchost_attr_init()
195 fc_host_maxframe_size(shost) = ntohs(ln->ln_sparm.csp.sp_bb_data); in csio_fchost_attr_init()
206 * csio_get_host_port_id - sysfs entries for nport_id is
215 spin_lock_irq(&hw->lock); in csio_get_host_port_id()
216 fc_host_port_id(shost) = ln->nport_id; in csio_get_host_port_id()
217 spin_unlock_irq(&hw->lock); in csio_get_host_port_id()
221 * csio_get_port_type - Return FC local port type.
231 spin_lock_irq(&hw->lock); in csio_get_host_port_type()
236 spin_unlock_irq(&hw->lock); in csio_get_host_port_type()
240 * csio_get_port_state - Return FC local port state.
251 spin_lock_irq(&hw->lock); in csio_get_host_port_state()
261 spin_unlock_irq(&hw->lock); in csio_get_host_port_state()
265 * csio_get_host_speed - Return link speed to FC transport.
275 spin_lock_irq(&hw->lock); in csio_get_host_speed()
276 switch (hw->pport[ln->portid].link_speed) { in csio_get_host_speed()
299 spin_unlock_irq(&hw->lock); in csio_get_host_speed()
303 * csio_get_host_fabric_name - Return fabric name
314 spin_lock_irq(&hw->lock); in csio_get_host_fabric_name()
320 spin_unlock_irq(&hw->lock); in csio_get_host_fabric_name()
324 * csio_get_host_speed - Return FC transport statistics.
333 struct fc_host_statistics *fhs = &ln->fch_stats; in csio_get_stats()
338 csio_get_phy_port_stats(hw, ln->portid, &fcoe_port_stats); in csio_get_stats()
340 fhs->tx_frames += (be64_to_cpu(fcoe_port_stats.tx_bcast_frames) + in csio_get_stats()
344 fhs->tx_words += (be64_to_cpu(fcoe_port_stats.tx_bcast_bytes) + in csio_get_stats()
349 fhs->rx_frames += (be64_to_cpu(fcoe_port_stats.rx_bcast_frames) + in csio_get_stats()
352 fhs->rx_words += (be64_to_cpu(fcoe_port_stats.rx_bcast_bytes) + in csio_get_stats()
356 fhs->error_frames += be64_to_cpu(fcoe_port_stats.rx_err_frames); in csio_get_stats()
357 fhs->fcp_input_requests += ln->stats.n_input_requests; in csio_get_stats()
358 fhs->fcp_output_requests += ln->stats.n_output_requests; in csio_get_stats()
359 fhs->fcp_control_requests += ln->stats.n_control_requests; in csio_get_stats()
360 fhs->fcp_input_megabytes += ln->stats.n_input_bytes >> 20; in csio_get_stats()
361 fhs->fcp_output_megabytes += ln->stats.n_output_bytes >> 20; in csio_get_stats()
362 fhs->link_failure_count = ln->stats.n_link_down; in csio_get_stats()
364 seconds = jiffies_to_msecs(jiffies) - hw->stats.n_reset_start; in csio_get_stats()
366 fhs->seconds_since_last_reset = seconds; in csio_get_stats()
372 * csio_set_rport_loss_tmo - Set the rport dev loss timeout
374 * @timeout: new value for dev loss tmo.
383 rport->dev_loss_tmo = timeout; in csio_set_rport_loss_tmo()
385 rport->dev_loss_tmo = 1; in csio_set_rport_loss_tmo()
391 struct fc_vport *fc_vport = ln->fc_vport; in csio_vport_set_state()
392 struct csio_lnode *pln = ln->pln; in csio_vport_set_state()
402 if (!(pln->flags & CSIO_LNF_NPIVSUPP)) { in csio_vport_set_state()
427 spin_lock_irq(&hw->lock); in csio_fcoe_alloc_vnp()
428 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_fcoe_alloc_vnp()
431 ret = -ENOMEM; in csio_fcoe_alloc_vnp()
435 pln = ln->pln; in csio_fcoe_alloc_vnp()
436 ln->fcf_flowid = pln->fcf_flowid; in csio_fcoe_alloc_vnp()
437 ln->portid = pln->portid; in csio_fcoe_alloc_vnp()
440 pln->fcf_flowid, pln->vnp_flowid, 0, in csio_fcoe_alloc_vnp()
447 * lock is held till completion of vnp mbox cmd. in csio_fcoe_alloc_vnp()
450 if (ret != -EBUSY) in csio_fcoe_alloc_vnp()
454 spin_unlock_irq(&hw->lock); in csio_fcoe_alloc_vnp()
456 spin_lock_irq(&hw->lock); in csio_fcoe_alloc_vnp()
464 /* Process Mbox response of VNP command */ in csio_fcoe_alloc_vnp()
465 rsp = (struct fw_fcoe_vnp_cmd *)(mbp->mb); in csio_fcoe_alloc_vnp()
466 if (FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16)) != FW_SUCCESS) { in csio_fcoe_alloc_vnp()
468 FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16))); in csio_fcoe_alloc_vnp()
469 ret = -EINVAL; in csio_fcoe_alloc_vnp()
473 ln->vnp_flowid = FW_FCOE_VNP_CMD_VNPI_GET( in csio_fcoe_alloc_vnp()
474 ntohl(rsp->gen_wwn_to_vnpi)); in csio_fcoe_alloc_vnp()
475 memcpy(csio_ln_wwnn(ln), rsp->vnport_wwnn, 8); in csio_fcoe_alloc_vnp()
476 memcpy(csio_ln_wwpn(ln), rsp->vnport_wwpn, 8); in csio_fcoe_alloc_vnp()
478 csio_ln_dbg(ln, "FCOE VNPI: 0x%x\n", ln->vnp_flowid); in csio_fcoe_alloc_vnp()
480 ln->ln_sparm.wwnn[0], ln->ln_sparm.wwnn[1], in csio_fcoe_alloc_vnp()
481 ln->ln_sparm.wwnn[2], ln->ln_sparm.wwnn[3], in csio_fcoe_alloc_vnp()
482 ln->ln_sparm.wwnn[4], ln->ln_sparm.wwnn[5], in csio_fcoe_alloc_vnp()
483 ln->ln_sparm.wwnn[6], ln->ln_sparm.wwnn[7]); in csio_fcoe_alloc_vnp()
485 ln->ln_sparm.wwpn[0], ln->ln_sparm.wwpn[1], in csio_fcoe_alloc_vnp()
486 ln->ln_sparm.wwpn[2], ln->ln_sparm.wwpn[3], in csio_fcoe_alloc_vnp()
487 ln->ln_sparm.wwpn[4], ln->ln_sparm.wwpn[5], in csio_fcoe_alloc_vnp()
488 ln->ln_sparm.wwpn[6], ln->ln_sparm.wwpn[7]); in csio_fcoe_alloc_vnp()
491 mempool_free(mbp, hw->mb_mempool); in csio_fcoe_alloc_vnp()
493 spin_unlock_irq(&hw->lock); in csio_fcoe_alloc_vnp()
508 spin_lock_irq(&hw->lock); in csio_fcoe_free_vnp()
509 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_fcoe_free_vnp()
512 ret = -ENOMEM; in csio_fcoe_free_vnp()
517 ln->fcf_flowid, ln->vnp_flowid, in csio_fcoe_free_vnp()
522 if (ret != -EBUSY) in csio_fcoe_free_vnp()
526 spin_unlock_irq(&hw->lock); in csio_fcoe_free_vnp()
528 spin_lock_irq(&hw->lock); in csio_fcoe_free_vnp()
536 /* Process Mbox response of VNP command */ in csio_fcoe_free_vnp()
537 rsp = (struct fw_fcoe_vnp_cmd *)(mbp->mb); in csio_fcoe_free_vnp()
538 if (FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16)) != FW_SUCCESS) { in csio_fcoe_free_vnp()
540 FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16))); in csio_fcoe_free_vnp()
541 ret = -EINVAL; in csio_fcoe_free_vnp()
545 mempool_free(mbp, hw->mb_mempool); in csio_fcoe_free_vnp()
547 spin_unlock_irq(&hw->lock); in csio_fcoe_free_vnp()
554 struct Scsi_Host *shost = fc_vport->shost; in csio_vport_create()
559 int ret = -1; in csio_vport_create()
561 ln = csio_shost_init(hw, &fc_vport->dev, false, pln); in csio_vport_create()
565 if (fc_vport->node_name != 0) { in csio_vport_create()
566 u64_to_wwn(fc_vport->node_name, wwn); in csio_vport_create()
576 if (fc_vport->port_name != 0) { in csio_vport_create()
577 u64_to_wwn(fc_vport->port_name, wwn); in csio_vport_create()
594 ln->fc_vport = fc_vport; in csio_vport_create()
599 *(struct csio_lnode **)fc_vport->dd_data = ln; in csio_vport_create()
600 if (!fc_vport->node_name) in csio_vport_create()
601 fc_vport->node_name = wwn_to_u64(csio_ln_wwnn(ln)); in csio_vport_create()
602 if (!fc_vport->port_name) in csio_vport_create()
603 fc_vport->port_name = wwn_to_u64(csio_ln_wwpn(ln)); in csio_vport_create()
616 struct csio_lnode *ln = *(struct csio_lnode **)fc_vport->dd_data; in csio_vport_delete()
621 spin_lock_irq(&hw->lock); in csio_vport_delete()
623 spin_unlock_irq(&hw->lock); in csio_vport_delete()
632 spin_lock_irq(&hw->lock); in csio_vport_delete()
635 spin_unlock_irq(&hw->lock); in csio_vport_delete()
639 if (fc_vport->vport_state != FC_VPORT_DISABLED) in csio_vport_delete()
649 struct csio_lnode *ln = *(struct csio_lnode **)fc_vport->dd_data; in csio_vport_disable()
657 spin_lock_irq(&hw->lock); in csio_vport_disable()
660 spin_unlock_irq(&hw->lock); in csio_vport_disable()
673 return -1; in csio_vport_disable()
687 rn = *((struct csio_rnode **)rport->dd_data); in csio_dev_loss_tmo_callbk()
691 spin_lock_irq(&hw->lock); in csio_dev_loss_tmo_callbk()
698 rn, rn->nport_id, csio_rn_flowid(rn)); in csio_dev_loss_tmo_callbk()
711 if (!(hw->flags & CSIO_HWF_FWEVT_PENDING)) { in csio_dev_loss_tmo_callbk()
712 hw->flags |= CSIO_HWF_FWEVT_PENDING; in csio_dev_loss_tmo_callbk()
713 spin_unlock_irq(&hw->lock); in csio_dev_loss_tmo_callbk()
714 schedule_work(&hw->evtq_work); in csio_dev_loss_tmo_callbk()
719 spin_unlock_irq(&hw->lock); in csio_dev_loss_tmo_callbk()
722 /* FC transport functions template - Physical port */
766 /* FC transport functions template - Virtual port */