aachba.c
来自「linux 内核源代码」· C语言 代码 · 共 2,197 行 · 第 1/5 页
C
2,197 行
/* Illegal parameter is in the CDB block */ sense_buf[15] |= bit_pointer; sense_buf[16] = field_pointer >> 8; /* MSB */ sense_buf[17] = field_pointer; /* LSB */ }}static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba){ if (lba & 0xffffffff00000000LL) { int cid = scmd_id(cmd); dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; set_sense((u8 *) &dev->fsa_dev[cid].sense_data, HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE, ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 0, 0); memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer)) ? sizeof(cmd->sense_buffer) : sizeof(dev->fsa_dev[cid].sense_data)); cmd->scsi_done(cmd); return 1; } return 0;}static int aac_bounds_64(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba){ return 0;}static void io_callback(void *context, struct fib * fibptr);static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count){ u16 fibsize; struct aac_raw_io *readcmd; aac_fib_init(fib); readcmd = (struct aac_raw_io *) fib_data(fib); readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); readcmd->count = cpu_to_le32(count<<9); readcmd->cid = cpu_to_le16(scmd_id(cmd)); readcmd->flags = cpu_to_le16(IO_TYPE_READ); readcmd->bpTotal = 0; readcmd->bpComplete = 0; aac_build_sgraw(cmd, &readcmd->sg); fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerRawIo, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count){ u16 fibsize; struct aac_read64 *readcmd; aac_fib_init(fib); readcmd = (struct aac_read64 *) fib_data(fib); readcmd->command = cpu_to_le32(VM_CtHostRead64); readcmd->cid = cpu_to_le16(scmd_id(cmd)); readcmd->sector_count = cpu_to_le16(count); readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); readcmd->pad = 0; readcmd->flags = 0; aac_build_sg64(cmd, &readcmd->sg); fibsize = sizeof(struct aac_read64) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentry64)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerCommand64, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count){ u16 fibsize; struct aac_read *readcmd; aac_fib_init(fib); readcmd = (struct aac_read *) fib_data(fib); readcmd->command = cpu_to_le32(VM_CtBlockRead); readcmd->cid = cpu_to_le16(scmd_id(cmd)); readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); readcmd->count = cpu_to_le32(count * 512); aac_build_sg(cmd, &readcmd->sg); fibsize = sizeof(struct aac_read) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentry)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerCommand, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua){ u16 fibsize; struct aac_raw_io *writecmd; aac_fib_init(fib); writecmd = (struct aac_raw_io *) fib_data(fib); writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); writecmd->count = cpu_to_le32(count<<9); writecmd->cid = cpu_to_le16(scmd_id(cmd)); writecmd->flags = fua ? cpu_to_le16(IO_TYPE_WRITE|IO_SUREWRITE) : cpu_to_le16(IO_TYPE_WRITE); writecmd->bpTotal = 0; writecmd->bpComplete = 0; aac_build_sgraw(cmd, &writecmd->sg); fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerRawIo, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua){ u16 fibsize; struct aac_write64 *writecmd; aac_fib_init(fib); writecmd = (struct aac_write64 *) fib_data(fib); writecmd->command = cpu_to_le32(VM_CtHostWrite64); writecmd->cid = cpu_to_le16(scmd_id(cmd)); writecmd->sector_count = cpu_to_le16(count); writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); writecmd->pad = 0; writecmd->flags = 0; aac_build_sg64(cmd, &writecmd->sg); fibsize = sizeof(struct aac_write64) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentry64)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerCommand64, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua){ u16 fibsize; struct aac_write *writecmd; aac_fib_init(fib); writecmd = (struct aac_write *) fib_data(fib); writecmd->command = cpu_to_le32(VM_CtBlockWrite); writecmd->cid = cpu_to_le16(scmd_id(cmd)); writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); writecmd->count = cpu_to_le32(count * 512); writecmd->sg.count = cpu_to_le32(1); /* ->stable is not used - it did mean which type of write */ aac_build_sg(cmd, &writecmd->sg); fibsize = sizeof(struct aac_write) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentry)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ContainerCommand, fib, fibsize, FsaNormal, 0, 1, (fib_callback) io_callback, (void *) cmd);}static struct aac_srb * aac_scsi_common(struct fib * fib, struct scsi_cmnd * cmd){ struct aac_srb * srbcmd; u32 flag; u32 timeout; aac_fib_init(fib); switch(cmd->sc_data_direction){ case DMA_TO_DEVICE: flag = SRB_DataOut; break; case DMA_BIDIRECTIONAL: flag = SRB_DataIn | SRB_DataOut; break; case DMA_FROM_DEVICE: flag = SRB_DataIn; break; case DMA_NONE: default: /* shuts up some versions of gcc */ flag = SRB_NoDataXfer; break; } srbcmd = (struct aac_srb*) fib_data(fib); srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd))); srbcmd->id = cpu_to_le32(scmd_id(cmd)); srbcmd->lun = cpu_to_le32(cmd->device->lun); srbcmd->flags = cpu_to_le32(flag); timeout = cmd->timeout_per_command/HZ; if (timeout == 0) timeout = 1; srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds srbcmd->retry_limit = 0; /* Obsolete parameter */ srbcmd->cdb_size = cpu_to_le32(cmd->cmd_len); return srbcmd;}static void aac_srb_callback(void *context, struct fib * fibptr);static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd){ u16 fibsize; struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg); srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); /* * Build Scatter/Gather list */ fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + ((le32_to_cpu(srbcmd->sg.count) & 0xff) * sizeof (struct sgentry64)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ScsiPortCommand64, fib, fibsize, FsaNormal, 0, 1, (fib_callback) aac_srb_callback, (void *) cmd);}static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd){ u16 fibsize; struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg); srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); /* * Build Scatter/Gather list */ fibsize = sizeof (struct aac_srb) + (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * sizeof (struct sgentry)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ return aac_fib_send(ScsiPortCommand, fib, fibsize, FsaNormal, 0, 1, (fib_callback) aac_srb_callback, (void *) cmd);}int aac_get_adapter_info(struct aac_dev* dev){ struct fib* fibptr; int rcode; u32 tmp; struct aac_adapter_info *info; struct aac_bus_info *command; struct aac_bus_info_response *bus_info; if (!(fibptr = aac_fib_alloc(dev))) return -ENOMEM; aac_fib_init(fibptr); info = (struct aac_adapter_info *) fib_data(fibptr); memset(info,0,sizeof(*info)); rcode = aac_fib_send(RequestAdapterInfo, fibptr, sizeof(*info), FsaNormal, -1, 1, /* First `interrupt' command uses special wait */ NULL, NULL); if (rcode < 0) { aac_fib_complete(fibptr); aac_fib_free(fibptr); return rcode; } memcpy(&dev->adapter_info, info, sizeof(*info)); if (dev->adapter_info.options & AAC_OPT_SUPPLEMENT_ADAPTER_INFO) { struct aac_supplement_adapter_info * info; aac_fib_init(fibptr); info = (struct aac_supplement_adapter_info *) fib_data(fibptr); memset(info,0,sizeof(*info)); rcode = aac_fib_send(RequestSupplementAdapterInfo, fibptr, sizeof(*info), FsaNormal, 1, 1, NULL, NULL); if (rcode >= 0) memcpy(&dev->supplement_adapter_info, info, sizeof(*info)); } /* * GetBusInfo */ aac_fib_init(fibptr); bus_info = (struct aac_bus_info_response *) fib_data(fibptr); memset(bus_info, 0, sizeof(*bus_info)); command = (struct aac_bus_info *)bus_info; command->Command = cpu_to_le32(VM_Ioctl); command->ObjType = cpu_to_le32(FT_DRIVE); command->MethodId = cpu_to_le32(1); command->CtlCmd = cpu_to_le32(GetBusInfo); rcode = aac_fib_send(ContainerCommand, fibptr, sizeof (*bus_info), FsaNormal, 1, 1, NULL, NULL); if (rcode >= 0 && le32_to_cpu(bus_info->Status) == ST_OK) { dev->maximum_num_physicals = le32_to_cpu(bus_info->TargetsPerBus); dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount); } if (!dev->in_reset) { char buffer[16]; tmp = le32_to_cpu(dev->adapter_info.kernelrev); printk(KERN_INFO "%s%d: kernel %d.%d-%d[%d] %.*s\n", dev->name, dev->id, tmp>>24, (tmp>>16)&0xff, tmp&0xff, le32_to_cpu(dev->adapter_info.kernelbuild), (int)sizeof(dev->supplement_adapter_info.BuildDate), dev->supplement_adapter_info.BuildDate); tmp = le32_to_cpu(dev->adapter_info.monitorrev); printk(KERN_INFO "%s%d: monitor %d.%d-%d[%d]\n", dev->name, dev->id, tmp>>24,(tmp>>16)&0xff,tmp&0xff, le32_to_cpu(dev->adapter_info.monitorbuild)); tmp = le32_to_cpu(dev->adapter_info.biosrev); printk(KERN_INFO "%s%d: bios %d.%d-%d[%d]\n", dev->name, dev->id, tmp>>24,(tmp>>16)&0xff,tmp&0xff, le32_to_cpu(dev->adapter_info.biosbuild)); buffer[0] = '\0'; if (aac_show_serial_number( shost_to_class(dev->scsi_host_ptr), buffer)) printk(KERN_INFO "%s%d: serial %s", dev->name, dev->id, buffer); if (dev->supplement_adapter_info.VpdInfo.Tsid[0]) { printk(KERN_INFO "%s%d: TSID %.*s\n", dev->name, dev->id, (int)sizeof(dev->supplement_adapter_info.VpdInfo.Tsid), dev->supplement_adapter_info.VpdInfo.Tsid); } if (!aac_check_reset || (dev->supplement_adapter_info.SupportedOptions2 & le32_to_cpu(AAC_OPTION_IGNORE_RESET))) { printk(KERN_INFO "%s%d: Reset Adapter Ignored\n", dev->name, dev->id); } } dev->nondasd_support = 0; dev->raid_scsi_mode = 0; if(dev->adapter_info.options & AAC_OPT_NONDASD){ dev->nondasd_support = 1; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?