diff options
Diffstat (limited to 'drivers/net/cxgb3/cxgb3_main.c')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 252 |
1 files changed, 153 insertions, 99 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index dc5d26988bb3..5ab319cfe5de 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -358,11 +358,14 @@ static int init_dummy_netdevs(struct adapter *adap) | |||
358 | 358 | ||
359 | for (j = 0; j < pi->nqsets - 1; j++) { | 359 | for (j = 0; j < pi->nqsets - 1; j++) { |
360 | if (!adap->dummy_netdev[dummy_idx]) { | 360 | if (!adap->dummy_netdev[dummy_idx]) { |
361 | nd = alloc_netdev(0, "", ether_setup); | 361 | struct port_info *p; |
362 | |||
363 | nd = alloc_netdev(sizeof(*p), "", ether_setup); | ||
362 | if (!nd) | 364 | if (!nd) |
363 | goto free_all; | 365 | goto free_all; |
364 | 366 | ||
365 | nd->priv = adap; | 367 | p = netdev_priv(nd); |
368 | p->adapter = adap; | ||
366 | nd->weight = 64; | 369 | nd->weight = 64; |
367 | set_bit(__LINK_STATE_START, &nd->state); | 370 | set_bit(__LINK_STATE_START, &nd->state); |
368 | adap->dummy_netdev[dummy_idx] = nd; | 371 | adap->dummy_netdev[dummy_idx] = nd; |
@@ -482,7 +485,8 @@ static ssize_t attr_store(struct device *d, struct device_attribute *attr, | |||
482 | #define CXGB3_SHOW(name, val_expr) \ | 485 | #define CXGB3_SHOW(name, val_expr) \ |
483 | static ssize_t format_##name(struct net_device *dev, char *buf) \ | 486 | static ssize_t format_##name(struct net_device *dev, char *buf) \ |
484 | { \ | 487 | { \ |
485 | struct adapter *adap = dev->priv; \ | 488 | struct port_info *pi = netdev_priv(dev); \ |
489 | struct adapter *adap = pi->adapter; \ | ||
486 | return sprintf(buf, "%u\n", val_expr); \ | 490 | return sprintf(buf, "%u\n", val_expr); \ |
487 | } \ | 491 | } \ |
488 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ | 492 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ |
@@ -493,7 +497,8 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ | |||
493 | 497 | ||
494 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) | 498 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) |
495 | { | 499 | { |
496 | struct adapter *adap = dev->priv; | 500 | struct port_info *pi = netdev_priv(dev); |
501 | struct adapter *adap = pi->adapter; | ||
497 | int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; | 502 | int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; |
498 | 503 | ||
499 | if (adap->flags & FULL_INIT_DONE) | 504 | if (adap->flags & FULL_INIT_DONE) |
@@ -515,7 +520,8 @@ static ssize_t store_nfilters(struct device *d, struct device_attribute *attr, | |||
515 | 520 | ||
516 | static ssize_t set_nservers(struct net_device *dev, unsigned int val) | 521 | static ssize_t set_nservers(struct net_device *dev, unsigned int val) |
517 | { | 522 | { |
518 | struct adapter *adap = dev->priv; | 523 | struct port_info *pi = netdev_priv(dev); |
524 | struct adapter *adap = pi->adapter; | ||
519 | 525 | ||
520 | if (adap->flags & FULL_INIT_DONE) | 526 | if (adap->flags & FULL_INIT_DONE) |
521 | return -EBUSY; | 527 | return -EBUSY; |
@@ -556,9 +562,10 @@ static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs }; | |||
556 | static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, | 562 | static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, |
557 | char *buf, int sched) | 563 | char *buf, int sched) |
558 | { | 564 | { |
559 | ssize_t len; | 565 | struct port_info *pi = netdev_priv(to_net_dev(d)); |
566 | struct adapter *adap = pi->adapter; | ||
560 | unsigned int v, addr, bpt, cpt; | 567 | unsigned int v, addr, bpt, cpt; |
561 | struct adapter *adap = to_net_dev(d)->priv; | 568 | ssize_t len; |
562 | 569 | ||
563 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; | 570 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; |
564 | rtnl_lock(); | 571 | rtnl_lock(); |
@@ -581,10 +588,11 @@ static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, | |||
581 | static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, | 588 | static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, |
582 | const char *buf, size_t len, int sched) | 589 | const char *buf, size_t len, int sched) |
583 | { | 590 | { |
591 | struct port_info *pi = netdev_priv(to_net_dev(d)); | ||
592 | struct adapter *adap = pi->adapter; | ||
593 | unsigned int val; | ||
584 | char *endp; | 594 | char *endp; |
585 | ssize_t ret; | 595 | ssize_t ret; |
586 | unsigned int val; | ||
587 | struct adapter *adap = to_net_dev(d)->priv; | ||
588 | 596 | ||
589 | if (!capable(CAP_NET_ADMIN)) | 597 | if (!capable(CAP_NET_ADMIN)) |
590 | return -EPERM; | 598 | return -EPERM; |
@@ -721,6 +729,7 @@ static void bind_qsets(struct adapter *adap) | |||
721 | } | 729 | } |
722 | 730 | ||
723 | #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" | ||
724 | 733 | ||
725 | static int upgrade_fw(struct adapter *adap) | 734 | static int upgrade_fw(struct adapter *adap) |
726 | { | 735 | { |
@@ -739,6 +748,71 @@ static int upgrade_fw(struct adapter *adap) | |||
739 | } | 748 | } |
740 | ret = t3_load_fw(adap, fw->data, fw->size); | 749 | ret = t3_load_fw(adap, fw->data, fw->size); |
741 | 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 | |||
762 | static 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 | |||
775 | int 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 | |||
813 | release_tpsram: | ||
814 | release_firmware(tpsram); | ||
815 | |||
742 | return ret; | 816 | return ret; |
743 | } | 817 | } |
744 | 818 | ||
@@ -755,6 +829,7 @@ static int upgrade_fw(struct adapter *adap) | |||
755 | static int cxgb_up(struct adapter *adap) | 829 | static int cxgb_up(struct adapter *adap) |
756 | { | 830 | { |
757 | int err = 0; | 831 | int err = 0; |
832 | int must_load; | ||
758 | 833 | ||
759 | if (!(adap->flags & FULL_INIT_DONE)) { | 834 | if (!(adap->flags & FULL_INIT_DONE)) { |
760 | err = t3_check_fw_version(adap); | 835 | err = t3_check_fw_version(adap); |
@@ -763,6 +838,13 @@ static int cxgb_up(struct adapter *adap) | |||
763 | if (err) | 838 | if (err) |
764 | goto out; | 839 | goto out; |
765 | 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 | |||
766 | err = init_dummy_netdevs(adap); | 848 | err = init_dummy_netdevs(adap); |
767 | if (err) | 849 | if (err) |
768 | goto out; | 850 | goto out; |
@@ -858,8 +940,9 @@ static void schedule_chk_task(struct adapter *adap) | |||
858 | 940 | ||
859 | static int offload_open(struct net_device *dev) | 941 | static int offload_open(struct net_device *dev) |
860 | { | 942 | { |
861 | struct adapter *adapter = dev->priv; | 943 | struct port_info *pi = netdev_priv(dev); |
862 | struct t3cdev *tdev = T3CDEV(dev); | 944 | struct adapter *adapter = pi->adapter; |
945 | struct t3cdev *tdev = dev2t3cdev(dev); | ||
863 | int adap_up = adapter->open_device_map & PORT_MASK; | 946 | int adap_up = adapter->open_device_map & PORT_MASK; |
864 | int err = 0; | 947 | int err = 0; |
865 | 948 | ||
@@ -924,10 +1007,10 @@ static int offload_close(struct t3cdev *tdev) | |||
924 | 1007 | ||
925 | static int cxgb_open(struct net_device *dev) | 1008 | static int cxgb_open(struct net_device *dev) |
926 | { | 1009 | { |
927 | int err; | ||
928 | struct adapter *adapter = dev->priv; | ||
929 | struct port_info *pi = netdev_priv(dev); | 1010 | struct port_info *pi = netdev_priv(dev); |
1011 | struct adapter *adapter = pi->adapter; | ||
930 | int other_ports = adapter->open_device_map & PORT_MASK; | 1012 | int other_ports = adapter->open_device_map & PORT_MASK; |
1013 | int err; | ||
931 | 1014 | ||
932 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) | 1015 | if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) |
933 | return err; | 1016 | return err; |
@@ -951,17 +1034,17 @@ static int cxgb_open(struct net_device *dev) | |||
951 | 1034 | ||
952 | static int cxgb_close(struct net_device *dev) | 1035 | static int cxgb_close(struct net_device *dev) |
953 | { | 1036 | { |
954 | struct adapter *adapter = dev->priv; | 1037 | struct port_info *pi = netdev_priv(dev); |
955 | struct port_info *p = netdev_priv(dev); | 1038 | struct adapter *adapter = pi->adapter; |
956 | 1039 | ||
957 | t3_port_intr_disable(adapter, p->port_id); | 1040 | t3_port_intr_disable(adapter, pi->port_id); |
958 | netif_stop_queue(dev); | 1041 | netif_stop_queue(dev); |
959 | p->phy.ops->power_down(&p->phy, 1); | 1042 | pi->phy.ops->power_down(&pi->phy, 1); |
960 | netif_carrier_off(dev); | 1043 | netif_carrier_off(dev); |
961 | t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); | 1044 | t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); |
962 | 1045 | ||
963 | spin_lock(&adapter->work_lock); /* sync with update task */ | 1046 | spin_lock(&adapter->work_lock); /* sync with update task */ |
964 | clear_bit(p->port_id, &adapter->open_device_map); | 1047 | clear_bit(pi->port_id, &adapter->open_device_map); |
965 | spin_unlock(&adapter->work_lock); | 1048 | spin_unlock(&adapter->work_lock); |
966 | 1049 | ||
967 | if (!(adapter->open_device_map & PORT_MASK)) | 1050 | if (!(adapter->open_device_map & PORT_MASK)) |
@@ -976,13 +1059,13 @@ static int cxgb_close(struct net_device *dev) | |||
976 | 1059 | ||
977 | static struct net_device_stats *cxgb_get_stats(struct net_device *dev) | 1060 | static struct net_device_stats *cxgb_get_stats(struct net_device *dev) |
978 | { | 1061 | { |
979 | struct adapter *adapter = dev->priv; | 1062 | struct port_info *pi = netdev_priv(dev); |
980 | struct port_info *p = netdev_priv(dev); | 1063 | struct adapter *adapter = pi->adapter; |
981 | struct net_device_stats *ns = &p->netstats; | 1064 | struct net_device_stats *ns = &pi->netstats; |
982 | const struct mac_stats *pstats; | 1065 | const struct mac_stats *pstats; |
983 | 1066 | ||
984 | spin_lock(&adapter->stats_lock); | 1067 | spin_lock(&adapter->stats_lock); |
985 | pstats = t3_mac_update_stats(&p->mac); | 1068 | pstats = t3_mac_update_stats(&pi->mac); |
986 | spin_unlock(&adapter->stats_lock); | 1069 | spin_unlock(&adapter->stats_lock); |
987 | 1070 | ||
988 | ns->tx_bytes = pstats->tx_octets; | 1071 | ns->tx_bytes = pstats->tx_octets; |
@@ -1015,14 +1098,16 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev) | |||
1015 | 1098 | ||
1016 | static u32 get_msglevel(struct net_device *dev) | 1099 | static u32 get_msglevel(struct net_device *dev) |
1017 | { | 1100 | { |
1018 | struct adapter *adapter = dev->priv; | 1101 | struct port_info *pi = netdev_priv(dev); |
1102 | struct adapter *adapter = pi->adapter; | ||
1019 | 1103 | ||
1020 | return adapter->msg_enable; | 1104 | return adapter->msg_enable; |
1021 | } | 1105 | } |
1022 | 1106 | ||
1023 | static void set_msglevel(struct net_device *dev, u32 val) | 1107 | static void set_msglevel(struct net_device *dev, u32 val) |
1024 | { | 1108 | { |
1025 | struct adapter *adapter = dev->priv; | 1109 | struct port_info *pi = netdev_priv(dev); |
1110 | struct adapter *adapter = pi->adapter; | ||
1026 | 1111 | ||
1027 | adapter->msg_enable = val; | 1112 | adapter->msg_enable = val; |
1028 | } | 1113 | } |
@@ -1096,10 +1181,13 @@ static int get_eeprom_len(struct net_device *dev) | |||
1096 | 1181 | ||
1097 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1182 | static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1098 | { | 1183 | { |
1184 | struct port_info *pi = netdev_priv(dev); | ||
1185 | struct adapter *adapter = pi->adapter; | ||
1099 | u32 fw_vers = 0; | 1186 | u32 fw_vers = 0; |
1100 | struct adapter *adapter = dev->priv; | 1187 | u32 tp_vers = 0; |
1101 | 1188 | ||
1102 | t3_get_fw_version(adapter, &fw_vers); | 1189 | t3_get_fw_version(adapter, &fw_vers); |
1190 | t3_get_tp_version(adapter, &tp_vers); | ||
1103 | 1191 | ||
1104 | strcpy(info->driver, DRV_NAME); | 1192 | strcpy(info->driver, DRV_NAME); |
1105 | strcpy(info->version, DRV_VERSION); | 1193 | strcpy(info->version, DRV_VERSION); |
@@ -1108,11 +1196,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1108 | strcpy(info->fw_version, "N/A"); | 1196 | strcpy(info->fw_version, "N/A"); |
1109 | else { | 1197 | else { |
1110 | snprintf(info->fw_version, sizeof(info->fw_version), | 1198 | snprintf(info->fw_version, sizeof(info->fw_version), |
1111 | "%s %u.%u.%u", | 1199 | "%s %u.%u.%u TP %u.%u.%u", |
1112 | G_FW_VERSION_TYPE(fw_vers) ? "T" : "N", | 1200 | G_FW_VERSION_TYPE(fw_vers) ? "T" : "N", |
1113 | G_FW_VERSION_MAJOR(fw_vers), | 1201 | G_FW_VERSION_MAJOR(fw_vers), |
1114 | G_FW_VERSION_MINOR(fw_vers), | 1202 | G_FW_VERSION_MINOR(fw_vers), |
1115 | 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)); | ||
1116 | } | 1207 | } |
1117 | } | 1208 | } |
1118 | 1209 | ||
@@ -1136,8 +1227,8 @@ static unsigned long collect_sge_port_stats(struct adapter *adapter, | |||
1136 | static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | 1227 | static void get_stats(struct net_device *dev, struct ethtool_stats *stats, |
1137 | u64 *data) | 1228 | u64 *data) |
1138 | { | 1229 | { |
1139 | struct adapter *adapter = dev->priv; | ||
1140 | struct port_info *pi = netdev_priv(dev); | 1230 | struct port_info *pi = netdev_priv(dev); |
1231 | struct adapter *adapter = pi->adapter; | ||
1141 | const struct mac_stats *s; | 1232 | const struct mac_stats *s; |
1142 | 1233 | ||
1143 | spin_lock(&adapter->stats_lock); | 1234 | spin_lock(&adapter->stats_lock); |
@@ -1205,7 +1296,8 @@ static inline void reg_block_dump(struct adapter *ap, void *buf, | |||
1205 | static void get_regs(struct net_device *dev, struct ethtool_regs *regs, | 1296 | static void get_regs(struct net_device *dev, struct ethtool_regs *regs, |
1206 | void *buf) | 1297 | void *buf) |
1207 | { | 1298 | { |
1208 | struct adapter *ap = dev->priv; | 1299 | struct port_info *pi = netdev_priv(dev); |
1300 | struct adapter *ap = pi->adapter; | ||
1209 | 1301 | ||
1210 | /* | 1302 | /* |
1211 | * Version scheme: | 1303 | * Version scheme: |
@@ -1246,8 +1338,9 @@ static int restart_autoneg(struct net_device *dev) | |||
1246 | 1338 | ||
1247 | static int cxgb3_phys_id(struct net_device *dev, u32 data) | 1339 | static int cxgb3_phys_id(struct net_device *dev, u32 data) |
1248 | { | 1340 | { |
1341 | struct port_info *pi = netdev_priv(dev); | ||
1342 | struct adapter *adapter = pi->adapter; | ||
1249 | int i; | 1343 | int i; |
1250 | struct adapter *adapter = dev->priv; | ||
1251 | 1344 | ||
1252 | if (data == 0) | 1345 | if (data == 0) |
1253 | data = 2; | 1346 | data = 2; |
@@ -1408,8 +1501,8 @@ static int set_rx_csum(struct net_device *dev, u32 data) | |||
1408 | 1501 | ||
1409 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1502 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1410 | { | 1503 | { |
1411 | const struct adapter *adapter = dev->priv; | 1504 | struct port_info *pi = netdev_priv(dev); |
1412 | const struct port_info *pi = netdev_priv(dev); | 1505 | struct adapter *adapter = pi->adapter; |
1413 | const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; | 1506 | const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; |
1414 | 1507 | ||
1415 | e->rx_max_pending = MAX_RX_BUFFERS; | 1508 | e->rx_max_pending = MAX_RX_BUFFERS; |
@@ -1425,10 +1518,10 @@ static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | |||
1425 | 1518 | ||
1426 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1519 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1427 | { | 1520 | { |
1428 | int i; | 1521 | struct port_info *pi = netdev_priv(dev); |
1522 | struct adapter *adapter = pi->adapter; | ||
1429 | struct qset_params *q; | 1523 | struct qset_params *q; |
1430 | struct adapter *adapter = dev->priv; | 1524 | int i; |
1431 | const struct port_info *pi = netdev_priv(dev); | ||
1432 | 1525 | ||
1433 | if (e->rx_pending > MAX_RX_BUFFERS || | 1526 | if (e->rx_pending > MAX_RX_BUFFERS || |
1434 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || | 1527 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || |
@@ -1457,7 +1550,8 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | |||
1457 | 1550 | ||
1458 | static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | 1551 | static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) |
1459 | { | 1552 | { |
1460 | struct adapter *adapter = dev->priv; | 1553 | struct port_info *pi = netdev_priv(dev); |
1554 | struct adapter *adapter = pi->adapter; | ||
1461 | struct qset_params *qsp = &adapter->params.sge.qset[0]; | 1555 | struct qset_params *qsp = &adapter->params.sge.qset[0]; |
1462 | struct sge_qset *qs = &adapter->sge.qs[0]; | 1556 | struct sge_qset *qs = &adapter->sge.qs[0]; |
1463 | 1557 | ||
@@ -1471,7 +1565,8 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | |||
1471 | 1565 | ||
1472 | static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | 1566 | static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) |
1473 | { | 1567 | { |
1474 | struct adapter *adapter = dev->priv; | 1568 | struct port_info *pi = netdev_priv(dev); |
1569 | struct adapter *adapter = pi->adapter; | ||
1475 | struct qset_params *q = adapter->params.sge.qset; | 1570 | struct qset_params *q = adapter->params.sge.qset; |
1476 | 1571 | ||
1477 | c->rx_coalesce_usecs = q->coalesce_usecs; | 1572 | c->rx_coalesce_usecs = q->coalesce_usecs; |
@@ -1481,8 +1576,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) | |||
1481 | static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, | 1576 | static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, |
1482 | u8 * data) | 1577 | u8 * data) |
1483 | { | 1578 | { |
1579 | struct port_info *pi = netdev_priv(dev); | ||
1580 | struct adapter *adapter = pi->adapter; | ||
1484 | int i, err = 0; | 1581 | int i, err = 0; |
1485 | struct adapter *adapter = dev->priv; | ||
1486 | 1582 | ||
1487 | u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); | 1583 | u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); |
1488 | if (!buf) | 1584 | if (!buf) |
@@ -1501,10 +1597,11 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, | |||
1501 | static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, | 1597 | static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, |
1502 | u8 * data) | 1598 | u8 * data) |
1503 | { | 1599 | { |
1600 | struct port_info *pi = netdev_priv(dev); | ||
1601 | struct adapter *adapter = pi->adapter; | ||
1602 | u32 aligned_offset, aligned_len, *p; | ||
1504 | u8 *buf; | 1603 | u8 *buf; |
1505 | int err = 0; | 1604 | int err = 0; |
1506 | u32 aligned_offset, aligned_len, *p; | ||
1507 | struct adapter *adapter = dev->priv; | ||
1508 | 1605 | ||
1509 | if (eeprom->magic != EEPROM_MAGIC) | 1606 | if (eeprom->magic != EEPROM_MAGIC) |
1510 | return -EINVAL; | 1607 | return -EINVAL; |
@@ -1592,9 +1689,10 @@ static int in_range(int val, int lo, int hi) | |||
1592 | 1689 | ||
1593 | static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) | 1690 | static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) |
1594 | { | 1691 | { |
1595 | int ret; | 1692 | struct port_info *pi = netdev_priv(dev); |
1693 | struct adapter *adapter = pi->adapter; | ||
1596 | u32 cmd; | 1694 | u32 cmd; |
1597 | struct adapter *adapter = dev->priv; | 1695 | int ret; |
1598 | 1696 | ||
1599 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | 1697 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) |
1600 | return -EFAULT; | 1698 | return -EFAULT; |
@@ -1923,10 +2021,10 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) | |||
1923 | 2021 | ||
1924 | static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | 2022 | static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) |
1925 | { | 2023 | { |
1926 | int ret, mmd; | ||
1927 | struct adapter *adapter = dev->priv; | ||
1928 | struct port_info *pi = netdev_priv(dev); | ||
1929 | struct mii_ioctl_data *data = if_mii(req); | 2024 | struct mii_ioctl_data *data = if_mii(req); |
2025 | struct port_info *pi = netdev_priv(dev); | ||
2026 | struct adapter *adapter = pi->adapter; | ||
2027 | int ret, mmd; | ||
1930 | 2028 | ||
1931 | switch (cmd) { | 2029 | switch (cmd) { |
1932 | case SIOCGMIIPHY: | 2030 | case SIOCGMIIPHY: |
@@ -1994,9 +2092,9 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1994 | 2092 | ||
1995 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) | 2093 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) |
1996 | { | 2094 | { |
1997 | int ret; | ||
1998 | struct adapter *adapter = dev->priv; | ||
1999 | struct port_info *pi = netdev_priv(dev); | 2095 | struct port_info *pi = netdev_priv(dev); |
2096 | struct adapter *adapter = pi->adapter; | ||
2097 | int ret; | ||
2000 | 2098 | ||
2001 | if (new_mtu < 81) /* accommodate SACK */ | 2099 | if (new_mtu < 81) /* accommodate SACK */ |
2002 | return -EINVAL; | 2100 | return -EINVAL; |
@@ -2013,8 +2111,8 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu) | |||
2013 | 2111 | ||
2014 | static int cxgb_set_mac_addr(struct net_device *dev, void *p) | 2112 | static int cxgb_set_mac_addr(struct net_device *dev, void *p) |
2015 | { | 2113 | { |
2016 | struct adapter *adapter = dev->priv; | ||
2017 | struct port_info *pi = netdev_priv(dev); | 2114 | struct port_info *pi = netdev_priv(dev); |
2115 | struct adapter *adapter = pi->adapter; | ||
2018 | struct sockaddr *addr = p; | 2116 | struct sockaddr *addr = p; |
2019 | 2117 | ||
2020 | if (!is_valid_ether_addr(addr->sa_data)) | 2118 | if (!is_valid_ether_addr(addr->sa_data)) |
@@ -2050,8 +2148,8 @@ static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p) | |||
2050 | 2148 | ||
2051 | static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | 2149 | static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) |
2052 | { | 2150 | { |
2053 | struct adapter *adapter = dev->priv; | ||
2054 | struct port_info *pi = netdev_priv(dev); | 2151 | struct port_info *pi = netdev_priv(dev); |
2152 | struct adapter *adapter = pi->adapter; | ||
2055 | 2153 | ||
2056 | pi->vlan_grp = grp; | 2154 | pi->vlan_grp = grp; |
2057 | if (adapter->params.rev > 0) | 2155 | if (adapter->params.rev > 0) |
@@ -2070,8 +2168,8 @@ static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | |||
2070 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2168 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2071 | static void cxgb_netpoll(struct net_device *dev) | 2169 | static void cxgb_netpoll(struct net_device *dev) |
2072 | { | 2170 | { |
2073 | struct adapter *adapter = dev->priv; | ||
2074 | struct port_info *pi = netdev_priv(dev); | 2171 | struct port_info *pi = netdev_priv(dev); |
2172 | struct adapter *adapter = pi->adapter; | ||
2075 | int qidx; | 2173 | int qidx; |
2076 | 2174 | ||
2077 | for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { | 2175 | for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { |
@@ -2088,42 +2186,6 @@ static void cxgb_netpoll(struct net_device *dev) | |||
2088 | } | 2186 | } |
2089 | #endif | 2187 | #endif |
2090 | 2188 | ||
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 | |||
2127 | /* | 2189 | /* |
2128 | * Periodic accumulation of MAC statistics. | 2190 | * Periodic accumulation of MAC statistics. |
2129 | */ | 2191 | */ |
@@ -2433,6 +2495,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2433 | 2495 | ||
2434 | adapter->port[i] = netdev; | 2496 | adapter->port[i] = netdev; |
2435 | pi = netdev_priv(netdev); | 2497 | pi = netdev_priv(netdev); |
2498 | pi->adapter = adapter; | ||
2436 | pi->rx_csum_offload = 1; | 2499 | pi->rx_csum_offload = 1; |
2437 | pi->nqsets = 1; | 2500 | pi->nqsets = 1; |
2438 | pi->first_qset = i; | 2501 | pi->first_qset = i; |
@@ -2442,7 +2505,6 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2442 | netdev->irq = pdev->irq; | 2505 | netdev->irq = pdev->irq; |
2443 | netdev->mem_start = mmio_start; | 2506 | netdev->mem_start = mmio_start; |
2444 | netdev->mem_end = mmio_start + mmio_len - 1; | 2507 | netdev->mem_end = mmio_start + mmio_len - 1; |
2445 | netdev->priv = adapter; | ||
2446 | netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; | 2508 | netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; |
2447 | netdev->features |= NETIF_F_LLTX; | 2509 | netdev->features |= NETIF_F_LLTX; |
2448 | if (pci_using_dac) | 2510 | if (pci_using_dac) |
@@ -2467,18 +2529,11 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2467 | SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); | 2529 | SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); |
2468 | } | 2530 | } |
2469 | 2531 | ||
2470 | pci_set_drvdata(pdev, adapter->port[0]); | 2532 | pci_set_drvdata(pdev, adapter); |
2471 | if (t3_prep_adapter(adapter, ai, 1) < 0) { | 2533 | if (t3_prep_adapter(adapter, ai, 1) < 0) { |
2472 | err = -ENODEV; | 2534 | err = -ENODEV; |
2473 | goto out_free_dev; | 2535 | goto out_free_dev; |
2474 | } | 2536 | } |
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 | 2537 | ||
2483 | /* | 2538 | /* |
2484 | * 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 |
@@ -2547,11 +2602,10 @@ out_release_regions: | |||
2547 | 2602 | ||
2548 | static void __devexit remove_one(struct pci_dev *pdev) | 2603 | static void __devexit remove_one(struct pci_dev *pdev) |
2549 | { | 2604 | { |
2550 | struct net_device *dev = pci_get_drvdata(pdev); | 2605 | struct adapter *adapter = pci_get_drvdata(pdev); |
2551 | 2606 | ||
2552 | if (dev) { | 2607 | if (adapter) { |
2553 | int i; | 2608 | int i; |
2554 | struct adapter *adapter = dev->priv; | ||
2555 | 2609 | ||
2556 | t3_sge_stop(adapter); | 2610 | t3_sge_stop(adapter); |
2557 | sysfs_remove_group(&adapter->port[0]->dev.kobj, | 2611 | sysfs_remove_group(&adapter->port[0]->dev.kobj, |