Deleted Added
full compact
mps_sas_lsi.c (238574) mps_sas_lsi.c (253460)
1/*-
2 * Copyright (c) 2011, 2012 LSI Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * LSI MPT-Fusion Host Adapter FreeBSD
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011, 2012 LSI Corp.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * LSI MPT-Fusion Host Adapter FreeBSD
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/mps/mps_sas_lsi.c 238574 2012-07-18 09:06:07Z brueffer $");
30__FBSDID("$FreeBSD: head/sys/dev/mps/mps_sas_lsi.c 253460 2013-07-19 00:12:41Z scottl $");
31
32/* Communications core for LSI MPT2 */
33
34/* TODO Move headers to mpsvar */
35#include <sys/types.h>
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>

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

186 * Return nothing.
187 */
188static void
189mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
190{
191 struct mpssas_softc *sassc;
192 sassc = sc->sassc;
193
31
32/* Communications core for LSI MPT2 */
33
34/* TODO Move headers to mpsvar */
35#include <sys/types.h>
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>

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

186 * Return nothing.
187 */
188static void
189mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
190{
191 struct mpssas_softc *sassc;
192 sassc = sc->sassc;
193
194 mps_dprint(sc, MPS_INFO, "(%d)->(%s) Working on Event: [%x]\n",
194 mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Working on Event: [%x]\n",
195 event_count++,__func__,fw_event->event);
196 switch (fw_event->event) {
197 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
198 {
199 MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data;
200 MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy;
201 int i;
202

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

369 }
370 case MPI2_EVENT_IR_VOLUME:
371 {
372 Mpi2EventDataIrVolume_t *event_data = fw_event->event_data;
373
374 /*
375 * Informational only.
376 */
195 event_count++,__func__,fw_event->event);
196 switch (fw_event->event) {
197 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
198 {
199 MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data;
200 MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy;
201 int i;
202

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

369 }
370 case MPI2_EVENT_IR_VOLUME:
371 {
372 Mpi2EventDataIrVolume_t *event_data = fw_event->event_data;
373
374 /*
375 * Informational only.
376 */
377 mps_dprint(sc, MPS_INFO, "Received IR Volume event:\n");
377 mps_dprint(sc, MPS_EVENT, "Received IR Volume event:\n");
378 switch (event_data->ReasonCode) {
379 case MPI2_EVENT_IR_VOLUME_RC_SETTINGS_CHANGED:
378 switch (event_data->ReasonCode) {
379 case MPI2_EVENT_IR_VOLUME_RC_SETTINGS_CHANGED:
380 mps_dprint(sc, MPS_INFO, " Volume Settings "
380 mps_dprint(sc, MPS_EVENT, " Volume Settings "
381 "changed from 0x%x to 0x%x for Volome with "
382 "handle 0x%x", le32toh(event_data->PreviousValue),
383 le32toh(event_data->NewValue),
384 le16toh(event_data->VolDevHandle));
385 break;
386 case MPI2_EVENT_IR_VOLUME_RC_STATUS_FLAGS_CHANGED:
381 "changed from 0x%x to 0x%x for Volome with "
382 "handle 0x%x", le32toh(event_data->PreviousValue),
383 le32toh(event_data->NewValue),
384 le16toh(event_data->VolDevHandle));
385 break;
386 case MPI2_EVENT_IR_VOLUME_RC_STATUS_FLAGS_CHANGED:
387 mps_dprint(sc, MPS_INFO, " Volume Status "
387 mps_dprint(sc, MPS_EVENT, " Volume Status "
388 "changed from 0x%x to 0x%x for Volome with "
389 "handle 0x%x", le32toh(event_data->PreviousValue),
390 le32toh(event_data->NewValue),
391 le16toh(event_data->VolDevHandle));
392 break;
393 case MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED:
388 "changed from 0x%x to 0x%x for Volome with "
389 "handle 0x%x", le32toh(event_data->PreviousValue),
390 le32toh(event_data->NewValue),
391 le16toh(event_data->VolDevHandle));
392 break;
393 case MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED:
394 mps_dprint(sc, MPS_INFO, " Volume State "
394 mps_dprint(sc, MPS_EVENT, " Volume State "
395 "changed from 0x%x to 0x%x for Volome with "
396 "handle 0x%x", le32toh(event_data->PreviousValue),
397 le32toh(event_data->NewValue),
398 le16toh(event_data->VolDevHandle));
399 u32 state;
400 struct mpssas_target *targ;
401 state = le32toh(event_data->NewValue);
402 switch (state) {

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

435 {
436 Mpi2EventDataIrPhysicalDisk_t *event_data =
437 fw_event->event_data;
438 struct mpssas_target *targ;
439
440 /*
441 * Informational only.
442 */
395 "changed from 0x%x to 0x%x for Volome with "
396 "handle 0x%x", le32toh(event_data->PreviousValue),
397 le32toh(event_data->NewValue),
398 le16toh(event_data->VolDevHandle));
399 u32 state;
400 struct mpssas_target *targ;
401 state = le32toh(event_data->NewValue);
402 switch (state) {

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

435 {
436 Mpi2EventDataIrPhysicalDisk_t *event_data =
437 fw_event->event_data;
438 struct mpssas_target *targ;
439
440 /*
441 * Informational only.
442 */
443 mps_dprint(sc, MPS_INFO, "Received IR Phys Disk event:\n");
443 mps_dprint(sc, MPS_EVENT, "Received IR Phys Disk event:\n");
444 switch (event_data->ReasonCode) {
445 case MPI2_EVENT_IR_PHYSDISK_RC_SETTINGS_CHANGED:
444 switch (event_data->ReasonCode) {
445 case MPI2_EVENT_IR_PHYSDISK_RC_SETTINGS_CHANGED:
446 mps_dprint(sc, MPS_INFO, " Phys Disk Settings "
446 mps_dprint(sc, MPS_EVENT, " Phys Disk Settings "
447 "changed from 0x%x to 0x%x for Phys Disk Number "
448 "%d and handle 0x%x at Enclosure handle 0x%x, Slot "
449 "%d", le32toh(event_data->PreviousValue),
450 le32toh(event_data->NewValue),
451 event_data->PhysDiskNum,
452 le16toh(event_data->PhysDiskDevHandle),
453 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
454 break;
455 case MPI2_EVENT_IR_PHYSDISK_RC_STATUS_FLAGS_CHANGED:
447 "changed from 0x%x to 0x%x for Phys Disk Number "
448 "%d and handle 0x%x at Enclosure handle 0x%x, Slot "
449 "%d", le32toh(event_data->PreviousValue),
450 le32toh(event_data->NewValue),
451 event_data->PhysDiskNum,
452 le16toh(event_data->PhysDiskDevHandle),
453 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
454 break;
455 case MPI2_EVENT_IR_PHYSDISK_RC_STATUS_FLAGS_CHANGED:
456 mps_dprint(sc, MPS_INFO, " Phys Disk Status changed "
456 mps_dprint(sc, MPS_EVENT, " Phys Disk Status changed "
457 "from 0x%x to 0x%x for Phys Disk Number %d and "
458 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
459 le32toh(event_data->PreviousValue),
460 le32toh(event_data->NewValue), event_data->PhysDiskNum,
461 le16toh(event_data->PhysDiskDevHandle),
462 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
463 break;
464 case MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED:
457 "from 0x%x to 0x%x for Phys Disk Number %d and "
458 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
459 le32toh(event_data->PreviousValue),
460 le32toh(event_data->NewValue), event_data->PhysDiskNum,
461 le16toh(event_data->PhysDiskDevHandle),
462 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
463 break;
464 case MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED:
465 mps_dprint(sc, MPS_INFO, " Phys Disk State changed "
465 mps_dprint(sc, MPS_EVENT, " Phys Disk State changed "
466 "from 0x%x to 0x%x for Phys Disk Number %d and "
467 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
468 le32toh(event_data->PreviousValue),
469 le32toh(event_data->NewValue), event_data->PhysDiskNum,
470 le16toh(event_data->PhysDiskDevHandle),
471 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
472 switch (event_data->NewValue) {
473 case MPI2_RAID_PD_STATE_ONLINE:

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

513 case MPI2_EVENT_IR_OPERATION_STATUS:
514 {
515 Mpi2EventDataIrOperationStatus_t *event_data =
516 fw_event->event_data;
517
518 /*
519 * Informational only.
520 */
466 "from 0x%x to 0x%x for Phys Disk Number %d and "
467 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
468 le32toh(event_data->PreviousValue),
469 le32toh(event_data->NewValue), event_data->PhysDiskNum,
470 le16toh(event_data->PhysDiskDevHandle),
471 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
472 switch (event_data->NewValue) {
473 case MPI2_RAID_PD_STATE_ONLINE:

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

513 case MPI2_EVENT_IR_OPERATION_STATUS:
514 {
515 Mpi2EventDataIrOperationStatus_t *event_data =
516 fw_event->event_data;
517
518 /*
519 * Informational only.
520 */
521 mps_dprint(sc, MPS_INFO, "Received IR Op Status event:\n");
522 mps_dprint(sc, MPS_INFO, " RAID Operation of %d is %d "
521 mps_dprint(sc, MPS_EVENT, "Received IR Op Status event:\n");
522 mps_dprint(sc, MPS_EVENT, " RAID Operation of %d is %d "
523 "percent complete for Volume with handle 0x%x",
524 event_data->RAIDOperation, event_data->PercentComplete,
525 le16toh(event_data->VolDevHandle));
526 break;
527 }
528 case MPI2_EVENT_LOG_ENTRY_ADDED:
529 {
530 pMpi2EventDataLogEntryAdded_t logEntry;

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

572 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
573 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
574 default:
575 mps_dprint(sc, MPS_TRACE,"Unhandled event 0x%0X\n",
576 fw_event->event);
577 break;
578
579 }
523 "percent complete for Volume with handle 0x%x",
524 event_data->RAIDOperation, event_data->PercentComplete,
525 le16toh(event_data->VolDevHandle));
526 break;
527 }
528 case MPI2_EVENT_LOG_ENTRY_ADDED:
529 {
530 pMpi2EventDataLogEntryAdded_t logEntry;

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

572 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
573 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
574 default:
575 mps_dprint(sc, MPS_TRACE,"Unhandled event 0x%0X\n",
576 fw_event->event);
577 break;
578
579 }
580 mps_dprint(sc, MPS_INFO, "(%d)->(%s) Event Free: [%x]\n",event_count,__func__, fw_event->event);
580 mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Event Free: [%x]\n",event_count,__func__, fw_event->event);
581 mpssas_fw_event_free(sc, fw_event);
582}
583
584void
585mpssas_firmware_event_work(void *arg, int pending)
586{
587 struct mps_fw_event_work *fw_event;
588 struct mps_softc *sc;

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

664
665 if (id == MPS_MAP_BAD_ID) {
666 printf("failure at %s:%d/%s()! Could not get ID for device "
667 "with handle 0x%04x\n", __FILE__, __LINE__, __func__,
668 handle);
669 error = ENXIO;
670 goto out;
671 }
581 mpssas_fw_event_free(sc, fw_event);
582}
583
584void
585mpssas_firmware_event_work(void *arg, int pending)
586{
587 struct mps_fw_event_work *fw_event;
588 struct mps_softc *sc;

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

664
665 if (id == MPS_MAP_BAD_ID) {
666 printf("failure at %s:%d/%s()! Could not get ID for device "
667 "with handle 0x%04x\n", __FILE__, __LINE__, __func__,
668 handle);
669 error = ENXIO;
670 goto out;
671 }
672 mps_dprint(sc, MPS_INFO, "SAS Address from SAS device page0 = %jx\n",
672 mps_dprint(sc, MPS_MAPPING, "SAS Address from SAS device page0 = %jx\n",
673 sas_address);
674 targ = &sassc->targets[id];
675 targ->devinfo = device_info;
676 targ->devname = le32toh(config_page.DeviceName.High);
677 targ->devname = (targ->devname << 32) |
678 le32toh(config_page.DeviceName.Low);
679 targ->encl_handle = le16toh(config_page.EnclosureHandle);
680 targ->encl_slot = le16toh(config_page.Slot);

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

691 while(!SLIST_EMPTY(&targ->luns)) {
692 lun = SLIST_FIRST(&targ->luns);
693 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
694 free(lun, M_MPT2);
695 }
696 SLIST_INIT(&targ->luns);
697
698 mps_describe_devinfo(targ->devinfo, devstring, 80);
673 sas_address);
674 targ = &sassc->targets[id];
675 targ->devinfo = device_info;
676 targ->devname = le32toh(config_page.DeviceName.High);
677 targ->devname = (targ->devname << 32) |
678 le32toh(config_page.DeviceName.Low);
679 targ->encl_handle = le16toh(config_page.EnclosureHandle);
680 targ->encl_slot = le16toh(config_page.Slot);

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

691 while(!SLIST_EMPTY(&targ->luns)) {
692 lun = SLIST_FIRST(&targ->luns);
693 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
694 free(lun, M_MPT2);
695 }
696 SLIST_INIT(&targ->luns);
697
698 mps_describe_devinfo(targ->devinfo, devstring, 80);
699 mps_dprint(sc, MPS_INFO, "Found device <%s> <%s> <0x%04x> <%d/%d>\n", devstring,
699 mps_dprint(sc, MPS_MAPPING, "Found device <%s> <%s> <0x%04x> <%d/%d>\n", devstring,
700 mps_describe_table(mps_linkrate_names, targ->linkrate),
701 targ->handle, targ->encl_handle, targ->encl_slot);
702 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
703 mpssas_rescan_target(sc, targ);
700 mps_describe_table(mps_linkrate_names, targ->linkrate),
701 targ->handle, targ->encl_handle, targ->encl_slot);
702 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
703 mpssas_rescan_target(sc, targ);
704 mps_dprint(sc, MPS_INFO, "Target id 0x%x added\n", targ->tid);
704 mps_dprint(sc, MPS_MAPPING, "Target id 0x%x added\n", targ->tid);
705out:
706 mpssas_startup_decrement(sassc);
707 return (error);
708
709}
710
711int
712mpssas_get_sas_address_for_sata_disk(struct mps_softc *sc,

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

729 try_count++;
730 ioc_status = le16toh(mpi_reply.IOCStatus)
731 & MPI2_IOCSTATUS_MASK;
732 sas_status = mpi_reply.SASStatus;
733 } while ((rc == -EAGAIN || ioc_status || sas_status) &&
734 (try_count < 5));
735
736 if (rc == 0 && !ioc_status && !sas_status) {
705out:
706 mpssas_startup_decrement(sassc);
707 return (error);
708
709}
710
711int
712mpssas_get_sas_address_for_sata_disk(struct mps_softc *sc,

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

729 try_count++;
730 ioc_status = le16toh(mpi_reply.IOCStatus)
731 & MPI2_IOCSTATUS_MASK;
732 sas_status = mpi_reply.SASStatus;
733 } while ((rc == -EAGAIN || ioc_status || sas_status) &&
734 (try_count < 5));
735
736 if (rc == 0 && !ioc_status && !sas_status) {
737 mps_dprint(sc, MPS_INFO, "%s: got SATA identify successfully "
737 mps_dprint(sc, MPS_MAPPING, "%s: got SATA identify successfully "
738 "for handle = 0x%x with try_count = %d\n",
739 __func__, handle, try_count);
740 } else {
738 "for handle = 0x%x with try_count = %d\n",
739 __func__, handle, try_count);
740 } else {
741 mps_dprint(sc, MPS_INFO, "%s: handle = 0x%x failed\n",
741 mps_dprint(sc, MPS_MAPPING, "%s: handle = 0x%x failed\n",
742 __func__, handle);
743 return -1;
744 }
745 /* Copy & byteswap the 40 byte model number to a buffer */
746 for (i = 0; i < MPT2SAS_MN_LEN; i += 2) {
747 buffer[i] = ((u8 *)ata_identify.model_number)[i + 1];
748 buffer[i + 1] = ((u8 *)ata_identify.model_number)[i];
749 }

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

882 while(!SLIST_EMPTY(&targ->luns)) {
883 lun = SLIST_FIRST(&targ->luns);
884 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
885 free(lun, M_MPT2);
886 }
887 SLIST_INIT(&targ->luns);
888 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
889 mpssas_rescan_target(sc, targ);
742 __func__, handle);
743 return -1;
744 }
745 /* Copy & byteswap the 40 byte model number to a buffer */
746 for (i = 0; i < MPT2SAS_MN_LEN; i += 2) {
747 buffer[i] = ((u8 *)ata_identify.model_number)[i + 1];
748 buffer[i + 1] = ((u8 *)ata_identify.model_number)[i];
749 }

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

882 while(!SLIST_EMPTY(&targ->luns)) {
883 lun = SLIST_FIRST(&targ->luns);
884 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
885 free(lun, M_MPT2);
886 }
887 SLIST_INIT(&targ->luns);
888 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
889 mpssas_rescan_target(sc, targ);
890 mps_dprint(sc, MPS_INFO, "RAID target id %d added (WWID = 0x%jx)\n",
890 mps_dprint(sc, MPS_MAPPING, "RAID target id %d added (WWID = 0x%jx)\n",
891 targ->tid, wwid);
892out:
893 mpssas_startup_decrement(sassc);
894 return (error);
895}
896
897/**
898 * mpssas_ir_shutdown - IR shutdown notification

--- 68 unchanged lines hidden ---
891 targ->tid, wwid);
892out:
893 mpssas_startup_decrement(sassc);
894 return (error);
895}
896
897/**
898 * mpssas_ir_shutdown - IR shutdown notification

--- 68 unchanged lines hidden ---