static ssize_t bfad_im_vport_create(struct class_device *cdev, const char *buf, size_t count) { struct Scsi_Host *shost = class_to_shost(cdev); struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; struct bfa_port_cfg_s port_cfg; u8 wwn[8]; int status; memset(&port_cfg, 0, sizeof(port_cfg)); status = bfad_im_parse_wwn(&buf[0], wwn); if (status) return status; memcpy(&port_cfg.pwwn, wwn, sizeof(wwn)); status = bfad_im_parse_wwn(&buf[17], wwn); if (status) return status; memcpy(&port_cfg.nwwn, wwn, sizeof(wwn)); port_cfg.roles = BFA_PORT_ROLE_FCP_IM; status = bfad_vport_create(bfad, 0, &port_cfg); if (status != BFA_STATUS_OK) return -EIO; return count; }
static int bfad_im_vport_create(struct fc_vport *fc_vport, bool disable) { char *vname = fc_vport->symbolic_name; struct Scsi_Host *shost = fc_vport->shost; struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_s *bfad = im_port->bfad; struct bfa_port_cfg_s port_cfg; int status = 0, rc; unsigned long flags; memset(&port_cfg, 0, sizeof(port_cfg)); port_cfg.pwwn = wwn_to_u64((u8 *) &fc_vport->port_name); port_cfg.nwwn = wwn_to_u64((u8 *) &fc_vport->node_name); if (strlen(vname) > 0) strcpy((char *)&port_cfg.sym_name, vname); port_cfg.roles = BFA_PORT_ROLE_FCP_IM; rc = bfad_vport_create(bfad, 0, &port_cfg, &fc_vport->dev); if (rc == BFA_STATUS_OK) { struct bfad_vport_s *vport; struct bfa_fcs_vport_s *fcs_vport; struct Scsi_Host *vshost; spin_lock_irqsave(&bfad->bfad_lock, flags); fcs_vport = bfa_fcs_vport_lookup(&bfad->bfa_fcs, 0, port_cfg.pwwn); if (fcs_vport == NULL) { spin_unlock_irqrestore(&bfad->bfad_lock, flags); return VPCERR_BAD_WWN; } fc_vport_set_state(fc_vport, FC_VPORT_ACTIVE); if (disable) { bfa_fcs_vport_stop(fcs_vport); fc_vport_set_state(fc_vport, FC_VPORT_DISABLED); } spin_unlock_irqrestore(&bfad->bfad_lock, flags); vport = fcs_vport->vport_drv; vshost = vport->drv_port.im_port->shost; fc_host_node_name(vshost) = wwn_to_u64((u8 *) &port_cfg.nwwn); fc_host_port_name(vshost) = wwn_to_u64((u8 *) &port_cfg.pwwn); fc_vport->dd_data = vport; vport->drv_port.im_port->fc_vport = fc_vport; } else if (rc == BFA_STATUS_INVALID_WWN) return VPCERR_BAD_WWN; else if (rc == BFA_STATUS_VPORT_EXISTS) return VPCERR_BAD_WWN; else if (rc == BFA_STATUS_VPORT_MAX) return VPCERR_NO_FABRIC_SUPP; else if (rc == BFA_STATUS_VPORT_WWN_BP) return VPCERR_BAD_WWN; else return FC_VPORT_FAILED; return status; }