/* * API corresponding to VmWare's NPIV_VPORT_GETINFO. */ void bfa_fcs_port_get_info(struct bfa_fcs_port_s *port, struct bfa_port_info_s *port_info) { bfa_trc(port->fcs, port->fabric->fabric_name); if (port->vport == NULL) { /* * This is a Physical port */ port_info->port_type = BFA_PORT_TYPE_PHYSICAL; /* * @todo : need to fix the state & reason */ port_info->port_state = 0; port_info->offline_reason = 0; port_info->port_wwn = bfa_fcs_port_get_pwwn(port); port_info->node_wwn = bfa_fcs_port_get_nwwn(port); port_info->max_vports_supp = bfa_lps_get_max_vport(port->fcs->bfa); port_info->num_vports_inuse = bfa_fcs_fabric_vport_count(port->fabric); port_info->max_rports_supp = BFA_FCS_MAX_RPORTS_SUPP; port_info->num_rports_inuse = port->num_rports; } else { /* * This is a virtual port */ port_info->port_type = BFA_PORT_TYPE_VIRTUAL; /* * @todo : need to fix the state & reason */ port_info->port_state = 0; port_info->offline_reason = 0; port_info->port_wwn = bfa_fcs_port_get_pwwn(port); port_info->node_wwn = bfa_fcs_port_get_nwwn(port); } }
static ssize_t bfad_im_node_name_show(struct class_device *dev, char *buf) { struct Scsi_Host *shost = class_to_shost(dev); struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0]; struct bfad_port_s *port = im_port->port; u64 nwwn; nwwn = bfa_fcs_port_get_nwwn(port->fcs_port); return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn)); }
static u16 bfa_fcs_port_fdmi_build_rhba_pyld(struct bfa_fcs_port_fdmi_s *fdmi, u8 *pyld) { struct bfa_fcs_port_s *port = fdmi->ms->port; struct bfa_fcs_fdmi_hba_attr_s hba_attr; /* @todo */ struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr = &hba_attr; /* @todo */ struct fdmi_rhba_s *rhba = (struct fdmi_rhba_s *) pyld; struct fdmi_attr_s *attr; u8 *curr_ptr; u16 len, count; /* * get hba attributes */ bfa_fcs_fdmi_get_hbaattr(fdmi, fcs_hba_attr); rhba->hba_id = bfa_fcs_port_get_pwwn(port); rhba->port_list.num_ports = bfa_os_htonl(1); rhba->port_list.port_entry = bfa_fcs_port_get_pwwn(port); len = sizeof(rhba->hba_id) + sizeof(rhba->port_list); count = 0; len += sizeof(rhba->hba_attr_blk.attr_count); /* * fill out the invididual entries of the HBA attrib Block */ curr_ptr = (u8 *) &rhba->hba_attr_blk.hba_attr; /* * Node Name */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_NODENAME); attr->len = sizeof(wwn_t); memcpy(attr->value, &bfa_fcs_port_get_nwwn(port), attr->len); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Manufacturer */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MANUFACTURER); attr->len = (u16) strlen(fcs_hba_attr->manufacturer); memcpy(attr->value, fcs_hba_attr->manufacturer, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Serial Number */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_SERIALNUM); attr->len = (u16) strlen(fcs_hba_attr->serial_num); memcpy(attr->value, fcs_hba_attr->serial_num, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Model */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MODEL); attr->len = (u16) strlen(fcs_hba_attr->model); memcpy(attr->value, fcs_hba_attr->model, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Model Desc */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MODEL_DESC); attr->len = (u16) strlen(fcs_hba_attr->model_desc); memcpy(attr->value, fcs_hba_attr->model_desc, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * H/W Version */ if (fcs_hba_attr->hw_version[0] != '\0') { attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_HW_VERSION); attr->len = (u16) strlen(fcs_hba_attr->hw_version); memcpy(attr->value, fcs_hba_attr->hw_version, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); } /* * Driver Version */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_DRIVER_VERSION); attr->len = (u16) strlen(fcs_hba_attr->driver_version); memcpy(attr->value, fcs_hba_attr->driver_version, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len;; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Option Rom Version */ if (fcs_hba_attr->option_rom_ver[0] != '\0') { attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_ROM_VERSION); attr->len = (u16) strlen(fcs_hba_attr->option_rom_ver); memcpy(attr->value, fcs_hba_attr->option_rom_ver, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); } /* * f/w Version = driver version */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_FW_VERSION); attr->len = (u16) strlen(fcs_hba_attr->driver_version); memcpy(attr->value, fcs_hba_attr->driver_version, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * OS Name */ if (fcs_hba_attr->os_name[0] != '\0') { attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_OS_NAME); attr->len = (u16) strlen(fcs_hba_attr->os_name); memcpy(attr->value, fcs_hba_attr->os_name, attr->len); /* variable fields need to be 4 byte aligned */ attr->len = fc_roundup(attr->len, sizeof(u32)); curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len; len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); } /* * MAX_CT_PAYLOAD */ attr = (struct fdmi_attr_s *) curr_ptr; attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MAX_CT); attr->len = sizeof(fcs_hba_attr->max_ct_pyld); memcpy(attr->value, &fcs_hba_attr->max_ct_pyld, attr->len); len += attr->len; count++; attr->len = bfa_os_htons(attr->len + sizeof(attr->type) + sizeof(attr->len)); /* * Update size of payload */ len += ((sizeof(attr->type) + sizeof(attr->len)) * count); rhba->hba_attr_blk.attr_count = bfa_os_htonl(count); return len; }