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

« back to all changes in this revision

Viewing changes to drivers/scsi/lpfc/lpfc_mbox.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:
610
610
        mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
611
611
        mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);
612
612
        mb->un.varRdSparm.un.sp64.addrLow = putPaddrLow(mp->phys);
613
 
        mb->un.varRdSparm.vpi = vpi + phba->vpi_base;
 
613
        if (phba->sli_rev >= LPFC_SLI_REV3)
 
614
                mb->un.varRdSparm.vpi = phba->vpi_ids[vpi];
614
615
 
615
616
        /* save address for completion */
616
617
        pmb->context1 = mp;
643
644
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
644
645
 
645
646
        mb->un.varUnregDID.did = did;
646
 
        if (vpi != 0xffff)
647
 
                vpi += phba->vpi_base;
648
647
        mb->un.varUnregDID.vpi = vpi;
 
648
        if ((vpi != 0xffff) &&
 
649
            (phba->sli_rev == LPFC_SLI_REV4))
 
650
                mb->un.varUnregDID.vpi = phba->vpi_ids[vpi];
649
651
 
650
652
        mb->mbxCommand = MBX_UNREG_D_ID;
651
653
        mb->mbxOwner = OWN_HOST;
738
740
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
739
741
 
740
742
        mb->un.varRegLogin.rpi = 0;
741
 
        if (phba->sli_rev == LPFC_SLI_REV4) {
742
 
                mb->un.varRegLogin.rpi = rpi;
743
 
                if (mb->un.varRegLogin.rpi == LPFC_RPI_ALLOC_ERROR)
744
 
                        return 1;
745
 
        }
746
 
        mb->un.varRegLogin.vpi = vpi + phba->vpi_base;
 
743
        if (phba->sli_rev == LPFC_SLI_REV4)
 
744
                mb->un.varRegLogin.rpi = phba->sli4_hba.rpi_ids[rpi];
 
745
        if (phba->sli_rev >= LPFC_SLI_REV3)
 
746
                mb->un.varRegLogin.vpi = phba->vpi_ids[vpi];
747
747
        mb->un.varRegLogin.did = did;
748
748
        mb->mbxOwner = OWN_HOST;
749
749
        /* Get a buffer to hold NPorts Service Parameters */
757
757
                lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
758
758
                                "0302 REG_LOGIN: no buffers, VPI:%d DID:x%x, "
759
759
                                "rpi x%x\n", vpi, did, rpi);
760
 
                return (1);
 
760
                return 1;
761
761
        }
762
762
        INIT_LIST_HEAD(&mp->list);
763
763
        sparam = mp->virt;
773
773
        mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);
774
774
        mb->un.varRegLogin.un.sp64.addrLow = putPaddrLow(mp->phys);
775
775
 
776
 
        return (0);
 
776
        return 0;
777
777
}
778
778
 
779
779
/**
789
789
 *
790
790
 * This routine prepares the mailbox command for unregistering remote port
791
791
 * login.
 
792
 *
 
793
 * For SLI4 ports, the rpi passed to this function must be the physical
 
794
 * rpi value, not the logical index.
792
795
 **/
793
796
void
794
797
lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi,
799
802
        mb = &pmb->u.mb;
800
803
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
801
804
 
802
 
        mb->un.varUnregLogin.rpi = (uint16_t) rpi;
 
805
        mb->un.varUnregLogin.rpi = rpi;
803
806
        mb->un.varUnregLogin.rsvd1 = 0;
804
 
        mb->un.varUnregLogin.vpi = vpi + phba->vpi_base;
 
807
        if (phba->sli_rev >= LPFC_SLI_REV3)
 
808
                mb->un.varUnregLogin.vpi = phba->vpi_ids[vpi];
805
809
 
806
810
        mb->mbxCommand = MBX_UNREG_LOGIN;
807
811
        mb->mbxOwner = OWN_HOST;
825
829
 
826
830
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
827
831
        if (mbox) {
828
 
                lpfc_unreg_login(phba, vport->vpi,
829
 
                        vport->vpi + phba->vpi_base, mbox);
830
 
                mbox->u.mb.un.varUnregLogin.rsvd1 = 0x4000 ;
 
832
                /*
 
833
                 * For SLI4 functions, the rpi field is overloaded for
 
834
                 * the vport context unreg all.  This routine passes
 
835
                 * 0 for the rpi field in lpfc_unreg_login for compatibility
 
836
                 * with SLI3 and then overrides the rpi field with the
 
837
                 * expected value for SLI4.
 
838
                 */
 
839
                lpfc_unreg_login(phba, vport->vpi, phba->vpi_ids[vport->vpi],
 
840
                                 mbox);
 
841
                mbox->u.mb.un.varUnregLogin.rsvd1 = 0x4000;
831
842
                mbox->vport = vport;
832
843
                mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
833
844
                mbox->context1 = NULL;
865
876
        if ((phba->sli_rev == LPFC_SLI_REV4) &&
866
877
                !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI))
867
878
                mb->un.varRegVpi.upd = 1;
868
 
        mb->un.varRegVpi.vpi = vport->vpi + vport->phba->vpi_base;
 
879
 
 
880
        mb->un.varRegVpi.vpi = phba->vpi_ids[vport->vpi];
869
881
        mb->un.varRegVpi.sid = vport->fc_myDID;
870
 
        mb->un.varRegVpi.vfi = vport->vfi + vport->phba->vfi_base;
 
882
        if (phba->sli_rev == LPFC_SLI_REV4)
 
883
                mb->un.varRegVpi.vfi = phba->sli4_hba.vfi_ids[vport->vfi];
 
884
        else
 
885
                mb->un.varRegVpi.vfi = vport->vfi + vport->phba->vfi_base;
871
886
        memcpy(mb->un.varRegVpi.wwn, &vport->fc_portname,
872
887
               sizeof(struct lpfc_name));
873
888
        mb->un.varRegVpi.wwn[0] = cpu_to_le32(mb->un.varRegVpi.wwn[0]);
901
916
        MAILBOX_t *mb = &pmb->u.mb;
902
917
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
903
918
 
904
 
        if (phba->sli_rev < LPFC_SLI_REV4)
905
 
                mb->un.varUnregVpi.vpi = vpi + phba->vpi_base;
906
 
        else
907
 
                mb->un.varUnregVpi.sli4_vpi = vpi + phba->vpi_base;
 
919
        if (phba->sli_rev == LPFC_SLI_REV3)
 
920
                mb->un.varUnregVpi.vpi = phba->vpi_ids[vpi];
 
921
        else if (phba->sli_rev >= LPFC_SLI_REV4)
 
922
                mb->un.varUnregVpi.sli4_vpi = phba->vpi_ids[vpi];
908
923
 
909
924
        mb->mbxCommand = MBX_UNREG_VPI;
910
925
        mb->mbxOwner = OWN_HOST;
1263
1278
        if (phba->sli_rev == LPFC_SLI_REV3 && phba->vpd.sli3Feat.cerbm) {
1264
1279
                if (phba->cfg_enable_bg)
1265
1280
                        mb->un.varCfgPort.cbg = 1; /* configure BlockGuard */
1266
 
                mb->un.varCfgPort.cdss = 1; /* Configure Security */
 
1281
                if (phba->cfg_enable_dss)
 
1282
                        mb->un.varCfgPort.cdss = 1; /* Configure Security */
1267
1283
                mb->un.varCfgPort.cerbm = 1; /* Request HBQs */
1268
1284
                mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */
1269
1285
                mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count();
1692
1708
 * @mbox: pointer to lpfc mbox command.
1693
1709
 * @subsystem: The sli4 config sub mailbox subsystem.
1694
1710
 * @opcode: The sli4 config sub mailbox command opcode.
1695
 
 * @length: Length of the sli4 config mailbox command.
 
1711
 * @length: Length of the sli4 config mailbox command (including sub-header).
1696
1712
 *
1697
1713
 * This routine sets up the header fields of SLI4 specific mailbox command
1698
1714
 * for sending IOCTL command.
1723
1739
        if (emb) {
1724
1740
                /* Set up main header fields */
1725
1741
                bf_set(lpfc_mbox_hdr_emb, &sli4_config->header.cfg_mhdr, 1);
1726
 
                sli4_config->header.cfg_mhdr.payload_length =
1727
 
                                        LPFC_MBX_CMD_HDR_LENGTH + length;
 
1742
                sli4_config->header.cfg_mhdr.payload_length = length;
1728
1743
                /* Set up sub-header fields following main header */
1729
1744
                bf_set(lpfc_mbox_hdr_opcode,
1730
1745
                        &sli4_config->header.cfg_shdr.request, opcode);
1731
1746
                bf_set(lpfc_mbox_hdr_subsystem,
1732
1747
                        &sli4_config->header.cfg_shdr.request, subsystem);
1733
 
                sli4_config->header.cfg_shdr.request.request_length = length;
 
1748
                sli4_config->header.cfg_shdr.request.request_length =
 
1749
                        length - LPFC_MBX_CMD_HDR_LENGTH;
1734
1750
                return length;
1735
1751
        }
1736
1752
 
1737
 
        /* Setup for the none-embedded mbox command */
1738
 
        pcount = (PAGE_ALIGN(length))/SLI4_PAGE_SIZE;
 
1753
        /* Setup for the non-embedded mbox command */
 
1754
        pcount = (SLI4_PAGE_ALIGN(length))/SLI4_PAGE_SIZE;
1739
1755
        pcount = (pcount > LPFC_SLI4_MBX_SGE_MAX_PAGES) ?
1740
1756
                                LPFC_SLI4_MBX_SGE_MAX_PAGES : pcount;
1741
1757
        /* Allocate record for keeping SGE virtual addresses */
1742
 
        mbox->sge_array = kmalloc(sizeof(struct lpfc_mbx_nembed_sge_virt),
 
1758
        mbox->sge_array = kzalloc(sizeof(struct lpfc_mbx_nembed_sge_virt),
1743
1759
                                  GFP_KERNEL);
1744
1760
        if (!mbox->sge_array) {
1745
1761
                lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
1789
1805
        /* The sub-header is in DMA memory, which needs endian converstion */
1790
1806
        if (cfg_shdr)
1791
1807
                lpfc_sli_pcimem_bcopy(cfg_shdr, cfg_shdr,
1792
 
                              sizeof(union  lpfc_sli4_cfg_shdr));
1793
 
 
 
1808
                                      sizeof(union  lpfc_sli4_cfg_shdr));
1794
1809
        return alloc_len;
1795
1810
}
1796
1811
 
1797
1812
/**
 
1813
 * lpfc_sli4_mbox_rsrc_extent - Initialize the opcode resource extent.
 
1814
 * @phba: pointer to lpfc hba data structure.
 
1815
 * @mbox: pointer to an allocated lpfc mbox resource.
 
1816
 * @exts_count: the number of extents, if required, to allocate.
 
1817
 * @rsrc_type: the resource extent type.
 
1818
 * @emb: true if LPFC_SLI4_MBX_EMBED. false if LPFC_SLI4_MBX_NEMBED.
 
1819
 *
 
1820
 * This routine completes the subcommand header for SLI4 resource extent
 
1821
 * mailbox commands.  It is called after lpfc_sli4_config.  The caller must
 
1822
 * pass an allocated mailbox and the attributes required to initialize the
 
1823
 * mailbox correctly.
 
1824
 *
 
1825
 * Return: the actual length of the mbox command allocated.
 
1826
 **/
 
1827
int
 
1828
lpfc_sli4_mbox_rsrc_extent(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
 
1829
                           uint16_t exts_count, uint16_t rsrc_type, bool emb)
 
1830
{
 
1831
        uint8_t opcode = 0;
 
1832
        struct lpfc_mbx_nembed_rsrc_extent *n_rsrc_extnt = NULL;
 
1833
        void *virtaddr = NULL;
 
1834
 
 
1835
        /* Set up SLI4 ioctl command header fields */
 
1836
        if (emb == LPFC_SLI4_MBX_NEMBED) {
 
1837
                /* Get the first SGE entry from the non-embedded DMA memory */
 
1838
                virtaddr = mbox->sge_array->addr[0];
 
1839
                if (virtaddr == NULL)
 
1840
                        return 1;
 
1841
                n_rsrc_extnt = (struct lpfc_mbx_nembed_rsrc_extent *) virtaddr;
 
1842
        }
 
1843
 
 
1844
        /*
 
1845
         * The resource type is common to all extent Opcodes and resides in the
 
1846
         * same position.
 
1847
         */
 
1848
        if (emb == LPFC_SLI4_MBX_EMBED)
 
1849
                bf_set(lpfc_mbx_alloc_rsrc_extents_type,
 
1850
                       &mbox->u.mqe.un.alloc_rsrc_extents.u.req,
 
1851
                       rsrc_type);
 
1852
        else {
 
1853
                /* This is DMA data.  Byteswap is required. */
 
1854
                bf_set(lpfc_mbx_alloc_rsrc_extents_type,
 
1855
                       n_rsrc_extnt, rsrc_type);
 
1856
                lpfc_sli_pcimem_bcopy(&n_rsrc_extnt->word4,
 
1857
                                      &n_rsrc_extnt->word4,
 
1858
                                      sizeof(uint32_t));
 
1859
        }
 
1860
 
 
1861
        /* Complete the initialization for the particular Opcode. */
 
1862
        opcode = lpfc_sli4_mbox_opcode_get(phba, mbox);
 
1863
        switch (opcode) {
 
1864
        case LPFC_MBOX_OPCODE_ALLOC_RSRC_EXTENT:
 
1865
                if (emb == LPFC_SLI4_MBX_EMBED)
 
1866
                        bf_set(lpfc_mbx_alloc_rsrc_extents_cnt,
 
1867
                               &mbox->u.mqe.un.alloc_rsrc_extents.u.req,
 
1868
                               exts_count);
 
1869
                else
 
1870
                        bf_set(lpfc_mbx_alloc_rsrc_extents_cnt,
 
1871
                               n_rsrc_extnt, exts_count);
 
1872
                break;
 
1873
        case LPFC_MBOX_OPCODE_GET_ALLOC_RSRC_EXTENT:
 
1874
        case LPFC_MBOX_OPCODE_GET_RSRC_EXTENT_INFO:
 
1875
        case LPFC_MBOX_OPCODE_DEALLOC_RSRC_EXTENT:
 
1876
                /* Initialization is complete.*/
 
1877
                break;
 
1878
        default:
 
1879
                lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
 
1880
                                "2929 Resource Extent Opcode x%x is "
 
1881
                                "unsupported\n", opcode);
 
1882
                return 1;
 
1883
        }
 
1884
 
 
1885
        return 0;
 
1886
}
 
1887
 
 
1888
/**
1798
1889
 * lpfc_sli4_mbox_opcode_get - Get the opcode from a sli4 mailbox command
1799
1890
 * @phba: pointer to lpfc hba data structure.
1800
1891
 * @mbox: pointer to lpfc mbox command.
1833
1924
 * @fcf_index: index to fcf table.
1834
1925
 *
1835
1926
 * This routine routine allocates and constructs non-embedded mailbox command
1836
 
 * for reading a FCF table entry refered by @fcf_index.
 
1927
 * for reading a FCF table entry referred by @fcf_index.
1837
1928
 *
1838
1929
 * Return: pointer to the mailbox command constructed if successful, otherwise
1839
1930
 * NULL.
1902
1993
 
1903
1994
        /* Set up host requested features. */
1904
1995
        bf_set(lpfc_mbx_rq_ftr_rq_fcpi, &mboxq->u.mqe.un.req_ftrs, 1);
 
1996
        bf_set(lpfc_mbx_rq_ftr_rq_perfh, &mboxq->u.mqe.un.req_ftrs, 1);
1905
1997
 
1906
1998
        /* Enable DIF (block guard) only if configured to do so. */
1907
1999
        if (phba->cfg_enable_bg)
1937
2029
        bf_set(lpfc_init_vfi_vr, init_vfi, 1);
1938
2030
        bf_set(lpfc_init_vfi_vt, init_vfi, 1);
1939
2031
        bf_set(lpfc_init_vfi_vp, init_vfi, 1);
1940
 
        bf_set(lpfc_init_vfi_vfi, init_vfi, vport->vfi + vport->phba->vfi_base);
1941
 
        bf_set(lpfc_init_vpi_vpi, init_vfi, vport->vpi + vport->phba->vpi_base);
1942
 
        bf_set(lpfc_init_vfi_fcfi, init_vfi, vport->phba->fcf.fcfi);
 
2032
        bf_set(lpfc_init_vfi_vfi, init_vfi,
 
2033
               vport->phba->sli4_hba.vfi_ids[vport->vfi]);
 
2034
        bf_set(lpfc_init_vpi_vpi, init_vfi,
 
2035
               vport->phba->vpi_ids[vport->vpi]);
 
2036
        bf_set(lpfc_init_vfi_fcfi, init_vfi,
 
2037
               vport->phba->fcf.fcfi);
1943
2038
}
1944
2039
 
1945
2040
/**
1962
2057
        reg_vfi = &mbox->u.mqe.un.reg_vfi;
1963
2058
        bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_VFI);
1964
2059
        bf_set(lpfc_reg_vfi_vp, reg_vfi, 1);
1965
 
        bf_set(lpfc_reg_vfi_vfi, reg_vfi, vport->vfi + vport->phba->vfi_base);
 
2060
        bf_set(lpfc_reg_vfi_vfi, reg_vfi,
 
2061
               vport->phba->sli4_hba.vfi_ids[vport->vfi]);
1966
2062
        bf_set(lpfc_reg_vfi_fcfi, reg_vfi, vport->phba->fcf.fcfi);
1967
 
        bf_set(lpfc_reg_vfi_vpi, reg_vfi, vport->vpi + vport->phba->vpi_base);
 
2063
        bf_set(lpfc_reg_vfi_vpi, reg_vfi, vport->phba->vpi_ids[vport->vpi]);
1968
2064
        memcpy(reg_vfi->wwn, &vport->fc_portname, sizeof(struct lpfc_name));
1969
2065
        reg_vfi->wwn[0] = cpu_to_le32(reg_vfi->wwn[0]);
1970
2066
        reg_vfi->wwn[1] = cpu_to_le32(reg_vfi->wwn[1]);
1995
2091
        memset(mbox, 0, sizeof(*mbox));
1996
2092
        bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VPI);
1997
2093
        bf_set(lpfc_init_vpi_vpi, &mbox->u.mqe.un.init_vpi,
1998
 
               vpi + phba->vpi_base);
 
2094
               phba->vpi_ids[vpi]);
1999
2095
        bf_set(lpfc_init_vpi_vfi, &mbox->u.mqe.un.init_vpi,
2000
 
               phba->pport->vfi + phba->vfi_base);
 
2096
               phba->sli4_hba.vfi_ids[phba->pport->vfi]);
2001
2097
}
2002
2098
 
2003
2099
/**
2017
2113
        memset(mbox, 0, sizeof(*mbox));
2018
2114
        bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_UNREG_VFI);
2019
2115
        bf_set(lpfc_unreg_vfi_vfi, &mbox->u.mqe.un.unreg_vfi,
2020
 
               vport->vfi + vport->phba->vfi_base);
 
2116
               vport->phba->sli4_hba.vfi_ids[vport->vfi]);
2021
2117
}
2022
2118
 
2023
2119
/**
2129
2225
void
2130
2226
lpfc_resume_rpi(struct lpfcMboxq *mbox, struct lpfc_nodelist *ndlp)
2131
2227
{
 
2228
        struct lpfc_hba *phba = ndlp->phba;
2132
2229
        struct lpfc_mbx_resume_rpi *resume_rpi;
2133
2230
 
2134
2231
        memset(mbox, 0, sizeof(*mbox));
2135
2232
        resume_rpi = &mbox->u.mqe.un.resume_rpi;
2136
2233
        bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_RESUME_RPI);
2137
 
        bf_set(lpfc_resume_rpi_index, resume_rpi, ndlp->nlp_rpi);
 
2234
        bf_set(lpfc_resume_rpi_index, resume_rpi,
 
2235
               phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
2138
2236
        bf_set(lpfc_resume_rpi_ii, resume_rpi, RESUME_INDEX_RPI);
2139
2237
        resume_rpi->event_tag = ndlp->phba->fc_eventTag;
2140
2238
}
2159
2257
}
2160
2258
 
2161
2259
/**
2162
 
 * lpfc_sli4_params - Initialize the PORT_CAPABILITIES SLI4 Params
2163
 
 *                    mailbox command.
 
2260
 * lpfc_pc_sli4_params - Initialize the PORT_CAPABILITIES SLI4 Params mbox cmd.
2164
2261
 * @mbox: pointer to lpfc mbox command to initialize.
2165
2262
 *
2166
2263
 * The PORT_CAPABILITIES SLI4 parameters mailbox command is issued to
2167
2264
 * retrieve the particular SLI4 features supported by the port.
2168
2265
 **/
2169
2266
void
2170
 
lpfc_sli4_params(struct lpfcMboxq *mbox)
 
2267
lpfc_pc_sli4_params(struct lpfcMboxq *mbox)
2171
2268
{
2172
 
        struct lpfc_mbx_sli4_params *sli4_params;
 
2269
        struct lpfc_mbx_pc_sli4_params *sli4_params;
2173
2270
 
2174
2271
        memset(mbox, 0, sizeof(*mbox));
2175
2272
        sli4_params = &mbox->u.mqe.un.sli4_params;