aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c390
1 files changed, 332 insertions, 58 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index e1a30a16a9fa..1849e33e68f9 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -23,12 +23,15 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/aer.h>
27#include <linux/gfp.h>
26 28
27#include <scsi/scsi.h> 29#include <scsi/scsi.h>
28#include <scsi/scsi_device.h> 30#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
30#include <scsi/scsi_tcq.h> 32#include <scsi/scsi_tcq.h>
31#include <scsi/scsi_transport_fc.h> 33#include <scsi/scsi_transport_fc.h>
34#include <scsi/fc/fc_fs.h>
32 35
33#include "lpfc_hw4.h" 36#include "lpfc_hw4.h"
34#include "lpfc_hw.h" 37#include "lpfc_hw.h"
@@ -98,6 +101,28 @@ lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
98 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); 101 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
99} 102}
100 103
104/**
105 * lpfc_enable_fip_show - Return the fip mode of the HBA
106 * @dev: class unused variable.
107 * @attr: device attribute, not used.
108 * @buf: on return contains the module description text.
109 *
110 * Returns: size of formatted string.
111 **/
112static ssize_t
113lpfc_enable_fip_show(struct device *dev, struct device_attribute *attr,
114 char *buf)
115{
116 struct Scsi_Host *shost = class_to_shost(dev);
117 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
118 struct lpfc_hba *phba = vport->phba;
119
120 if (phba->hba_flag & HBA_FIP_SUPPORT)
121 return snprintf(buf, PAGE_SIZE, "1\n");
122 else
123 return snprintf(buf, PAGE_SIZE, "0\n");
124}
125
101static ssize_t 126static ssize_t
102lpfc_bg_info_show(struct device *dev, struct device_attribute *attr, 127lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
103 char *buf) 128 char *buf)
@@ -458,6 +483,41 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr,
458} 483}
459 484
460/** 485/**
486 * lpfc_link_state_store - Transition the link_state on an HBA port
487 * @dev: class device that is converted into a Scsi_host.
488 * @attr: device attribute, not used.
489 * @buf: one or more lpfc_polling_flags values.
490 * @count: not used.
491 *
492 * Returns:
493 * -EINVAL if the buffer is not "up" or "down"
494 * return from link state change function if non-zero
495 * length of the buf on success
496 **/
497static ssize_t
498lpfc_link_state_store(struct device *dev, struct device_attribute *attr,
499 const char *buf, size_t count)
500{
501 struct Scsi_Host *shost = class_to_shost(dev);
502 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
503 struct lpfc_hba *phba = vport->phba;
504
505 int status = -EINVAL;
506
507 if ((strncmp(buf, "up", sizeof("up") - 1) == 0) &&
508 (phba->link_state == LPFC_LINK_DOWN))
509 status = phba->lpfc_hba_init_link(phba);
510 else if ((strncmp(buf, "down", sizeof("down") - 1) == 0) &&
511 (phba->link_state >= LPFC_LINK_UP))
512 status = phba->lpfc_hba_down_link(phba);
513
514 if (status == 0)
515 return strlen(buf);
516 else
517 return status;
518}
519
520/**
461 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports 521 * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports
462 * @dev: class device that is converted into a Scsi_host. 522 * @dev: class device that is converted into a Scsi_host.
463 * @attr: device attribute, not used. 523 * @attr: device attribute, not used.
@@ -654,7 +714,7 @@ lpfc_selective_reset(struct lpfc_hba *phba)
654 * Notes: 714 * Notes:
655 * Assumes any error from lpfc_selective_reset() will be negative. 715 * Assumes any error from lpfc_selective_reset() will be negative.
656 * If lpfc_selective_reset() returns zero then the length of the buffer 716 * If lpfc_selective_reset() returns zero then the length of the buffer
657 * is returned which indicates succcess 717 * is returned which indicates success
658 * 718 *
659 * Returns: 719 * Returns:
660 * -EINVAL if the buffer does not contain the string "selective" 720 * -EINVAL if the buffer does not contain the string "selective"
@@ -762,9 +822,15 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr,
762 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) 822 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
763 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 823 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
764 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) 824 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
765 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START); 825 if (phba->sli_rev == LPFC_SLI_REV4)
826 return -EINVAL;
827 else
828 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
766 else if (strncmp(buf, "error", sizeof("error") - 1) == 0) 829 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
767 status = lpfc_do_offline(phba, LPFC_EVT_KILL); 830 if (phba->sli_rev == LPFC_SLI_REV4)
831 return -EINVAL;
832 else
833 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
768 else 834 else
769 return -EINVAL; 835 return -EINVAL;
770 836
@@ -1126,6 +1192,9 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr,
1126 if ((val & 0x3) != val) 1192 if ((val & 0x3) != val)
1127 return -EINVAL; 1193 return -EINVAL;
1128 1194
1195 if (phba->sli_rev == LPFC_SLI_REV4)
1196 val = 0;
1197
1129 spin_lock_irq(&phba->hbalock); 1198 spin_lock_irq(&phba->hbalock);
1130 1199
1131 old_val = phba->cfg_poll; 1200 old_val = phba->cfg_poll;
@@ -1186,7 +1255,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1186 struct Scsi_Host *shost = class_to_shost(dev);\ 1255 struct Scsi_Host *shost = class_to_shost(dev);\
1187 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1256 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1188 struct lpfc_hba *phba = vport->phba;\ 1257 struct lpfc_hba *phba = vport->phba;\
1189 int val = 0;\ 1258 uint val = 0;\
1190 val = phba->cfg_##attr;\ 1259 val = phba->cfg_##attr;\
1191 return snprintf(buf, PAGE_SIZE, "%d\n",\ 1260 return snprintf(buf, PAGE_SIZE, "%d\n",\
1192 phba->cfg_##attr);\ 1261 phba->cfg_##attr);\
@@ -1214,7 +1283,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1214 struct Scsi_Host *shost = class_to_shost(dev);\ 1283 struct Scsi_Host *shost = class_to_shost(dev);\
1215 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1284 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1216 struct lpfc_hba *phba = vport->phba;\ 1285 struct lpfc_hba *phba = vport->phba;\
1217 int val = 0;\ 1286 uint val = 0;\
1218 val = phba->cfg_##attr;\ 1287 val = phba->cfg_##attr;\
1219 return snprintf(buf, PAGE_SIZE, "%#x\n",\ 1288 return snprintf(buf, PAGE_SIZE, "%#x\n",\
1220 phba->cfg_##attr);\ 1289 phba->cfg_##attr);\
@@ -1241,7 +1310,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1241 **/ 1310 **/
1242#define lpfc_param_init(attr, default, minval, maxval) \ 1311#define lpfc_param_init(attr, default, minval, maxval) \
1243static int \ 1312static int \
1244lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ 1313lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1245{ \ 1314{ \
1246 if (val >= minval && val <= maxval) {\ 1315 if (val >= minval && val <= maxval) {\
1247 phba->cfg_##attr = val;\ 1316 phba->cfg_##attr = val;\
@@ -1276,7 +1345,7 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
1276 **/ 1345 **/
1277#define lpfc_param_set(attr, default, minval, maxval) \ 1346#define lpfc_param_set(attr, default, minval, maxval) \
1278static int \ 1347static int \
1279lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ 1348lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1280{ \ 1349{ \
1281 if (val >= minval && val <= maxval) {\ 1350 if (val >= minval && val <= maxval) {\
1282 phba->cfg_##attr = val;\ 1351 phba->cfg_##attr = val;\
@@ -1317,7 +1386,7 @@ lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1317 struct Scsi_Host *shost = class_to_shost(dev);\ 1386 struct Scsi_Host *shost = class_to_shost(dev);\
1318 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1387 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1319 struct lpfc_hba *phba = vport->phba;\ 1388 struct lpfc_hba *phba = vport->phba;\
1320 int val=0;\ 1389 uint val = 0;\
1321 if (!isdigit(buf[0]))\ 1390 if (!isdigit(buf[0]))\
1322 return -EINVAL;\ 1391 return -EINVAL;\
1323 if (sscanf(buf, "%i", &val) != 1)\ 1392 if (sscanf(buf, "%i", &val) != 1)\
@@ -1349,7 +1418,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1349{ \ 1418{ \
1350 struct Scsi_Host *shost = class_to_shost(dev);\ 1419 struct Scsi_Host *shost = class_to_shost(dev);\
1351 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1420 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1352 int val = 0;\ 1421 uint val = 0;\
1353 val = vport->cfg_##attr;\ 1422 val = vport->cfg_##attr;\
1354 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ 1423 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
1355} 1424}
@@ -1376,7 +1445,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1376{ \ 1445{ \
1377 struct Scsi_Host *shost = class_to_shost(dev);\ 1446 struct Scsi_Host *shost = class_to_shost(dev);\
1378 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1447 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1379 int val = 0;\ 1448 uint val = 0;\
1380 val = vport->cfg_##attr;\ 1449 val = vport->cfg_##attr;\
1381 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ 1450 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
1382} 1451}
@@ -1401,7 +1470,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1401 **/ 1470 **/
1402#define lpfc_vport_param_init(attr, default, minval, maxval) \ 1471#define lpfc_vport_param_init(attr, default, minval, maxval) \
1403static int \ 1472static int \
1404lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ 1473lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1405{ \ 1474{ \
1406 if (val >= minval && val <= maxval) {\ 1475 if (val >= minval && val <= maxval) {\
1407 vport->cfg_##attr = val;\ 1476 vport->cfg_##attr = val;\
@@ -1433,7 +1502,7 @@ lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
1433 **/ 1502 **/
1434#define lpfc_vport_param_set(attr, default, minval, maxval) \ 1503#define lpfc_vport_param_set(attr, default, minval, maxval) \
1435static int \ 1504static int \
1436lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ 1505lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1437{ \ 1506{ \
1438 if (val >= minval && val <= maxval) {\ 1507 if (val >= minval && val <= maxval) {\
1439 vport->cfg_##attr = val;\ 1508 vport->cfg_##attr = val;\
@@ -1469,7 +1538,7 @@ lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1469{ \ 1538{ \
1470 struct Scsi_Host *shost = class_to_shost(dev);\ 1539 struct Scsi_Host *shost = class_to_shost(dev);\
1471 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\ 1540 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
1472 int val=0;\ 1541 uint val = 0;\
1473 if (!isdigit(buf[0]))\ 1542 if (!isdigit(buf[0]))\
1474 return -EINVAL;\ 1543 return -EINVAL;\
1475 if (sscanf(buf, "%i", &val) != 1)\ 1544 if (sscanf(buf, "%i", &val) != 1)\
@@ -1482,22 +1551,22 @@ lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \
1482 1551
1483 1552
1484#define LPFC_ATTR(name, defval, minval, maxval, desc) \ 1553#define LPFC_ATTR(name, defval, minval, maxval, desc) \
1485static int lpfc_##name = defval;\ 1554static uint lpfc_##name = defval;\
1486module_param(lpfc_##name, int, 0);\ 1555module_param(lpfc_##name, uint, 0);\
1487MODULE_PARM_DESC(lpfc_##name, desc);\ 1556MODULE_PARM_DESC(lpfc_##name, desc);\
1488lpfc_param_init(name, defval, minval, maxval) 1557lpfc_param_init(name, defval, minval, maxval)
1489 1558
1490#define LPFC_ATTR_R(name, defval, minval, maxval, desc) \ 1559#define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
1491static int lpfc_##name = defval;\ 1560static uint lpfc_##name = defval;\
1492module_param(lpfc_##name, int, 0);\ 1561module_param(lpfc_##name, uint, 0);\
1493MODULE_PARM_DESC(lpfc_##name, desc);\ 1562MODULE_PARM_DESC(lpfc_##name, desc);\
1494lpfc_param_show(name)\ 1563lpfc_param_show(name)\
1495lpfc_param_init(name, defval, minval, maxval)\ 1564lpfc_param_init(name, defval, minval, maxval)\
1496static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 1565static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1497 1566
1498#define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \ 1567#define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
1499static int lpfc_##name = defval;\ 1568static uint lpfc_##name = defval;\
1500module_param(lpfc_##name, int, 0);\ 1569module_param(lpfc_##name, uint, 0);\
1501MODULE_PARM_DESC(lpfc_##name, desc);\ 1570MODULE_PARM_DESC(lpfc_##name, desc);\
1502lpfc_param_show(name)\ 1571lpfc_param_show(name)\
1503lpfc_param_init(name, defval, minval, maxval)\ 1572lpfc_param_init(name, defval, minval, maxval)\
@@ -1507,16 +1576,16 @@ static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1507 lpfc_##name##_show, lpfc_##name##_store) 1576 lpfc_##name##_show, lpfc_##name##_store)
1508 1577
1509#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 1578#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1510static int lpfc_##name = defval;\ 1579static uint lpfc_##name = defval;\
1511module_param(lpfc_##name, int, 0);\ 1580module_param(lpfc_##name, uint, 0);\
1512MODULE_PARM_DESC(lpfc_##name, desc);\ 1581MODULE_PARM_DESC(lpfc_##name, desc);\
1513lpfc_param_hex_show(name)\ 1582lpfc_param_hex_show(name)\
1514lpfc_param_init(name, defval, minval, maxval)\ 1583lpfc_param_init(name, defval, minval, maxval)\
1515static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 1584static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1516 1585
1517#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 1586#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1518static int lpfc_##name = defval;\ 1587static uint lpfc_##name = defval;\
1519module_param(lpfc_##name, int, 0);\ 1588module_param(lpfc_##name, uint, 0);\
1520MODULE_PARM_DESC(lpfc_##name, desc);\ 1589MODULE_PARM_DESC(lpfc_##name, desc);\
1521lpfc_param_hex_show(name)\ 1590lpfc_param_hex_show(name)\
1522lpfc_param_init(name, defval, minval, maxval)\ 1591lpfc_param_init(name, defval, minval, maxval)\
@@ -1526,22 +1595,22 @@ static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1526 lpfc_##name##_show, lpfc_##name##_store) 1595 lpfc_##name##_show, lpfc_##name##_store)
1527 1596
1528#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \ 1597#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
1529static int lpfc_##name = defval;\ 1598static uint lpfc_##name = defval;\
1530module_param(lpfc_##name, int, 0);\ 1599module_param(lpfc_##name, uint, 0);\
1531MODULE_PARM_DESC(lpfc_##name, desc);\ 1600MODULE_PARM_DESC(lpfc_##name, desc);\
1532lpfc_vport_param_init(name, defval, minval, maxval) 1601lpfc_vport_param_init(name, defval, minval, maxval)
1533 1602
1534#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \ 1603#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
1535static int lpfc_##name = defval;\ 1604static uint lpfc_##name = defval;\
1536module_param(lpfc_##name, int, 0);\ 1605module_param(lpfc_##name, uint, 0);\
1537MODULE_PARM_DESC(lpfc_##name, desc);\ 1606MODULE_PARM_DESC(lpfc_##name, desc);\
1538lpfc_vport_param_show(name)\ 1607lpfc_vport_param_show(name)\
1539lpfc_vport_param_init(name, defval, minval, maxval)\ 1608lpfc_vport_param_init(name, defval, minval, maxval)\
1540static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 1609static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1541 1610
1542#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \ 1611#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
1543static int lpfc_##name = defval;\ 1612static uint lpfc_##name = defval;\
1544module_param(lpfc_##name, int, 0);\ 1613module_param(lpfc_##name, uint, 0);\
1545MODULE_PARM_DESC(lpfc_##name, desc);\ 1614MODULE_PARM_DESC(lpfc_##name, desc);\
1546lpfc_vport_param_show(name)\ 1615lpfc_vport_param_show(name)\
1547lpfc_vport_param_init(name, defval, minval, maxval)\ 1616lpfc_vport_param_init(name, defval, minval, maxval)\
@@ -1551,16 +1620,16 @@ static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1551 lpfc_##name##_show, lpfc_##name##_store) 1620 lpfc_##name##_show, lpfc_##name##_store)
1552 1621
1553#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \ 1622#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
1554static int lpfc_##name = defval;\ 1623static uint lpfc_##name = defval;\
1555module_param(lpfc_##name, int, 0);\ 1624module_param(lpfc_##name, uint, 0);\
1556MODULE_PARM_DESC(lpfc_##name, desc);\ 1625MODULE_PARM_DESC(lpfc_##name, desc);\
1557lpfc_vport_param_hex_show(name)\ 1626lpfc_vport_param_hex_show(name)\
1558lpfc_vport_param_init(name, defval, minval, maxval)\ 1627lpfc_vport_param_init(name, defval, minval, maxval)\
1559static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL) 1628static DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
1560 1629
1561#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \ 1630#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
1562static int lpfc_##name = defval;\ 1631static uint lpfc_##name = defval;\
1563module_param(lpfc_##name, int, 0);\ 1632module_param(lpfc_##name, uint, 0);\
1564MODULE_PARM_DESC(lpfc_##name, desc);\ 1633MODULE_PARM_DESC(lpfc_##name, desc);\
1565lpfc_vport_param_hex_show(name)\ 1634lpfc_vport_param_hex_show(name)\
1566lpfc_vport_param_init(name, defval, minval, maxval)\ 1635lpfc_vport_param_init(name, defval, minval, maxval)\
@@ -1581,7 +1650,8 @@ static DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
1581static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL); 1650static DEVICE_ATTR(portnum, S_IRUGO, lpfc_vportnum_show, NULL);
1582static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL); 1651static DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
1583static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL); 1652static DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
1584static DEVICE_ATTR(link_state, S_IRUGO, lpfc_link_state_show, NULL); 1653static DEVICE_ATTR(link_state, S_IRUGO | S_IWUSR, lpfc_link_state_show,
1654 lpfc_link_state_store);
1585static DEVICE_ATTR(option_rom_version, S_IRUGO, 1655static DEVICE_ATTR(option_rom_version, S_IRUGO,
1586 lpfc_option_rom_version_show, NULL); 1656 lpfc_option_rom_version_show, NULL);
1587static DEVICE_ATTR(num_discovered_ports, S_IRUGO, 1657static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
@@ -1589,6 +1659,7 @@ static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
1589static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); 1659static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
1590static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 1660static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
1591static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); 1661static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL);
1662static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL);
1592static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 1663static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
1593 lpfc_board_mode_show, lpfc_board_mode_store); 1664 lpfc_board_mode_show, lpfc_board_mode_store);
1594static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 1665static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -1863,6 +1934,17 @@ static DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
1863 lpfc_enable_npiv_show, NULL); 1934 lpfc_enable_npiv_show, NULL);
1864 1935
1865/* 1936/*
1937# lpfc_suppress_link_up: Bring link up at initialization
1938# 0x0 = bring link up (issue MBX_INIT_LINK)
1939# 0x1 = do NOT bring link up at initialization(MBX_INIT_LINK)
1940# 0x2 = never bring up link
1941# Default value is 0.
1942*/
1943LPFC_ATTR_R(suppress_link_up, LPFC_INITIALIZE_LINK, LPFC_INITIALIZE_LINK,
1944 LPFC_DELAY_INIT_LINK_INDEFINITELY,
1945 "Suppress Link Up at initialization");
1946
1947/*
1866# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear 1948# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
1867# until the timer expires. Value range is [0,255]. Default value is 30. 1949# until the timer expires. Value range is [0,255]. Default value is 30.
1868*/ 1950*/
@@ -1887,8 +1969,7 @@ lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr,
1887{ 1969{
1888 struct Scsi_Host *shost = class_to_shost(dev); 1970 struct Scsi_Host *shost = class_to_shost(dev);
1889 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1971 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1890 int val = 0; 1972
1891 val = vport->cfg_devloss_tmo;
1892 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); 1973 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
1893} 1974}
1894 1975
@@ -2759,6 +2840,196 @@ static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
2759 lpfc_link_speed_show, lpfc_link_speed_store); 2840 lpfc_link_speed_show, lpfc_link_speed_store);
2760 2841
2761/* 2842/*
2843# lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
2844# 0 = aer disabled or not supported
2845# 1 = aer supported and enabled (default)
2846# Value range is [0,1]. Default value is 1.
2847*/
2848
2849/**
2850 * lpfc_aer_support_store - Set the adapter for aer support
2851 *
2852 * @dev: class device that is converted into a Scsi_host.
2853 * @attr: device attribute, not used.
2854 * @buf: containing the string "selective".
2855 * @count: unused variable.
2856 *
2857 * Description:
2858 * If the val is 1 and currently the device's AER capability was not
2859 * enabled, invoke the kernel's enable AER helper routine, trying to
2860 * enable the device's AER capability. If the helper routine enabling
2861 * AER returns success, update the device's cfg_aer_support flag to
2862 * indicate AER is supported by the device; otherwise, if the device
2863 * AER capability is already enabled to support AER, then do nothing.
2864 *
2865 * If the val is 0 and currently the device's AER support was enabled,
2866 * invoke the kernel's disable AER helper routine. After that, update
2867 * the device's cfg_aer_support flag to indicate AER is not supported
2868 * by the device; otherwise, if the device AER capability is already
2869 * disabled from supporting AER, then do nothing.
2870 *
2871 * Returns:
2872 * length of the buf on success if val is in range the intended mode
2873 * is supported.
2874 * -EINVAL if val out of range or intended mode is not supported.
2875 **/
2876static ssize_t
2877lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
2878 const char *buf, size_t count)
2879{
2880 struct Scsi_Host *shost = class_to_shost(dev);
2881 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
2882 struct lpfc_hba *phba = vport->phba;
2883 int val = 0, rc = -EINVAL;
2884
2885 /* AER not supported on OC devices yet */
2886 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
2887 return -EPERM;
2888 if (!isdigit(buf[0]))
2889 return -EINVAL;
2890 if (sscanf(buf, "%i", &val) != 1)
2891 return -EINVAL;
2892
2893 switch (val) {
2894 case 0:
2895 if (phba->hba_flag & HBA_AER_ENABLED) {
2896 rc = pci_disable_pcie_error_reporting(phba->pcidev);
2897 if (!rc) {
2898 spin_lock_irq(&phba->hbalock);
2899 phba->hba_flag &= ~HBA_AER_ENABLED;
2900 spin_unlock_irq(&phba->hbalock);
2901 phba->cfg_aer_support = 0;
2902 rc = strlen(buf);
2903 } else
2904 rc = -EPERM;
2905 } else {
2906 phba->cfg_aer_support = 0;
2907 rc = strlen(buf);
2908 }
2909 break;
2910 case 1:
2911 if (!(phba->hba_flag & HBA_AER_ENABLED)) {
2912 rc = pci_enable_pcie_error_reporting(phba->pcidev);
2913 if (!rc) {
2914 spin_lock_irq(&phba->hbalock);
2915 phba->hba_flag |= HBA_AER_ENABLED;
2916 spin_unlock_irq(&phba->hbalock);
2917 phba->cfg_aer_support = 1;
2918 rc = strlen(buf);
2919 } else
2920 rc = -EPERM;
2921 } else {
2922 phba->cfg_aer_support = 1;
2923 rc = strlen(buf);
2924 }
2925 break;
2926 default:
2927 rc = -EINVAL;
2928 break;
2929 }
2930 return rc;
2931}
2932
2933static int lpfc_aer_support = 1;
2934module_param(lpfc_aer_support, int, 1);
2935MODULE_PARM_DESC(lpfc_aer_support, "Enable PCIe device AER support");
2936lpfc_param_show(aer_support)
2937
2938/**
2939 * lpfc_aer_support_init - Set the initial adapters aer support flag
2940 * @phba: lpfc_hba pointer.
2941 * @val: link speed value.
2942 *
2943 * Description:
2944 * If val is in a valid range [0,1], then set the adapter's initial
2945 * cfg_aer_support field. It will be up to the driver's probe_one
2946 * routine to determine whether the device's AER support can be set
2947 * or not.
2948 *
2949 * Notes:
2950 * If the value is not in range log a kernel error message, and
2951 * choose the default value of setting AER support and return.
2952 *
2953 * Returns:
2954 * zero if val saved.
2955 * -EINVAL val out of range
2956 **/
2957static int
2958lpfc_aer_support_init(struct lpfc_hba *phba, int val)
2959{
2960 /* AER not supported on OC devices yet */
2961 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) {
2962 phba->cfg_aer_support = 0;
2963 return -EPERM;
2964 }
2965
2966 if (val == 0 || val == 1) {
2967 phba->cfg_aer_support = val;
2968 return 0;
2969 }
2970 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2971 "2712 lpfc_aer_support attribute value %d out "
2972 "of range, allowed values are 0|1, setting it "
2973 "to default value of 1\n", val);
2974 /* By default, try to enable AER on a device */
2975 phba->cfg_aer_support = 1;
2976 return -EINVAL;
2977}
2978
2979static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR,
2980 lpfc_aer_support_show, lpfc_aer_support_store);
2981
2982/**
2983 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
2984 * @dev: class device that is converted into a Scsi_host.
2985 * @attr: device attribute, not used.
2986 * @buf: containing the string "selective".
2987 * @count: unused variable.
2988 *
2989 * Description:
2990 * If the @buf contains 1 and the device currently has the AER support
2991 * enabled, then invokes the kernel AER helper routine
2992 * pci_cleanup_aer_uncorrect_error_status to clean up the uncorrectable
2993 * error status register.
2994 *
2995 * Notes:
2996 *
2997 * Returns:
2998 * -EINVAL if the buf does not contain the 1 or the device is not currently
2999 * enabled with the AER support.
3000 **/
3001static ssize_t
3002lpfc_aer_cleanup_state(struct device *dev, struct device_attribute *attr,
3003 const char *buf, size_t count)
3004{
3005 struct Scsi_Host *shost = class_to_shost(dev);
3006 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3007 struct lpfc_hba *phba = vport->phba;
3008 int val, rc = -1;
3009
3010 /* AER not supported on OC devices yet */
3011 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
3012 return -EPERM;
3013 if (!isdigit(buf[0]))
3014 return -EINVAL;
3015 if (sscanf(buf, "%i", &val) != 1)
3016 return -EINVAL;
3017 if (val != 1)
3018 return -EINVAL;
3019
3020 if (phba->hba_flag & HBA_AER_ENABLED)
3021 rc = pci_cleanup_aer_uncorrect_error_status(phba->pcidev);
3022
3023 if (rc == 0)
3024 return strlen(buf);
3025 else
3026 return -EPERM;
3027}
3028
3029static DEVICE_ATTR(lpfc_aer_state_cleanup, S_IWUSR, NULL,
3030 lpfc_aer_cleanup_state);
3031
3032/*
2762# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 3033# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
2763# Value range is [2,3]. Default value is 3. 3034# Value range is [2,3]. Default value is 3.
2764*/ 3035*/
@@ -2846,7 +3117,7 @@ LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
2846# identifies what rctl value to configure the additional ring for. 3117# identifies what rctl value to configure the additional ring for.
2847# Value range is [1,0xff]. Default value is 4 (Unsolicated Data). 3118# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
2848*/ 3119*/
2849LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1, 3120LPFC_ATTR_R(multi_ring_rctl, FC_RCTL_DD_UNSOL_DATA, 1,
2850 255, "Identifies RCTL for additional ring configuration"); 3121 255, "Identifies RCTL for additional ring configuration");
2851 3122
2852/* 3123/*
@@ -2854,7 +3125,7 @@ LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1,
2854# identifies what type value to configure the additional ring for. 3125# identifies what type value to configure the additional ring for.
2855# Value range is [1,0xff]. Default value is 5 (LLC/SNAP). 3126# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
2856*/ 3127*/
2857LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1, 3128LPFC_ATTR_R(multi_ring_type, FC_TYPE_IP, 1,
2858 255, "Identifies TYPE for additional ring configuration"); 3129 255, "Identifies TYPE for additional ring configuration");
2859 3130
2860/* 3131/*
@@ -2890,12 +3161,12 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
2890/* 3161/*
2891# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that 3162# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
2892# support this feature 3163# support this feature
2893# 0 = MSI disabled (default) 3164# 0 = MSI disabled
2894# 1 = MSI enabled 3165# 1 = MSI enabled
2895# 2 = MSI-X enabled 3166# 2 = MSI-X enabled (default)
2896# Value range is [0,2]. Default value is 0. 3167# Value range is [0,2]. Default value is 2.
2897*/ 3168*/
2898LPFC_ATTR_R(use_msi, 0, 0, 2, "Use Message Signaled Interrupts (1) or " 3169LPFC_ATTR_R(use_msi, 2, 0, 2, "Use Message Signaled Interrupts (1) or "
2899 "MSI-X (2), if possible"); 3170 "MSI-X (2), if possible");
2900 3171
2901/* 3172/*
@@ -2947,15 +3218,6 @@ LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
2947LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support"); 3218LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
2948 3219
2949/* 3220/*
2950# lpfc_enable_fip: When set, FIP is required to start discovery. If not
2951# set, the driver will add an FCF record manually if the port has no
2952# FCF records available and start discovery.
2953# Value range is [0,1]. Default value is 1 (enabled)
2954*/
2955LPFC_ATTR_RW(enable_fip, 0, 0, 1, "Enable FIP Discovery");
2956
2957
2958/*
2959# lpfc_prot_mask: i 3221# lpfc_prot_mask: i
2960# - Bit mask of host protection capabilities used to register with the 3222# - Bit mask of host protection capabilities used to register with the
2961# SCSI mid-layer 3223# SCSI mid-layer
@@ -3013,6 +3275,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
3013 &dev_attr_num_discovered_ports, 3275 &dev_attr_num_discovered_ports,
3014 &dev_attr_menlo_mgmt_mode, 3276 &dev_attr_menlo_mgmt_mode,
3015 &dev_attr_lpfc_drvr_version, 3277 &dev_attr_lpfc_drvr_version,
3278 &dev_attr_lpfc_enable_fip,
3016 &dev_attr_lpfc_temp_sensor, 3279 &dev_attr_lpfc_temp_sensor,
3017 &dev_attr_lpfc_log_verbose, 3280 &dev_attr_lpfc_log_verbose,
3018 &dev_attr_lpfc_lun_queue_depth, 3281 &dev_attr_lpfc_lun_queue_depth,
@@ -3020,7 +3283,6 @@ struct device_attribute *lpfc_hba_attrs[] = {
3020 &dev_attr_lpfc_peer_port_login, 3283 &dev_attr_lpfc_peer_port_login,
3021 &dev_attr_lpfc_nodev_tmo, 3284 &dev_attr_lpfc_nodev_tmo,
3022 &dev_attr_lpfc_devloss_tmo, 3285 &dev_attr_lpfc_devloss_tmo,
3023 &dev_attr_lpfc_enable_fip,
3024 &dev_attr_lpfc_fcp_class, 3286 &dev_attr_lpfc_fcp_class,
3025 &dev_attr_lpfc_use_adisc, 3287 &dev_attr_lpfc_use_adisc,
3026 &dev_attr_lpfc_ack0, 3288 &dev_attr_lpfc_ack0,
@@ -3061,6 +3323,9 @@ struct device_attribute *lpfc_hba_attrs[] = {
3061 &dev_attr_lpfc_max_scsicmpl_time, 3323 &dev_attr_lpfc_max_scsicmpl_time,
3062 &dev_attr_lpfc_stat_data_ctrl, 3324 &dev_attr_lpfc_stat_data_ctrl,
3063 &dev_attr_lpfc_prot_sg_seg_cnt, 3325 &dev_attr_lpfc_prot_sg_seg_cnt,
3326 &dev_attr_lpfc_aer_support,
3327 &dev_attr_lpfc_aer_state_cleanup,
3328 &dev_attr_lpfc_suppress_link_up,
3064 NULL, 3329 NULL,
3065}; 3330};
3066 3331
@@ -3073,7 +3338,6 @@ struct device_attribute *lpfc_vport_attrs[] = {
3073 &dev_attr_lpfc_lun_queue_depth, 3338 &dev_attr_lpfc_lun_queue_depth,
3074 &dev_attr_lpfc_nodev_tmo, 3339 &dev_attr_lpfc_nodev_tmo,
3075 &dev_attr_lpfc_devloss_tmo, 3340 &dev_attr_lpfc_devloss_tmo,
3076 &dev_attr_lpfc_enable_fip,
3077 &dev_attr_lpfc_hba_queue_depth, 3341 &dev_attr_lpfc_hba_queue_depth,
3078 &dev_attr_lpfc_peer_port_login, 3342 &dev_attr_lpfc_peer_port_login,
3079 &dev_attr_lpfc_restrict_login, 3343 &dev_attr_lpfc_restrict_login,
@@ -3147,7 +3411,7 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
3147 * sysfs_ctlreg_read - Read method for reading from ctlreg 3411 * sysfs_ctlreg_read - Read method for reading from ctlreg
3148 * @kobj: kernel kobject that contains the kernel class device. 3412 * @kobj: kernel kobject that contains the kernel class device.
3149 * @bin_attr: kernel attributes passed to us. 3413 * @bin_attr: kernel attributes passed to us.
3150 * @buf: if succesful contains the data from the adapter IOREG space. 3414 * @buf: if successful contains the data from the adapter IOREG space.
3151 * @off: offset into buffer to beginning of data. 3415 * @off: offset into buffer to beginning of data.
3152 * @count: bytes to transfer. 3416 * @count: bytes to transfer.
3153 * 3417 *
@@ -3815,7 +4079,11 @@ lpfc_get_stats(struct Scsi_Host *shost)
3815 hs->invalid_crc_count -= lso->invalid_crc_count; 4079 hs->invalid_crc_count -= lso->invalid_crc_count;
3816 hs->error_frames -= lso->error_frames; 4080 hs->error_frames -= lso->error_frames;
3817 4081
3818 if (phba->fc_topology == TOPOLOGY_LOOP) { 4082 if (phba->hba_flag & HBA_FCOE_SUPPORT) {
4083 hs->lip_count = -1;
4084 hs->nos_count = (phba->link_events >> 1);
4085 hs->nos_count -= lso->link_events;
4086 } else if (phba->fc_topology == TOPOLOGY_LOOP) {
3819 hs->lip_count = (phba->fc_eventTag >> 1); 4087 hs->lip_count = (phba->fc_eventTag >> 1);
3820 hs->lip_count -= lso->link_events; 4088 hs->lip_count -= lso->link_events;
3821 hs->nos_count = -1; 4089 hs->nos_count = -1;
@@ -3906,7 +4174,10 @@ lpfc_reset_stats(struct Scsi_Host *shost)
3906 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; 4174 lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
3907 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; 4175 lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
3908 lso->error_frames = pmb->un.varRdLnk.crcCnt; 4176 lso->error_frames = pmb->un.varRdLnk.crcCnt;
3909 lso->link_events = (phba->fc_eventTag >> 1); 4177 if (phba->hba_flag & HBA_FCOE_SUPPORT)
4178 lso->link_events = (phba->link_events >> 1);
4179 else
4180 lso->link_events = (phba->fc_eventTag >> 1);
3910 4181
3911 psli->stats_start = get_seconds(); 4182 psli->stats_start = get_seconds();
3912 4183
@@ -4222,15 +4493,18 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
4222 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); 4493 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
4223 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); 4494 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
4224 lpfc_enable_bg_init(phba, lpfc_enable_bg); 4495 lpfc_enable_bg_init(phba, lpfc_enable_bg);
4496 if (phba->sli_rev == LPFC_SLI_REV4)
4497 phba->cfg_poll = 0;
4498 else
4225 phba->cfg_poll = lpfc_poll; 4499 phba->cfg_poll = lpfc_poll;
4226 phba->cfg_soft_wwnn = 0L; 4500 phba->cfg_soft_wwnn = 0L;
4227 phba->cfg_soft_wwpn = 0L; 4501 phba->cfg_soft_wwpn = 0L;
4228 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); 4502 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
4229 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt); 4503 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt);
4230 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 4504 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
4231 lpfc_enable_fip_init(phba, lpfc_enable_fip);
4232 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose); 4505 lpfc_hba_log_verbose_init(phba, lpfc_log_verbose);
4233 4506 lpfc_aer_support_init(phba, lpfc_aer_support);
4507 lpfc_suppress_link_up_init(phba, lpfc_suppress_link_up);
4234 return; 4508 return;
4235} 4509}
4236 4510