diff options
author | Divy Le Ray <divy@chelsio.com> | 2007-05-31 00:10:58 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-08 22:16:39 -0400 |
commit | 480fe1a31c662ef4ff0598a7cacefa21f98335f1 (patch) | |
tree | 66da8f259d7093d7f9290054f4fbda1f68ff9e0a /drivers | |
parent | 8a9fab22cf6a3abde7731f4425d4ff87509bc15a (diff) |
cxgb3 - TP SRAM update
The chip executes microcode present in internal RAM,
whose content is loaded from EEPROM on power cycle.
This patch allows an update of the microcode through PIO
without forcing a power cycle.
Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/cxgb3/common.h | 28 | ||||
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 43 | ||||
-rw-r--r-- | drivers/net/cxgb3/regs.h | 7 | ||||
-rw-r--r-- | drivers/net/cxgb3/t3_hw.c | 86 |
4 files changed, 164 insertions, 0 deletions
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h index 8d1379633698..16378004507a 100644 --- a/drivers/net/cxgb3/common.h +++ b/drivers/net/cxgb3/common.h | |||
@@ -101,6 +101,7 @@ enum { | |||
101 | TCB_SIZE = 128, /* TCB size */ | 101 | TCB_SIZE = 128, /* TCB size */ |
102 | NMTUS = 16, /* size of MTU table */ | 102 | NMTUS = 16, /* size of MTU table */ |
103 | NCCTRL_WIN = 32, /* # of congestion control windows */ | 103 | NCCTRL_WIN = 32, /* # of congestion control windows */ |
104 | PROTO_SRAM_LINES = 128, /* size of TP sram */ | ||
104 | }; | 105 | }; |
105 | 106 | ||
106 | #define MAX_RX_COALESCING_LEN 16224U | 107 | #define MAX_RX_COALESCING_LEN 16224U |
@@ -124,6 +125,30 @@ enum { /* adapter interrupt-maintained statistics */ | |||
124 | }; | 125 | }; |
125 | 126 | ||
126 | enum { | 127 | enum { |
128 | TP_VERSION_MAJOR = 1, | ||
129 | TP_VERSION_MINOR = 0, | ||
130 | TP_VERSION_MICRO = 44 | ||
131 | }; | ||
132 | |||
133 | #define S_TP_VERSION_MAJOR 16 | ||
134 | #define M_TP_VERSION_MAJOR 0xFF | ||
135 | #define V_TP_VERSION_MAJOR(x) ((x) << S_TP_VERSION_MAJOR) | ||
136 | #define G_TP_VERSION_MAJOR(x) \ | ||
137 | (((x) >> S_TP_VERSION_MAJOR) & M_TP_VERSION_MAJOR) | ||
138 | |||
139 | #define S_TP_VERSION_MINOR 8 | ||
140 | #define M_TP_VERSION_MINOR 0xFF | ||
141 | #define V_TP_VERSION_MINOR(x) ((x) << S_TP_VERSION_MINOR) | ||
142 | #define G_TP_VERSION_MINOR(x) \ | ||
143 | (((x) >> S_TP_VERSION_MINOR) & M_TP_VERSION_MINOR) | ||
144 | |||
145 | #define S_TP_VERSION_MICRO 0 | ||
146 | #define M_TP_VERSION_MICRO 0xFF | ||
147 | #define V_TP_VERSION_MICRO(x) ((x) << S_TP_VERSION_MICRO) | ||
148 | #define G_TP_VERSION_MICRO(x) \ | ||
149 | (((x) >> S_TP_VERSION_MICRO) & M_TP_VERSION_MICRO) | ||
150 | |||
151 | enum { | ||
127 | SGE_QSETS = 8, /* # of SGE Tx/Rx/RspQ sets */ | 152 | SGE_QSETS = 8, /* # of SGE Tx/Rx/RspQ sets */ |
128 | SGE_RXQ_PER_SET = 2, /* # of Rx queues per set */ | 153 | SGE_RXQ_PER_SET = 2, /* # of Rx queues per set */ |
129 | SGE_TXQ_PER_SET = 3 /* # of Tx queues per set */ | 154 | SGE_TXQ_PER_SET = 3 /* # of Tx queues per set */ |
@@ -654,6 +679,9 @@ const struct adapter_info *t3_get_adapter_info(unsigned int board_id); | |||
654 | int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data); | 679 | int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data); |
655 | int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data); | 680 | int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data); |
656 | int t3_seeprom_wp(struct adapter *adapter, int enable); | 681 | int t3_seeprom_wp(struct adapter *adapter, int enable); |
682 | int t3_check_tpsram_version(struct adapter *adapter); | ||
683 | int t3_check_tpsram(struct adapter *adapter, u8 *tp_ram, unsigned int size); | ||
684 | int t3_set_proto_sram(struct adapter *adap, u8 *data); | ||
657 | int t3_read_flash(struct adapter *adapter, unsigned int addr, | 685 | int t3_read_flash(struct adapter *adapter, unsigned int addr, |
658 | unsigned int nwords, u32 *data, int byte_oriented); | 686 | unsigned int nwords, u32 *data, int byte_oriented); |
659 | int t3_load_fw(struct adapter *adapter, const u8 * fw_data, unsigned int size); | 687 | int t3_load_fw(struct adapter *adapter, const u8 * fw_data, unsigned int size); |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index d8a1f5452c51..15defe4c4f05 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -2088,6 +2088,42 @@ static void cxgb_netpoll(struct net_device *dev) | |||
2088 | } | 2088 | } |
2089 | #endif | 2089 | #endif |
2090 | 2090 | ||
2091 | #define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin" | ||
2092 | int update_tpsram(struct adapter *adap) | ||
2093 | { | ||
2094 | const struct firmware *tpsram; | ||
2095 | char buf[64]; | ||
2096 | struct device *dev = &adap->pdev->dev; | ||
2097 | int ret; | ||
2098 | char rev; | ||
2099 | |||
2100 | rev = adap->params.rev == T3_REV_B2 ? 'b' : 'a'; | ||
2101 | |||
2102 | snprintf(buf, sizeof(buf), TPSRAM_NAME, rev, | ||
2103 | TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO); | ||
2104 | |||
2105 | ret = request_firmware(&tpsram, buf, dev); | ||
2106 | if (ret < 0) { | ||
2107 | dev_err(dev, "could not load TP SRAM: unable to load %s\n", | ||
2108 | buf); | ||
2109 | return ret; | ||
2110 | } | ||
2111 | |||
2112 | ret = t3_check_tpsram(adap, tpsram->data, tpsram->size); | ||
2113 | if (ret) | ||
2114 | goto release_tpsram; | ||
2115 | |||
2116 | ret = t3_set_proto_sram(adap, tpsram->data); | ||
2117 | if (ret) | ||
2118 | dev_err(dev, "loading protocol SRAM failed\n"); | ||
2119 | |||
2120 | release_tpsram: | ||
2121 | release_firmware(tpsram); | ||
2122 | |||
2123 | return ret; | ||
2124 | } | ||
2125 | |||
2126 | |||
2091 | /* | 2127 | /* |
2092 | * Periodic accumulation of MAC statistics. | 2128 | * Periodic accumulation of MAC statistics. |
2093 | */ | 2129 | */ |
@@ -2437,6 +2473,13 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2437 | goto out_free_dev; | 2473 | goto out_free_dev; |
2438 | } | 2474 | } |
2439 | 2475 | ||
2476 | err = t3_check_tpsram_version(adapter); | ||
2477 | if (err == -EINVAL) | ||
2478 | err = update_tpsram(adapter); | ||
2479 | |||
2480 | if (err) | ||
2481 | goto out_free_dev; | ||
2482 | |||
2440 | /* | 2483 | /* |
2441 | * The card is now ready to go. If any errors occur during device | 2484 | * The card is now ready to go. If any errors occur during device |
2442 | * registration we do not fail the whole card but rather proceed only | 2485 | * registration we do not fail the whole card but rather proceed only |
diff --git a/drivers/net/cxgb3/regs.h b/drivers/net/cxgb3/regs.h index 02f8731ffb02..aa80313c922e 100644 --- a/drivers/net/cxgb3/regs.h +++ b/drivers/net/cxgb3/regs.h | |||
@@ -1218,6 +1218,13 @@ | |||
1218 | 1218 | ||
1219 | #define A_TP_PROXY_FLOW_CNTL 0x4b0 | 1219 | #define A_TP_PROXY_FLOW_CNTL 0x4b0 |
1220 | 1220 | ||
1221 | #define A_TP_EMBED_OP_FIELD0 0x4e8 | ||
1222 | #define A_TP_EMBED_OP_FIELD1 0x4ec | ||
1223 | #define A_TP_EMBED_OP_FIELD2 0x4f0 | ||
1224 | #define A_TP_EMBED_OP_FIELD3 0x4f4 | ||
1225 | #define A_TP_EMBED_OP_FIELD4 0x4f8 | ||
1226 | #define A_TP_EMBED_OP_FIELD5 0x4fc | ||
1227 | |||
1221 | #define A_ULPRX_CTL 0x500 | 1228 | #define A_ULPRX_CTL 0x500 |
1222 | 1229 | ||
1223 | #define S_ROUND_ROBIN 4 | 1230 | #define S_ROUND_ROBIN 4 |
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c index 9e3591d7706f..dd3149d94ba8 100644 --- a/drivers/net/cxgb3/t3_hw.c +++ b/drivers/net/cxgb3/t3_hw.c | |||
@@ -847,6 +847,64 @@ static int t3_write_flash(struct adapter *adapter, unsigned int addr, | |||
847 | return 0; | 847 | return 0; |
848 | } | 848 | } |
849 | 849 | ||
850 | /** | ||
851 | * t3_check_tpsram_version - read the tp sram version | ||
852 | * @adapter: the adapter | ||
853 | * | ||
854 | * Reads the protocol sram version from serial eeprom. | ||
855 | */ | ||
856 | int t3_check_tpsram_version(struct adapter *adapter) | ||
857 | { | ||
858 | int ret; | ||
859 | u32 vers; | ||
860 | unsigned int major, minor; | ||
861 | |||
862 | /* Get version loaded in SRAM */ | ||
863 | t3_write_reg(adapter, A_TP_EMBED_OP_FIELD0, 0); | ||
864 | ret = t3_wait_op_done(adapter, A_TP_EMBED_OP_FIELD0, | ||
865 | 1, 1, 5, 1); | ||
866 | if (ret) | ||
867 | return ret; | ||
868 | |||
869 | vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1); | ||
870 | |||
871 | major = G_TP_VERSION_MAJOR(vers); | ||
872 | minor = G_TP_VERSION_MINOR(vers); | ||
873 | |||
874 | if (major == TP_VERSION_MAJOR && minor == TP_VERSION_MINOR) | ||
875 | return 0; | ||
876 | |||
877 | return -EINVAL; | ||
878 | } | ||
879 | |||
880 | /** | ||
881 | * t3_check_tpsram - check if provided protocol SRAM | ||
882 | * is compatible with this driver | ||
883 | * @adapter: the adapter | ||
884 | * @tp_sram: the firmware image to write | ||
885 | * @size: image size | ||
886 | * | ||
887 | * Checks if an adapter's tp sram is compatible with the driver. | ||
888 | * Returns 0 if the versions are compatible, a negative error otherwise. | ||
889 | */ | ||
890 | int t3_check_tpsram(struct adapter *adapter, u8 *tp_sram, unsigned int size) | ||
891 | { | ||
892 | u32 csum; | ||
893 | unsigned int i; | ||
894 | const u32 *p = (const u32 *)tp_sram; | ||
895 | |||
896 | /* Verify checksum */ | ||
897 | for (csum = 0, i = 0; i < size / sizeof(csum); i++) | ||
898 | csum += ntohl(p[i]); | ||
899 | if (csum != 0xffffffff) { | ||
900 | CH_ERR(adapter, "corrupted protocol SRAM image, checksum %u\n", | ||
901 | csum); | ||
902 | return -EINVAL; | ||
903 | } | ||
904 | |||
905 | return 0; | ||
906 | } | ||
907 | |||
850 | enum fw_version_type { | 908 | enum fw_version_type { |
851 | FW_VERSION_N3, | 909 | FW_VERSION_N3, |
852 | FW_VERSION_T3 | 910 | FW_VERSION_T3 |
@@ -2686,6 +2744,34 @@ static void ulp_config(struct adapter *adap, const struct tp_params *p) | |||
2686 | t3_write_reg(adap, A_ULPRX_TDDP_TAGMASK, 0xffffffff); | 2744 | t3_write_reg(adap, A_ULPRX_TDDP_TAGMASK, 0xffffffff); |
2687 | } | 2745 | } |
2688 | 2746 | ||
2747 | /** | ||
2748 | * t3_set_proto_sram - set the contents of the protocol sram | ||
2749 | * @adapter: the adapter | ||
2750 | * @data: the protocol image | ||
2751 | * | ||
2752 | * Write the contents of the protocol SRAM. | ||
2753 | */ | ||
2754 | int t3_set_proto_sram(struct adapter *adap, u8 *data) | ||
2755 | { | ||
2756 | int i; | ||
2757 | u32 *buf = (u32 *)data; | ||
2758 | |||
2759 | for (i = 0; i < PROTO_SRAM_LINES; i++) { | ||
2760 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD5, cpu_to_be32(*buf++)); | ||
2761 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD4, cpu_to_be32(*buf++)); | ||
2762 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD3, cpu_to_be32(*buf++)); | ||
2763 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD2, cpu_to_be32(*buf++)); | ||
2764 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD1, cpu_to_be32(*buf++)); | ||
2765 | |||
2766 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD0, i << 1 | 1 << 31); | ||
2767 | if (t3_wait_op_done(adap, A_TP_EMBED_OP_FIELD0, 1, 1, 5, 1)) | ||
2768 | return -EIO; | ||
2769 | } | ||
2770 | t3_write_reg(adap, A_TP_EMBED_OP_FIELD0, 0); | ||
2771 | |||
2772 | return 0; | ||
2773 | } | ||
2774 | |||
2689 | void t3_config_trace_filter(struct adapter *adapter, | 2775 | void t3_config_trace_filter(struct adapter *adapter, |
2690 | const struct trace_params *tp, int filter_index, | 2776 | const struct trace_params *tp, int filter_index, |
2691 | int invert, int enable) | 2777 | int invert, int enable) |