diff options
Diffstat (limited to 'drivers/net/cxgb3/cxgb3_main.c')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 121 |
1 files changed, 104 insertions, 17 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 7ff834e45d6..67b4b219d92 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/workqueue.h> | 42 | #include <linux/workqueue.h> |
43 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
44 | #include <linux/rtnetlink.h> | 44 | #include <linux/rtnetlink.h> |
45 | #include <linux/firmware.h> | ||
45 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
46 | 47 | ||
47 | #include "common.h" | 48 | #include "common.h" |
@@ -184,16 +185,24 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat, | |||
184 | int speed, int duplex, int pause) | 185 | int speed, int duplex, int pause) |
185 | { | 186 | { |
186 | struct net_device *dev = adapter->port[port_id]; | 187 | struct net_device *dev = adapter->port[port_id]; |
188 | struct port_info *pi = netdev_priv(dev); | ||
189 | struct cmac *mac = &pi->mac; | ||
187 | 190 | ||
188 | /* Skip changes from disabled ports. */ | 191 | /* Skip changes from disabled ports. */ |
189 | if (!netif_running(dev)) | 192 | if (!netif_running(dev)) |
190 | return; | 193 | return; |
191 | 194 | ||
192 | if (link_stat != netif_carrier_ok(dev)) { | 195 | if (link_stat != netif_carrier_ok(dev)) { |
193 | if (link_stat) | 196 | if (link_stat) { |
197 | t3_mac_enable(mac, MAC_DIRECTION_RX); | ||
194 | netif_carrier_on(dev); | 198 | netif_carrier_on(dev); |
195 | else | 199 | } else { |
196 | netif_carrier_off(dev); | 200 | netif_carrier_off(dev); |
201 | pi->phy.ops->power_down(&pi->phy, 1); | ||
202 | t3_mac_disable(mac, MAC_DIRECTION_RX); | ||
203 | t3_link_start(&pi->phy, mac, &pi->link_config); | ||
204 | } | ||
205 | |||
197 | link_report(dev); | 206 | link_report(dev); |
198 | } | 207 | } |
199 | } | 208 | } |
@@ -406,7 +415,7 @@ static void quiesce_rx(struct adapter *adap) | |||
406 | static int setup_sge_qsets(struct adapter *adap) | 415 | static int setup_sge_qsets(struct adapter *adap) |
407 | { | 416 | { |
408 | int i, j, err, irq_idx = 0, qset_idx = 0, dummy_dev_idx = 0; | 417 | int i, j, err, irq_idx = 0, qset_idx = 0, dummy_dev_idx = 0; |
409 | unsigned int ntxq = is_offload(adap) ? SGE_TXQ_PER_SET : 1; | 418 | unsigned int ntxq = SGE_TXQ_PER_SET; |
410 | 419 | ||
411 | if (adap->params.rev > 0 && !(adap->flags & USING_MSI)) | 420 | if (adap->params.rev > 0 && !(adap->flags & USING_MSI)) |
412 | irq_idx = -1; | 421 | irq_idx = -1; |
@@ -484,12 +493,14 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ | |||
484 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) | 493 | static ssize_t set_nfilters(struct net_device *dev, unsigned int val) |
485 | { | 494 | { |
486 | struct adapter *adap = dev->priv; | 495 | struct adapter *adap = dev->priv; |
496 | int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; | ||
487 | 497 | ||
488 | if (adap->flags & FULL_INIT_DONE) | 498 | if (adap->flags & FULL_INIT_DONE) |
489 | return -EBUSY; | 499 | return -EBUSY; |
490 | if (val && adap->params.rev == 0) | 500 | if (val && adap->params.rev == 0) |
491 | return -EINVAL; | 501 | return -EINVAL; |
492 | if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers) | 502 | if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers - |
503 | min_tids) | ||
493 | return -EINVAL; | 504 | return -EINVAL; |
494 | adap->params.mc5.nfilters = val; | 505 | adap->params.mc5.nfilters = val; |
495 | return 0; | 506 | return 0; |
@@ -507,7 +518,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val) | |||
507 | 518 | ||
508 | if (adap->flags & FULL_INIT_DONE) | 519 | if (adap->flags & FULL_INIT_DONE) |
509 | return -EBUSY; | 520 | return -EBUSY; |
510 | if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters) | 521 | if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters - |
522 | MC5_MIN_TIDS) | ||
511 | return -EINVAL; | 523 | return -EINVAL; |
512 | adap->params.mc5.nservers = val; | 524 | adap->params.mc5.nservers = val; |
513 | return 0; | 525 | return 0; |
@@ -707,6 +719,28 @@ static void bind_qsets(struct adapter *adap) | |||
707 | } | 719 | } |
708 | } | 720 | } |
709 | 721 | ||
722 | #define FW_FNAME "t3fw-%d.%d.%d.bin" | ||
723 | |||
724 | static int upgrade_fw(struct adapter *adap) | ||
725 | { | ||
726 | int ret; | ||
727 | char buf[64]; | ||
728 | const struct firmware *fw; | ||
729 | struct device *dev = &adap->pdev->dev; | ||
730 | |||
731 | snprintf(buf, sizeof(buf), FW_FNAME, FW_VERSION_MAJOR, | ||
732 | FW_VERSION_MINOR, FW_VERSION_MICRO); | ||
733 | ret = request_firmware(&fw, buf, dev); | ||
734 | if (ret < 0) { | ||
735 | dev_err(dev, "could not upgrade firmware: unable to load %s\n", | ||
736 | buf); | ||
737 | return ret; | ||
738 | } | ||
739 | ret = t3_load_fw(adap, fw->data, fw->size); | ||
740 | release_firmware(fw); | ||
741 | return ret; | ||
742 | } | ||
743 | |||
710 | /** | 744 | /** |
711 | * cxgb_up - enable the adapter | 745 | * cxgb_up - enable the adapter |
712 | * @adapter: adapter being enabled | 746 | * @adapter: adapter being enabled |
@@ -723,6 +757,8 @@ static int cxgb_up(struct adapter *adap) | |||
723 | 757 | ||
724 | if (!(adap->flags & FULL_INIT_DONE)) { | 758 | if (!(adap->flags & FULL_INIT_DONE)) { |
725 | err = t3_check_fw_version(adap); | 759 | err = t3_check_fw_version(adap); |
760 | if (err == -EINVAL) | ||
761 | err = upgrade_fw(adap); | ||
726 | if (err) | 762 | if (err) |
727 | goto out; | 763 | goto out; |
728 | 764 | ||
@@ -734,6 +770,8 @@ static int cxgb_up(struct adapter *adap) | |||
734 | if (err) | 770 | if (err) |
735 | goto out; | 771 | goto out; |
736 | 772 | ||
773 | t3_write_reg(adap, A_ULPRX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12)); | ||
774 | |||
737 | err = setup_sge_qsets(adap); | 775 | err = setup_sge_qsets(adap); |
738 | if (err) | 776 | if (err) |
739 | goto out; | 777 | goto out; |
@@ -894,7 +932,7 @@ static int cxgb_open(struct net_device *dev) | |||
894 | return err; | 932 | return err; |
895 | 933 | ||
896 | set_bit(pi->port_id, &adapter->open_device_map); | 934 | set_bit(pi->port_id, &adapter->open_device_map); |
897 | if (!ofld_disable) { | 935 | if (is_offload(adapter) && !ofld_disable) { |
898 | err = offload_open(dev); | 936 | err = offload_open(dev); |
899 | if (err) | 937 | if (err) |
900 | printk(KERN_WARNING | 938 | printk(KERN_WARNING |
@@ -1031,7 +1069,11 @@ static char stats_strings[][ETH_GSTRING_LEN] = { | |||
1031 | "VLANinsertions ", | 1069 | "VLANinsertions ", |
1032 | "TxCsumOffload ", | 1070 | "TxCsumOffload ", |
1033 | "RxCsumGood ", | 1071 | "RxCsumGood ", |
1034 | "RxDrops " | 1072 | "RxDrops ", |
1073 | |||
1074 | "CheckTXEnToggled ", | ||
1075 | "CheckResets ", | ||
1076 | |||
1035 | }; | 1077 | }; |
1036 | 1078 | ||
1037 | static int get_stats_count(struct net_device *dev) | 1079 | static int get_stats_count(struct net_device *dev) |
@@ -1145,6 +1187,9 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | |||
1145 | *data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_TX_CSUM); | 1187 | *data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_TX_CSUM); |
1146 | *data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_RX_CSUM_GOOD); | 1188 | *data++ = collect_sge_port_stats(adapter, pi, SGE_PSTAT_RX_CSUM_GOOD); |
1147 | *data++ = s->rx_cong_drops; | 1189 | *data++ = s->rx_cong_drops; |
1190 | |||
1191 | *data++ = s->num_toggled; | ||
1192 | *data++ = s->num_resets; | ||
1148 | } | 1193 | } |
1149 | 1194 | ||
1150 | static inline void reg_block_dump(struct adapter *ap, void *buf, | 1195 | static inline void reg_block_dump(struct adapter *ap, void *buf, |
@@ -1362,23 +1407,27 @@ static int set_rx_csum(struct net_device *dev, u32 data) | |||
1362 | 1407 | ||
1363 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1408 | static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1364 | { | 1409 | { |
1365 | struct adapter *adapter = dev->priv; | 1410 | const struct adapter *adapter = dev->priv; |
1411 | const struct port_info *pi = netdev_priv(dev); | ||
1412 | const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; | ||
1366 | 1413 | ||
1367 | e->rx_max_pending = MAX_RX_BUFFERS; | 1414 | e->rx_max_pending = MAX_RX_BUFFERS; |
1368 | e->rx_mini_max_pending = 0; | 1415 | e->rx_mini_max_pending = 0; |
1369 | e->rx_jumbo_max_pending = MAX_RX_JUMBO_BUFFERS; | 1416 | e->rx_jumbo_max_pending = MAX_RX_JUMBO_BUFFERS; |
1370 | e->tx_max_pending = MAX_TXQ_ENTRIES; | 1417 | e->tx_max_pending = MAX_TXQ_ENTRIES; |
1371 | 1418 | ||
1372 | e->rx_pending = adapter->params.sge.qset[0].fl_size; | 1419 | e->rx_pending = q->fl_size; |
1373 | e->rx_mini_pending = adapter->params.sge.qset[0].rspq_size; | 1420 | e->rx_mini_pending = q->rspq_size; |
1374 | e->rx_jumbo_pending = adapter->params.sge.qset[0].jumbo_size; | 1421 | e->rx_jumbo_pending = q->jumbo_size; |
1375 | e->tx_pending = adapter->params.sge.qset[0].txq_size[0]; | 1422 | e->tx_pending = q->txq_size[0]; |
1376 | } | 1423 | } |
1377 | 1424 | ||
1378 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | 1425 | static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) |
1379 | { | 1426 | { |
1380 | int i; | 1427 | int i; |
1428 | struct qset_params *q; | ||
1381 | struct adapter *adapter = dev->priv; | 1429 | struct adapter *adapter = dev->priv; |
1430 | const struct port_info *pi = netdev_priv(dev); | ||
1382 | 1431 | ||
1383 | if (e->rx_pending > MAX_RX_BUFFERS || | 1432 | if (e->rx_pending > MAX_RX_BUFFERS || |
1384 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || | 1433 | e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || |
@@ -1393,9 +1442,8 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) | |||
1393 | if (adapter->flags & FULL_INIT_DONE) | 1442 | if (adapter->flags & FULL_INIT_DONE) |
1394 | return -EBUSY; | 1443 | return -EBUSY; |
1395 | 1444 | ||
1396 | for (i = 0; i < SGE_QSETS; ++i) { | 1445 | q = &adapter->params.sge.qset[pi->first_qset]; |
1397 | struct qset_params *q = &adapter->params.sge.qset[i]; | 1446 | for (i = 0; i < pi->nqsets; ++i, ++q) { |
1398 | |||
1399 | q->rspq_size = e->rx_mini_pending; | 1447 | q->rspq_size = e->rx_mini_pending; |
1400 | q->fl_size = e->rx_pending; | 1448 | q->fl_size = e->rx_pending; |
1401 | q->jumbo_size = e->rx_jumbo_pending; | 1449 | q->jumbo_size = e->rx_jumbo_pending; |
@@ -2067,6 +2115,42 @@ static void check_link_status(struct adapter *adapter) | |||
2067 | } | 2115 | } |
2068 | } | 2116 | } |
2069 | 2117 | ||
2118 | static void check_t3b2_mac(struct adapter *adapter) | ||
2119 | { | ||
2120 | int i; | ||
2121 | |||
2122 | if (!rtnl_trylock()) /* synchronize with ifdown */ | ||
2123 | return; | ||
2124 | |||
2125 | for_each_port(adapter, i) { | ||
2126 | struct net_device *dev = adapter->port[i]; | ||
2127 | struct port_info *p = netdev_priv(dev); | ||
2128 | int status; | ||
2129 | |||
2130 | if (!netif_running(dev)) | ||
2131 | continue; | ||
2132 | |||
2133 | status = 0; | ||
2134 | if (netif_running(dev) && netif_carrier_ok(dev)) | ||
2135 | status = t3b2_mac_watchdog_task(&p->mac); | ||
2136 | if (status == 1) | ||
2137 | p->mac.stats.num_toggled++; | ||
2138 | else if (status == 2) { | ||
2139 | struct cmac *mac = &p->mac; | ||
2140 | |||
2141 | t3_mac_set_mtu(mac, dev->mtu); | ||
2142 | t3_mac_set_address(mac, 0, dev->dev_addr); | ||
2143 | cxgb_set_rxmode(dev); | ||
2144 | t3_link_start(&p->phy, mac, &p->link_config); | ||
2145 | t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX); | ||
2146 | t3_port_intr_enable(adapter, p->port_id); | ||
2147 | p->mac.stats.num_resets++; | ||
2148 | } | ||
2149 | } | ||
2150 | rtnl_unlock(); | ||
2151 | } | ||
2152 | |||
2153 | |||
2070 | static void t3_adap_check_task(struct work_struct *work) | 2154 | static void t3_adap_check_task(struct work_struct *work) |
2071 | { | 2155 | { |
2072 | struct adapter *adapter = container_of(work, struct adapter, | 2156 | struct adapter *adapter = container_of(work, struct adapter, |
@@ -2087,6 +2171,9 @@ static void t3_adap_check_task(struct work_struct *work) | |||
2087 | adapter->check_task_cnt = 0; | 2171 | adapter->check_task_cnt = 0; |
2088 | } | 2172 | } |
2089 | 2173 | ||
2174 | if (p->rev == T3_REV_B2) | ||
2175 | check_t3b2_mac(adapter); | ||
2176 | |||
2090 | /* Schedule the next check update if any port is active. */ | 2177 | /* Schedule the next check update if any port is active. */ |
2091 | spin_lock(&adapter->work_lock); | 2178 | spin_lock(&adapter->work_lock); |
2092 | if (adapter->open_device_map & PORT_MASK) | 2179 | if (adapter->open_device_map & PORT_MASK) |
@@ -2195,9 +2282,9 @@ static void __devinit print_port_info(struct adapter *adap, | |||
2195 | 2282 | ||
2196 | if (!test_bit(i, &adap->registered_device_map)) | 2283 | if (!test_bit(i, &adap->registered_device_map)) |
2197 | continue; | 2284 | continue; |
2198 | printk(KERN_INFO "%s: %s %s RNIC (rev %d) %s%s\n", | 2285 | printk(KERN_INFO "%s: %s %s %sNIC (rev %d) %s%s\n", |
2199 | dev->name, ai->desc, pi->port_type->desc, | 2286 | dev->name, ai->desc, pi->port_type->desc, |
2200 | adap->params.rev, buf, | 2287 | is_offload(adap) ? "R" : "", adap->params.rev, buf, |
2201 | (adap->flags & USING_MSIX) ? " MSI-X" : | 2288 | (adap->flags & USING_MSIX) ? " MSI-X" : |
2202 | (adap->flags & USING_MSI) ? " MSI" : ""); | 2289 | (adap->flags & USING_MSI) ? " MSI" : ""); |
2203 | if (adap->name == dev->name && adap->params.vpd.mclk) | 2290 | if (adap->name == dev->name && adap->params.vpd.mclk) |