738
740
memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
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)
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 */
800
803
memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
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];
806
810
mb->mbxCommand = MBX_UNREG_LOGIN;
807
811
mb->mbxOwner = OWN_HOST;
826
830
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
828
lpfc_unreg_login(phba, vport->vpi,
829
vport->vpi + phba->vpi_base, mbox);
830
mbox->u.mb.un.varUnregLogin.rsvd1 = 0x4000 ;
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.
839
lpfc_unreg_login(phba, vport->vpi, phba->vpi_ids[vport->vpi],
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;
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];
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));
904
if (phba->sli_rev < LPFC_SLI_REV4)
905
mb->un.varUnregVpi.vpi = vpi + phba->vpi_base;
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];
909
924
mb->mbxCommand = MBX_UNREG_VPI;
910
925
mb->mbxOwner = OWN_HOST;
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;
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),
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 */
1791
1807
lpfc_sli_pcimem_bcopy(cfg_shdr, cfg_shdr,
1792
sizeof(union lpfc_sli4_cfg_shdr));
1808
sizeof(union lpfc_sli4_cfg_shdr));
1794
1809
return alloc_len;
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.
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.
1825
* Return: the actual length of the mbox command allocated.
1828
lpfc_sli4_mbox_rsrc_extent(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
1829
uint16_t exts_count, uint16_t rsrc_type, bool emb)
1832
struct lpfc_mbx_nembed_rsrc_extent *n_rsrc_extnt = NULL;
1833
void *virtaddr = NULL;
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)
1841
n_rsrc_extnt = (struct lpfc_mbx_nembed_rsrc_extent *) virtaddr;
1845
* The resource type is common to all extent Opcodes and resides in the
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,
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,
1861
/* Complete the initialization for the particular Opcode. */
1862
opcode = lpfc_sli4_mbox_opcode_get(phba, mbox);
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,
1870
bf_set(lpfc_mbx_alloc_rsrc_extents_cnt,
1871
n_rsrc_extnt, exts_count);
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.*/
1879
lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
1880
"2929 Resource Extent Opcode x%x is "
1881
"unsupported\n", opcode);
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.
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);
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]);
2130
2226
lpfc_resume_rpi(struct lpfcMboxq *mbox, struct lpfc_nodelist *ndlp)
2228
struct lpfc_hba *phba = ndlp->phba;
2132
2229
struct lpfc_mbx_resume_rpi *resume_rpi;
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;
2162
* lpfc_sli4_params - Initialize the PORT_CAPABILITIES SLI4 Params
2260
* lpfc_pc_sli4_params - Initialize the PORT_CAPABILITIES SLI4 Params mbox cmd.
2164
2261
* @mbox: pointer to lpfc mbox command to initialize.
2166
2263
* The PORT_CAPABILITIES SLI4 parameters mailbox command is issued to
2167
2264
* retrieve the particular SLI4 features supported by the port.
2170
lpfc_sli4_params(struct lpfcMboxq *mbox)
2267
lpfc_pc_sli4_params(struct lpfcMboxq *mbox)
2172
struct lpfc_mbx_sli4_params *sli4_params;
2269
struct lpfc_mbx_pc_sli4_params *sli4_params;
2174
2271
memset(mbox, 0, sizeof(*mbox));
2175
2272
sli4_params = &mbox->u.mqe.un.sli4_params;