aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/cxgb3/common.h3
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c126
-rw-r--r--drivers/net/cxgb3/t3_hw.c46
3 files changed, 123 insertions, 52 deletions
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 16378004507a..2129210a67c1 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -679,7 +679,8 @@ const struct adapter_info *t3_get_adapter_info(unsigned int board_id);
679int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data); 679int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data);
680int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data); 680int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data);
681int t3_seeprom_wp(struct adapter *adapter, int enable); 681int t3_seeprom_wp(struct adapter *adapter, int enable);
682int t3_check_tpsram_version(struct adapter *adapter); 682int t3_get_tp_version(struct adapter *adapter, u32 *vers);
683int t3_check_tpsram_version(struct adapter *adapter, int *must_load);
683int t3_check_tpsram(struct adapter *adapter, u8 *tp_ram, unsigned int size); 684int t3_check_tpsram(struct adapter *adapter, u8 *tp_ram, unsigned int size);
684int t3_set_proto_sram(struct adapter *adap, u8 *data); 685int t3_set_proto_sram(struct adapter *adap, u8 *data);
685int t3_read_flash(struct adapter *adapter, unsigned int addr, 686int t3_read_flash(struct adapter *adapter, unsigned int addr,
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index f3bf1283c9a7..5ab319cfe5de 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -729,6 +729,7 @@ static void bind_qsets(struct adapter *adap)
729} 729}
730 730
731#define FW_FNAME "t3fw-%d.%d.%d.bin" 731#define FW_FNAME "t3fw-%d.%d.%d.bin"
732#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin"
732 733
733static int upgrade_fw(struct adapter *adap) 734static int upgrade_fw(struct adapter *adap)
734{ 735{
@@ -747,6 +748,71 @@ static int upgrade_fw(struct adapter *adap)
747 } 748 }
748 ret = t3_load_fw(adap, fw->data, fw->size); 749 ret = t3_load_fw(adap, fw->data, fw->size);
749 release_firmware(fw); 750 release_firmware(fw);
751
752 if (ret == 0)
753 dev_info(dev, "successful upgrade to firmware %d.%d.%d\n",
754 FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO);
755 else
756 dev_err(dev, "failed to upgrade to firmware %d.%d.%d\n",
757 FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO);
758
759 return ret;
760}
761
762static inline char t3rev2char(struct adapter *adapter)
763{
764 char rev = 0;
765
766 switch(adapter->params.rev) {
767 case T3_REV_B:
768 case T3_REV_B2:
769 rev = 'b';
770 break;
771 }
772 return rev;
773}
774
775int update_tpsram(struct adapter *adap)
776{
777 const struct firmware *tpsram;
778 char buf[64];
779 struct device *dev = &adap->pdev->dev;
780 int ret;
781 char rev;
782
783 rev = t3rev2char(adap);
784 if (!rev)
785 return 0;
786
787 snprintf(buf, sizeof(buf), TPSRAM_NAME, rev,
788 TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
789
790 ret = request_firmware(&tpsram, buf, dev);
791 if (ret < 0) {
792 dev_err(dev, "could not load TP SRAM: unable to load %s\n",
793 buf);
794 return ret;
795 }
796
797 ret = t3_check_tpsram(adap, tpsram->data, tpsram->size);
798 if (ret)
799 goto release_tpsram;
800
801 ret = t3_set_proto_sram(adap, tpsram->data);
802 if (ret == 0)
803 dev_info(dev,
804 "successful update of protocol engine "
805 "to %d.%d.%d\n",
806 TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
807 else
808 dev_err(dev, "failed to update of protocol engine %d.%d.%d\n",
809 TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
810 if (ret)
811 dev_err(dev, "loading protocol SRAM failed\n");
812
813release_tpsram:
814 release_firmware(tpsram);
815
750 return ret; 816 return ret;
751} 817}
752 818
@@ -763,6 +829,7 @@ static int upgrade_fw(struct adapter *adap)
763static int cxgb_up(struct adapter *adap) 829static int cxgb_up(struct adapter *adap)
764{ 830{
765 int err = 0; 831 int err = 0;
832 int must_load;
766 833
767 if (!(adap->flags & FULL_INIT_DONE)) { 834 if (!(adap->flags & FULL_INIT_DONE)) {
768 err = t3_check_fw_version(adap); 835 err = t3_check_fw_version(adap);
@@ -771,6 +838,13 @@ static int cxgb_up(struct adapter *adap)
771 if (err) 838 if (err)
772 goto out; 839 goto out;
773 840
841 err = t3_check_tpsram_version(adap, &must_load);
842 if (err == -EINVAL) {
843 err = update_tpsram(adap);
844 if (err && must_load)
845 goto out;
846 }
847
774 err = init_dummy_netdevs(adap); 848 err = init_dummy_netdevs(adap);
775 if (err) 849 if (err)
776 goto out; 850 goto out;
@@ -1110,8 +1184,10 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1110 struct port_info *pi = netdev_priv(dev); 1184 struct port_info *pi = netdev_priv(dev);
1111 struct adapter *adapter = pi->adapter; 1185 struct adapter *adapter = pi->adapter;
1112 u32 fw_vers = 0; 1186 u32 fw_vers = 0;
1187 u32 tp_vers = 0;
1113 1188
1114 t3_get_fw_version(adapter, &fw_vers); 1189 t3_get_fw_version(adapter, &fw_vers);
1190 t3_get_tp_version(adapter, &tp_vers);
1115 1191
1116 strcpy(info->driver, DRV_NAME); 1192 strcpy(info->driver, DRV_NAME);
1117 strcpy(info->version, DRV_VERSION); 1193 strcpy(info->version, DRV_VERSION);
@@ -1120,11 +1196,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1120 strcpy(info->fw_version, "N/A"); 1196 strcpy(info->fw_version, "N/A");
1121 else { 1197 else {
1122 snprintf(info->fw_version, sizeof(info->fw_version), 1198 snprintf(info->fw_version, sizeof(info->fw_version),
1123 "%s %u.%u.%u", 1199 "%s %u.%u.%u TP %u.%u.%u",
1124 G_FW_VERSION_TYPE(fw_vers) ? "T" : "N", 1200 G_FW_VERSION_TYPE(fw_vers) ? "T" : "N",
1125 G_FW_VERSION_MAJOR(fw_vers), 1201 G_FW_VERSION_MAJOR(fw_vers),
1126 G_FW_VERSION_MINOR(fw_vers), 1202 G_FW_VERSION_MINOR(fw_vers),
1127 G_FW_VERSION_MICRO(fw_vers)); 1203 G_FW_VERSION_MICRO(fw_vers),
1204 G_TP_VERSION_MAJOR(tp_vers),
1205 G_TP_VERSION_MINOR(tp_vers),
1206 G_TP_VERSION_MICRO(tp_vers));
1128 } 1207 }
1129} 1208}
1130 1209
@@ -2107,42 +2186,6 @@ static void cxgb_netpoll(struct net_device *dev)
2107} 2186}
2108#endif 2187#endif
2109 2188
2110#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin"
2111int update_tpsram(struct adapter *adap)
2112{
2113 const struct firmware *tpsram;
2114 char buf[64];
2115 struct device *dev = &adap->pdev->dev;
2116 int ret;
2117 char rev;
2118
2119 rev = adap->params.rev == T3_REV_B2 ? 'b' : 'a';
2120
2121 snprintf(buf, sizeof(buf), TPSRAM_NAME, rev,
2122 TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
2123
2124 ret = request_firmware(&tpsram, buf, dev);
2125 if (ret < 0) {
2126 dev_err(dev, "could not load TP SRAM: unable to load %s\n",
2127 buf);
2128 return ret;
2129 }
2130
2131 ret = t3_check_tpsram(adap, tpsram->data, tpsram->size);
2132 if (ret)
2133 goto release_tpsram;
2134
2135 ret = t3_set_proto_sram(adap, tpsram->data);
2136 if (ret)
2137 dev_err(dev, "loading protocol SRAM failed\n");
2138
2139release_tpsram:
2140 release_firmware(tpsram);
2141
2142 return ret;
2143}
2144
2145
2146/* 2189/*
2147 * Periodic accumulation of MAC statistics. 2190 * Periodic accumulation of MAC statistics.
2148 */ 2191 */
@@ -2491,13 +2534,6 @@ static int __devinit init_one(struct pci_dev *pdev,
2491 err = -ENODEV; 2534 err = -ENODEV;
2492 goto out_free_dev; 2535 goto out_free_dev;
2493 } 2536 }
2494
2495 err = t3_check_tpsram_version(adapter);
2496 if (err == -EINVAL)
2497 err = update_tpsram(adapter);
2498
2499 if (err)
2500 goto out_free_dev;
2501 2537
2502 /* 2538 /*
2503 * The card is now ready to go. If any errors occur during device 2539 * The card is now ready to go. If any errors occur during device
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index dd3149d94ba8..b02d15daf5d9 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -848,16 +848,15 @@ static int t3_write_flash(struct adapter *adapter, unsigned int addr,
848} 848}
849 849
850/** 850/**
851 * t3_check_tpsram_version - read the tp sram version 851 * t3_get_tp_version - read the tp sram version
852 * @adapter: the adapter 852 * @adapter: the adapter
853 * @vers: where to place the version
853 * 854 *
854 * Reads the protocol sram version from serial eeprom. 855 * Reads the protocol sram version from sram.
855 */ 856 */
856int t3_check_tpsram_version(struct adapter *adapter) 857int t3_get_tp_version(struct adapter *adapter, u32 *vers)
857{ 858{
858 int ret; 859 int ret;
859 u32 vers;
860 unsigned int major, minor;
861 860
862 /* Get version loaded in SRAM */ 861 /* Get version loaded in SRAM */
863 t3_write_reg(adapter, A_TP_EMBED_OP_FIELD0, 0); 862 t3_write_reg(adapter, A_TP_EMBED_OP_FIELD0, 0);
@@ -866,7 +865,32 @@ int t3_check_tpsram_version(struct adapter *adapter)
866 if (ret) 865 if (ret)
867 return ret; 866 return ret;
868 867
869 vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1); 868 *vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1);
869
870 return 0;
871}
872
873/**
874 * t3_check_tpsram_version - read the tp sram version
875 * @adapter: the adapter
876 * @must_load: set to 1 if loading a new microcode image is required
877 *
878 * Reads the protocol sram version from flash.
879 */
880int t3_check_tpsram_version(struct adapter *adapter, int *must_load)
881{
882 int ret;
883 u32 vers;
884 unsigned int major, minor;
885
886 if (adapter->params.rev == T3_REV_A)
887 return 0;
888
889 *must_load = 1;
890
891 ret = t3_get_tp_version(adapter, &vers);
892 if (ret)
893 return ret;
870 894
871 major = G_TP_VERSION_MAJOR(vers); 895 major = G_TP_VERSION_MAJOR(vers);
872 minor = G_TP_VERSION_MINOR(vers); 896 minor = G_TP_VERSION_MINOR(vers);
@@ -874,6 +898,16 @@ int t3_check_tpsram_version(struct adapter *adapter)
874 if (major == TP_VERSION_MAJOR && minor == TP_VERSION_MINOR) 898 if (major == TP_VERSION_MAJOR && minor == TP_VERSION_MINOR)
875 return 0; 899 return 0;
876 900
901 if (major != TP_VERSION_MAJOR)
902 CH_ERR(adapter, "found wrong TP version (%u.%u), "
903 "driver needs version %d.%d\n", major, minor,
904 TP_VERSION_MAJOR, TP_VERSION_MINOR);
905 else {
906 *must_load = 0;
907 CH_ERR(adapter, "found wrong TP version (%u.%u), "
908 "driver compiled for version %d.%d\n", major, minor,
909 TP_VERSION_MAJOR, TP_VERSION_MINOR);
910 }
877 return -EINVAL; 911 return -EINVAL;
878} 912}
879 913