/* This function searches the @phba for a vport that matches the content of the @fc_hdr passed in and the @fcfi. This function uses the @fc_hdr to fetch the VFI, if the Virtual Fabric Tagging Header exists, and the DID. This function returns the matching vport pointer or NULL if unable to match frame to a vport.  */
static struct lpfc_vport* lpfc_fc_frame_to_vport(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr, uint16_t fcfi)
/* This function searches the @phba for a vport that matches the content of the @fc_hdr passed in and the @fcfi. This function uses the @fc_hdr to fetch the VFI, if the Virtual Fabric Tagging Header exists, and the DID. This function returns the matching vport pointer or NULL if unable to match frame to a vport.  */
static struct lpfc_vport* lpfc_fc_frame_to_vport(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr, uint16_t fcfi)
{
	struct lpfc_vport **vports;
	struct lpfc_vport *vport = NULL;
	int i;
	uint32_t did = (fc_hdr->fh_d_id[0] << 16 |
			fc_hdr->fh_d_id[1] << 8 |
			fc_hdr->fh_d_id[2]);
	vports = lpfc_create_vport_work_array(phba);
	if (vports != NULL)
		for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
			if (phba->fcf.fcfi == fcfi &&
			    vports[i]->vfi == lpfc_fc_hdr_get_vfi(fc_hdr) &&
			    vports[i]->fc_myDID == did) {
				vport = vports[i];
				break;
			}
		}
	lpfc_destroy_vport_work_array(phba, vports);
	return vport;
}