mptbase.c (f0cd91a68acdc9b49d7f6738b514a426da627649) mptbase.c (80d3ac77a84987d5132726f3d7cef342a280f7d9)
1/*
2 * linux/drivers/message/fusion/mptbase.c
3 * This is the Fusion MPT base driver which supports multiple
4 * (SCSI + LAN) specialized protocol drivers.
5 * For use with LSI Logic PCI chip/adapter(s)
6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
7 *
8 * Copyright (c) 1999-2005 LSI Logic Corporation

--- 1174 unchanged lines hidden (view full) ---

1183 }
1184 ioc->alloc_total = sizeof(MPT_ADAPTER);
1185 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1186 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
1187
1188 ioc->pcidev = pdev;
1189 ioc->diagPending = 0;
1190 spin_lock_init(&ioc->diagLock);
1/*
2 * linux/drivers/message/fusion/mptbase.c
3 * This is the Fusion MPT base driver which supports multiple
4 * (SCSI + LAN) specialized protocol drivers.
5 * For use with LSI Logic PCI chip/adapter(s)
6 * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
7 *
8 * Copyright (c) 1999-2005 LSI Logic Corporation

--- 1174 unchanged lines hidden (view full) ---

1183 }
1184 ioc->alloc_total = sizeof(MPT_ADAPTER);
1185 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1186 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
1187
1188 ioc->pcidev = pdev;
1189 ioc->diagPending = 0;
1190 spin_lock_init(&ioc->diagLock);
1191 spin_lock_init(&ioc->fc_rescan_work_lock);
1192 spin_lock_init(&ioc->initializing_hba_lock);
1193
1194 /* Initialize the event logging.
1195 */
1196 ioc->eventTypes = 0; /* None */
1197 ioc->eventContext = 0;
1198 ioc->eventLogSize = 0;
1199 ioc->events = NULL;

--- 642 unchanged lines hidden (view full) ---

1842 goto out;
1843 }
1844
1845 /* Find IM volumes
1846 */
1847 mpt_findImVolumes(ioc);
1848
1849 } else if (ioc->bus_type == FC) {
1191 spin_lock_init(&ioc->initializing_hba_lock);
1192
1193 /* Initialize the event logging.
1194 */
1195 ioc->eventTypes = 0; /* None */
1196 ioc->eventContext = 0;
1197 ioc->eventLogSize = 0;
1198 ioc->events = NULL;

--- 642 unchanged lines hidden (view full) ---

1841 goto out;
1842 }
1843
1844 /* Find IM volumes
1845 */
1846 mpt_findImVolumes(ioc);
1847
1848 } else if (ioc->bus_type == FC) {
1850 /*
1851 * Pre-fetch FC port WWN and stuff...
1852 * (FCPortPage0_t stuff)
1853 */
1854 for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {
1855 (void) mptbase_GetFcPortPage0(ioc, ii);
1856 }
1857
1858 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) &&
1859 (ioc->lan_cnfg_page0.Header.PageLength == 0)) {
1860 /*
1861 * Pre-fetch the ports LAN MAC address!
1862 * (LANPage1_t stuff)
1863 */
1864 (void) GetLanConfigPages(ioc);
1865#ifdef MPT_DEBUG

--- 2315 unchanged lines hidden (view full) ---

4181
4182 }
4183
4184 return rc;
4185}
4186
4187/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4188/*
1849 if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) &&
1850 (ioc->lan_cnfg_page0.Header.PageLength == 0)) {
1851 /*
1852 * Pre-fetch the ports LAN MAC address!
1853 * (LANPage1_t stuff)
1854 */
1855 (void) GetLanConfigPages(ioc);
1856#ifdef MPT_DEBUG

--- 2315 unchanged lines hidden (view full) ---

4172
4173 }
4174
4175 return rc;
4176}
4177
4178/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4179/*
4189 * mptbase_GetFcPortPage0 - Fetch FCPort config Page0.
4190 * @ioc: Pointer to MPT_ADAPTER structure
4191 * @portnum: IOC Port number
4192 *
4193 * Return: 0 for success
4194 * -ENOMEM if no memory available
4195 * -EPERM if not allowed due to ISR context
4196 * -EAGAIN if no msg frames currently available
4197 * -EFAULT for non-successful reply or no reply (timeout)
4198 */
4199int
4200mptbase_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4201{
4202 ConfigPageHeader_t hdr;
4203 CONFIGPARMS cfg;
4204 FCPortPage0_t *ppage0_alloc;
4205 FCPortPage0_t *pp0dest;
4206 dma_addr_t page0_dma;
4207 int data_sz;
4208 int copy_sz;
4209 int rc;
4210 int count = 400;
4211
4212
4213 /* Get FCPort Page 0 header */
4214 hdr.PageVersion = 0;
4215 hdr.PageLength = 0;
4216 hdr.PageNumber = 0;
4217 hdr.PageType = MPI_CONFIG_PAGETYPE_FC_PORT;
4218 cfg.cfghdr.hdr = &hdr;
4219 cfg.physAddr = -1;
4220 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
4221 cfg.dir = 0;
4222 cfg.pageAddr = portnum;
4223 cfg.timeout = 0;
4224
4225 if ((rc = mpt_config(ioc, &cfg)) != 0)
4226 return rc;
4227
4228 if (hdr.PageLength == 0)
4229 return 0;
4230
4231 data_sz = hdr.PageLength * 4;
4232 rc = -ENOMEM;
4233 ppage0_alloc = (FCPortPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
4234 if (ppage0_alloc) {
4235
4236 try_again:
4237 memset((u8 *)ppage0_alloc, 0, data_sz);
4238 cfg.physAddr = page0_dma;
4239 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
4240
4241 if ((rc = mpt_config(ioc, &cfg)) == 0) {
4242 /* save the data */
4243 pp0dest = &ioc->fc_port_page0[portnum];
4244 copy_sz = min_t(int, sizeof(FCPortPage0_t), data_sz);
4245 memcpy(pp0dest, ppage0_alloc, copy_sz);
4246
4247 /*
4248 * Normalize endianness of structure data,
4249 * by byte-swapping all > 1 byte fields!
4250 */
4251 pp0dest->Flags = le32_to_cpu(pp0dest->Flags);
4252 pp0dest->PortIdentifier = le32_to_cpu(pp0dest->PortIdentifier);
4253 pp0dest->WWNN.Low = le32_to_cpu(pp0dest->WWNN.Low);
4254 pp0dest->WWNN.High = le32_to_cpu(pp0dest->WWNN.High);
4255 pp0dest->WWPN.Low = le32_to_cpu(pp0dest->WWPN.Low);
4256 pp0dest->WWPN.High = le32_to_cpu(pp0dest->WWPN.High);
4257 pp0dest->SupportedServiceClass = le32_to_cpu(pp0dest->SupportedServiceClass);
4258 pp0dest->SupportedSpeeds = le32_to_cpu(pp0dest->SupportedSpeeds);
4259 pp0dest->CurrentSpeed = le32_to_cpu(pp0dest->CurrentSpeed);
4260 pp0dest->MaxFrameSize = le32_to_cpu(pp0dest->MaxFrameSize);
4261 pp0dest->FabricWWNN.Low = le32_to_cpu(pp0dest->FabricWWNN.Low);
4262 pp0dest->FabricWWNN.High = le32_to_cpu(pp0dest->FabricWWNN.High);
4263 pp0dest->FabricWWPN.Low = le32_to_cpu(pp0dest->FabricWWPN.Low);
4264 pp0dest->FabricWWPN.High = le32_to_cpu(pp0dest->FabricWWPN.High);
4265 pp0dest->DiscoveredPortsCount = le32_to_cpu(pp0dest->DiscoveredPortsCount);
4266 pp0dest->MaxInitiators = le32_to_cpu(pp0dest->MaxInitiators);
4267
4268 /*
4269 * if still doing discovery,
4270 * hang loose a while until finished
4271 */
4272 if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) {
4273 if (count-- > 0) {
4274 msleep_interruptible(100);
4275 goto try_again;
4276 }
4277 printk(MYIOC_s_INFO_FMT "Firmware discovery not"
4278 " complete.\n",
4279 ioc->name);
4280 }
4281 }
4282
4283 pci_free_consistent(ioc->pcidev, data_sz, (u8 *) ppage0_alloc, page0_dma);
4284 }
4285
4286 return rc;
4287}
4288
4289/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4290/*
4291 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table
4292 * @ioc: Pointer to MPT_ADAPTER structure
4293 * @sas_address: 64bit SAS Address for operation.
4294 * @target_id: specified target for operation
4295 * @bus: specified bus for operation
4296 * @persist_opcode: see below
4297 *
4298 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for

--- 2191 unchanged lines hidden (view full) ---

6490EXPORT_SYMBOL(mpt_lan_index);
6491EXPORT_SYMBOL(mpt_stm_index);
6492EXPORT_SYMBOL(mpt_HardResetHandler);
6493EXPORT_SYMBOL(mpt_config);
6494EXPORT_SYMBOL(mpt_findImVolumes);
6495EXPORT_SYMBOL(mpt_alloc_fw_memory);
6496EXPORT_SYMBOL(mpt_free_fw_memory);
6497EXPORT_SYMBOL(mptbase_sas_persist_operation);
4180 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table
4181 * @ioc: Pointer to MPT_ADAPTER structure
4182 * @sas_address: 64bit SAS Address for operation.
4183 * @target_id: specified target for operation
4184 * @bus: specified bus for operation
4185 * @persist_opcode: see below
4186 *
4187 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for

--- 2191 unchanged lines hidden (view full) ---

6379EXPORT_SYMBOL(mpt_lan_index);
6380EXPORT_SYMBOL(mpt_stm_index);
6381EXPORT_SYMBOL(mpt_HardResetHandler);
6382EXPORT_SYMBOL(mpt_config);
6383EXPORT_SYMBOL(mpt_findImVolumes);
6384EXPORT_SYMBOL(mpt_alloc_fw_memory);
6385EXPORT_SYMBOL(mpt_free_fw_memory);
6386EXPORT_SYMBOL(mptbase_sas_persist_operation);
6498EXPORT_SYMBOL(mptbase_GetFcPortPage0);
6499
6500
6501/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6502/*
6503 * fusion_init - Fusion MPT base driver initialization routine.
6504 *
6505 * Returns 0 for success, non-zero for failure.
6506 */

--- 56 unchanged lines hidden ---
6387
6388
6389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6390/*
6391 * fusion_init - Fusion MPT base driver initialization routine.
6392 *
6393 * Returns 0 for success, non-zero for failure.
6394 */

--- 56 unchanged lines hidden ---