~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/scsi/lpfc/lpfc_hbadisc.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************
2
2
 * This file is part of the Emulex Linux Device Driver for         *
3
3
 * Fibre Channel Host Bus Adapters.                                *
4
 
 * Copyright (C) 2004-2009 Emulex.  All rights reserved.           *
 
4
 * Copyright (C) 2004-2011 Emulex.  All rights reserved.           *
5
5
 * EMULEX and SLI are trademarks of Emulex.                        *
6
6
 * www.emulex.com                                                  *
7
7
 * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
658
658
                                lpfc_ramp_down_queue_handler(phba);
659
659
                        if (work_port_events & WORKER_RAMP_UP_QUEUE)
660
660
                                lpfc_ramp_up_queue_handler(phba);
 
661
                        if (work_port_events & WORKER_DELAYED_DISC_TMO)
 
662
                                lpfc_delayed_disc_timeout_handler(vport);
661
663
                }
662
664
        lpfc_destroy_vport_work_array(phba, vports);
663
665
 
737
739
 
738
740
/*
739
741
 * This is only called to handle FC worker events. Since this a rare
740
 
 * occurance, we allocate a struct lpfc_work_evt structure here instead of
 
742
 * occurrence, we allocate a struct lpfc_work_evt structure here instead of
741
743
 * embedding it in the IOCB.
742
744
 */
743
745
int
838
840
 
839
841
        lpfc_port_link_failure(vport);
840
842
 
 
843
        /* Stop delayed Nport discovery */
 
844
        spin_lock_irq(shost->host_lock);
 
845
        vport->fc_flag &= ~FC_DISC_DELAYED;
 
846
        spin_unlock_irq(shost->host_lock);
 
847
        del_timer_sync(&vport->delayed_disc_tmo);
841
848
}
842
849
 
843
850
int
874
881
        /* Clean up any firmware default rpi's */
875
882
        mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
876
883
        if (mb) {
877
 
                lpfc_unreg_did(phba, 0xffff, 0xffffffff, mb);
 
884
                lpfc_unreg_did(phba, 0xffff, LPFC_UNREG_ALL_DFLT_RPIS, mb);
878
885
                mb->vport = vport;
879
886
                mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
880
887
                if (lpfc_sli_issue_mbox(phba, mb, MBX_NOWAIT)
1341
1348
        int rc;
1342
1349
 
1343
1350
        spin_lock_irq(&phba->hbalock);
1344
 
        /* If the FCF is not availabe do nothing. */
 
1351
        /* If the FCF is not available do nothing. */
1345
1352
        if (!(phba->fcf.fcf_flag & FCF_AVAILABLE)) {
1346
1353
                phba->hba_flag &= ~(FCF_TS_INPROG | FCF_RR_INPROG);
1347
1354
                spin_unlock_irq(&phba->hbalock);
1531
1538
 
1532
1539
                /*
1533
1540
                 * If user did not specify any addressing mode, or if the
1534
 
                 * prefered addressing mode specified by user is not supported
 
1541
                 * preferred addressing mode specified by user is not supported
1535
1542
                 * by FCF, allow fabric to pick the addressing mode.
1536
1543
                 */
1537
1544
                *addr_mode = bf_get(lpfc_fcf_record_mac_addr_prov,
1546
1553
                                FCFCNCT_AM_SPMA) ?
1547
1554
                                LPFC_FCF_SPMA : LPFC_FCF_FPMA;
1548
1555
                /*
1549
 
                 * If the user specified a prefered address mode, use the
 
1556
                 * If the user specified a preferred address mode, use the
1550
1557
                 * addr mode only if FCF support the addr_mode.
1551
1558
                 */
1552
1559
                else if ((conn_entry->conn_rec.flags & FCFCNCT_AM_VALID) &&
2683
2690
 
2684
2691
        memcpy((uint8_t *) &vport->fc_sparam, (uint8_t *) mp->virt,
2685
2692
               sizeof (struct serv_parm));
2686
 
        if (phba->cfg_soft_wwnn)
2687
 
                u64_to_wwn(phba->cfg_soft_wwnn,
2688
 
                           vport->fc_sparam.nodeName.u.wwn);
2689
 
        if (phba->cfg_soft_wwpn)
2690
 
                u64_to_wwn(phba->cfg_soft_wwpn,
2691
 
                           vport->fc_sparam.portName.u.wwn);
2692
 
        memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName,
2693
 
               sizeof(vport->fc_nodename));
2694
 
        memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
2695
 
               sizeof(vport->fc_portname));
 
2693
        lpfc_update_vport_wwn(vport);
2696
2694
        if (vport->port_type == LPFC_PHYSICAL_PORT) {
2697
2695
                memcpy(&phba->wwnn, &vport->fc_nodename, sizeof(phba->wwnn));
2698
2696
                memcpy(&phba->wwpn, &vport->fc_portname, sizeof(phba->wwnn));
3110
3108
                 * back at reg login state so this
3111
3109
                 * mbox needs to be ignored becase
3112
3110
                 * there is another reg login in
3113
 
                 * proccess.
 
3111
                 * process.
3114
3112
                 */
3115
3113
                spin_lock_irq(shost->host_lock);
3116
3114
                ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL;
3160
3158
        spin_unlock_irq(shost->host_lock);
3161
3159
        vport->unreg_vpi_cmpl = VPORT_OK;
3162
3160
        mempool_free(pmb, phba->mbox_mem_pool);
3163
 
        lpfc_cleanup_vports_rrqs(vport);
 
3161
        lpfc_cleanup_vports_rrqs(vport, NULL);
3164
3162
        /*
3165
3163
         * This shost reference might have been taken at the beginning of
3166
3164
         * lpfc_vport_delete()
3423
3421
                return;
3424
3422
        }
3425
3423
 
3426
 
        ndlp->nlp_rpi = mb->un.varWords[0];
 
3424
        if (phba->sli_rev < LPFC_SLI_REV4)
 
3425
                ndlp->nlp_rpi = mb->un.varWords[0];
3427
3426
        ndlp->nlp_flag |= NLP_RPI_REGISTERED;
3428
3427
        ndlp->nlp_type |= NLP_FABRIC;
3429
3428
        lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
3497
3496
                return;
3498
3497
        }
3499
3498
 
3500
 
        ndlp->nlp_rpi = mb->un.varWords[0];
 
3499
        if (phba->sli_rev < LPFC_SLI_REV4)
 
3500
                ndlp->nlp_rpi = mb->un.varWords[0];
3501
3501
        ndlp->nlp_flag |= NLP_RPI_REGISTERED;
3502
3502
        ndlp->nlp_type |= NLP_FABRIC;
3503
3503
        lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
3562
3562
                "rport add:       did:x%x flg:x%x type x%x",
3563
3563
                ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type);
3564
3564
 
 
3565
        /* Don't add the remote port if unloading. */
 
3566
        if (vport->load_flag & FC_UNLOADING)
 
3567
                return;
 
3568
 
3565
3569
        ndlp->rport = rport = fc_remote_port_add(shost, 0, &rport_ids);
3566
3570
        if (!rport || !get_device(&rport->dev)) {
3567
3571
                dev_printk(KERN_WARNING, &phba->pcidev->dev,
3580
3584
        if (ndlp->nlp_type & NLP_FCP_INITIATOR)
3581
3585
                rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
3582
3586
 
3583
 
 
3584
3587
        if (rport_ids.roles !=  FC_RPORT_ROLE_UNKNOWN)
3585
3588
                fc_remote_port_rolechg(rport, rport_ids.roles);
3586
3589
 
3900
3903
        if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
3901
3904
                return;
3902
3905
        lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
 
3906
        if (vport->phba->sli_rev == LPFC_SLI_REV4)
 
3907
                lpfc_cleanup_vports_rrqs(vport, ndlp);
3903
3908
        lpfc_nlp_put(ndlp);
3904
3909
        return;
3905
3910
}
4093
4098
        struct lpfc_hba *phba = vport->phba;
4094
4099
        LPFC_MBOXQ_t    *mbox;
4095
4100
        int rc;
 
4101
        uint16_t rpi;
4096
4102
 
4097
4103
        if (ndlp->nlp_flag & NLP_RPI_REGISTERED) {
4098
4104
                mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4099
4105
                if (mbox) {
4100
 
                        lpfc_unreg_login(phba, vport->vpi, ndlp->nlp_rpi, mbox);
 
4106
                        /* SLI4 ports require the physical rpi value. */
 
4107
                        rpi = ndlp->nlp_rpi;
 
4108
                        if (phba->sli_rev == LPFC_SLI_REV4)
 
4109
                                rpi = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
 
4110
                        lpfc_unreg_login(phba, vport->vpi, rpi, mbox);
4101
4111
                        mbox->vport = vport;
4102
4112
                        mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
4103
4113
                        rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
4166
4176
 
4167
4177
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4168
4178
        if (mbox) {
4169
 
                lpfc_unreg_login(phba, vport->vpi, 0xffff, mbox);
 
4179
                lpfc_unreg_login(phba, vport->vpi, LPFC_UNREG_ALL_RPIS_VPORT,
 
4180
                                 mbox);
4170
4181
                mbox->vport = vport;
4171
4182
                mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
4172
4183
                mbox->context1 = NULL;
4190
4201
 
4191
4202
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
4192
4203
        if (mbox) {
4193
 
                lpfc_unreg_did(phba, vport->vpi, 0xffffffff, mbox);
 
4204
                lpfc_unreg_did(phba, vport->vpi, LPFC_UNREG_ALL_DFLT_RPIS,
 
4205
                               mbox);
4194
4206
                mbox->vport = vport;
4195
4207
                mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
4196
4208
                mbox->context1 = NULL;
4289
4301
 
4290
4302
        list_del_init(&ndlp->els_retry_evt.evt_listp);
4291
4303
        list_del_init(&ndlp->dev_loss_evt.evt_listp);
4292
 
 
 
4304
        lpfc_cleanup_vports_rrqs(vport, ndlp);
4293
4305
        lpfc_unreg_rpi(vport, ndlp);
4294
4306
 
4295
4307
        return 0;
4426
4438
{
4427
4439
        struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
4428
4440
        struct lpfc_nodelist *ndlp;
 
4441
        unsigned long iflags;
4429
4442
 
4430
 
        spin_lock_irq(shost->host_lock);
 
4443
        spin_lock_irqsave(shost->host_lock, iflags);
4431
4444
        ndlp = __lpfc_findnode_did(vport, did);
4432
 
        spin_unlock_irq(shost->host_lock);
 
4445
        spin_unlock_irqrestore(shost->host_lock, iflags);
4433
4446
        return ndlp;
4434
4447
}
4435
4448
 
4467
4480
        if ((vport->fc_flag & FC_RSCN_MODE) &&
4468
4481
            !(vport->fc_flag & FC_NDISC_ACTIVE)) {
4469
4482
                if (lpfc_rscn_payload_check(vport, did)) {
4470
 
                        /* If we've already recieved a PLOGI from this NPort
 
4483
                        /* If we've already received a PLOGI from this NPort
4471
4484
                         * we don't need to try to discover it again.
4472
4485
                         */
4473
4486
                        if (ndlp->nlp_flag & NLP_RCV_PLOGI)
4483
4496
                } else
4484
4497
                        ndlp = NULL;
4485
4498
        } else {
4486
 
                /* If we've already recieved a PLOGI from this NPort,
 
4499
                /* If we've already received a PLOGI from this NPort,
4487
4500
                 * or we are already in the process of discovery on it,
4488
4501
                 * we don't need to try to discover it again.
4489
4502
                 */
4639
4652
        if (num_sent)
4640
4653
                return;
4641
4654
 
4642
 
        /*
4643
 
         * For SLI3, cmpl_reg_vpi will set port_state to READY, and
4644
 
         * continue discovery.
4645
 
         */
 
4655
        /* Register the VPI for SLI3, NON-NPIV only. */
4646
4656
        if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
4647
4657
            !(vport->fc_flag & FC_PT2PT) &&
4648
4658
            !(vport->fc_flag & FC_RSCN_MODE) &&
4929
4939
                if (phba->sli_rev < LPFC_SLI_REV4) {
4930
4940
                        if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
4931
4941
                                lpfc_issue_reg_vpi(phba, vport);
4932
 
                        else  { /* NPIV Not enabled */
 
4942
                        else  {
4933
4943
                                lpfc_issue_clear_la(phba, vport);
4934
4944
                                vport->port_state = LPFC_VPORT_READY;
4935
4945
                        }
5055
5065
        pmb->context1 = NULL;
5056
5066
        pmb->context2 = NULL;
5057
5067
 
5058
 
        ndlp->nlp_rpi = mb->un.varWords[0];
 
5068
        if (phba->sli_rev < LPFC_SLI_REV4)
 
5069
                ndlp->nlp_rpi = mb->un.varWords[0];
5059
5070
        ndlp->nlp_flag |= NLP_RPI_REGISTERED;
5060
5071
        ndlp->nlp_type |= NLP_FABRIC;
5061
5072
        lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
5340
5351
        for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
5341
5352
                shost = lpfc_shost_from_vport(vports[i]);
5342
5353
                spin_lock_irq(shost->host_lock);
 
5354
                /*
 
5355
                 * IF the CVL_RCVD bit is not set then we have sent the
 
5356
                 * flogi.
 
5357
                 * If dev_loss fires while we are waiting we do not want to
 
5358
                 * unreg the fcf.
 
5359
                 */
 
5360
                if (!(vports[i]->fc_flag & FC_VPORT_CVL_RCVD)) {
 
5361
                        spin_unlock_irq(shost->host_lock);
 
5362
                        ret =  1;
 
5363
                        goto out;
 
5364
                }
5343
5365
                list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) {
5344
5366
                        if (NLP_CHK_NODE_ACT(ndlp) && ndlp->rport &&
5345
5367
                          (ndlp->rport->roles & FC_RPORT_ROLE_FCP_TARGET)) {
5746
5768
 * @size: Size of the data buffer.
5747
5769
 * @rec_type: Record type to be searched.
5748
5770
 *
5749
 
 * This function searches config region data to find the begining
 
5771
 * This function searches config region data to find the beginning
5750
5772
 * of the record specified by record_type. If record found, this
5751
5773
 * function return pointer to the record else return NULL.
5752
5774
 */