aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-12-04 22:39:46 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-12-29 12:24:27 -0500
commit81301a9b05c3690bf32bf4ef37d941f0f870a7ba (patch)
treecd4f13d46241e0652a697f057e5accd8df06b9a9
parent9f1e1b50ab43a281dbc75c25f11e1926a9ea367a (diff)
[SCSI] lpfc 8.3.0 : Add BlockGuard support (T10-DIF) structs and defs
Update struct definitions, #defines, sysfs entries, and initialization to support BlockGuard. Signed-off-by: James Smart <James.Smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/lpfc/lpfc.h14
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c119
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h12
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h207
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c89
-rw-r--r--drivers/scsi/lpfc/lpfc_logmsg.h1
6 files changed, 432 insertions, 10 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index fee14ae9353d..960ba307613a 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -29,8 +29,10 @@ struct lpfc_sli2_slim;
29#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact 29#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
30 the NameServer before giving up. */ 30 the NameServer before giving up. */
31#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */ 31#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
32#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */ 32#define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
33#define LPFC_MAX_SG_SEG_CNT 256 /* sg element count per scsi cmnd */ 33#define LPFC_DEFAULT_PROT_SG_SEG_CNT 4096 /* sg protection elements count */
34#define LPFC_MAX_SG_SEG_CNT 4096 /* sg element count per scsi cmnd */
35#define LPFC_MAX_PROT_SG_SEG_CNT 4096 /* prot sg element count per scsi cmd*/
34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ 36#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
35#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */ 37#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
36#define LPFC_VNAME_LEN 100 /* vport symbolic name length */ 38#define LPFC_VNAME_LEN 100 /* vport symbolic name length */
@@ -426,6 +428,7 @@ struct lpfc_hba {
426#define LPFC_SLI3_VPORT_TEARDOWN 0x04 428#define LPFC_SLI3_VPORT_TEARDOWN 0x04
427#define LPFC_SLI3_CRP_ENABLED 0x08 429#define LPFC_SLI3_CRP_ENABLED 0x08
428#define LPFC_SLI3_INB_ENABLED 0x10 430#define LPFC_SLI3_INB_ENABLED 0x10
431#define LPFC_SLI3_BG_ENABLED 0x20
429 uint32_t iocb_cmd_size; 432 uint32_t iocb_cmd_size;
430 uint32_t iocb_rsp_size; 433 uint32_t iocb_rsp_size;
431 434
@@ -499,12 +502,14 @@ struct lpfc_hba {
499 uint32_t cfg_poll_tmo; 502 uint32_t cfg_poll_tmo;
500 uint32_t cfg_use_msi; 503 uint32_t cfg_use_msi;
501 uint32_t cfg_sg_seg_cnt; 504 uint32_t cfg_sg_seg_cnt;
505 uint32_t cfg_prot_sg_seg_cnt;
502 uint32_t cfg_sg_dma_buf_size; 506 uint32_t cfg_sg_dma_buf_size;
503 uint64_t cfg_soft_wwnn; 507 uint64_t cfg_soft_wwnn;
504 uint64_t cfg_soft_wwpn; 508 uint64_t cfg_soft_wwpn;
505 uint32_t cfg_hba_queue_depth; 509 uint32_t cfg_hba_queue_depth;
506 uint32_t cfg_enable_hba_reset; 510 uint32_t cfg_enable_hba_reset;
507 uint32_t cfg_enable_hba_heartbeat; 511 uint32_t cfg_enable_hba_heartbeat;
512 uint32_t cfg_enable_bg;
508 513
509 lpfc_vpd_t vpd; /* vital product data */ 514 lpfc_vpd_t vpd; /* vital product data */
510 515
@@ -570,6 +575,9 @@ struct lpfc_hba {
570 uint64_t fc4InputRequests; 575 uint64_t fc4InputRequests;
571 uint64_t fc4OutputRequests; 576 uint64_t fc4OutputRequests;
572 uint64_t fc4ControlRequests; 577 uint64_t fc4ControlRequests;
578 uint64_t bg_guard_err_cnt;
579 uint64_t bg_apptag_err_cnt;
580 uint64_t bg_reftag_err_cnt;
573 581
574 struct lpfc_sysfs_mbox sysfs_mbox; 582 struct lpfc_sysfs_mbox sysfs_mbox;
575 583
@@ -619,6 +627,8 @@ struct lpfc_hba {
619 struct dentry *debug_hbqinfo; 627 struct dentry *debug_hbqinfo;
620 struct dentry *debug_dumpHostSlim; 628 struct dentry *debug_dumpHostSlim;
621 struct dentry *debug_dumpHBASlim; 629 struct dentry *debug_dumpHBASlim;
630 struct dentry *debug_dumpData; /* BlockGuard BPL*/
631 struct dentry *debug_dumpDif; /* BlockGuard BPL*/
622 struct dentry *debug_slow_ring_trc; 632 struct dentry *debug_slow_ring_trc;
623 struct lpfc_debugfs_trc *slow_ring_trc; 633 struct lpfc_debugfs_trc *slow_ring_trc;
624 atomic_t slow_ring_trc_cnt; 634 atomic_t slow_ring_trc_cnt;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 7c015982b40f..9ec046001300 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -96,6 +96,58 @@ lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr,
96 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); 96 return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
97} 97}
98 98
99static ssize_t
100lpfc_bg_info_show(struct device *dev, struct device_attribute *attr,
101 char *buf)
102{
103 struct Scsi_Host *shost = class_to_shost(dev);
104 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
105 struct lpfc_hba *phba = vport->phba;
106
107 if (phba->cfg_enable_bg)
108 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED)
109 return snprintf(buf, PAGE_SIZE, "BlockGuard Enabled\n");
110 else
111 return snprintf(buf, PAGE_SIZE,
112 "BlockGuard Not Supported\n");
113 else
114 return snprintf(buf, PAGE_SIZE,
115 "BlockGuard Disabled\n");
116}
117
118static ssize_t
119lpfc_bg_guard_err_show(struct device *dev, struct device_attribute *attr,
120 char *buf)
121{
122 struct Scsi_Host *shost = class_to_shost(dev);
123 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
124 struct lpfc_hba *phba = vport->phba;
125
126 return snprintf(buf, PAGE_SIZE, "%llu\n", phba->bg_guard_err_cnt);
127}
128
129static ssize_t
130lpfc_bg_apptag_err_show(struct device *dev, struct device_attribute *attr,
131 char *buf)
132{
133 struct Scsi_Host *shost = class_to_shost(dev);
134 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
135 struct lpfc_hba *phba = vport->phba;
136
137 return snprintf(buf, PAGE_SIZE, "%llu\n", phba->bg_apptag_err_cnt);
138}
139
140static ssize_t
141lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr,
142 char *buf)
143{
144 struct Scsi_Host *shost = class_to_shost(dev);
145 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
146 struct lpfc_hba *phba = vport->phba;
147
148 return snprintf(buf, PAGE_SIZE, "%llu\n", phba->bg_reftag_err_cnt);
149}
150
99/** 151/**
100 * lpfc_info_show: Return some pci info about the host in ascii. 152 * lpfc_info_show: Return some pci info about the host in ascii.
101 * @dev: class converted to a Scsi_host structure. 153 * @dev: class converted to a Scsi_host structure.
@@ -1485,6 +1537,10 @@ lpfc_vport_param_store(name)\
1485static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 1537static DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
1486 lpfc_##name##_show, lpfc_##name##_store) 1538 lpfc_##name##_show, lpfc_##name##_store)
1487 1539
1540static DEVICE_ATTR(bg_info, S_IRUGO, lpfc_bg_info_show, NULL);
1541static DEVICE_ATTR(bg_guard_err, S_IRUGO, lpfc_bg_guard_err_show, NULL);
1542static DEVICE_ATTR(bg_apptag_err, S_IRUGO, lpfc_bg_apptag_err_show, NULL);
1543static DEVICE_ATTR(bg_reftag_err, S_IRUGO, lpfc_bg_reftag_err_show, NULL);
1488static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 1544static DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
1489static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 1545static DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
1490static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 1546static DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
@@ -1970,6 +2026,7 @@ static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1970# LOG_LINK_EVENT 0x10 Link events 2026# LOG_LINK_EVENT 0x10 Link events
1971# LOG_FCP 0x40 FCP traffic history 2027# LOG_FCP 0x40 FCP traffic history
1972# LOG_NODE 0x80 Node table events 2028# LOG_NODE 0x80 Node table events
2029# LOG_BG 0x200 BlockBuard events
1973# LOG_MISC 0x400 Miscellaneous events 2030# LOG_MISC 0x400 Miscellaneous events
1974# LOG_SLI 0x800 SLI events 2031# LOG_SLI 0x800 SLI events
1975# LOG_FCP_ERROR 0x1000 Only log FCP errors 2032# LOG_FCP_ERROR 0x1000 Only log FCP errors
@@ -2769,6 +2826,42 @@ LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
2769LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat."); 2826LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
2770 2827
2771/* 2828/*
2829# lpfc_enable_bg: Enable BlockGuard (Emulex's Implementation of T10-DIF)
2830# 0 = BlockGuard disabled (default)
2831# 1 = BlockGuard enabled
2832# Value range is [0,1]. Default value is 0.
2833*/
2834LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
2835
2836
2837/*
2838# lpfc_prot_mask: i
2839# - Bit mask of host protection capabilities used to register with the
2840# SCSI mid-layer
2841# - Only meaningful if BG is turned on (lpfc_enable_bg=1).
2842# - Allows you to ultimately specify which profiles to use
2843# - Default will result in registering capabilities for all profiles.
2844#
2845*/
2846unsigned int lpfc_prot_mask = SHOST_DIX_TYPE0_PROTECTION;
2847
2848module_param(lpfc_prot_mask, uint, 0);
2849MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask");
2850
2851/*
2852# lpfc_prot_guard: i
2853# - Bit mask of protection guard types to register with the SCSI mid-layer
2854# - Guard types are currently either 1) IP checksum 2) T10-DIF CRC
2855# - Allows you to ultimately specify which profiles to use
2856# - Default will result in registering capabilities for all guard types
2857#
2858*/
2859unsigned char lpfc_prot_guard = SHOST_DIX_GUARD_IP;
2860module_param(lpfc_prot_guard, byte, 0);
2861MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type");
2862
2863
2864/*
2772 * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count 2865 * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count
2773 * This value can be set to values between 64 and 256. The default value is 2866 * This value can be set to values between 64 and 256. The default value is
2774 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer 2867 * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
@@ -2777,7 +2870,15 @@ LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
2777LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT, 2870LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
2778 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count"); 2871 LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
2779 2872
2873LPFC_ATTR_R(prot_sg_seg_cnt, LPFC_DEFAULT_PROT_SG_SEG_CNT,
2874 LPFC_DEFAULT_PROT_SG_SEG_CNT, LPFC_MAX_PROT_SG_SEG_CNT,
2875 "Max Protection Scatter Gather Segment Count");
2876
2780struct device_attribute *lpfc_hba_attrs[] = { 2877struct device_attribute *lpfc_hba_attrs[] = {
2878 &dev_attr_bg_info,
2879 &dev_attr_bg_guard_err,
2880 &dev_attr_bg_apptag_err,
2881 &dev_attr_bg_reftag_err,
2781 &dev_attr_info, 2882 &dev_attr_info,
2782 &dev_attr_serialnum, 2883 &dev_attr_serialnum,
2783 &dev_attr_modeldesc, 2884 &dev_attr_modeldesc,
@@ -2825,6 +2926,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
2825 &dev_attr_lpfc_poll, 2926 &dev_attr_lpfc_poll,
2826 &dev_attr_lpfc_poll_tmo, 2927 &dev_attr_lpfc_poll_tmo,
2827 &dev_attr_lpfc_use_msi, 2928 &dev_attr_lpfc_use_msi,
2929 &dev_attr_lpfc_enable_bg,
2828 &dev_attr_lpfc_soft_wwnn, 2930 &dev_attr_lpfc_soft_wwnn,
2829 &dev_attr_lpfc_soft_wwpn, 2931 &dev_attr_lpfc_soft_wwpn,
2830 &dev_attr_lpfc_soft_wwn_enable, 2932 &dev_attr_lpfc_soft_wwn_enable,
@@ -2833,6 +2935,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
2833 &dev_attr_lpfc_sg_seg_cnt, 2935 &dev_attr_lpfc_sg_seg_cnt,
2834 &dev_attr_lpfc_max_scsicmpl_time, 2936 &dev_attr_lpfc_max_scsicmpl_time,
2835 &dev_attr_lpfc_stat_data_ctrl, 2937 &dev_attr_lpfc_stat_data_ctrl,
2938 &dev_attr_lpfc_prot_sg_seg_cnt,
2836 NULL, 2939 NULL,
2837}; 2940};
2838 2941
@@ -3961,13 +4064,12 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
3961 lpfc_use_msi_init(phba, lpfc_use_msi); 4064 lpfc_use_msi_init(phba, lpfc_use_msi);
3962 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset); 4065 lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
3963 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat); 4066 lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
4067 lpfc_enable_bg_init(phba, lpfc_enable_bg);
3964 phba->cfg_poll = lpfc_poll; 4068 phba->cfg_poll = lpfc_poll;
3965 phba->cfg_soft_wwnn = 0L; 4069 phba->cfg_soft_wwnn = 0L;
3966 phba->cfg_soft_wwpn = 0L; 4070 phba->cfg_soft_wwpn = 0L;
3967 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt); 4071 lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
3968 /* Also reinitialize the host templates with new values. */ 4072 lpfc_prot_sg_seg_cnt_init(phba, lpfc_prot_sg_seg_cnt);
3969 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt;
3970 lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt;
3971 /* 4073 /*
3972 * Since the sg_tablesize is module parameter, the sg_dma_buf_size 4074 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
3973 * used to create the sg_dma_buf_pool must be dynamically calculated. 4075 * used to create the sg_dma_buf_pool must be dynamically calculated.
@@ -3976,6 +4078,17 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
3976 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + 4078 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
3977 sizeof(struct fcp_rsp) + 4079 sizeof(struct fcp_rsp) +
3978 ((phba->cfg_sg_seg_cnt + 2) * sizeof(struct ulp_bde64)); 4080 ((phba->cfg_sg_seg_cnt + 2) * sizeof(struct ulp_bde64));
4081
4082 if (phba->cfg_enable_bg) {
4083 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT;
4084 phba->cfg_sg_dma_buf_size +=
4085 phba->cfg_prot_sg_seg_cnt * sizeof(struct ulp_bde64);
4086 }
4087
4088 /* Also reinitialize the host templates with new values. */
4089 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt;
4090 lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt;
4091
3979 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 4092 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
3980 return; 4093 return;
3981} 4094}
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 73481c8fd98f..07f4976319a5 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -285,6 +285,18 @@ extern void lpfc_debugfs_slow_ring_trc(struct lpfc_hba *, char *, uint32_t,
285 uint32_t, uint32_t); 285 uint32_t, uint32_t);
286extern struct lpfc_hbq_init *lpfc_hbq_defs[]; 286extern struct lpfc_hbq_init *lpfc_hbq_defs[];
287 287
288/* externs BlockGuard */
289extern char *_dump_buf_data;
290extern unsigned long _dump_buf_data_order;
291extern char *_dump_buf_dif;
292extern unsigned long _dump_buf_dif_order;
293extern spinlock_t _dump_buf_lock;
294extern int _dump_buf_done;
295extern spinlock_t pgcnt_lock;
296extern unsigned int pgcnt;
297extern unsigned int lpfc_prot_mask;
298extern unsigned char lpfc_prot_guard;
299
288/* Interface exported by fabric iocb scheduler */ 300/* Interface exported by fabric iocb scheduler */
289void lpfc_fabric_abort_nport(struct lpfc_nodelist *); 301void lpfc_fabric_abort_nport(struct lpfc_nodelist *);
290void lpfc_fabric_abort_hba(struct lpfc_hba *); 302void lpfc_fabric_abort_hba(struct lpfc_hba *);
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 74a4b306d021..4168c7b498b8 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1544,6 +1544,108 @@ typedef struct ULP_BDL { /* SLI-2 */
1544 uint32_t ulpIoTag32; /* Can be used for 32 bit I/O Tag */ 1544 uint32_t ulpIoTag32; /* Can be used for 32 bit I/O Tag */
1545} ULP_BDL; 1545} ULP_BDL;
1546 1546
1547/*
1548 * BlockGuard Definitions
1549 */
1550
1551enum lpfc_protgrp_type {
1552 LPFC_PG_TYPE_INVALID = 0, /* used to indicate errors */
1553 LPFC_PG_TYPE_NO_DIF, /* no DIF data pointed to by prot grp */
1554 LPFC_PG_TYPE_EMBD_DIF, /* DIF is embedded (inline) with data */
1555 LPFC_PG_TYPE_DIF_BUF /* DIF has its own scatter/gather list */
1556};
1557
1558/* PDE Descriptors */
1559#define LPFC_PDE1_DESCRIPTOR 0x81
1560#define LPFC_PDE2_DESCRIPTOR 0x82
1561#define LPFC_PDE3_DESCRIPTOR 0x83
1562
1563/* BlockGuard Profiles */
1564enum lpfc_bg_prof_codes {
1565 LPFC_PROF_INVALID,
1566 LPFC_PROF_A1 = 128, /* Full Protection */
1567 LPFC_PROF_A2, /* Disabled Protection Checks:A2~A4 */
1568 LPFC_PROF_A3,
1569 LPFC_PROF_A4,
1570 LPFC_PROF_B1, /* Embedded DIFs: B1~B3 */
1571 LPFC_PROF_B2,
1572 LPFC_PROF_B3,
1573 LPFC_PROF_C1, /* Separate DIFs: C1~C3 */
1574 LPFC_PROF_C2,
1575 LPFC_PROF_C3,
1576 LPFC_PROF_D1, /* Full Protection */
1577 LPFC_PROF_D2, /* Partial Protection & Check Disabling */
1578 LPFC_PROF_D3,
1579 LPFC_PROF_E1, /* E1~E4:out - check-only, in - update apptag */
1580 LPFC_PROF_E2,
1581 LPFC_PROF_E3,
1582 LPFC_PROF_E4,
1583 LPFC_PROF_F1, /* Full Translation - F1 Prot Descriptor */
1584 /* F1 Translation BDE */
1585 LPFC_PROF_ANT1, /* TCP checksum, DIF inline with data buffers */
1586 LPFC_PROF_AST1, /* TCP checksum, DIF split from data buffer */
1587 LPFC_PROF_ANT2,
1588 LPFC_PROF_AST2
1589};
1590
1591/* BlockGuard error-control defines */
1592#define BG_EC_STOP_ERR 0x00
1593#define BG_EC_CONT_ERR 0x01
1594#define BG_EC_IGN_UNINIT_STOP_ERR 0x10
1595#define BG_EC_IGN_UNINIT_CONT_ERR 0x11
1596
1597/* PDE (Protection Descriptor Entry) word 0 bit masks and shifts */
1598#define PDE_DESC_TYPE_MASK 0xff000000
1599#define PDE_DESC_TYPE_SHIFT 24
1600#define PDE_BG_PROFILE_MASK 0x00ff0000
1601#define PDE_BG_PROFILE_SHIFT 16
1602#define PDE_BLOCK_LEN_MASK 0x0000fffc
1603#define PDE_BLOCK_LEN_SHIFT 2
1604#define PDE_ERR_CTRL_MASK 0x00000003
1605#define PDE_ERR_CTRL_SHIFT 0
1606/* PDE word 1 bit masks and shifts */
1607#define PDE_APPTAG_MASK_MASK 0xffff0000
1608#define PDE_APPTAG_MASK_SHIFT 16
1609#define PDE_APPTAG_VAL_MASK 0x0000ffff
1610#define PDE_APPTAG_VAL_SHIFT 0
1611struct lpfc_pde {
1612 uint32_t parms; /* bitfields of descriptor, prof, len, and ec */
1613 uint32_t apptag; /* bitfields of app tag maskand app tag value */
1614 uint32_t reftag; /* reference tag occupying all 32 bits */
1615};
1616
1617/* inline function to set fields in parms of PDE */
1618static inline void
1619lpfc_pde_set_bg_parms(struct lpfc_pde *p, u8 desc, u8 prof, u16 len, u8 ec)
1620{
1621 uint32_t *wp = &p->parms;
1622
1623 /* spec indicates that adapter appends two 0's to length field */
1624 len = len >> 2;
1625
1626 *wp &= 0;
1627 *wp |= ((desc << PDE_DESC_TYPE_SHIFT) & PDE_DESC_TYPE_MASK);
1628 *wp |= ((prof << PDE_BG_PROFILE_SHIFT) & PDE_BG_PROFILE_MASK);
1629 *wp |= ((len << PDE_BLOCK_LEN_SHIFT) & PDE_BLOCK_LEN_MASK);
1630 *wp |= ((ec << PDE_ERR_CTRL_SHIFT) & PDE_ERR_CTRL_MASK);
1631 *wp = le32_to_cpu(*wp);
1632}
1633
1634/* inline function to set apptag and reftag fields of PDE */
1635static inline void
1636lpfc_pde_set_dif_parms(struct lpfc_pde *p, u16 apptagmask, u16 apptagval,
1637 u32 reftag)
1638{
1639 uint32_t *wp = &p->apptag;
1640 *wp &= 0;
1641 *wp |= ((apptagmask << PDE_APPTAG_MASK_SHIFT) & PDE_APPTAG_MASK_MASK);
1642 *wp |= ((apptagval << PDE_APPTAG_VAL_SHIFT) & PDE_APPTAG_VAL_MASK);
1643 *wp = le32_to_cpu(*wp);
1644 wp = &p->reftag;
1645 *wp = le32_to_cpu(reftag);
1646}
1647
1648
1547/* Structure for MB Command LOAD_SM and DOWN_LOAD */ 1649/* Structure for MB Command LOAD_SM and DOWN_LOAD */
1548 1650
1549typedef struct { 1651typedef struct {
@@ -2595,8 +2697,9 @@ typedef struct {
2595#endif 2697#endif
2596 2698
2597#ifdef __BIG_ENDIAN_BITFIELD 2699#ifdef __BIG_ENDIAN_BITFIELD
2598 uint32_t rsvd1 : 24; /* Reserved */ 2700 uint32_t rsvd1 : 23; /* Reserved */
2599 uint32_t cmv : 1; /* Configure Max VPIs */ 2701 uint32_t cbg : 1; /* Configure BlockGuard */
2702 uint32_t cmv : 1; /* Configure Max VPIs */
2600 uint32_t ccrp : 1; /* Config Command Ring Polling */ 2703 uint32_t ccrp : 1; /* Config Command Ring Polling */
2601 uint32_t csah : 1; /* Configure Synchronous Abort Handling */ 2704 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
2602 uint32_t chbs : 1; /* Cofigure Host Backing store */ 2705 uint32_t chbs : 1; /* Cofigure Host Backing store */
@@ -2613,10 +2716,12 @@ typedef struct {
2613 uint32_t csah : 1; /* Configure Synchronous Abort Handling */ 2716 uint32_t csah : 1; /* Configure Synchronous Abort Handling */
2614 uint32_t ccrp : 1; /* Config Command Ring Polling */ 2717 uint32_t ccrp : 1; /* Config Command Ring Polling */
2615 uint32_t cmv : 1; /* Configure Max VPIs */ 2718 uint32_t cmv : 1; /* Configure Max VPIs */
2616 uint32_t rsvd1 : 24; /* Reserved */ 2719 uint32_t cbg : 1; /* Configure BlockGuard */
2720 uint32_t rsvd1 : 23; /* Reserved */
2617#endif 2721#endif
2618#ifdef __BIG_ENDIAN_BITFIELD 2722#ifdef __BIG_ENDIAN_BITFIELD
2619 uint32_t rsvd2 : 24; /* Reserved */ 2723 uint32_t rsvd2 : 23; /* Reserved */
2724 uint32_t gbg : 1; /* Grant BlockGuard */
2620 uint32_t gmv : 1; /* Grant Max VPIs */ 2725 uint32_t gmv : 1; /* Grant Max VPIs */
2621 uint32_t gcrp : 1; /* Grant Command Ring Polling */ 2726 uint32_t gcrp : 1; /* Grant Command Ring Polling */
2622 uint32_t gsah : 1; /* Grant Synchronous Abort Handling */ 2727 uint32_t gsah : 1; /* Grant Synchronous Abort Handling */
@@ -2634,7 +2739,8 @@ typedef struct {
2634 uint32_t gsah : 1; /* Grant Synchronous Abort Handling */ 2739 uint32_t gsah : 1; /* Grant Synchronous Abort Handling */
2635 uint32_t gcrp : 1; /* Grant Command Ring Polling */ 2740 uint32_t gcrp : 1; /* Grant Command Ring Polling */
2636 uint32_t gmv : 1; /* Grant Max VPIs */ 2741 uint32_t gmv : 1; /* Grant Max VPIs */
2637 uint32_t rsvd2 : 24; /* Reserved */ 2742 uint32_t gbg : 1; /* Grant BlockGuard */
2743 uint32_t rsvd2 : 23; /* Reserved */
2638#endif 2744#endif
2639 2745
2640#ifdef __BIG_ENDIAN_BITFIELD 2746#ifdef __BIG_ENDIAN_BITFIELD
@@ -3254,6 +3360,94 @@ struct que_xri64cx_ext_fields {
3254 struct lpfc_hbq_entry buff[5]; 3360 struct lpfc_hbq_entry buff[5];
3255}; 3361};
3256 3362
3363struct sli3_bg_fields {
3364 uint32_t filler[6]; /* word 8-13 in IOCB */
3365 uint32_t bghm; /* word 14 - BlockGuard High Water Mark */
3366/* Bitfields for bgstat (BlockGuard Status - word 15 of IOCB) */
3367#define BGS_BIDIR_BG_PROF_MASK 0xff000000
3368#define BGS_BIDIR_BG_PROF_SHIFT 24
3369#define BGS_BIDIR_ERR_COND_FLAGS_MASK 0x003f0000
3370#define BGS_BIDIR_ERR_COND_SHIFT 16
3371#define BGS_BG_PROFILE_MASK 0x0000ff00
3372#define BGS_BG_PROFILE_SHIFT 8
3373#define BGS_INVALID_PROF_MASK 0x00000020
3374#define BGS_INVALID_PROF_SHIFT 5
3375#define BGS_UNINIT_DIF_BLOCK_MASK 0x00000010
3376#define BGS_UNINIT_DIF_BLOCK_SHIFT 4
3377#define BGS_HI_WATER_MARK_PRESENT_MASK 0x00000008
3378#define BGS_HI_WATER_MARK_PRESENT_SHIFT 3
3379#define BGS_REFTAG_ERR_MASK 0x00000004
3380#define BGS_REFTAG_ERR_SHIFT 2
3381#define BGS_APPTAG_ERR_MASK 0x00000002
3382#define BGS_APPTAG_ERR_SHIFT 1
3383#define BGS_GUARD_ERR_MASK 0x00000001
3384#define BGS_GUARD_ERR_SHIFT 0
3385 uint32_t bgstat; /* word 15 - BlockGuard Status */
3386};
3387
3388static inline uint32_t
3389lpfc_bgs_get_bidir_bg_prof(uint32_t bgstat)
3390{
3391 return (le32_to_cpu(bgstat) & BGS_BIDIR_BG_PROF_MASK) >>
3392 BGS_BIDIR_BG_PROF_SHIFT;
3393}
3394
3395static inline uint32_t
3396lpfc_bgs_get_bidir_err_cond(uint32_t bgstat)
3397{
3398 return (le32_to_cpu(bgstat) & BGS_BIDIR_ERR_COND_FLAGS_MASK) >>
3399 BGS_BIDIR_ERR_COND_SHIFT;
3400}
3401
3402static inline uint32_t
3403lpfc_bgs_get_bg_prof(uint32_t bgstat)
3404{
3405 return (le32_to_cpu(bgstat) & BGS_BG_PROFILE_MASK) >>
3406 BGS_BG_PROFILE_SHIFT;
3407}
3408
3409static inline uint32_t
3410lpfc_bgs_get_invalid_prof(uint32_t bgstat)
3411{
3412 return (le32_to_cpu(bgstat) & BGS_INVALID_PROF_MASK) >>
3413 BGS_INVALID_PROF_SHIFT;
3414}
3415
3416static inline uint32_t
3417lpfc_bgs_get_uninit_dif_block(uint32_t bgstat)
3418{
3419 return (le32_to_cpu(bgstat) & BGS_UNINIT_DIF_BLOCK_MASK) >>
3420 BGS_UNINIT_DIF_BLOCK_SHIFT;
3421}
3422
3423static inline uint32_t
3424lpfc_bgs_get_hi_water_mark_present(uint32_t bgstat)
3425{
3426 return (le32_to_cpu(bgstat) & BGS_HI_WATER_MARK_PRESENT_MASK) >>
3427 BGS_HI_WATER_MARK_PRESENT_SHIFT;
3428}
3429
3430static inline uint32_t
3431lpfc_bgs_get_reftag_err(uint32_t bgstat)
3432{
3433 return (le32_to_cpu(bgstat) & BGS_REFTAG_ERR_MASK) >>
3434 BGS_REFTAG_ERR_SHIFT;
3435}
3436
3437static inline uint32_t
3438lpfc_bgs_get_apptag_err(uint32_t bgstat)
3439{
3440 return (le32_to_cpu(bgstat) & BGS_APPTAG_ERR_MASK) >>
3441 BGS_APPTAG_ERR_SHIFT;
3442}
3443
3444static inline uint32_t
3445lpfc_bgs_get_guard_err(uint32_t bgstat)
3446{
3447 return (le32_to_cpu(bgstat) & BGS_GUARD_ERR_MASK) >>
3448 BGS_GUARD_ERR_SHIFT;
3449}
3450
3257#define LPFC_EXT_DATA_BDE_COUNT 3 3451#define LPFC_EXT_DATA_BDE_COUNT 3
3258struct fcp_irw_ext { 3452struct fcp_irw_ext {
3259 uint32_t io_tag64_low; 3453 uint32_t io_tag64_low;
@@ -3362,6 +3556,9 @@ typedef struct _IOCB { /* IOCB structure */
3362 struct que_xri64cx_ext_fields que_xri64cx_ext_words; 3556 struct que_xri64cx_ext_fields que_xri64cx_ext_words;
3363 struct fcp_irw_ext fcp_ext; 3557 struct fcp_irw_ext fcp_ext;
3364 uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */ 3558 uint32_t sli3Words[24]; /* 96 extra bytes for SLI-3 */
3559
3560 /* words 8-15 for BlockGuard */
3561 struct sli3_bg_fields sli3_bg;
3365 } unsli3; 3562 } unsli3;
3366 3563
3367#define ulpCt_h ulpXS 3564#define ulpCt_h ulpXS
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 7a216d478a94..4c77038c8f1c 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -45,6 +45,12 @@
45#include "lpfc_vport.h" 45#include "lpfc_vport.h"
46#include "lpfc_version.h" 46#include "lpfc_version.h"
47 47
48char *_dump_buf_data;
49unsigned long _dump_buf_data_order;
50char *_dump_buf_dif;
51unsigned long _dump_buf_dif_order;
52spinlock_t _dump_buf_lock;
53
48static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int); 54static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int);
49static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *); 55static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
50static int lpfc_post_rcv_buf(struct lpfc_hba *); 56static int lpfc_post_rcv_buf(struct lpfc_hba *);
@@ -2037,6 +2043,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
2037 shost->max_lun = vport->cfg_max_luns; 2043 shost->max_lun = vport->cfg_max_luns;
2038 shost->this_id = -1; 2044 shost->this_id = -1;
2039 shost->max_cmd_len = 16; 2045 shost->max_cmd_len = 16;
2046
2040 /* 2047 /*
2041 * Set initial can_queue value since 0 is no longer supported and 2048 * Set initial can_queue value since 0 is no longer supported and
2042 * scsi_add_host will fail. This will be adjusted later based on the 2049 * scsi_add_host will fail. This will be adjusted later based on the
@@ -2864,6 +2871,75 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
2864 * the value of can_queue. 2871 * the value of can_queue.
2865 */ 2872 */
2866 shost->can_queue = phba->cfg_hba_queue_depth - 10; 2873 shost->can_queue = phba->cfg_hba_queue_depth - 10;
2874 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) {
2875
2876 if (lpfc_prot_mask && lpfc_prot_guard) {
2877 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
2878 "1478 Registering BlockGuard with the "
2879 "SCSI layer\n");
2880
2881 scsi_host_set_prot(shost, lpfc_prot_mask);
2882 scsi_host_set_guard(shost, lpfc_prot_guard);
2883 }
2884 }
2885
2886 if (!_dump_buf_data) {
2887 int pagecnt = 10;
2888 while (pagecnt) {
2889 spin_lock_init(&_dump_buf_lock);
2890 _dump_buf_data =
2891 (char *) __get_free_pages(GFP_KERNEL, pagecnt);
2892 if (_dump_buf_data) {
2893 printk(KERN_ERR "BLKGRD allocated %d pages for "
2894 "_dump_buf_data at 0x%p\n",
2895 (1 << pagecnt), _dump_buf_data);
2896 _dump_buf_data_order = pagecnt;
2897 memset(_dump_buf_data, 0, ((1 << PAGE_SHIFT)
2898 << pagecnt));
2899 break;
2900 } else {
2901 --pagecnt;
2902 }
2903
2904 }
2905
2906 if (!_dump_buf_data_order)
2907 printk(KERN_ERR "BLKGRD ERROR unable to allocate "
2908 "memory for hexdump\n");
2909
2910 } else {
2911 printk(KERN_ERR "BLKGRD already allocated _dump_buf_data=0x%p"
2912 "\n", _dump_buf_data);
2913 }
2914
2915
2916 if (!_dump_buf_dif) {
2917 int pagecnt = 10;
2918 while (pagecnt) {
2919 _dump_buf_dif =
2920 (char *) __get_free_pages(GFP_KERNEL, pagecnt);
2921 if (_dump_buf_dif) {
2922 printk(KERN_ERR "BLKGRD allocated %d pages for "
2923 "_dump_buf_dif at 0x%p\n",
2924 (1 << pagecnt), _dump_buf_dif);
2925 _dump_buf_dif_order = pagecnt;
2926 memset(_dump_buf_dif, 0, ((1 << PAGE_SHIFT)
2927 << pagecnt));
2928 break;
2929 } else {
2930 --pagecnt;
2931 }
2932
2933 }
2934
2935 if (!_dump_buf_dif_order)
2936 printk(KERN_ERR "BLKGRD ERROR unable to allocate "
2937 "memory for hexdump\n");
2938
2939 } else {
2940 printk(KERN_ERR "BLKGRD already allocated _dump_buf_dif=0x%p\n",
2941 _dump_buf_dif);
2942 }
2867 2943
2868 lpfc_host_attrib_init(shost); 2944 lpfc_host_attrib_init(shost);
2869 2945
@@ -3408,6 +3484,19 @@ lpfc_exit(void)
3408 fc_release_transport(lpfc_transport_template); 3484 fc_release_transport(lpfc_transport_template);
3409 if (lpfc_enable_npiv) 3485 if (lpfc_enable_npiv)
3410 fc_release_transport(lpfc_vport_transport_template); 3486 fc_release_transport(lpfc_vport_transport_template);
3487 if (_dump_buf_data) {
3488 printk(KERN_ERR "BLKGRD freeing %lu pages for _dump_buf_data "
3489 "at 0x%p\n",
3490 (1L << _dump_buf_data_order), _dump_buf_data);
3491 free_pages((unsigned long)_dump_buf_data, _dump_buf_data_order);
3492 }
3493
3494 if (_dump_buf_dif) {
3495 printk(KERN_ERR "BLKGRD freeing %lu pages for _dump_buf_dif "
3496 "at 0x%p\n",
3497 (1L << _dump_buf_dif_order), _dump_buf_dif);
3498 free_pages((unsigned long)_dump_buf_dif, _dump_buf_dif_order);
3499 }
3411} 3500}
3412 3501
3413module_init(lpfc_init); 3502module_init(lpfc_init);
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h
index 39fd2b843bec..a85b7c196bbc 100644
--- a/drivers/scsi/lpfc/lpfc_logmsg.h
+++ b/drivers/scsi/lpfc/lpfc_logmsg.h
@@ -27,6 +27,7 @@
27#define LOG_FCP 0x40 /* FCP traffic history */ 27#define LOG_FCP 0x40 /* FCP traffic history */
28#define LOG_NODE 0x80 /* Node table events */ 28#define LOG_NODE 0x80 /* Node table events */
29#define LOG_TEMP 0x100 /* Temperature sensor events */ 29#define LOG_TEMP 0x100 /* Temperature sensor events */
30#define LOG_BG 0x200 /* BlockBuard events */
30#define LOG_MISC 0x400 /* Miscellaneous events */ 31#define LOG_MISC 0x400 /* Miscellaneous events */
31#define LOG_SLI 0x800 /* SLI events */ 32#define LOG_SLI 0x800 /* SLI events */
32#define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */ 33#define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */