aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c190
1 files changed, 168 insertions, 22 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 54161aef3cac..702d546567ad 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -32,6 +32,7 @@
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <asm/byteorder.h> 34#include <asm/byteorder.h>
35#include <asm/page.h>
35#include <linux/time.h> 36#include <linux/time.h>
36#include <linux/ethtool.h> 37#include <linux/ethtool.h>
37#include <linux/mii.h> 38#include <linux/mii.h>
@@ -49,14 +50,15 @@
49#include <linux/crc32.h> 50#include <linux/crc32.h>
50#include <linux/prefetch.h> 51#include <linux/prefetch.h>
51#include <linux/cache.h> 52#include <linux/cache.h>
53#include <linux/zlib.h>
52 54
53#include "bnx2.h" 55#include "bnx2.h"
54#include "bnx2_fw.h" 56#include "bnx2_fw.h"
55 57
56#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
57#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
58#define DRV_MODULE_VERSION "1.4.40" 60#define DRV_MODULE_VERSION "1.4.42"
59#define DRV_MODULE_RELDATE "May 22, 2006" 61#define DRV_MODULE_RELDATE "June 12, 2006"
60 62
61#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
62 64
@@ -1820,7 +1822,7 @@ reuse_rx:
1820 skb->protocol = eth_type_trans(skb, bp->dev); 1822 skb->protocol = eth_type_trans(skb, bp->dev);
1821 1823
1822 if ((len > (bp->dev->mtu + ETH_HLEN)) && 1824 if ((len > (bp->dev->mtu + ETH_HLEN)) &&
1823 (htons(skb->protocol) != 0x8100)) { 1825 (ntohs(skb->protocol) != 0x8100)) {
1824 1826
1825 dev_kfree_skb_irq(skb); 1827 dev_kfree_skb_irq(skb);
1826 goto next_rx; 1828 goto next_rx;
@@ -2009,7 +2011,7 @@ bnx2_poll(struct net_device *dev, int *budget)
2009 return 1; 2011 return 1;
2010} 2012}
2011 2013
2012/* Called with rtnl_lock from vlan functions and also dev->xmit_lock 2014/* Called with rtnl_lock from vlan functions and also netif_tx_lock
2013 * from set_multicast. 2015 * from set_multicast.
2014 */ 2016 */
2015static void 2017static void
@@ -2083,6 +2085,92 @@ bnx2_set_rx_mode(struct net_device *dev)
2083 spin_unlock_bh(&bp->phy_lock); 2085 spin_unlock_bh(&bp->phy_lock);
2084} 2086}
2085 2087
2088#define FW_BUF_SIZE 0x8000
2089
2090static int
2091bnx2_gunzip_init(struct bnx2 *bp)
2092{
2093 if ((bp->gunzip_buf = vmalloc(FW_BUF_SIZE)) == NULL)
2094 goto gunzip_nomem1;
2095
2096 if ((bp->strm = kmalloc(sizeof(*bp->strm), GFP_KERNEL)) == NULL)
2097 goto gunzip_nomem2;
2098
2099 bp->strm->workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
2100 if (bp->strm->workspace == NULL)
2101 goto gunzip_nomem3;
2102
2103 return 0;
2104
2105gunzip_nomem3:
2106 kfree(bp->strm);
2107 bp->strm = NULL;
2108
2109gunzip_nomem2:
2110 vfree(bp->gunzip_buf);
2111 bp->gunzip_buf = NULL;
2112
2113gunzip_nomem1:
2114 printk(KERN_ERR PFX "%s: Cannot allocate firmware buffer for "
2115 "uncompression.\n", bp->dev->name);
2116 return -ENOMEM;
2117}
2118
2119static void
2120bnx2_gunzip_end(struct bnx2 *bp)
2121{
2122 kfree(bp->strm->workspace);
2123
2124 kfree(bp->strm);
2125 bp->strm = NULL;
2126
2127 if (bp->gunzip_buf) {
2128 vfree(bp->gunzip_buf);
2129 bp->gunzip_buf = NULL;
2130 }
2131}
2132
2133static int
2134bnx2_gunzip(struct bnx2 *bp, u8 *zbuf, int len, void **outbuf, int *outlen)
2135{
2136 int n, rc;
2137
2138 /* check gzip header */
2139 if ((zbuf[0] != 0x1f) || (zbuf[1] != 0x8b) || (zbuf[2] != Z_DEFLATED))
2140 return -EINVAL;
2141
2142 n = 10;
2143
2144#define FNAME 0x8
2145 if (zbuf[3] & FNAME)
2146 while ((zbuf[n++] != 0) && (n < len));
2147
2148 bp->strm->next_in = zbuf + n;
2149 bp->strm->avail_in = len - n;
2150 bp->strm->next_out = bp->gunzip_buf;
2151 bp->strm->avail_out = FW_BUF_SIZE;
2152
2153 rc = zlib_inflateInit2(bp->strm, -MAX_WBITS);
2154 if (rc != Z_OK)
2155 return rc;
2156
2157 rc = zlib_inflate(bp->strm, Z_FINISH);
2158
2159 *outlen = FW_BUF_SIZE - bp->strm->avail_out;
2160 *outbuf = bp->gunzip_buf;
2161
2162 if ((rc != Z_OK) && (rc != Z_STREAM_END))
2163 printk(KERN_ERR PFX "%s: Firmware decompression error: %s\n",
2164 bp->dev->name, bp->strm->msg);
2165
2166 zlib_inflateEnd(bp->strm);
2167
2168 if (rc == Z_STREAM_END)
2169 return 0;
2170
2171 return rc;
2172}
2173
2086static void 2174static void
2087load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len, 2175load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2088 u32 rv2p_proc) 2176 u32 rv2p_proc)
@@ -2092,9 +2180,9 @@ load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2092 2180
2093 2181
2094 for (i = 0; i < rv2p_code_len; i += 8) { 2182 for (i = 0; i < rv2p_code_len; i += 8) {
2095 REG_WR(bp, BNX2_RV2P_INSTR_HIGH, *rv2p_code); 2183 REG_WR(bp, BNX2_RV2P_INSTR_HIGH, cpu_to_le32(*rv2p_code));
2096 rv2p_code++; 2184 rv2p_code++;
2097 REG_WR(bp, BNX2_RV2P_INSTR_LOW, *rv2p_code); 2185 REG_WR(bp, BNX2_RV2P_INSTR_LOW, cpu_to_le32(*rv2p_code));
2098 rv2p_code++; 2186 rv2p_code++;
2099 2187
2100 if (rv2p_proc == RV2P_PROC1) { 2188 if (rv2p_proc == RV2P_PROC1) {
@@ -2134,7 +2222,7 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2134 int j; 2222 int j;
2135 2223
2136 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) { 2224 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
2137 REG_WR_IND(bp, offset, fw->text[j]); 2225 REG_WR_IND(bp, offset, cpu_to_le32(fw->text[j]));
2138 } 2226 }
2139 } 2227 }
2140 2228
@@ -2190,15 +2278,32 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2190 REG_WR_IND(bp, cpu_reg->mode, val); 2278 REG_WR_IND(bp, cpu_reg->mode, val);
2191} 2279}
2192 2280
2193static void 2281static int
2194bnx2_init_cpus(struct bnx2 *bp) 2282bnx2_init_cpus(struct bnx2 *bp)
2195{ 2283{
2196 struct cpu_reg cpu_reg; 2284 struct cpu_reg cpu_reg;
2197 struct fw_info fw; 2285 struct fw_info fw;
2286 int rc = 0;
2287 void *text;
2288 u32 text_len;
2289
2290 if ((rc = bnx2_gunzip_init(bp)) != 0)
2291 return rc;
2198 2292
2199 /* Initialize the RV2P processor. */ 2293 /* Initialize the RV2P processor. */
2200 load_rv2p_fw(bp, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1), RV2P_PROC1); 2294 rc = bnx2_gunzip(bp, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1), &text,
2201 load_rv2p_fw(bp, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2), RV2P_PROC2); 2295 &text_len);
2296 if (rc)
2297 goto init_cpu_err;
2298
2299 load_rv2p_fw(bp, text, text_len, RV2P_PROC1);
2300
2301 rc = bnx2_gunzip(bp, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2), &text,
2302 &text_len);
2303 if (rc)
2304 goto init_cpu_err;
2305
2306 load_rv2p_fw(bp, text, text_len, RV2P_PROC2);
2202 2307
2203 /* Initialize the RX Processor. */ 2308 /* Initialize the RX Processor. */
2204 cpu_reg.mode = BNX2_RXP_CPU_MODE; 2309 cpu_reg.mode = BNX2_RXP_CPU_MODE;
@@ -2222,7 +2327,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2222 fw.text_addr = bnx2_RXP_b06FwTextAddr; 2327 fw.text_addr = bnx2_RXP_b06FwTextAddr;
2223 fw.text_len = bnx2_RXP_b06FwTextLen; 2328 fw.text_len = bnx2_RXP_b06FwTextLen;
2224 fw.text_index = 0; 2329 fw.text_index = 0;
2225 fw.text = bnx2_RXP_b06FwText; 2330
2331 rc = bnx2_gunzip(bp, bnx2_RXP_b06FwText, sizeof(bnx2_RXP_b06FwText),
2332 &text, &text_len);
2333 if (rc)
2334 goto init_cpu_err;
2335
2336 fw.text = text;
2226 2337
2227 fw.data_addr = bnx2_RXP_b06FwDataAddr; 2338 fw.data_addr = bnx2_RXP_b06FwDataAddr;
2228 fw.data_len = bnx2_RXP_b06FwDataLen; 2339 fw.data_len = bnx2_RXP_b06FwDataLen;
@@ -2268,7 +2379,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2268 fw.text_addr = bnx2_TXP_b06FwTextAddr; 2379 fw.text_addr = bnx2_TXP_b06FwTextAddr;
2269 fw.text_len = bnx2_TXP_b06FwTextLen; 2380 fw.text_len = bnx2_TXP_b06FwTextLen;
2270 fw.text_index = 0; 2381 fw.text_index = 0;
2271 fw.text = bnx2_TXP_b06FwText; 2382
2383 rc = bnx2_gunzip(bp, bnx2_TXP_b06FwText, sizeof(bnx2_TXP_b06FwText),
2384 &text, &text_len);
2385 if (rc)
2386 goto init_cpu_err;
2387
2388 fw.text = text;
2272 2389
2273 fw.data_addr = bnx2_TXP_b06FwDataAddr; 2390 fw.data_addr = bnx2_TXP_b06FwDataAddr;
2274 fw.data_len = bnx2_TXP_b06FwDataLen; 2391 fw.data_len = bnx2_TXP_b06FwDataLen;
@@ -2314,7 +2431,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2314 fw.text_addr = bnx2_TPAT_b06FwTextAddr; 2431 fw.text_addr = bnx2_TPAT_b06FwTextAddr;
2315 fw.text_len = bnx2_TPAT_b06FwTextLen; 2432 fw.text_len = bnx2_TPAT_b06FwTextLen;
2316 fw.text_index = 0; 2433 fw.text_index = 0;
2317 fw.text = bnx2_TPAT_b06FwText; 2434
2435 rc = bnx2_gunzip(bp, bnx2_TPAT_b06FwText, sizeof(bnx2_TPAT_b06FwText),
2436 &text, &text_len);
2437 if (rc)
2438 goto init_cpu_err;
2439
2440 fw.text = text;
2318 2441
2319 fw.data_addr = bnx2_TPAT_b06FwDataAddr; 2442 fw.data_addr = bnx2_TPAT_b06FwDataAddr;
2320 fw.data_len = bnx2_TPAT_b06FwDataLen; 2443 fw.data_len = bnx2_TPAT_b06FwDataLen;
@@ -2360,7 +2483,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2360 fw.text_addr = bnx2_COM_b06FwTextAddr; 2483 fw.text_addr = bnx2_COM_b06FwTextAddr;
2361 fw.text_len = bnx2_COM_b06FwTextLen; 2484 fw.text_len = bnx2_COM_b06FwTextLen;
2362 fw.text_index = 0; 2485 fw.text_index = 0;
2363 fw.text = bnx2_COM_b06FwText; 2486
2487 rc = bnx2_gunzip(bp, bnx2_COM_b06FwText, sizeof(bnx2_COM_b06FwText),
2488 &text, &text_len);
2489 if (rc)
2490 goto init_cpu_err;
2491
2492 fw.text = text;
2364 2493
2365 fw.data_addr = bnx2_COM_b06FwDataAddr; 2494 fw.data_addr = bnx2_COM_b06FwDataAddr;
2366 fw.data_len = bnx2_COM_b06FwDataLen; 2495 fw.data_len = bnx2_COM_b06FwDataLen;
@@ -2384,6 +2513,9 @@ bnx2_init_cpus(struct bnx2 *bp)
2384 2513
2385 load_cpu_fw(bp, &cpu_reg, &fw); 2514 load_cpu_fw(bp, &cpu_reg, &fw);
2386 2515
2516init_cpu_err:
2517 bnx2_gunzip_end(bp);
2518 return rc;
2387} 2519}
2388 2520
2389static int 2521static int
@@ -3256,7 +3388,9 @@ bnx2_init_chip(struct bnx2 *bp)
3256 * context block must have already been enabled. */ 3388 * context block must have already been enabled. */
3257 bnx2_init_context(bp); 3389 bnx2_init_context(bp);
3258 3390
3259 bnx2_init_cpus(bp); 3391 if ((rc = bnx2_init_cpus(bp)) != 0)
3392 return rc;
3393
3260 bnx2_init_nvram(bp); 3394 bnx2_init_nvram(bp);
3261 3395
3262 bnx2_set_mac_addr(bp); 3396 bnx2_set_mac_addr(bp);
@@ -3556,7 +3690,9 @@ bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
3556 if (rc) 3690 if (rc)
3557 return rc; 3691 return rc;
3558 3692
3559 bnx2_init_chip(bp); 3693 if ((rc = bnx2_init_chip(bp)) != 0)
3694 return rc;
3695
3560 bnx2_init_tx_ring(bp); 3696 bnx2_init_tx_ring(bp);
3561 bnx2_init_rx_ring(bp); 3697 bnx2_init_rx_ring(bp);
3562 return 0; 3698 return 0;
@@ -4034,6 +4170,8 @@ bnx2_timer(unsigned long data)
4034 msg = (u32) ++bp->fw_drv_pulse_wr_seq; 4170 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
4035 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg); 4171 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg);
4036 4172
4173 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT);
4174
4037 if ((bp->phy_flags & PHY_SERDES_FLAG) && 4175 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
4038 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 4176 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
4039 4177
@@ -4252,7 +4390,7 @@ bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
4252} 4390}
4253#endif 4391#endif
4254 4392
4255/* Called with dev->xmit_lock. 4393/* Called with netif_tx_lock.
4256 * hard_start_xmit is pseudo-lockless - a lock is only required when 4394 * hard_start_xmit is pseudo-lockless - a lock is only required when
4257 * the tx queue is full. This way, we get the benefit of lockless 4395 * the tx queue is full. This way, we get the benefit of lockless
4258 * operations most of the time without the complexities to handle 4396 * operations most of the time without the complexities to handle
@@ -4310,7 +4448,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4310 ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr); 4448 ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr);
4311 4449
4312 skb->nh.iph->check = 0; 4450 skb->nh.iph->check = 0;
4313 skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len); 4451 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
4314 skb->h.th->check = 4452 skb->h.th->check =
4315 ~csum_tcpudp_magic(skb->nh.iph->saddr, 4453 ~csum_tcpudp_magic(skb->nh.iph->saddr,
4316 skb->nh.iph->daddr, 4454 skb->nh.iph->daddr,
@@ -4504,6 +4642,10 @@ bnx2_get_stats(struct net_device *dev)
4504 net_stats->tx_aborted_errors + 4642 net_stats->tx_aborted_errors +
4505 net_stats->tx_carrier_errors; 4643 net_stats->tx_carrier_errors;
4506 4644
4645 net_stats->rx_missed_errors =
4646 (unsigned long) (stats_blk->stat_IfInMBUFDiscards +
4647 stats_blk->stat_FwRxDrop);
4648
4507 return net_stats; 4649 return net_stats;
4508} 4650}
4509 4651
@@ -4986,7 +5128,7 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data)
4986 return 0; 5128 return 0;
4987} 5129}
4988 5130
4989#define BNX2_NUM_STATS 45 5131#define BNX2_NUM_STATS 46
4990 5132
4991static struct { 5133static struct {
4992 char string[ETH_GSTRING_LEN]; 5134 char string[ETH_GSTRING_LEN];
@@ -5036,6 +5178,7 @@ static struct {
5036 { "rx_mac_ctrl_frames" }, 5178 { "rx_mac_ctrl_frames" },
5037 { "rx_filtered_packets" }, 5179 { "rx_filtered_packets" },
5038 { "rx_discards" }, 5180 { "rx_discards" },
5181 { "rx_fw_discards" },
5039}; 5182};
5040 5183
5041#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4) 5184#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4)
@@ -5086,6 +5229,7 @@ static const unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = {
5086 STATS_OFFSET32(stat_MacControlFramesReceived), 5229 STATS_OFFSET32(stat_MacControlFramesReceived),
5087 STATS_OFFSET32(stat_IfInFramesL2FilterDiscards), 5230 STATS_OFFSET32(stat_IfInFramesL2FilterDiscards),
5088 STATS_OFFSET32(stat_IfInMBUFDiscards), 5231 STATS_OFFSET32(stat_IfInMBUFDiscards),
5232 STATS_OFFSET32(stat_FwRxDrop),
5089}; 5233};
5090 5234
5091/* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are 5235/* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are
@@ -5096,7 +5240,7 @@ static u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = {
5096 4,0,4,4,4,4,4,4,4,4, 5240 4,0,4,4,4,4,4,4,4,4,
5097 4,4,4,4,4,4,4,4,4,4, 5241 4,4,4,4,4,4,4,4,4,4,
5098 4,4,4,4,4,4,4,4,4,4, 5242 4,4,4,4,4,4,4,4,4,4,
5099 4,4,4,4,4, 5243 4,4,4,4,4,4,
5100}; 5244};
5101 5245
5102static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = { 5246static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
@@ -5104,7 +5248,7 @@ static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
5104 4,4,4,4,4,4,4,4,4,4, 5248 4,4,4,4,4,4,4,4,4,4,
5105 4,4,4,4,4,4,4,4,4,4, 5249 4,4,4,4,4,4,4,4,4,4,
5106 4,4,4,4,4,4,4,4,4,4, 5250 4,4,4,4,4,4,4,4,4,4,
5107 4,4,4,4,4, 5251 4,4,4,4,4,4,
5108}; 5252};
5109 5253
5110#define BNX2_NUM_TESTS 6 5254#define BNX2_NUM_TESTS 6
@@ -5634,7 +5778,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5634 } 5778 }
5635 } 5779 }
5636 5780
5637 if (CHIP_NUM(bp) == CHIP_NUM_5708) 5781 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
5782 (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
5783 (CHIP_ID(bp) == CHIP_ID_5708_B1))
5638 bp->flags |= NO_WOL_FLAG; 5784 bp->flags |= NO_WOL_FLAG;
5639 5785
5640 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 5786 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {