Skip to content

Commit

Permalink
[SCSI] lpfc 8.3.27: T10 additions for SLI4
Browse files Browse the repository at this point in the history
Added T10 DIFF error injection code.
Added T10 DIFF structure definitions for SLI4 devices.

Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
James Smart authored and James Bottomley committed Oct 16, 2011
1 parent 5350d87 commit f9bb2da
Show file tree
Hide file tree
Showing 5 changed files with 471 additions and 19 deletions.
20 changes: 18 additions & 2 deletions drivers/scsi/lpfc/lpfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,24 @@ struct lpfc_hba {
struct dentry *debug_hbqinfo;
struct dentry *debug_dumpHostSlim;
struct dentry *debug_dumpHBASlim;
struct dentry *debug_dumpData; /* BlockGuard BPL*/
struct dentry *debug_dumpDif; /* BlockGuard BPL*/
struct dentry *debug_dumpData; /* BlockGuard BPL */
struct dentry *debug_dumpDif; /* BlockGuard BPL */
struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
struct dentry *debug_writeGuard; /* inject write guard_tag errors */
struct dentry *debug_writeApp; /* inject write app_tag errors */
struct dentry *debug_writeRef; /* inject write ref_tag errors */
struct dentry *debug_readApp; /* inject read app_tag errors */
struct dentry *debug_readRef; /* inject read ref_tag errors */

/* T10 DIF error injection */
uint32_t lpfc_injerr_wgrd_cnt;
uint32_t lpfc_injerr_wapp_cnt;
uint32_t lpfc_injerr_wref_cnt;
uint32_t lpfc_injerr_rapp_cnt;
uint32_t lpfc_injerr_rref_cnt;
sector_t lpfc_injerr_lba;
#define LPFC_INJERR_LBA_OFF (sector_t)0xffffffffffffffff

struct dentry *debug_slow_ring_trc;
struct lpfc_debugfs_trc *slow_ring_trc;
atomic_t slow_ring_trc_cnt;
Expand Down
181 changes: 181 additions & 0 deletions drivers/scsi/lpfc/lpfc_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,85 @@ lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf,
return nbytes;
}

static int
lpfc_debugfs_dif_err_open(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;
return 0;
}

static ssize_t
lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct dentry *dent = file->f_dentry;
struct lpfc_hba *phba = file->private_data;
char cbuf[16];
int cnt = 0;

if (dent == phba->debug_writeGuard)
cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wgrd_cnt);
else if (dent == phba->debug_writeApp)
cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wapp_cnt);
else if (dent == phba->debug_writeRef)
cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wref_cnt);
else if (dent == phba->debug_readApp)
cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rapp_cnt);
else if (dent == phba->debug_readRef)
cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rref_cnt);
else if (dent == phba->debug_InjErrLBA)
cnt = snprintf(cbuf, 16, "0x%lx\n",
(unsigned long) phba->lpfc_injerr_lba);
else
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0547 Unknown debugfs error injection entry\n");

return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
}

static ssize_t
lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct dentry *dent = file->f_dentry;
struct lpfc_hba *phba = file->private_data;
char dstbuf[32];
unsigned long tmp;
int size;

memset(dstbuf, 0, 32);
size = (nbytes < 32) ? nbytes : 32;
if (copy_from_user(dstbuf, buf, size))
return 0;

if (strict_strtoul(dstbuf, 0, &tmp))
return 0;

if (dent == phba->debug_writeGuard)
phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp;
else if (dent == phba->debug_writeApp)
phba->lpfc_injerr_wapp_cnt = (uint32_t)tmp;
else if (dent == phba->debug_writeRef)
phba->lpfc_injerr_wref_cnt = (uint32_t)tmp;
else if (dent == phba->debug_readApp)
phba->lpfc_injerr_rapp_cnt = (uint32_t)tmp;
else if (dent == phba->debug_readRef)
phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
else if (dent == phba->debug_InjErrLBA)
phba->lpfc_injerr_lba = (sector_t)tmp;
else
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0548 Unknown debugfs error injection entry\n");

return nbytes;
}

static int
lpfc_debugfs_dif_err_release(struct inode *inode, struct file *file)
{
return 0;
}

/**
* lpfc_debugfs_nodelist_open - Open the nodelist debugfs file
* @inode: The inode pointer that contains a vport pointer.
Expand Down Expand Up @@ -3380,6 +3459,16 @@ static const struct file_operations lpfc_debugfs_op_dumpDif = {
.release = lpfc_debugfs_dumpDataDif_release,
};

#undef lpfc_debugfs_op_dif_err
static const struct file_operations lpfc_debugfs_op_dif_err = {
.owner = THIS_MODULE,
.open = lpfc_debugfs_dif_err_open,
.llseek = lpfc_debugfs_lseek,
.read = lpfc_debugfs_dif_err_read,
.write = lpfc_debugfs_dif_err_write,
.release = lpfc_debugfs_dif_err_release,
};

#undef lpfc_debugfs_op_slow_ring_trc
static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
.owner = THIS_MODULE,
Expand Down Expand Up @@ -3788,6 +3877,74 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
goto debug_failed;
}

/* Setup DIF Error Injections */
snprintf(name, sizeof(name), "InjErrLBA");
phba->debug_InjErrLBA =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_InjErrLBA) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0807 Cannot create debugfs InjErrLBA\n");
goto debug_failed;
}
phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;

snprintf(name, sizeof(name), "writeGuardInjErr");
phba->debug_writeGuard =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_writeGuard) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0802 Cannot create debugfs writeGuard\n");
goto debug_failed;
}

snprintf(name, sizeof(name), "writeAppInjErr");
phba->debug_writeApp =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_writeApp) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0803 Cannot create debugfs writeApp\n");
goto debug_failed;
}

snprintf(name, sizeof(name), "writeRefInjErr");
phba->debug_writeRef =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_writeRef) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0804 Cannot create debugfs writeRef\n");
goto debug_failed;
}

snprintf(name, sizeof(name), "readAppInjErr");
phba->debug_readApp =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_readApp) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0805 Cannot create debugfs readApp\n");
goto debug_failed;
}

snprintf(name, sizeof(name), "readRefInjErr");
phba->debug_readRef =
debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
phba->hba_debugfs_root,
phba, &lpfc_debugfs_op_dif_err);
if (!phba->debug_readRef) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
"0806 Cannot create debugfs readApp\n");
goto debug_failed;
}

/* Setup slow ring trace */
if (lpfc_debugfs_max_slow_ring_trc) {
num = lpfc_debugfs_max_slow_ring_trc - 1;
Expand Down Expand Up @@ -4090,6 +4247,30 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
debugfs_remove(phba->debug_dumpDif); /* dumpDif */
phba->debug_dumpDif = NULL;
}
if (phba->debug_InjErrLBA) {
debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
phba->debug_InjErrLBA = NULL;
}
if (phba->debug_writeGuard) {
debugfs_remove(phba->debug_writeGuard); /* writeGuard */
phba->debug_writeGuard = NULL;
}
if (phba->debug_writeApp) {
debugfs_remove(phba->debug_writeApp); /* writeApp */
phba->debug_writeApp = NULL;
}
if (phba->debug_writeRef) {
debugfs_remove(phba->debug_writeRef); /* writeRef */
phba->debug_writeRef = NULL;
}
if (phba->debug_readApp) {
debugfs_remove(phba->debug_readApp); /* readApp */
phba->debug_readApp = NULL;
}
if (phba->debug_readRef) {
debugfs_remove(phba->debug_readRef); /* readRef */
phba->debug_readRef = NULL;
}

if (phba->slow_ring_trc) {
kfree(phba->slow_ring_trc);
Expand Down
88 changes: 84 additions & 4 deletions drivers/scsi/lpfc/lpfc_hw4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1484,16 +1484,81 @@ struct sli4_sge { /* SLI-4 */
uint32_t addr_lo;

uint32_t word2;
#define lpfc_sli4_sge_offset_SHIFT 0 /* Offset of buffer - Not used*/
#define lpfc_sli4_sge_offset_MASK 0x1FFFFFFF
#define lpfc_sli4_sge_offset_SHIFT 0
#define lpfc_sli4_sge_offset_MASK 0x07FFFFFF
#define lpfc_sli4_sge_offset_WORD word2
#define lpfc_sli4_sge_last_SHIFT 31 /* Last SEG in the SGL sets
this flag !! */
#define lpfc_sli4_sge_type_SHIFT 27
#define lpfc_sli4_sge_type_MASK 0x0000000F
#define lpfc_sli4_sge_type_WORD word2
#define LPFC_SGE_TYPE_DATA 0x0
#define LPFC_SGE_TYPE_DIF 0x4
#define LPFC_SGE_TYPE_LSP 0x5
#define LPFC_SGE_TYPE_PEDIF 0x6
#define LPFC_SGE_TYPE_PESEED 0x7
#define LPFC_SGE_TYPE_DISEED 0x8
#define LPFC_SGE_TYPE_ENC 0x9
#define LPFC_SGE_TYPE_ATM 0xA
#define LPFC_SGE_TYPE_SKIP 0xC
#define lpfc_sli4_sge_last_SHIFT 31 /* Last SEG in the SGL sets it */
#define lpfc_sli4_sge_last_MASK 0x00000001
#define lpfc_sli4_sge_last_WORD word2
uint32_t sge_len;
};

struct sli4_sge_diseed { /* SLI-4 */
uint32_t ref_tag;
uint32_t ref_tag_tran;

uint32_t word2;
#define lpfc_sli4_sge_dif_apptran_SHIFT 0
#define lpfc_sli4_sge_dif_apptran_MASK 0x0000FFFF
#define lpfc_sli4_sge_dif_apptran_WORD word2
#define lpfc_sli4_sge_dif_af_SHIFT 24
#define lpfc_sli4_sge_dif_af_MASK 0x00000001
#define lpfc_sli4_sge_dif_af_WORD word2
#define lpfc_sli4_sge_dif_na_SHIFT 25
#define lpfc_sli4_sge_dif_na_MASK 0x00000001
#define lpfc_sli4_sge_dif_na_WORD word2
#define lpfc_sli4_sge_dif_hi_SHIFT 26
#define lpfc_sli4_sge_dif_hi_MASK 0x00000001
#define lpfc_sli4_sge_dif_hi_WORD word2
#define lpfc_sli4_sge_dif_type_SHIFT 27
#define lpfc_sli4_sge_dif_type_MASK 0x0000000F
#define lpfc_sli4_sge_dif_type_WORD word2
#define lpfc_sli4_sge_dif_last_SHIFT 31 /* Last SEG in the SGL sets it */
#define lpfc_sli4_sge_dif_last_MASK 0x00000001
#define lpfc_sli4_sge_dif_last_WORD word2
uint32_t word3;
#define lpfc_sli4_sge_dif_apptag_SHIFT 0
#define lpfc_sli4_sge_dif_apptag_MASK 0x0000FFFF
#define lpfc_sli4_sge_dif_apptag_WORD word3
#define lpfc_sli4_sge_dif_bs_SHIFT 16
#define lpfc_sli4_sge_dif_bs_MASK 0x00000007
#define lpfc_sli4_sge_dif_bs_WORD word3
#define lpfc_sli4_sge_dif_ai_SHIFT 19
#define lpfc_sli4_sge_dif_ai_MASK 0x00000001
#define lpfc_sli4_sge_dif_ai_WORD word3
#define lpfc_sli4_sge_dif_me_SHIFT 20
#define lpfc_sli4_sge_dif_me_MASK 0x00000001
#define lpfc_sli4_sge_dif_me_WORD word3
#define lpfc_sli4_sge_dif_re_SHIFT 21
#define lpfc_sli4_sge_dif_re_MASK 0x00000001
#define lpfc_sli4_sge_dif_re_WORD word3
#define lpfc_sli4_sge_dif_ce_SHIFT 22
#define lpfc_sli4_sge_dif_ce_MASK 0x00000001
#define lpfc_sli4_sge_dif_ce_WORD word3
#define lpfc_sli4_sge_dif_nr_SHIFT 23
#define lpfc_sli4_sge_dif_nr_MASK 0x00000001
#define lpfc_sli4_sge_dif_nr_WORD word3
#define lpfc_sli4_sge_dif_oprx_SHIFT 24
#define lpfc_sli4_sge_dif_oprx_MASK 0x0000000F
#define lpfc_sli4_sge_dif_oprx_WORD word3
#define lpfc_sli4_sge_dif_optx_SHIFT 28
#define lpfc_sli4_sge_dif_optx_MASK 0x0000000F
#define lpfc_sli4_sge_dif_optx_WORD word3
/* optx and oprx use BG_OP_IN defines in lpfc_hw.h */
};

struct fcf_record {
uint32_t max_rcv_size;
uint32_t fka_adv_period;
Expand Down Expand Up @@ -3023,6 +3088,9 @@ struct wqe_common {
#define wqe_ctxt_tag_MASK 0x0000FFFF
#define wqe_ctxt_tag_WORD word6
uint32_t word7;
#define wqe_dif_SHIFT 0
#define wqe_dif_MASK 0x00000003
#define wqe_dif_WORD word7
#define wqe_ct_SHIFT 2
#define wqe_ct_MASK 0x00000003
#define wqe_ct_WORD word7
Expand All @@ -3035,12 +3103,21 @@ struct wqe_common {
#define wqe_class_SHIFT 16
#define wqe_class_MASK 0x00000007
#define wqe_class_WORD word7
#define wqe_ar_SHIFT 19
#define wqe_ar_MASK 0x00000001
#define wqe_ar_WORD word7
#define wqe_ag_SHIFT wqe_ar_SHIFT
#define wqe_ag_MASK wqe_ar_MASK
#define wqe_ag_WORD wqe_ar_WORD
#define wqe_pu_SHIFT 20
#define wqe_pu_MASK 0x00000003
#define wqe_pu_WORD word7
#define wqe_erp_SHIFT 22
#define wqe_erp_MASK 0x00000001
#define wqe_erp_WORD word7
#define wqe_conf_SHIFT wqe_erp_SHIFT
#define wqe_conf_MASK wqe_erp_MASK
#define wqe_conf_WORD wqe_erp_WORD
#define wqe_lnk_SHIFT 23
#define wqe_lnk_MASK 0x00000001
#define wqe_lnk_WORD word7
Expand Down Expand Up @@ -3099,6 +3176,9 @@ struct wqe_common {
#define wqe_xc_SHIFT 21
#define wqe_xc_MASK 0x00000001
#define wqe_xc_WORD word10
#define wqe_sr_SHIFT 22
#define wqe_sr_MASK 0x00000001
#define wqe_sr_WORD word10
#define wqe_ccpe_SHIFT 23
#define wqe_ccpe_MASK 0x00000001
#define wqe_ccpe_WORD word10
Expand Down
Loading

0 comments on commit f9bb2da

Please sign in to comment.