static void ccmni_make_etherframe(void *_eth_hdr, unsigned char *mac_addr, unsigned int packet_type) { struct ethhdr *eth_hdr = _eth_hdr; memcpy(eth_hdr->h_dest, mac_addr, sizeof(eth_hdr->h_dest)); memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_source)); if (packet_type == 0x60) eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IPV6); else eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IP); }
static void ccmni_make_etherframe(void *_eth_hdr, u8 *mac_addr, int packet_type) { struct ethhdr *eth_hdr = _eth_hdr; memcpy(eth_hdr->h_dest, mac_addr, sizeof(eth_hdr->h_dest)); memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_source)); if(packet_type == IPV6_VERSION){ eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IPV6); }else{ eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IP); } }
static int __devinit ina3221_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ina3221_data *data; int ret, i; data = devm_kzalloc(&client->dev, sizeof(struct ina3221_data), GFP_KERNEL); if (!data) { ret = -ENOMEM; goto exit; } i2c_set_clientdata(client, data); data->plat_data = client->dev.platform_data; mutex_init(&data->mutex); data->mode = TRIGGERED; data->shutdown_complete = 0; /* reset ina3221 */ ret = i2c_smbus_write_word_data(client, INA3221_CONFIG, __constant_cpu_to_be16((INA3221_RESET))); if (ret < 0) { dev_err(&client->dev, "ina3221 reset failure status: 0x%x\n", ret); goto exit_free; } for (i = 0; i < ARRAY_SIZE(ina3221); i++) { ret = device_create_file(&client->dev, &ina3221[i].dev_attr); if (ret) { dev_err(&client->dev, "device_create_file failed.\n"); goto exit_remove; } } data->client = client; data->nb.notifier_call = ina3221_hotplug_notify; register_hotcpu_notifier(&(data->nb)); data->hwmon_dev = hwmon_device_register(&client->dev); if (IS_ERR(data->hwmon_dev)) { ret = PTR_ERR(data->hwmon_dev); goto exit_remove; } /* set ina3221 to power down mode */ ret = __locked_power_down_ina3221(client); if (ret < 0) goto exit_remove; return 0; exit_remove: while (i--) device_remove_file(&client->dev, &ina3221[i].dev_attr); exit_free: devm_kfree(&client->dev, data); exit: return ret; }
/* Does address match the link local multicast address. * 01:80:c2:00:00:0X */ static inline int is_link_local(const unsigned char *dest) { const u16 *a = (const u16 *) dest; static const u16 *const b = (const u16 *const ) br_group_address; static const u16 m = __constant_cpu_to_be16(0xfff0); return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0; }
s32 ina230_get_current(void) { struct i2c_client *client; struct ina230_data *data; s32 current_mA; int retval; if (!p_ina230_data) return INA230_ERROR; client = p_ina230_data->client; data = p_ina230_data; mutex_lock(&data->mutex); /* fill calib data */ retval = i2c_smbus_write_word_data(client, INA230_CAL, __constant_cpu_to_be16(data->pdata->calibration_data)); if (retval < 0) { dev_err(&client->dev, "calibration data write failed sts: 0x%x\n", retval); mutex_unlock(&data->mutex); return INA230_ERROR; } retval = ensure_enabled_start(client); if (retval < 0) { mutex_unlock(&data->mutex); return INA230_ERROR; } retval = __locked_wait_for_conversion(&client->dev); if (retval) { mutex_unlock(&data->mutex); return INA230_ERROR; } /* getting current readings in milli amps*/ retval = i2c_smbus_read_word_data(client, INA230_CURRENT); if (retval < 0) { mutex_unlock(&data->mutex); return INA230_ERROR; } current_mA = (s16) be16_to_cpu(retval); ensure_enabled_end(client); mutex_unlock(&data->mutex); if (data->pdata->shunt_polarity_inverted) current_mA *= -1; current_mA *= (s16) data->pdata->power_lsb; if (data->pdata->divisor) current_mA /= (s16) data->pdata->divisor; if (data->pdata->precision_multiplier) current_mA /= (s16) data->pdata->precision_multiplier; return current_mA; }
/** * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. * @ha: HA context * @list: switch info entries to populate * * Returns 0 on success. */ int qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_gpn_id(ha, list)); } for (i = 0; i < MAX_FIBRE_DEVICES; i++) { /* Issue GPN_ID */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GPN_ID_REQ_SIZE, GPN_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, GPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id */ ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed " "(%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected " "request, gpn_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Save portname */ memcpy(list[i].port_name, ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); } /* Last device exit. */ if (list[i].d_id.b.rsvd_1 != 0) break; } return (rval); }
static s32 show_current(struct device *dev, struct device_attribute *attr, char *buf) { struct i2c_client *client = to_i2c_client(dev); struct ina230_data *data = i2c_get_clientdata(client); s32 current_mA; int retval; mutex_lock(&data->mutex); /* fill calib data */ retval = i2c_smbus_write_word_data(client, INA230_CAL, __constant_cpu_to_be16(data->pdata->calibration_data)); if (retval < 0) { dev_err(dev, "calibration data write failed sts: 0x%x\n", retval); mutex_unlock(&data->mutex); return retval; } retval = ensure_enabled_start(client); if (retval < 0) { mutex_unlock(&data->mutex); return retval; } retval = __locked_wait_for_conversion(dev); if (retval) { mutex_unlock(&data->mutex); return retval; } /* getting current readings in milli amps*/ retval = i2c_smbus_read_word_data(client, INA230_CURRENT); if (retval < 0) { mutex_unlock(&data->mutex); return retval; } current_mA = (s16) be16_to_cpu(retval); ensure_enabled_end(client); mutex_unlock(&data->mutex); if (data->pdata->shunt_polarity_inverted) current_mA *= -1; current_mA *= (s16) data->pdata->power_lsb; if (data->pdata->divisor) current_mA /= (s16) data->pdata->divisor; if (data->pdata->precision_multiplier) current_mA /= (s16) data->pdata->precision_multiplier; return sprintf(buf, "%d mA\n", current_mA); }
/** * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rff_id(scsi_qla_host_t *ha) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on " "ISP2100/ISP2200.\n", ha->host_no)); return (QLA_SUCCESS); } /* Issue RFF_ID */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, RFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain; ct_req->req.rff_id.port_id[1] = ha->d_id.b.area; ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa; ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): RFF_ID failed, rejected " "request, rff_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n", ha->host_no)); } return (rval); }
static s32 __locked_power_up_ina3221(struct i2c_client *client, int config) { s32 ret; struct ina3221_data *data = i2c_get_clientdata(client); if (data->shutdown_complete) return -ENODEV; ret = i2c_smbus_write_word_data(client, INA3221_CONFIG, __constant_cpu_to_be16(config)); if (ret < 0) dev_err(&client->dev, "Config data write failed, error: 0x%x", ret); return ret; }
static s32 show_power(struct device *dev, struct device_attribute *attr, char *buf) { struct i2c_client *client = to_i2c_client(dev); struct ina230_data *data = i2c_get_clientdata(client); s32 power_mW; int retval; mutex_lock(&data->mutex); /* fill calib data */ retval = i2c_smbus_write_word_data(client, INA230_CAL, __constant_cpu_to_be16(data->pdata->calibration_data)); if (retval < 0) { dev_err(dev, "calibration data write failed sts: 0x%x\n", retval); mutex_unlock(&data->mutex); return retval; } retval = ensure_enabled_start(client); if (retval < 0) { mutex_unlock(&data->mutex); return retval; } retval = __locked_wait_for_conversion(dev); if (retval) { mutex_unlock(&data->mutex); return retval; } /* getting power readings in milli watts*/ power_mW = be16_to_cpu(i2c_smbus_read_word_data(client, INA230_POWER)); if (power_mW < 0) { mutex_unlock(&data->mutex); return -EINVAL; } ensure_enabled_end(client); mutex_unlock(&data->mutex); power_mW = power_mW * data->pdata->power_lsb; if (data->pdata->precision_multiplier) power_mW /= data->pdata->precision_multiplier; return sprintf(buf, "%d mW\n", power_mW); }
static void ensure_enabled_end(struct i2c_client *client) { struct ina230_data *data = i2c_get_clientdata(client); int retval; if (data->running) return; retval = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_POWER_DOWN)); if (retval < 0) dev_err(&client->dev, "power down failure sts: 0x%x\n", retval); }
static int qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt, struct ct_sns_rsp *ct_rsp, const char *routine) { int rval; uint16_t comp_status; struct qla_hw_data *ha = vha->hw; rval = QLA_FUNCTION_FAILED; if (ms_pkt->entry_status != 0) { ql_dbg(ql_dbg_disc, vha, 0x2031, "%s failed, error status (%x) on port_id: %02x%02x%02x.\n", routine, ms_pkt->entry_status, vha->d_id.b.domain, vha->d_id.b.area, vha->d_id.b.al_pa); } else { if (IS_FWI2_CAPABLE(ha)) comp_status = le16_to_cpu( ((struct ct_entry_24xx *)ms_pkt)->comp_status); else comp_status = le16_to_cpu(ms_pkt->status); switch (comp_status) { case CS_COMPLETE: case CS_DATA_UNDERRUN: case CS_DATA_OVERRUN: /* Overrun? */ if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2077, "%s failed rejected request on port_id: " "%02x%02x%02x.\n", routine, vha->d_id.b.domain, vha->d_id.b.area, vha->d_id.b.al_pa); ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2078, (uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr)); rval = QLA_INVALID_COMMAND; } else rval = QLA_SUCCESS; break; default: ql_dbg(ql_dbg_disc, vha, 0x2033, "%s failed, completion status (%x) on port_id: " "%02x%02x%02x.\n", routine, comp_status, vha->d_id.b.domain, vha->d_id.b.area, vha->d_id.b.al_pa); break; } } return rval; }
static s32 __locked_start_current_mon(struct i2c_client *client) { s32 retval; s32 shunt_uV; s16 shunt_limit; s16 alert_mask; struct ina230_data *data = i2c_get_clientdata(client); if (!data->pdata->current_threshold) { dev_err(&client->dev, "no current threshold specified\n"); return -EINVAL; } retval = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_CONT_CONFIG)); if (retval < 0) { dev_err(&client->dev, "config data write failed sts: 0x%x\n", retval); return retval; } shunt_uV = data->pdata->resistor * data->pdata->current_threshold; if (data->pdata->shunt_polarity_inverted) shunt_uV *= -1; shunt_limit = (s16) uv_to_alert_register(shunt_uV); retval = i2c_smbus_write_word_data(client, INA230_ALERT, cpu_to_be16(shunt_limit)); if (retval < 0) { dev_err(&client->dev, "alert data write failed sts: 0x%x\n", retval); return retval; } alert_mask = shunt_limit >= 0 ? INA230_MASK_SOL : INA230_MASK_SUL; retval = i2c_smbus_write_word_data(client, INA230_MASK, cpu_to_be16(alert_mask)); if (retval < 0) { dev_err(&client->dev, "mask data write failed sts: 0x%x\n", retval); return retval; } data->running = true; return 0; }
static int aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h) { u32 host_tag = newtag(d); memcpy(h->src, d->ifp->dev_addr, sizeof h->src); memcpy(h->dst, d->addr, sizeof h->dst); h->type = __constant_cpu_to_be16(ETH_P_AOE); h->verfl = AOE_HVER; h->major = cpu_to_be16(d->aoemajor); h->minor = d->aoeminor; h->cmd = AOECMD_ATA; h->tag = cpu_to_be32(host_tag); return host_tag; }
static s32 ensure_enabled_start(struct i2c_client *client) { struct ina230_data *data = i2c_get_clientdata(client); int retval; if (data->running) return 0; retval = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_TRIG_CONFIG)); if (retval < 0) dev_err(&client->dev, "config data write failed sts: 0x%x\n", retval); return retval; }
/* some callers cannot sleep, and they can call this function, * transmitting the packets later, when interrupts are on */ static struct sk_buff * aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail) { struct aoe_hdr *h; struct aoe_cfghdr *ch; struct sk_buff *skb, *sl, *sl_tail; struct net_device *ifp; sl = sl_tail = NULL; read_lock(&dev_base_lock); for_each_netdev(ifp) { dev_hold(ifp); if (!is_aoe_netif(ifp)) goto cont; skb = new_skb(sizeof *h + sizeof *ch); if (skb == NULL) { printk(KERN_INFO "aoe: skb alloc failure\n"); goto cont; } skb_put(skb, sizeof *h + sizeof *ch); skb->dev = ifp; if (sl_tail == NULL) sl_tail = skb; h = aoe_hdr(skb); memset(h, 0, sizeof *h + sizeof *ch); memset(h->dst, 0xff, sizeof h->dst); memcpy(h->src, ifp->dev_addr, sizeof h->src); h->type = __constant_cpu_to_be16(ETH_P_AOE); h->verfl = AOE_HVER; h->major = cpu_to_be16(aoemajor); h->minor = aoeminor; h->cmd = AOECMD_CFG; skb->next = sl; sl = skb; cont: dev_put(ifp); } read_unlock(&dev_base_lock); if (tail != NULL) *tail = sl_tail; return sl; }
static int qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt, struct ct_sns_rsp *ct_rsp, const char *routine) { int rval; uint16_t comp_status; rval = QLA_FUNCTION_FAILED; if (ms_pkt->entry_status != 0) { DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n", ha->host_no, routine, ms_pkt->entry_status)); } else { if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) comp_status = ((struct ct_entry_24xx *)ms_pkt)->comp_status; else comp_status = le16_to_cpu(ms_pkt->status); switch (comp_status) { case CS_COMPLETE: case CS_DATA_UNDERRUN: case CS_DATA_OVERRUN: /* Overrun? */ if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): %s failed, " "rejected request:\n", ha->host_no, routine)); DEBUG2_3(qla2x00_dump_buffer( (uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); } else rval = QLA_SUCCESS; break; default: DEBUG2_3(printk("scsi(%ld): %s failed, completion " "status (%x).\n", ha->host_no, routine, comp_status)); break; } } return rval; }
static s32 __locked_power_down_ina230(struct i2c_client *client) { s32 retval; struct ina230_data *data = i2c_get_clientdata(client); if (!data->running) return 0; retval = i2c_smbus_write_word_data(client, INA230_MASK, 0); if (retval < 0) dev_err(&client->dev, "mask write failure sts: 0x%x\n", retval); retval = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_POWER_DOWN)); if (retval < 0) dev_err(&client->dev, "power down failure sts: 0x%x\n", retval); data->running = false; return retval; }
static int qla2x00_fdmi_rhba(scsi_qla_host_t *vha) { int rval, alen; uint32_t size, sn; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_hba_attr *eiter; struct qla_hw_data *ha = vha->hw; ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, RHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE); ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE); size = 2 * WWN_SIZE + 4 + 4; ct_req->req.rhba.attrs.count = __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); entries = ct_req->req.rhba.hba_identifier; eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); size += 4 + WWN_SIZE; ql_dbg(ql_dbg_disc, vha, 0x2025, "NodeName = %02x%02x%02x%02x%02x%02x%02x%02x.\n", eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], eiter->a.node_name[6], eiter->a.node_name[7]); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); strcpy(eiter->a.manufacturer, "QLogic Corporation"); alen = strlen(eiter->a.manufacturer); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2026, "Manufacturer = %s.\n", eiter->a.manufacturer); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); alen = strlen(eiter->a.serial_num); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2027, "Serial no. = %s.\n", eiter->a.serial_num); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); strcpy(eiter->a.model, ha->model_number); alen = strlen(eiter->a.model); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2028, "Model Name = %s.\n", eiter->a.model); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); if (ha->model_desc) strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2029, "Model Desc = %s.\n", eiter->a.model_desc); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); strcpy(eiter->a.hw_version, ha->adapter_id); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x202a, "Hardware ver = %s.\n", eiter->a.hw_version); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); strcpy(eiter->a.driver_version, qla2x00_version_str); alen = strlen(eiter->a.driver_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x202b, "Driver ver = %s.\n", eiter->a.driver_version); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); strcpy(eiter->a.orom_version, "0.00"); alen = strlen(eiter->a.orom_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha , 0x202c, "Optrom vers = %s.\n", eiter->a.orom_version); eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); ha->isp_ops->fw_version_str(vha, eiter->a.fw_version); alen = strlen(eiter->a.fw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x202d, "Firmware vers = %s.\n", eiter->a.fw_version); qla2x00_update_ms_fdmi_iocb(vha, size + 16); ql_dbg(ql_dbg_disc, vha, 0x202e, "RHBA identifier = " "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", ct_req->req.rhba.hba_identifier[0], ct_req->req.rhba.hba_identifier[1], ct_req->req.rhba.hba_identifier[2], ct_req->req.rhba.hba_identifier[3], ct_req->req.rhba.hba_identifier[4], ct_req->req.rhba.hba_identifier[5], ct_req->req.rhba.hba_identifier[6], ct_req->req.rhba.hba_identifier[7], size); ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2076, entries, size); rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { ql_dbg(ql_dbg_disc, vha, 0x2030, "RHBA issue IOCB failed (%d).\n", rval); } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && ct_rsp->header.explanation_code == CT_EXPL_ALREADY_REGISTERED) { ql_dbg(ql_dbg_disc, vha, 0x2034, "HBA already registered.\n"); rval = QLA_ALREADY_REGISTERED; } } else { ql_dbg(ql_dbg_disc, vha, 0x2035, "RHBA exiting normally.\n"); } return rval; }
static int __devinit ina230_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ina230_data *data; int err; u8 i; data = devm_kzalloc(&client->dev, sizeof(struct ina230_data), GFP_KERNEL); if (!data) { err = -ENOMEM; goto exit; } i2c_set_clientdata(client, data); data->pdata = client->dev.platform_data; data->running = false; data->nb.notifier_call = ina230_hotplug_notify; data->client = client; mutex_init(&data->mutex); err = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_RESET)); if (err < 0) { dev_err(&client->dev, "ina230 reset failure status: 0x%x\n", err); goto exit; } for (i = 0; i < ARRAY_SIZE(ina230); i++) { err = device_create_file(&client->dev, &ina230[i].dev_attr); if (err) { dev_err(&client->dev, "device_create_file failed.\n"); goto exit_remove; } } data->hwmon_dev = hwmon_device_register(&client->dev); if (IS_ERR(data->hwmon_dev)) { err = PTR_ERR(data->hwmon_dev); goto exit_remove; } register_hotcpu_notifier(&(data->nb)); err = i2c_smbus_write_word_data(client, INA230_MASK, 0); if (err < 0) { dev_err(&client->dev, "mask write failure sts: 0x%x\n", err); goto exit_remove; } /* set ina230 to power down mode */ err = i2c_smbus_write_word_data(client, INA230_CONFIG, __constant_cpu_to_be16(INA230_POWER_DOWN)); if (err < 0) { dev_err(&client->dev, "power down failure sts: 0x%x\n", err); goto exit_remove; } return 0; exit_remove: for (i = 0; i < ARRAY_SIZE(ina230); i++) device_remove_file(&client->dev, &ina230[i].dev_attr); exit: return err; }
/** * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. * @ha: HA context * @fcport: fcport entry to updated * * Returns 0 on success. */ int qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) { int rval; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_ga_nxt(ha, fcport)); } /* Issue GA_NXT */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, GA_NXT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id */ ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain; ct_req->req.port_id.port_id[1] = fcport->d_id.b.area; ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, " "ga_nxt_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Populate fc_port_t entry. */ fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0]; fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1]; fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2]; memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name, WWN_SIZE); memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name, WWN_SIZE); if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE && ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE) fcport->d_id.b.domain = 0xf0; DEBUG2_3(printk("scsi(%ld): GA_NXT entry - " "nn %02x%02x%02x%02x%02x%02x%02x%02x " "pn %02x%02x%02x%02x%02x%02x%02x%02x " "portid=%02x%02x%02x.\n", ha->host_no, fcport->node_name[0], fcport->node_name[1], fcport->node_name[2], fcport->node_name[3], fcport->node_name[4], fcport->node_name[5], fcport->node_name[6], fcport->node_name[7], fcport->port_name[0], fcport->port_name[1], fcport->port_name[2], fcport->port_name[3], fcport->port_name[4], fcport->port_name[5], fcport->port_name[6], fcport->port_name[7], fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa)); } return (rval); }
/** * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command. * @ha: HA context * @list: switch info entries to populate * * NOTE: Non-Nx_Ports are not requested. * * Returns 0 on success. */ int qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) { int rval; uint16_t i; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; struct ct_sns_gid_pt_data *gid_data; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { return (qla2x00_sns_gid_pt(ha, list)); } gid_data = NULL; /* Issue GID_PT */ /* Prepare common MS IOCB */ ms_pkt = qla2x00_prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, GID_PT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_type */ ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, " "gid_pt_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { /* Set port IDs in switch info list. */ for (i = 0; i < MAX_FIBRE_DEVICES; i++) { gid_data = &ct_rsp->rsp.gid_pt.entries[i]; list[i].d_id.b.domain = gid_data->port_id[0]; list[i].d_id.b.area = gid_data->port_id[1]; list[i].d_id.b.al_pa = gid_data->port_id[2]; /* Last one exit. */ if (gid_data->control_byte & BIT_7) { list[i].d_id.b.rsvd_1 = gid_data->control_byte; break; } } /* * If we've used all available slots, then the switch is * reporting back more devices than we can handle with this * single call. Return a failed status, and let GA_NXT handle * the overload. */ if (i == MAX_FIBRE_DEVICES) rval = QLA_FUNCTION_FAILED; } return (rval); }
/** * qla2x00_fdmi_rhba() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_rhba(scsi_qla_host_t *ha) { int rval, alen; uint32_t size, sn; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_hba_attr *eiter; /* Issue RHBA */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, RHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ memcpy(ct_req->req.rhba.hba_identifier, ha->port_name, WWN_SIZE); ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); memcpy(ct_req->req.rhba.port_name, ha->port_name, WWN_SIZE); size = 2 * WWN_SIZE + 4 + 4; /* Attributes */ ct_req->req.rhba.attrs.count = __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); entries = ct_req->req.rhba.hba_identifier; /* Nodename. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); memcpy(eiter->a.node_name, ha->node_name, WWN_SIZE); size += 4 + WWN_SIZE; DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, ha->host_no, eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], eiter->a.node_name[6], eiter->a.node_name[7])); /* Manufacturer. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); strcpy(eiter->a.manufacturer, "QLogic Corporation"); alen = strlen(eiter->a.manufacturer); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, ha->host_no, eiter->a.manufacturer)); /* Serial number. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); alen = strlen(eiter->a.serial_num); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, ha->host_no, eiter->a.serial_num)); /* Model name. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); strcpy(eiter->a.model, ha->model_number); alen = strlen(eiter->a.model); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, ha->host_no, eiter->a.model)); /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); if (ha->model_desc) strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, ha->host_no, eiter->a.model_desc)); /* Hardware version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); strcpy(eiter->a.hw_version, ha->adapter_id); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, ha->host_no, eiter->a.hw_version)); /* Driver version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); strcpy(eiter->a.driver_version, qla2x00_version_str); alen = strlen(eiter->a.driver_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, ha->host_no, eiter->a.driver_version)); /* Option ROM version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); strcpy(eiter->a.orom_version, "0.00"); alen = strlen(eiter->a.orom_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, ha->host_no, eiter->a.orom_version)); /* Firmware version */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); ha->isp_ops.fw_version_str(ha, eiter->a.fw_version); alen = strlen(eiter->a.fw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, ha->host_no, eiter->a.fw_version)); /* Update MS request size. */ qla2x00_update_ms_fdmi_iocb(ha, size + 16); DEBUG13(printk("%s(%ld): RHBA identifier=" "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, ha->host_no, ct_req->req.rhba.hba_identifier[0], ct_req->req.rhba.hba_identifier[1], ct_req->req.rhba.hba_identifier[2], ct_req->req.rhba.hba_identifier[3], ct_req->req.rhba.hba_identifier[4], ct_req->req.rhba.hba_identifier[5], ct_req->req.rhba.hba_identifier[6], ct_req->req.rhba.hba_identifier[7], size)); DEBUG13(qla2x00_dump_buffer(entries, size)); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RHBA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && ct_rsp->header.explanation_code == CT_EXPL_ALREADY_REGISTERED) { DEBUG2_13(printk("%s(%ld): HBA already registered.\n", __func__, ha->host_no)); rval = QLA_ALREADY_REGISTERED; } } else { DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n", ha->host_no)); } return rval; }
static int qla2x00_fdmi_rpa(scsi_qla_host_t *vha) { int rval, alen; uint32_t size, max_frame_size; struct qla_hw_data *ha = vha->hw; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_port_attr *eiter; struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE); ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, RPA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE); size = WWN_SIZE + 4; ct_req->req.rpa.attrs.count = __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT - 1); entries = ct_req->req.rpa.port_name; eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); eiter->len = __constant_cpu_to_be16(4 + 32); eiter->a.fc4_types[2] = 0x01; size += 4 + 32; ql_dbg(ql_dbg_disc, vha, 0x2039, "FC4_TYPES=%02x %02x.\n", eiter->a.fc4_types[2], eiter->a.fc4_types[1]); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); if (IS_CNA_CAPABLE(ha)) eiter->a.sup_speed = __constant_cpu_to_be32( FDMI_PORT_SPEED_10GB); else if (IS_QLA25XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32( FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB); else if (IS_QLA24XX_TYPE(ha)) eiter->a.sup_speed = __constant_cpu_to_be32( FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| FDMI_PORT_SPEED_4GB); else if (IS_QLA23XX(ha)) eiter->a.sup_speed =__constant_cpu_to_be32( FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB); else eiter->a.sup_speed = __constant_cpu_to_be32( FDMI_PORT_SPEED_1GB); size += 4 + 4; ql_dbg(ql_dbg_disc, vha, 0x203a, "Supported_Speed=%x.\n", eiter->a.sup_speed); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); switch (ha->link_data_rate) { case PORT_SPEED_1GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB); break; case PORT_SPEED_2GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB); break; case PORT_SPEED_4GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB); break; case PORT_SPEED_8GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB); break; case PORT_SPEED_10GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB); break; case PORT_SPEED_16GB: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_16GB); break; default: eiter->a.cur_speed = __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); break; } size += 4 + 4; ql_dbg(ql_dbg_disc, vha, 0x203b, "Current_Speed=%x.\n", eiter->a.cur_speed); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); eiter->len = __constant_cpu_to_be16(4 + 4); max_frame_size = IS_FWI2_CAPABLE(ha) ? le16_to_cpu(icb24->frame_payload_size): le16_to_cpu(ha->init_cb->frame_payload_size); eiter->a.max_frame_size = cpu_to_be32(max_frame_size); size += 4 + 4; ql_dbg(ql_dbg_disc, vha, 0x203c, "Max_Frame_Size=%x.\n", eiter->a.max_frame_size); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); strcpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME); alen = strlen(eiter->a.os_dev_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x204b, "OS_Device_Name=%s.\n", eiter->a.os_dev_name); if (strlen(fc_host_system_hostname(vha->host))) { ct_req->req.rpa.attrs.count = __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME); snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), "%s", fc_host_system_hostname(vha->host)); alen = strlen(eiter->a.host_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x203d, "HostName=%s.\n", eiter->a.host_name); } qla2x00_update_ms_fdmi_iocb(vha, size + 16); ql_dbg(ql_dbg_disc, vha, 0x203e, "RPA portname= %02x%02x%02x%02x%02X%02x%02x%02x size=%d.\n", ct_req->req.rpa.port_name[0], ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], ct_req->req.rpa.port_name[7], size); ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2079, entries, size); rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { ql_dbg(ql_dbg_disc, vha, 0x2040, "RPA issue IOCB failed (%d).\n", rval); } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { ql_dbg(ql_dbg_disc, vha, 0x2041, "RPA exiting nornally.\n"); } return rval; }
/** * qla2x00_fdmi_rhba() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_rhba(scsi_qla_host_t *vha) { int rval, alen; uint32_t size, sn; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_hba_attr *eiter; struct qla_hw_data *ha = vha->hw; /* Issue RHBA */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, RHBA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE); ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE); size = 2 * WWN_SIZE + 4 + 4; /* Attributes */ ct_req->req.rhba.attrs.count = __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); entries = ct_req->req.rhba.hba_identifier; /* Nodename. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); size += 4 + WWN_SIZE; ql_dbg(ql_dbg_disc, vha, 0x2025, "NodeName = %02x%02x%02x%02x%02x%02x%02x%02x.\n", eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2], eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5], eiter->a.node_name[6], eiter->a.node_name[7]); /* Manufacturer. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); strcpy(eiter->a.manufacturer, "QLogic Corporation"); alen = strlen(eiter->a.manufacturer); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2026, "Manufacturer = %s.\n", eiter->a.manufacturer); /* Serial number. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); alen = strlen(eiter->a.serial_num); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2027, "Serial no. = %s.\n", eiter->a.serial_num); /* Model name. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); strcpy(eiter->a.model, ha->model_number); alen = strlen(eiter->a.model); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2028, "Model Name = %s.\n", eiter->a.model); /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); if (ha->model_desc) strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; ql_dbg(ql_dbg_disc, vha, 0x2029, "Model Desc = %s.\n", eiter->a.model_desc); /* Hardware version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); strcpy(eiter->a.hw_version, ha->adapter_id); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + ale
/** * qla2x00_fdmi_rpa() - * @ha: HA context * * Returns 0 on success. */ static int qla2x00_fdmi_rpa(scsi_qla_host_t *ha) { int rval, alen; uint32_t size, max_frame_size; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; uint8_t *entries; struct ct_fdmi_port_attr *eiter; struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; /* Issue RPA */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, RPA_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare FDMI command arguments -- attribute block, attributes. */ memcpy(ct_req->req.rpa.port_name, ha->port_name, WWN_SIZE); size = WWN_SIZE + 4; /* Attributes */ ct_req->req.rpa.attrs.count = __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); entries = ct_req->req.rpa.port_name; /* FC4 types. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); eiter->len = __constant_cpu_to_be16(4 + 32); eiter->a.fc4_types[2] = 0x01; size += 4 + 32; DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__, ha->host_no, eiter->a.fc4_types[2], eiter->a.fc4_types[1])); /* Supported speed. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); if (IS_QLA25XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(4); else if (IS_QLA24XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(8); else if (IS_QLA23XX(ha)) eiter->a.sup_speed = __constant_cpu_to_be32(2); else eiter->a.sup_speed = __constant_cpu_to_be32(1); size += 4 + 4; DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, eiter->a.sup_speed)); /* Current speed. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); eiter->len = __constant_cpu_to_be16(4 + 4); switch (ha->link_data_rate) { case 0: eiter->a.cur_speed = __constant_cpu_to_be32(1); break; case 1: eiter->a.cur_speed = __constant_cpu_to_be32(2); break; case 3: eiter->a.cur_speed = __constant_cpu_to_be32(8); break; case 4: eiter->a.cur_speed = __constant_cpu_to_be32(4); break; } size += 4 + 4; DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, ha->host_no, eiter->a.cur_speed)); /* Max frame size. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); eiter->len = __constant_cpu_to_be16(4 + 4); max_frame_size = IS_QLA24XX(ha) || IS_QLA25XX(ha) ? (uint32_t) icb24->frame_payload_size: (uint32_t) ha->init_cb->frame_payload_size; eiter->a.max_frame_size = cpu_to_be32(max_frame_size); size += 4 + 4; DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, ha->host_no, eiter->a.max_frame_size)); /* OS device name. */ eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); sprintf(eiter->a.os_dev_name, "/proc/scsi/qla2xxx/%ld", ha->host_no); alen = strlen(eiter->a.os_dev_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); size += 4 + alen; DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, ha->host_no, eiter->a.os_dev_name)); /* Update MS request size. */ qla2x00_update_ms_fdmi_iocb(ha, size + 16); DEBUG13(printk("%s(%ld): RPA portname=" "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__, ha->host_no, ct_req->req.rpa.port_name[0], ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2], ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4], ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6], ct_req->req.rpa.port_name[7], size)); DEBUG13(qla2x00_dump_buffer(entries, size)); /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RPA") != QLA_SUCCESS) { rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RPA exiting normally.\n", ha->host_no)); } return rval; }
/** * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA. * @ha: HA context * * Returns 0 on success. */ int qla2x00_rsnn_nn(scsi_qla_host_t *ha) { int rval; uint8_t *snn; uint8_t version[20]; ms_iocb_entry_t *ms_pkt; struct ct_sns_req *ct_req; struct ct_sns_rsp *ct_rsp; if (IS_QLA2100(ha) || IS_QLA2200(ha)) { DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on " "ISP2100/ISP2200.\n", ha->host_no)); return (QLA_SUCCESS); } /* Issue RSNN_NN */ /* Prepare common MS IOCB */ /* Request size adjusted after CT preparation */ ms_pkt = qla2x00_prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE); /* Prepare CT request */ ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, RSNN_NN_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- node_name, symbolic node_name, size */ memcpy(ct_req->req.rsnn_nn.node_name, ha->init_cb->node_name, WWN_SIZE); /* Prepare the Symbolic Node Name */ /* Board type */ snn = ct_req->req.rsnn_nn.sym_node_name; strcpy(snn, ha->model_number); /* Firmware version */ strcat(snn, " FW:v"); sprintf(version, "%d.%02d.%02d", ha->fw_major_version, ha->fw_minor_version, ha->fw_subminor_version); strcat(snn, version); /* Driver version */ strcat(snn, " DVR:v"); strcat(snn, qla2x00_version_str); /* Calculate SNN length */ ct_req->req.rsnn_nn.name_len = (uint8_t)strlen(snn); /* Update MS IOCB request */ ms_pkt->req_bytecount = cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len); ms_pkt->dseg_req_length = ms_pkt->req_bytecount; /* Execute MS IOCB */ rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma, sizeof(ms_iocb_entry_t)); if (rval != QLA_SUCCESS) { /*EMPTY*/ DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n", ha->host_no, rval)); } else if (ct_rsp->header.response != __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { DEBUG2_3(printk("scsi(%ld): RSNN_NN failed, rejected " "request, rsnn_id_rsp:\n", ha->host_no)); DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header, sizeof(struct ct_rsp_hdr))); rval = QLA_FUNCTION_FAILED; } else { DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n", ha->host_no)); } return (rval); }