hpsa.c (aca4a5200dc2b0835f5477d6609a05b0401a91f3) | hpsa.c (4f4eb9f1d8f8eb91d0dd486deafd4800b425f289) |
---|---|
1/* 2 * Disk Array driver for HP Smart Array SAS controllers 3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * --- 200 unchanged lines hidden (view full) --- 209 case LUN_FAILED: 210 dev_warn(&h->pdev->dev, HPSA "%d: LUN failure " 211 "detected, action required\n", h->ctlr); 212 break; 213 case REPORT_LUNS_CHANGED: 214 dev_warn(&h->pdev->dev, HPSA "%d: report LUN data " 215 "changed, action required\n", h->ctlr); 216 /* | 1/* 2 * Disk Array driver for HP Smart Array SAS controllers 3 * Copyright 2000, 2009 Hewlett-Packard Development Company, L.P. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * --- 200 unchanged lines hidden (view full) --- 209 case LUN_FAILED: 210 dev_warn(&h->pdev->dev, HPSA "%d: LUN failure " 211 "detected, action required\n", h->ctlr); 212 break; 213 case REPORT_LUNS_CHANGED: 214 dev_warn(&h->pdev->dev, HPSA "%d: report LUN data " 215 "changed, action required\n", h->ctlr); 216 /* |
217 * Note: this REPORT_LUNS_CHANGED condition only occurs on the MSA2012. | 217 * Note: this REPORT_LUNS_CHANGED condition only occurs on the external 218 * target (array) devices. |
218 */ 219 break; 220 case POWER_OR_RESET: 221 dev_warn(&h->pdev->dev, HPSA "%d: a power on " 222 "or device reset detected\n", h->ctlr); 223 break; 224 case UNIT_ATTENTION_CLEARED: 225 dev_warn(&h->pdev->dev, HPSA "%d: unit attention " --- 1371 unchanged lines hidden (view full) --- 1597 kfree(inq_buff); 1598 return 0; 1599 1600bail_out: 1601 kfree(inq_buff); 1602 return 1; 1603} 1604 | 219 */ 220 break; 221 case POWER_OR_RESET: 222 dev_warn(&h->pdev->dev, HPSA "%d: a power on " 223 "or device reset detected\n", h->ctlr); 224 break; 225 case UNIT_ATTENTION_CLEARED: 226 dev_warn(&h->pdev->dev, HPSA "%d: unit attention " --- 1371 unchanged lines hidden (view full) --- 1598 kfree(inq_buff); 1599 return 0; 1600 1601bail_out: 1602 kfree(inq_buff); 1603 return 1; 1604} 1605 |
1605static unsigned char *msa2xxx_model[] = { | 1606static unsigned char *ext_target_model[] = { |
1606 "MSA2012", 1607 "MSA2024", 1608 "MSA2312", 1609 "MSA2324", 1610 "P2000 G3 SAS", 1611 NULL, 1612}; 1613 | 1607 "MSA2012", 1608 "MSA2024", 1609 "MSA2312", 1610 "MSA2324", 1611 "P2000 G3 SAS", 1612 NULL, 1613}; 1614 |
1614static int is_msa2xxx(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) | 1615static int is_ext_target(struct ctlr_info *h, struct hpsa_scsi_dev_t *device) |
1615{ 1616 int i; 1617 | 1616{ 1617 int i; 1618 |
1618 for (i = 0; msa2xxx_model[i]; i++) 1619 if (strncmp(device->model, msa2xxx_model[i], 1620 strlen(msa2xxx_model[i])) == 0) | 1619 for (i = 0; ext_target_model[i]; i++) 1620 if (strncmp(device->model, ext_target_model[i], 1621 strlen(ext_target_model[i])) == 0) |
1621 return 1; 1622 return 0; 1623} 1624 1625/* Helper function to assign bus, target, lun mapping of devices. | 1622 return 1; 1623 return 0; 1624} 1625 1626/* Helper function to assign bus, target, lun mapping of devices. |
1626 * Puts non-msa2xxx logical volumes on bus 0, msa2xxx logical | 1627 * Puts non-external target logical volumes on bus 0, external target logical |
1627 * volumes on bus 1, physical devices on bus 2. and the hba on bus 3. 1628 * Logical drive target and lun are assigned at this time, but 1629 * physical device lun and target assignment are deferred (assigned 1630 * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.) 1631 */ 1632static void figure_bus_target_lun(struct ctlr_info *h, 1633 u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device) 1634{ --- 4 unchanged lines hidden (view full) --- 1639 if (is_hba_lunid(lunaddrbytes)) 1640 hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff); 1641 else 1642 /* defer target, lun assignment for physical devices */ 1643 hpsa_set_bus_target_lun(device, 2, -1, -1); 1644 return; 1645 } 1646 /* It's a logical device */ | 1628 * volumes on bus 1, physical devices on bus 2. and the hba on bus 3. 1629 * Logical drive target and lun are assigned at this time, but 1630 * physical device lun and target assignment are deferred (assigned 1631 * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.) 1632 */ 1633static void figure_bus_target_lun(struct ctlr_info *h, 1634 u8 *lunaddrbytes, struct hpsa_scsi_dev_t *device) 1635{ --- 4 unchanged lines hidden (view full) --- 1640 if (is_hba_lunid(lunaddrbytes)) 1641 hpsa_set_bus_target_lun(device, 3, 0, lunid & 0x3fff); 1642 else 1643 /* defer target, lun assignment for physical devices */ 1644 hpsa_set_bus_target_lun(device, 2, -1, -1); 1645 return; 1646 } 1647 /* It's a logical device */ |
1647 if (is_msa2xxx(h, device)) { 1648 /* msa2xxx way, put logicals on bus 1 | 1648 if (is_ext_target(h, device)) { 1649 /* external target way, put logicals on bus 1 |
1649 * and match target/lun numbers box 1650 * reports, other smart array, bus 0, target 0, match lunid 1651 */ 1652 hpsa_set_bus_target_lun(device, 1653 1, (lunid >> 16) & 0x3fff, lunid & 0x00ff); 1654 return; 1655 } 1656 hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff); 1657} 1658 1659/* 1660 * If there is no lun 0 on a target, linux won't find any devices. | 1650 * and match target/lun numbers box 1651 * reports, other smart array, bus 0, target 0, match lunid 1652 */ 1653 hpsa_set_bus_target_lun(device, 1654 1, (lunid >> 16) & 0x3fff, lunid & 0x00ff); 1655 return; 1656 } 1657 hpsa_set_bus_target_lun(device, 0, 0, lunid & 0x3fff); 1658} 1659 1660/* 1661 * If there is no lun 0 on a target, linux won't find any devices. |
1661 * For the MSA2xxx boxes, we have to manually detect the enclosure | 1662 * For the external targets (arrays), we have to manually detect the enclosure |
1662 * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report 1663 * it for some reason. *tmpdevice is the target we're adding, 1664 * this_device is a pointer into the current element of currentsd[] 1665 * that we're building up in update_scsi_devices(), below. 1666 * lunzerobits is a bitmap that tracks which targets already have a 1667 * lun 0 assigned. 1668 * Returns 1 if an enclosure was added, 0 if not. 1669 */ | 1663 * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report 1664 * it for some reason. *tmpdevice is the target we're adding, 1665 * this_device is a pointer into the current element of currentsd[] 1666 * that we're building up in update_scsi_devices(), below. 1667 * lunzerobits is a bitmap that tracks which targets already have a 1668 * lun 0 assigned. 1669 * Returns 1 if an enclosure was added, 0 if not. 1670 */ |
1670static int add_msa2xxx_enclosure_device(struct ctlr_info *h, | 1671static int add_ext_target_dev(struct ctlr_info *h, |
1671 struct hpsa_scsi_dev_t *tmpdevice, 1672 struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes, | 1672 struct hpsa_scsi_dev_t *tmpdevice, 1673 struct hpsa_scsi_dev_t *this_device, u8 *lunaddrbytes, |
1673 unsigned long lunzerobits[], int *nmsa2xxx_enclosures) | 1674 unsigned long lunzerobits[], int *n_ext_target_devs) |
1674{ 1675 unsigned char scsi3addr[8]; 1676 1677 if (test_bit(tmpdevice->target, lunzerobits)) 1678 return 0; /* There is already a lun 0 on this target. */ 1679 1680 if (!is_logical_dev_addr_mode(lunaddrbytes)) 1681 return 0; /* It's the logical targets that may lack lun 0. */ 1682 | 1675{ 1676 unsigned char scsi3addr[8]; 1677 1678 if (test_bit(tmpdevice->target, lunzerobits)) 1679 return 0; /* There is already a lun 0 on this target. */ 1680 1681 if (!is_logical_dev_addr_mode(lunaddrbytes)) 1682 return 0; /* It's the logical targets that may lack lun 0. */ 1683 |
1683 if (!is_msa2xxx(h, tmpdevice)) 1684 return 0; /* It's only the MSA2xxx that have this problem. */ | 1684 if (!is_ext_target(h, tmpdevice)) 1685 return 0; /* Only external target devices have this problem. */ |
1685 1686 if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */ 1687 return 0; 1688 1689 memset(scsi3addr, 0, 8); 1690 scsi3addr[3] = tmpdevice->target; 1691 if (is_hba_lunid(scsi3addr)) 1692 return 0; /* Don't add the RAID controller here. */ 1693 1694 if (is_scsi_rev_5(h)) 1695 return 0; /* p1210m doesn't need to do this. */ 1696 | 1686 1687 if (tmpdevice->lun == 0) /* if lun is 0, then we have a lun 0. */ 1688 return 0; 1689 1690 memset(scsi3addr, 0, 8); 1691 scsi3addr[3] = tmpdevice->target; 1692 if (is_hba_lunid(scsi3addr)) 1693 return 0; /* Don't add the RAID controller here. */ 1694 1695 if (is_scsi_rev_5(h)) 1696 return 0; /* p1210m doesn't need to do this. */ 1697 |
1697 if (*nmsa2xxx_enclosures >= MAX_EXT_TARGETS) { | 1698 if (*n_ext_target_devs >= MAX_EXT_TARGETS) { |
1698 dev_warn(&h->pdev->dev, "Maximum number of external " 1699 "target devices exceeded. Check your hardware " 1700 "configuration."); 1701 return 0; 1702 } 1703 1704 if (hpsa_update_device_info(h, scsi3addr, this_device, NULL)) 1705 return 0; | 1699 dev_warn(&h->pdev->dev, "Maximum number of external " 1700 "target devices exceeded. Check your hardware " 1701 "configuration."); 1702 return 0; 1703 } 1704 1705 if (hpsa_update_device_info(h, scsi3addr, this_device, NULL)) 1706 return 0; |
1706 (*nmsa2xxx_enclosures)++; | 1707 (*n_ext_target_devs)++; |
1707 hpsa_set_bus_target_lun(this_device, 1708 tmpdevice->bus, tmpdevice->target, 0); 1709 set_bit(tmpdevice->target, lunzerobits); 1710 return 1; 1711} 1712 1713/* 1714 * Do CISS_REPORT_PHYS and CISS_REPORT_LOG. Data is returned in physdev, --- 80 unchanged lines hidden (view full) --- 1795 struct ReportLUNdata *physdev_list = NULL; 1796 struct ReportLUNdata *logdev_list = NULL; 1797 u32 nphysicals = 0; 1798 u32 nlogicals = 0; 1799 u32 ndev_allocated = 0; 1800 struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice; 1801 int ncurrent = 0; 1802 int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8; | 1708 hpsa_set_bus_target_lun(this_device, 1709 tmpdevice->bus, tmpdevice->target, 0); 1710 set_bit(tmpdevice->target, lunzerobits); 1711 return 1; 1712} 1713 1714/* 1715 * Do CISS_REPORT_PHYS and CISS_REPORT_LOG. Data is returned in physdev, --- 80 unchanged lines hidden (view full) --- 1796 struct ReportLUNdata *physdev_list = NULL; 1797 struct ReportLUNdata *logdev_list = NULL; 1798 u32 nphysicals = 0; 1799 u32 nlogicals = 0; 1800 u32 ndev_allocated = 0; 1801 struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice; 1802 int ncurrent = 0; 1803 int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8; |
1803 int i, nmsa2xxx_enclosures, ndevs_to_allocate; | 1804 int i, n_ext_target_devs, ndevs_to_allocate; |
1804 int raid_ctlr_position; 1805 DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); 1806 1807 currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL); 1808 physdev_list = kzalloc(reportlunsize, GFP_KERNEL); 1809 logdev_list = kzalloc(reportlunsize, GFP_KERNEL); 1810 tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); 1811 --- 32 unchanged lines hidden (view full) --- 1844 } 1845 1846 if (unlikely(is_scsi_rev_5(h))) 1847 raid_ctlr_position = 0; 1848 else 1849 raid_ctlr_position = nphysicals + nlogicals; 1850 1851 /* adjust our table of devices */ | 1805 int raid_ctlr_position; 1806 DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); 1807 1808 currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL); 1809 physdev_list = kzalloc(reportlunsize, GFP_KERNEL); 1810 logdev_list = kzalloc(reportlunsize, GFP_KERNEL); 1811 tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); 1812 --- 32 unchanged lines hidden (view full) --- 1845 } 1846 1847 if (unlikely(is_scsi_rev_5(h))) 1848 raid_ctlr_position = 0; 1849 else 1850 raid_ctlr_position = nphysicals + nlogicals; 1851 1852 /* adjust our table of devices */ |
1852 nmsa2xxx_enclosures = 0; | 1853 n_ext_target_devs = 0; |
1853 for (i = 0; i < nphysicals + nlogicals + 1; i++) { 1854 u8 *lunaddrbytes, is_OBDR = 0; 1855 1856 /* Figure out where the LUN ID info is coming from */ 1857 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, 1858 i, nphysicals, nlogicals, physdev_list, logdev_list); 1859 /* skip masked physical devices. */ 1860 if (lunaddrbytes[3] & 0xC0 && 1861 i < nphysicals + (raid_ctlr_position == 0)) 1862 continue; 1863 1864 /* Get device type, vendor, model, device id */ 1865 if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice, 1866 &is_OBDR)) 1867 continue; /* skip it if we can't talk to it. */ 1868 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); 1869 this_device = currentsd[ncurrent]; 1870 1871 /* | 1854 for (i = 0; i < nphysicals + nlogicals + 1; i++) { 1855 u8 *lunaddrbytes, is_OBDR = 0; 1856 1857 /* Figure out where the LUN ID info is coming from */ 1858 lunaddrbytes = figure_lunaddrbytes(h, raid_ctlr_position, 1859 i, nphysicals, nlogicals, physdev_list, logdev_list); 1860 /* skip masked physical devices. */ 1861 if (lunaddrbytes[3] & 0xC0 && 1862 i < nphysicals + (raid_ctlr_position == 0)) 1863 continue; 1864 1865 /* Get device type, vendor, model, device id */ 1866 if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice, 1867 &is_OBDR)) 1868 continue; /* skip it if we can't talk to it. */ 1869 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); 1870 this_device = currentsd[ncurrent]; 1871 1872 /* |
1872 * For the msa2xxx boxes, we have to insert a LUN 0 which | 1873 * For external target devices, we have to insert a LUN 0 which |
1873 * doesn't show up in CCISS_REPORT_PHYSICAL data, but there 1874 * is nonetheless an enclosure device there. We have to 1875 * present that otherwise linux won't find anything if 1876 * there is no lun 0. 1877 */ | 1874 * doesn't show up in CCISS_REPORT_PHYSICAL data, but there 1875 * is nonetheless an enclosure device there. We have to 1876 * present that otherwise linux won't find anything if 1877 * there is no lun 0. 1878 */ |
1878 if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device, | 1879 if (add_ext_target_dev(h, tmpdevice, this_device, |
1879 lunaddrbytes, lunzerobits, | 1880 lunaddrbytes, lunzerobits, |
1880 &nmsa2xxx_enclosures)) { | 1881 &n_ext_target_devs)) { |
1881 ncurrent++; 1882 this_device = currentsd[ncurrent]; 1883 } 1884 1885 *this_device = *tmpdevice; 1886 1887 switch (this_device->devtype) { 1888 case TYPE_ROM: --- 2780 unchanged lines hidden --- | 1882 ncurrent++; 1883 this_device = currentsd[ncurrent]; 1884 } 1885 1886 *this_device = *tmpdevice; 1887 1888 switch (this_device->devtype) { 1889 case TYPE_ROM: --- 2780 unchanged lines hidden --- |