diff options
author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-01-20 01:32:20 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-24 20:13:24 -0500 |
commit | 49216c1c170f07c138b043d67cd34c67d75a27cc (patch) | |
tree | 1b12e8aac0c9cbbf2a254c075dc05d09ded38d95 | |
parent | 1650d5455bd2dc6b5ee134bd6fc1a3236c266b5b (diff) |
cxgb4: Add debugfs entry to dump the contents of the flash
Adds support to dump the contents of the flash in the adapter
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 73 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 28 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 6 |
5 files changed, 110 insertions, 3 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index e468f920892f..29c523294c0d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | |||
@@ -1008,7 +1008,10 @@ static inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr, | |||
1008 | 1008 | ||
1009 | int t4_seeprom_wp(struct adapter *adapter, bool enable); | 1009 | int t4_seeprom_wp(struct adapter *adapter, bool enable); |
1010 | int get_vpd_params(struct adapter *adapter, struct vpd_params *p); | 1010 | int get_vpd_params(struct adapter *adapter, struct vpd_params *p); |
1011 | int t4_read_flash(struct adapter *adapter, unsigned int addr, | ||
1012 | unsigned int nwords, u32 *data, int byte_oriented); | ||
1011 | int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size); | 1013 | int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size); |
1014 | int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op); | ||
1012 | int t4_fw_upgrade(struct adapter *adap, unsigned int mbox, | 1015 | int t4_fw_upgrade(struct adapter *adap, unsigned int mbox, |
1013 | const u8 *fw_data, unsigned int size, int force); | 1016 | const u8 *fw_data, unsigned int size, int force); |
1014 | unsigned int t4_flash_cfg_addr(struct adapter *adapter); | 1017 | unsigned int t4_flash_cfg_addr(struct adapter *adapter); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 6dabfe5ba44e..8b2e230beb99 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
@@ -434,6 +434,51 @@ static const struct file_operations devlog_fops = { | |||
434 | .release = seq_release_private | 434 | .release = seq_release_private |
435 | }; | 435 | }; |
436 | 436 | ||
437 | static ssize_t flash_read(struct file *file, char __user *buf, size_t count, | ||
438 | loff_t *ppos) | ||
439 | { | ||
440 | loff_t pos = *ppos; | ||
441 | loff_t avail = FILE_DATA(file)->i_size; | ||
442 | struct adapter *adap = file->private_data; | ||
443 | |||
444 | if (pos < 0) | ||
445 | return -EINVAL; | ||
446 | if (pos >= avail) | ||
447 | return 0; | ||
448 | if (count > avail - pos) | ||
449 | count = avail - pos; | ||
450 | |||
451 | while (count) { | ||
452 | size_t len; | ||
453 | int ret, ofst; | ||
454 | u8 data[256]; | ||
455 | |||
456 | ofst = pos & 3; | ||
457 | len = min(count + ofst, sizeof(data)); | ||
458 | ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4, | ||
459 | (u32 *)data, 1); | ||
460 | if (ret) | ||
461 | return ret; | ||
462 | |||
463 | len -= ofst; | ||
464 | if (copy_to_user(buf, data + ofst, len)) | ||
465 | return -EFAULT; | ||
466 | |||
467 | buf += len; | ||
468 | pos += len; | ||
469 | count -= len; | ||
470 | } | ||
471 | count = pos - *ppos; | ||
472 | *ppos = pos; | ||
473 | return count; | ||
474 | } | ||
475 | |||
476 | static const struct file_operations flash_debugfs_fops = { | ||
477 | .owner = THIS_MODULE, | ||
478 | .open = mem_open, | ||
479 | .read = flash_read, | ||
480 | }; | ||
481 | |||
437 | static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask) | 482 | static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask) |
438 | { | 483 | { |
439 | *mask = x | y; | 484 | *mask = x | y; |
@@ -579,6 +624,21 @@ static const struct file_operations clip_tbl_debugfs_fops = { | |||
579 | }; | 624 | }; |
580 | #endif | 625 | #endif |
581 | 626 | ||
627 | int mem_open(struct inode *inode, struct file *file) | ||
628 | { | ||
629 | unsigned int mem; | ||
630 | struct adapter *adap; | ||
631 | |||
632 | file->private_data = inode->i_private; | ||
633 | |||
634 | mem = (uintptr_t)file->private_data & 0x3; | ||
635 | adap = file->private_data - mem; | ||
636 | |||
637 | (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH); | ||
638 | |||
639 | return 0; | ||
640 | } | ||
641 | |||
582 | static ssize_t mem_read(struct file *file, char __user *buf, size_t count, | 642 | static ssize_t mem_read(struct file *file, char __user *buf, size_t count, |
583 | loff_t *ppos) | 643 | loff_t *ppos) |
584 | { | 644 | { |
@@ -616,7 +676,6 @@ static ssize_t mem_read(struct file *file, char __user *buf, size_t count, | |||
616 | *ppos = pos + count; | 676 | *ppos = pos + count; |
617 | return count; | 677 | return count; |
618 | } | 678 | } |
619 | |||
620 | static const struct file_operations mem_debugfs_fops = { | 679 | static const struct file_operations mem_debugfs_fops = { |
621 | .owner = THIS_MODULE, | 680 | .owner = THIS_MODULE, |
622 | .open = simple_open, | 681 | .open = simple_open, |
@@ -624,6 +683,12 @@ static const struct file_operations mem_debugfs_fops = { | |||
624 | .llseek = default_llseek, | 683 | .llseek = default_llseek, |
625 | }; | 684 | }; |
626 | 685 | ||
686 | static void set_debugfs_file_size(struct dentry *de, loff_t size) | ||
687 | { | ||
688 | if (!IS_ERR(de) && de->d_inode) | ||
689 | de->d_inode->i_size = size; | ||
690 | } | ||
691 | |||
627 | static void add_debugfs_mem(struct adapter *adap, const char *name, | 692 | static void add_debugfs_mem(struct adapter *adap, const char *name, |
628 | unsigned int idx, unsigned int size_mb) | 693 | unsigned int idx, unsigned int size_mb) |
629 | { | 694 | { |
@@ -655,6 +720,7 @@ int t4_setup_debugfs(struct adapter *adap) | |||
655 | { | 720 | { |
656 | int i; | 721 | int i; |
657 | u32 size; | 722 | u32 size; |
723 | struct dentry *de; | ||
658 | 724 | ||
659 | static struct t4_debugfs_entry t4_debugfs_files[] = { | 725 | static struct t4_debugfs_entry t4_debugfs_files[] = { |
660 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, | 726 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, |
@@ -697,5 +763,10 @@ int t4_setup_debugfs(struct adapter *adap) | |||
697 | EXT_MEM1_SIZE_G(size)); | 763 | EXT_MEM1_SIZE_G(size)); |
698 | } | 764 | } |
699 | } | 765 | } |
766 | |||
767 | de = debugfs_create_file("flash", S_IRUSR, adap->debugfs_root, adap, | ||
768 | &flash_debugfs_fops); | ||
769 | set_debugfs_file_size(de, adap->params.sf_size); | ||
770 | |||
700 | return 0; | 771 | return 0; |
701 | } | 772 | } |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h index 70fcbc930826..e162c611e089 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h | |||
@@ -37,6 +37,8 @@ | |||
37 | 37 | ||
38 | #include <linux/export.h> | 38 | #include <linux/export.h> |
39 | 39 | ||
40 | #define FILE_DATA(_file) ((_file)->f_path.dentry->d_inode) | ||
41 | |||
40 | struct t4_debugfs_entry { | 42 | struct t4_debugfs_entry { |
41 | const char *name; | 43 | const char *name; |
42 | const struct file_operations *ops; | 44 | const struct file_operations *ops; |
@@ -60,5 +62,6 @@ int t4_setup_debugfs(struct adapter *adap); | |||
60 | void add_debugfs_files(struct adapter *adap, | 62 | void add_debugfs_files(struct adapter *adap, |
61 | struct t4_debugfs_entry *files, | 63 | struct t4_debugfs_entry *files, |
62 | unsigned int nfiles); | 64 | unsigned int nfiles); |
65 | int mem_open(struct inode *inode, struct file *file); | ||
63 | 66 | ||
64 | #endif | 67 | #endif |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 734d33e3f53b..73da6f548fad 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | |||
@@ -835,8 +835,8 @@ static int flash_wait_op(struct adapter *adapter, int attempts, int delay) | |||
835 | * (i.e., big-endian), otherwise as 32-bit words in the platform's | 835 | * (i.e., big-endian), otherwise as 32-bit words in the platform's |
836 | * natural endianess. | 836 | * natural endianess. |
837 | */ | 837 | */ |
838 | static int t4_read_flash(struct adapter *adapter, unsigned int addr, | 838 | int t4_read_flash(struct adapter *adapter, unsigned int addr, |
839 | unsigned int nwords, u32 *data, int byte_oriented) | 839 | unsigned int nwords, u32 *data, int byte_oriented) |
840 | { | 840 | { |
841 | int ret; | 841 | int ret; |
842 | 842 | ||
@@ -1239,6 +1239,30 @@ out: | |||
1239 | return ret; | 1239 | return ret; |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | /** | ||
1243 | * t4_fwcache - firmware cache operation | ||
1244 | * @adap: the adapter | ||
1245 | * @op : the operation (flush or flush and invalidate) | ||
1246 | */ | ||
1247 | int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op) | ||
1248 | { | ||
1249 | struct fw_params_cmd c; | ||
1250 | |||
1251 | memset(&c, 0, sizeof(c)); | ||
1252 | c.op_to_vfn = | ||
1253 | cpu_to_be32(FW_CMD_OP_V(FW_PARAMS_CMD) | | ||
1254 | FW_CMD_REQUEST_F | FW_CMD_WRITE_F | | ||
1255 | FW_PARAMS_CMD_PFN_V(adap->fn) | | ||
1256 | FW_PARAMS_CMD_VFN_V(0)); | ||
1257 | c.retval_len16 = cpu_to_be32(FW_LEN16(c)); | ||
1258 | c.param[0].mnem = | ||
1259 | cpu_to_be32(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | | ||
1260 | FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_FWCACHE)); | ||
1261 | c.param[0].val = (__force __be32)op; | ||
1262 | |||
1263 | return t4_wr_mbox(adap, adap->mbox, &c, sizeof(c), NULL); | ||
1264 | } | ||
1265 | |||
1242 | #define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\ | 1266 | #define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\ |
1243 | FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \ | 1267 | FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \ |
1244 | FW_PORT_CAP_ANEG) | 1268 | FW_PORT_CAP_ANEG) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h index de8283324f1f..1e72cda5eb1a 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | |||
@@ -1062,6 +1062,7 @@ enum fw_params_param_dev { | |||
1062 | FW_PARAMS_PARAM_DEV_MAXORDIRD_QP = 0x13, /* max supported QP IRD/ORD */ | 1062 | FW_PARAMS_PARAM_DEV_MAXORDIRD_QP = 0x13, /* max supported QP IRD/ORD */ |
1063 | FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER = 0x14, /* max supported adap IRD */ | 1063 | FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER = 0x14, /* max supported adap IRD */ |
1064 | FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17, | 1064 | FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17, |
1065 | FW_PARAMS_PARAM_DEV_FWCACHE = 0x18, | ||
1065 | }; | 1066 | }; |
1066 | 1067 | ||
1067 | /* | 1068 | /* |
@@ -1121,6 +1122,11 @@ enum fw_params_param_dmaq { | |||
1121 | FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH = 0x13, | 1122 | FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH = 0x13, |
1122 | }; | 1123 | }; |
1123 | 1124 | ||
1125 | enum fw_params_param_dev_fwcache { | ||
1126 | FW_PARAM_DEV_FWCACHE_FLUSH = 0x00, | ||
1127 | FW_PARAM_DEV_FWCACHE_FLUSHINV = 0x01, | ||
1128 | }; | ||
1129 | |||
1124 | #define FW_PARAMS_MNEM_S 24 | 1130 | #define FW_PARAMS_MNEM_S 24 |
1125 | #define FW_PARAMS_MNEM_V(x) ((x) << FW_PARAMS_MNEM_S) | 1131 | #define FW_PARAMS_MNEM_V(x) ((x) << FW_PARAMS_MNEM_S) |
1126 | 1132 | ||