📄 dac960.c
字号:
CommandMailbox.SetMemoryMailbox.CommandOpcode = DAC960_V2_IOCTL; CommandMailbox.SetMemoryMailbox.CommandControlBits.NoAutoRequestSense = true; CommandMailbox.SetMemoryMailbox.FirstCommandMailboxSizeKB = (DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T)) >> 10; CommandMailbox.SetMemoryMailbox.FirstStatusMailboxSizeKB = (DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T)) >> 10; CommandMailbox.SetMemoryMailbox.SecondCommandMailboxSizeKB = 0; CommandMailbox.SetMemoryMailbox.SecondStatusMailboxSizeKB = 0; CommandMailbox.SetMemoryMailbox.RequestSenseSize = 0; CommandMailbox.SetMemoryMailbox.IOCTL_Opcode = DAC960_V2_SetMemoryMailbox; CommandMailbox.SetMemoryMailbox.HealthStatusBufferSizeKB = 1; CommandMailbox.SetMemoryMailbox.HealthStatusBufferBusAddress = Virtual_to_Bus64(Controller->V2.HealthStatusBuffer); CommandMailbox.SetMemoryMailbox.FirstCommandMailboxBusAddress = Virtual_to_Bus64(Controller->V2.FirstCommandMailbox); CommandMailbox.SetMemoryMailbox.FirstStatusMailboxBusAddress = Virtual_to_Bus64(Controller->V2.FirstStatusMailbox); switch (Controller->HardwareType) { case DAC960_BA_Controller: while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress)) udelay(1); DAC960_BA_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox); DAC960_BA_HardwareMailboxNewCommand(ControllerBaseAddress); while (!DAC960_BA_HardwareMailboxStatusAvailableP(ControllerBaseAddress)) udelay(1); CommandStatus = DAC960_BA_ReadCommandStatus(ControllerBaseAddress); DAC960_BA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress); DAC960_BA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress); break; case DAC960_LP_Controller: while (DAC960_LP_HardwareMailboxFullP(ControllerBaseAddress)) udelay(1); DAC960_LP_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox); DAC960_LP_HardwareMailboxNewCommand(ControllerBaseAddress); while (!DAC960_LP_HardwareMailboxStatusAvailableP(ControllerBaseAddress)) udelay(1); CommandStatus = DAC960_LP_ReadCommandStatus(ControllerBaseAddress); DAC960_LP_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress); DAC960_LP_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress); break; default: break; } return (CommandStatus == DAC960_V2_NormalCompletion);}/* DAC960_V1_ReadControllerConfiguration reads the Configuration Information from DAC960 V1 Firmware Controllers and initializes the Controller structure.*/static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T *Controller){ DAC960_V1_Enquiry2_T Enquiry2; DAC960_V1_Config2_T Config2; int LogicalDriveNumber, Channel, TargetID; if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry, &Controller->V1.Enquiry)) return DAC960_Failure(Controller, "ENQUIRY"); if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry2, &Enquiry2)) return DAC960_Failure(Controller, "ENQUIRY2"); if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_ReadConfig2, &Config2)) return DAC960_Failure(Controller, "READ CONFIG2"); if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_GetLogicalDriveInformation, &Controller->V1.LogicalDriveInformation)) return DAC960_Failure(Controller, "GET LOGICAL DRIVE INFORMATION"); for (Channel = 0; Channel < Enquiry2.ActualChannels; Channel++) for (TargetID = 0; TargetID < Enquiry2.MaxTargets; TargetID++) if (!DAC960_V1_ExecuteType3D(Controller, DAC960_V1_GetDeviceState, Channel, TargetID, &Controller->V1.DeviceState [Channel][TargetID])) return DAC960_Failure(Controller, "GET DEVICE STATE"); /* Initialize the Controller Model Name and Full Model Name fields. */ switch (Enquiry2.HardwareID.SubModel) { case DAC960_V1_P_PD_PU: if (Enquiry2.SCSICapability.BusSpeed == DAC960_V1_Ultra) strcpy(Controller->ModelName, "DAC960PU"); else strcpy(Controller->ModelName, "DAC960PD"); break; case DAC960_V1_PL: strcpy(Controller->ModelName, "DAC960PL"); break; case DAC960_V1_PG: strcpy(Controller->ModelName, "DAC960PG"); break; case DAC960_V1_PJ: strcpy(Controller->ModelName, "DAC960PJ"); break; case DAC960_V1_PR: strcpy(Controller->ModelName, "DAC960PR"); break; case DAC960_V1_PT: strcpy(Controller->ModelName, "DAC960PT"); break; case DAC960_V1_PTL0: strcpy(Controller->ModelName, "DAC960PTL0"); break; case DAC960_V1_PRL: strcpy(Controller->ModelName, "DAC960PRL"); break; case DAC960_V1_PTL1: strcpy(Controller->ModelName, "DAC960PTL1"); break; case DAC960_V1_1164P: strcpy(Controller->ModelName, "DAC1164P"); break; default: return DAC960_Failure(Controller, "MODEL VERIFICATION"); } strcpy(Controller->FullModelName, "Mylex "); strcat(Controller->FullModelName, Controller->ModelName); /* Initialize the Controller Firmware Version field and verify that it is a supported firmware version. The supported firmware versions are: DAC1164P 5.06 and above DAC960PTL/PRL/PJ/PG 4.06 and above DAC960PU/PD/PL 3.51 and above DAC960PU/PD/PL/P 2.73 and above */ if (Enquiry2.FirmwareID.MajorVersion == 0) { Enquiry2.FirmwareID.MajorVersion = Controller->V1.Enquiry.MajorFirmwareVersion; Enquiry2.FirmwareID.MinorVersion = Controller->V1.Enquiry.MinorFirmwareVersion; Enquiry2.FirmwareID.FirmwareType = '0'; Enquiry2.FirmwareID.TurnID = 0; } sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d", Enquiry2.FirmwareID.MajorVersion, Enquiry2.FirmwareID.MinorVersion, Enquiry2.FirmwareID.FirmwareType, Enquiry2.FirmwareID.TurnID); if (!((Controller->FirmwareVersion[0] == '5' && strcmp(Controller->FirmwareVersion, "5.06") >= 0) || (Controller->FirmwareVersion[0] == '4' && strcmp(Controller->FirmwareVersion, "4.06") >= 0) || (Controller->FirmwareVersion[0] == '3' && strcmp(Controller->FirmwareVersion, "3.51") >= 0) || (Controller->FirmwareVersion[0] == '2' && strcmp(Controller->FirmwareVersion, "2.73") >= 0))) { DAC960_Failure(Controller, "FIRMWARE VERSION VERIFICATION"); DAC960_Error("Firmware Version = '%s'\n", Controller, Controller->FirmwareVersion); return false; } /* Initialize the Controller Channels, Targets, Memory Size, and SAF-TE Enclosure Management Enabled fields. */ Controller->Channels = Enquiry2.ActualChannels; Controller->Targets = Enquiry2.MaxTargets; Controller->MemorySize = Enquiry2.MemorySize >> 20; Controller->V1.SAFTE_EnclosureManagementEnabled = (Enquiry2.FaultManagementType == DAC960_V1_SAFTE); /* Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one less than the Controller Queue Depth to allow for an automatic drive rebuild operation. */ Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands; Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1; if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth) Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth; Controller->LogicalDriveCount = Controller->V1.Enquiry.NumberOfLogicalDrives; Controller->MaxBlocksPerCommand = Enquiry2.MaxBlocksPerCommand; Controller->ControllerScatterGatherLimit = Enquiry2.MaxScatterGatherEntries; Controller->DriverScatterGatherLimit = Controller->ControllerScatterGatherLimit; if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit) Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit; /* Initialize the Stripe Size, Segment Size, and Geometry Translation. */ Controller->V1.StripeSize = Config2.BlocksPerStripe * Config2.BlockFactor >> (10 - DAC960_BlockSizeBits); Controller->V1.SegmentSize = Config2.BlocksPerCacheLine * Config2.BlockFactor >> (10 - DAC960_BlockSizeBits); switch (Config2.DriveGeometry) { case DAC960_V1_Geometry_128_32: Controller->V1.GeometryTranslationHeads = 128; Controller->V1.GeometryTranslationSectors = 32; break; case DAC960_V1_Geometry_255_63: Controller->V1.GeometryTranslationHeads = 255; Controller->V1.GeometryTranslationSectors = 63; break; default: return DAC960_Failure(Controller, "CONFIG2 DRIVE GEOMETRY"); } /* Initialize the Background Initialization Status. */ if ((Controller->FirmwareVersion[0] == '4' && strcmp(Controller->FirmwareVersion, "4.08") >= 0) || (Controller->FirmwareVersion[0] == '5' && strcmp(Controller->FirmwareVersion, "5.08") >= 0)) { Controller->V1.BackgroundInitializationStatusSupported = true; DAC960_V1_ExecuteType3B(Controller, DAC960_V1_BackgroundInitializationControl, 0x20, &Controller-> V1.LastBackgroundInitializationStatus); } /* Initialize the Logical Drive Initially Accessible flag. */ for (LogicalDriveNumber = 0; LogicalDriveNumber < Controller->LogicalDriveCount; LogicalDriveNumber++) if (Controller->V1.LogicalDriveInformation [LogicalDriveNumber].LogicalDriveState != DAC960_V1_LogicalDrive_Offline) Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true; Controller->V1.LastRebuildStatus = DAC960_V1_NoRebuildOrCheckInProgress; return true;}/* DAC960_V2_ReadControllerConfiguration reads the Configuration Information from DAC960 V2 Firmware Controllers and initializes the Controller structure.*/static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T *Controller){ DAC960_V2_ControllerInfo_T *ControllerInfo = &Controller->V2.ControllerInformation; unsigned short LogicalDeviceNumber = 0; int ModelNameLength; if (!DAC960_V2_ControllerInfo(Controller, DAC960_V2_GetControllerInfo, ControllerInfo, sizeof(DAC960_V2_ControllerInfo_T))) return DAC960_Failure(Controller, "GET CONTROLLER INFO"); if (!DAC960_V2_GeneralInfo(Controller, DAC960_V2_GetHealthStatus, Controller->V2.HealthStatusBuffer, sizeof(DAC960_V2_HealthStatusBuffer_T))) return DAC960_Failure(Controller, "GET HEALTH STATUS"); /* Initialize the Controller Model Name and Full Model Name fields. */ ModelNameLength = sizeof(ControllerInfo->ControllerName); if (ModelNameLength > sizeof(Controller->ModelName)-1) ModelNameLength = sizeof(Controller->ModelName)-1; memcpy(Controller->ModelName, ControllerInfo->ControllerName, ModelNameLength); ModelNameLength--; while (Controller->ModelName[ModelNameLength] == ' ' || Controller->ModelName[ModelNameLength] == '\0') ModelNameLength--; Controller->ModelName[++ModelNameLength] = '\0'; strcpy(Controller->FullModelName, "Mylex "); strcat(Controller->FullModelName, Controller->ModelName); /* Initialize the Controller Firmware Version field. */ sprintf(Controller->FirmwareVersion, "%d.%02d-%02d", ControllerInfo->FirmwareMajorVersion, ControllerInfo->FirmwareMinorVersion, ControllerInfo->FirmwareTurnNumber); if (ControllerInfo->FirmwareMajorVersion == 6 && ControllerInfo->FirmwareMinorVersion == 0 && ControllerInfo->FirmwareTurnNumber < 1) { DAC960_Info("FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n", Controller, Controller->FirmwareVersion); DAC960_Info("STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n", Controller); DAC960_Info("PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n", Controller); } /* Initialize the Controller Channels, Targets, and Memory Size. */ Controller->Channels = ControllerInfo->NumberOfPhysicalChannelsPresent; Controller->Targets = ControllerInfo->MaximumTargetsPerChannel [ControllerInfo->NumberOfPhysicalChannelsPresent-1]; Controller->MemorySize = ControllerInfo->MemorySizeMB; /* Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one less than the Controller Queue Depth to allow for an automatic drive rebuild operation. */ Controller->ControllerQueueDepth = ControllerInfo->MaximumParallelCommands; Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1; if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth) Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth; Controller->LogicalDriveCount = ControllerInfo->LogicalDevicesPresent; Controller->MaxBlocksPerCommand = ControllerInfo->MaximumDataTransferSizeInBlocks; Controller->ControllerScatterGatherLimit = ControllerInfo->MaximumScatterGatherEntries; Controller->DriverScatterGatherLimit = Controller->ControllerScatterGatherLimit; if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit) Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit; /* Initialize the Logical Device Information. */ while (true) { DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo = &Controller->V2.NewLogicalDeviceInformation; DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo; DAC960_V2_PhysicalDevice_T PhysicalDevice; if (!DAC960_V2_LogicalDeviceInfo(Controller, DAC960_V2_GetLogicalDeviceInfoValid, LogicalDeviceNumber, NewLogicalDeviceInfo, sizeof(DAC960_V2_LogicalDeviceInfo_T))) break; LogicalDeviceNumber = NewLogicalDeviceInfo->LogicalDeviceNumber; if (LogicalDeviceNumber > DAC960_MaxLogicalDrives) panic("DAC960: Logical Drive Number %d not supported\n", LogicalDeviceNumber); if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize) panic("DAC960: Logical Drive Block Size %d not supported\n", NewLogicalDeviceInfo->DeviceBlockSizeInBytes); PhysicalDevice.Controller = 0; PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel; PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -