Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: lpfc: vmid: Add support for VMID in mailbox command

Add supporting datastructures for mailbox command which helps in
determining if the firmware supports appid. Allocate resources for VMID at
initialization time and clean them up on removal.

Link: https://lore.kernel.org/r/20210608043556.274139-7-muneendra.kumar@broadcom.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Gaurav Srivastava <gaurav.srivastava@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Muneendra Kumar <muneendra.kumar@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Gaurav Srivastava and committed by
Martin K. Petersen
5e633302 7ba2272c

+114
+12
drivers/scsi/lpfc/lpfc_hw4.h
··· 273 273 #define lpfc_vfi_rsrc_rdy_MASK 0x00000001 274 274 #define lpfc_vfi_rsrc_rdy_WORD word0 275 275 #define LPFC_VFI_RSRC_RDY 1 276 + #define lpfc_ftr_ashdr_SHIFT 4 277 + #define lpfc_ftr_ashdr_MASK 0x00000001 278 + #define lpfc_ftr_ashdr_WORD word0 276 279 }; 277 280 278 281 struct sli4_bls_rsp { ··· 2947 2944 #define lpfc_mbx_rq_ftr_rq_mrqp_SHIFT 16 2948 2945 #define lpfc_mbx_rq_ftr_rq_mrqp_MASK 0x00000001 2949 2946 #define lpfc_mbx_rq_ftr_rq_mrqp_WORD word2 2947 + #define lpfc_mbx_rq_ftr_rq_ashdr_SHIFT 17 2948 + #define lpfc_mbx_rq_ftr_rq_ashdr_MASK 0x00000001 2949 + #define lpfc_mbx_rq_ftr_rq_ashdr_WORD word2 2950 2950 uint32_t word3; 2951 2951 #define lpfc_mbx_rq_ftr_rsp_iaab_SHIFT 0 2952 2952 #define lpfc_mbx_rq_ftr_rsp_iaab_MASK 0x00000001 ··· 2981 2975 #define lpfc_mbx_rq_ftr_rsp_mrqp_SHIFT 16 2982 2976 #define lpfc_mbx_rq_ftr_rsp_mrqp_MASK 0x00000001 2983 2977 #define lpfc_mbx_rq_ftr_rsp_mrqp_WORD word3 2978 + #define lpfc_mbx_rq_ftr_rsp_ashdr_SHIFT 17 2979 + #define lpfc_mbx_rq_ftr_rsp_ashdr_MASK 0x00000001 2980 + #define lpfc_mbx_rq_ftr_rsp_ashdr_WORD word3 2984 2981 }; 2985 2982 2986 2983 struct lpfc_mbx_memory_dump_type3 { ··· 4228 4219 #define wqe_xchg_WORD word10 4229 4220 #define LPFC_SCSI_XCHG 0x0 4230 4221 #define LPFC_NVME_XCHG 0x1 4222 + #define wqe_appid_SHIFT 5 4223 + #define wqe_appid_MASK 0x00000001 4224 + #define wqe_appid_WORD word10 4231 4225 #define wqe_oas_SHIFT 6 4232 4226 #define wqe_oas_MASK 0x00000001 4233 4227 #define wqe_oas_WORD word10
+62
drivers/scsi/lpfc/lpfc_init.c
··· 98 98 static struct scsi_transport_template *lpfc_vport_transport_template = NULL; 99 99 static DEFINE_IDR(lpfc_hba_index); 100 100 #define LPFC_NVMET_BUF_POST 254 101 + static int lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport); 101 102 102 103 /** 103 104 * lpfc_config_port_prep - Perform lpfc initialization prior to config port ··· 2889 2888 if (phba->link_state > LPFC_LINK_DOWN) 2890 2889 lpfc_port_link_failure(vport); 2891 2890 2891 + /* Clean up VMID resources */ 2892 + if (lpfc_is_vmid_enabled(phba)) 2893 + lpfc_vmid_vport_cleanup(vport); 2894 + 2892 2895 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { 2893 2896 if (vport->port_type != LPFC_PHYSICAL_PORT && 2894 2897 ndlp->nlp_DID == Fabric_DID) { ··· 4313 4308 } 4314 4309 4315 4310 /** 4311 + * lpfc_vmid_res_alloc - Allocates resources for VMID 4312 + * @phba: pointer to lpfc hba data structure. 4313 + * @vport: pointer to vport data structure 4314 + * 4315 + * This routine allocated the resources needed for the VMID. 4316 + * 4317 + * Return codes 4318 + * 0 on Success 4319 + * Non-0 on Failure 4320 + */ 4321 + static int 4322 + lpfc_vmid_res_alloc(struct lpfc_hba *phba, struct lpfc_vport *vport) 4323 + { 4324 + /* VMID feature is supported only on SLI4 */ 4325 + if (phba->sli_rev == LPFC_SLI_REV3) { 4326 + phba->cfg_vmid_app_header = 0; 4327 + phba->cfg_vmid_priority_tagging = 0; 4328 + } 4329 + 4330 + if (lpfc_is_vmid_enabled(phba)) { 4331 + vport->vmid = 4332 + kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), 4333 + GFP_KERNEL); 4334 + if (!vport->vmid) 4335 + return -ENOMEM; 4336 + 4337 + rwlock_init(&vport->vmid_lock); 4338 + 4339 + /* Set the VMID parameters for the vport */ 4340 + vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; 4341 + vport->vmid_inactivity_timeout = 4342 + phba->cfg_vmid_inactivity_timeout; 4343 + vport->max_vmid = phba->cfg_max_vmid; 4344 + vport->cur_vmid_cnt = 0; 4345 + 4346 + vport->vmid_priority_range = bitmap_zalloc 4347 + (LPFC_VMID_MAX_PRIORITY_RANGE, GFP_KERNEL); 4348 + 4349 + if (!vport->vmid_priority_range) { 4350 + kfree(vport->vmid); 4351 + return -ENOMEM; 4352 + } 4353 + 4354 + hash_init(vport->hash_table); 4355 + } 4356 + return 0; 4357 + } 4358 + 4359 + /** 4316 4360 * lpfc_create_port - Create an FC port 4317 4361 * @phba: pointer to lpfc hba data structure. 4318 4362 * @instance: a unique integer ID to this FC port. ··· 4513 4459 vport->port_type, shost->sg_tablesize, 4514 4460 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); 4515 4461 4462 + /* Allocate the resources for VMID */ 4463 + rc = lpfc_vmid_res_alloc(phba, vport); 4464 + 4465 + if (rc) 4466 + goto out; 4467 + 4516 4468 /* Initialize all internally managed lists. */ 4517 4469 INIT_LIST_HEAD(&vport->fc_nodes); 4518 4470 INIT_LIST_HEAD(&vport->rcv_buffer_list); ··· 4543 4483 return vport; 4544 4484 4545 4485 out_put_shost: 4486 + kfree(vport->vmid); 4487 + bitmap_free(vport->vmid_priority_range); 4546 4488 scsi_host_put(shost); 4547 4489 out: 4548 4490 return NULL;
+6
drivers/scsi/lpfc/lpfc_mbox.c
··· 2101 2101 bf_set(lpfc_mbx_rq_ftr_rq_iaab, &mboxq->u.mqe.un.req_ftrs, 0); 2102 2102 bf_set(lpfc_mbx_rq_ftr_rq_iaar, &mboxq->u.mqe.un.req_ftrs, 0); 2103 2103 } 2104 + 2105 + /* Enable Application Services Header for appheader VMID */ 2106 + if (phba->cfg_vmid_app_header) { 2107 + bf_set(lpfc_mbx_rq_ftr_rq_ashdr, &mboxq->u.mqe.un.req_ftrs, 1); 2108 + bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 1); 2109 + } 2104 2110 return; 2105 2111 } 2106 2112
+25
drivers/scsi/lpfc/lpfc_scsi.c
··· 5399 5399 return 0; 5400 5400 } 5401 5401 5402 + /* 5403 + * lpfc_vmid_vport_cleanup - cleans up the resources associated with a vport 5404 + * @vport: The virtual port for which this call is being executed. 5405 + */ 5406 + void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport) 5407 + { 5408 + u32 bucket; 5409 + struct lpfc_vmid *cur; 5410 + 5411 + if (vport->port_type == LPFC_PHYSICAL_PORT) 5412 + del_timer_sync(&vport->phba->inactive_vmid_poll); 5413 + 5414 + kfree(vport->qfpa_res); 5415 + kfree(vport->vmid_priority.vmid_range); 5416 + kfree(vport->vmid); 5417 + 5418 + if (!hash_empty(vport->hash_table)) 5419 + hash_for_each(vport->hash_table, bucket, cur, hnode) 5420 + hash_del(&cur->hnode); 5421 + 5422 + vport->qfpa_res = NULL; 5423 + vport->vmid_priority.vmid_range = NULL; 5424 + vport->vmid = NULL; 5425 + vport->cur_vmid_cnt = 0; 5426 + } 5402 5427 5403 5428 /** 5404 5429 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
+9
drivers/scsi/lpfc/lpfc_sli.c
··· 7699 7699 goto out_free_mbox; 7700 7700 } 7701 7701 7702 + /* Disable VMID if app header is not supported */ 7703 + if (phba->cfg_vmid_app_header && !(bf_get(lpfc_mbx_rq_ftr_rsp_ashdr, 7704 + &mqe->un.req_ftrs))) { 7705 + bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 0); 7706 + phba->cfg_vmid_app_header = 0; 7707 + lpfc_printf_log(phba, KERN_DEBUG, LOG_SLI, 7708 + "1242 vmid feature not supported\n"); 7709 + } 7710 + 7702 7711 /* 7703 7712 * The port must support FCP initiator mode as this is the 7704 7713 * only mode running in the host.