aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgb/ixgb_main.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-24 13:15:13 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-24 13:15:13 -0400
commita319a2773a13bab56a0d0b3744ba8703324313b5 (patch)
treef02c86acabd1031439fd422a167784007e84ebb1 /drivers/net/ixgb/ixgb_main.c
parente18fa700c9a31360bc8f193aa543b7ef7b39a06b (diff)
parent183798799216fad36c7219fe8d4d6dee6b8fa755 (diff)
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (217 commits) net/ieee80211: fix more crypto-related build breakage [PATCH] Spidernet: add ethtool -S (show statistics) [NET] GT96100: Delete bitrotting ethernet driver [PATCH] mv643xx_eth: restrict to 32-bit PPC_MULTIPLATFORM [PATCH] Cirrus Logic ep93xx ethernet driver r8169: the MMIO region of the 8167 stands behin BAR#1 e1000, ixgb: Remove pointless wrappers [PATCH] Remove powerpc specific parts of 3c509 driver [PATCH] s2io: Switch to pci_get_device [PATCH] gt96100: move to pci_get_device API [PATCH] ehea: bugfix for register access functions [PATCH] e1000 disable device on PCI error drivers/net/phy/fixed: #if 0 some incomplete code drivers/net: const-ify ethtool_ops declarations [PATCH] ethtool: allow const ethtool_ops [PATCH] sky2: big endian [PATCH] sky2: fiber support [PATCH] sky2: tx pause bug fix drivers/net: Trim trailing whitespace [PATCH] ehea: IBM eHEA Ethernet Device Driver ... Manually resolved conflicts in drivers/net/ixgb/ixgb_main.c and drivers/net/sky2.c related to CHECKSUM_HW/CHECKSUM_PARTIAL changes by commit 84fa7933a33f806bbbaae6775e87459b1ec584c0 that just happened to be next to unrelated changes in this update.
Diffstat (limited to 'drivers/net/ixgb/ixgb_main.c')
-rw-r--r--drivers/net/ixgb/ixgb_main.c152
1 files changed, 133 insertions, 19 deletions
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 9405b44f3214..2e0f4b950a90 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -36,7 +36,7 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
36#else 36#else
37#define DRIVERNAPI "-NAPI" 37#define DRIVERNAPI "-NAPI"
38#endif 38#endif
39#define DRV_VERSION "1.0.109-k2"DRIVERNAPI 39#define DRV_VERSION "1.0.112-k2"DRIVERNAPI
40char ixgb_driver_version[] = DRV_VERSION; 40char ixgb_driver_version[] = DRV_VERSION;
41static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 41static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
42 42
@@ -118,15 +118,26 @@ static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
118static void ixgb_netpoll(struct net_device *dev); 118static void ixgb_netpoll(struct net_device *dev);
119#endif 119#endif
120 120
121/* Exported from other modules */ 121static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev,
122 enum pci_channel_state state);
123static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
124static void ixgb_io_resume (struct pci_dev *pdev);
122 125
126/* Exported from other modules */
123extern void ixgb_check_options(struct ixgb_adapter *adapter); 127extern void ixgb_check_options(struct ixgb_adapter *adapter);
124 128
129static struct pci_error_handlers ixgb_err_handler = {
130 .error_detected = ixgb_io_error_detected,
131 .slot_reset = ixgb_io_slot_reset,
132 .resume = ixgb_io_resume,
133};
134
125static struct pci_driver ixgb_driver = { 135static struct pci_driver ixgb_driver = {
126 .name = ixgb_driver_name, 136 .name = ixgb_driver_name,
127 .id_table = ixgb_pci_tbl, 137 .id_table = ixgb_pci_tbl,
128 .probe = ixgb_probe, 138 .probe = ixgb_probe,
129 .remove = __devexit_p(ixgb_remove), 139 .remove = __devexit_p(ixgb_remove),
140 .err_handler = &ixgb_err_handler
130}; 141};
131 142
132MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 143MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
@@ -140,12 +151,12 @@ module_param(debug, int, 0);
140MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 151MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
141 152
142/* some defines for controlling descriptor fetches in h/w */ 153/* some defines for controlling descriptor fetches in h/w */
143#define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */ 154#define RXDCTL_WTHRESH_DEFAULT 15 /* chip writes back at this many or RXT0 */
144#define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below 155#define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below
145 * this */ 156 * this */
146#define RXDCTL_HTHRESH_DEFAULT 0 /* chip will only prefetch if tail 157#define RXDCTL_HTHRESH_DEFAULT 0 /* chip will only prefetch if tail
147 * is pushed this many descriptors 158 * is pushed this many descriptors
148 * from head */ 159 * from head */
149 160
150/** 161/**
151 * ixgb_init_module - Driver Registration Routine 162 * ixgb_init_module - Driver Registration Routine
@@ -162,7 +173,7 @@ ixgb_init_module(void)
162 173
163 printk(KERN_INFO "%s\n", ixgb_copyright); 174 printk(KERN_INFO "%s\n", ixgb_copyright);
164 175
165 return pci_module_init(&ixgb_driver); 176 return pci_register_driver(&ixgb_driver);
166} 177}
167 178
168module_init(ixgb_init_module); 179module_init(ixgb_init_module);
@@ -1174,6 +1185,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1174 int err; 1185 int err;
1175 1186
1176 if (likely(skb_is_gso(skb))) { 1187 if (likely(skb_is_gso(skb))) {
1188 struct ixgb_buffer *buffer_info;
1177 if (skb_header_cloned(skb)) { 1189 if (skb_header_cloned(skb)) {
1178 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 1190 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
1179 if (err) 1191 if (err)
@@ -1196,6 +1208,8 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1196 1208
1197 i = adapter->tx_ring.next_to_use; 1209 i = adapter->tx_ring.next_to_use;
1198 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i); 1210 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1211 buffer_info = &adapter->tx_ring.buffer_info[i];
1212 WARN_ON(buffer_info->dma != 0);
1199 1213
1200 context_desc->ipcss = ipcss; 1214 context_desc->ipcss = ipcss;
1201 context_desc->ipcso = ipcso; 1215 context_desc->ipcso = ipcso;
@@ -1233,11 +1247,14 @@ ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1233 uint8_t css, cso; 1247 uint8_t css, cso;
1234 1248
1235 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 1249 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
1250 struct ixgb_buffer *buffer_info;
1236 css = skb->h.raw - skb->data; 1251 css = skb->h.raw - skb->data;
1237 cso = (skb->h.raw + skb->csum) - skb->data; 1252 cso = (skb->h.raw + skb->csum) - skb->data;
1238 1253
1239 i = adapter->tx_ring.next_to_use; 1254 i = adapter->tx_ring.next_to_use;
1240 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i); 1255 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
1256 buffer_info = &adapter->tx_ring.buffer_info[i];
1257 WARN_ON(buffer_info->dma != 0);
1241 1258
1242 context_desc->tucss = css; 1259 context_desc->tucss = css;
1243 context_desc->tucso = cso; 1260 context_desc->tucso = cso;
@@ -1283,6 +1300,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1283 buffer_info = &tx_ring->buffer_info[i]; 1300 buffer_info = &tx_ring->buffer_info[i];
1284 size = min(len, IXGB_MAX_DATA_PER_TXD); 1301 size = min(len, IXGB_MAX_DATA_PER_TXD);
1285 buffer_info->length = size; 1302 buffer_info->length = size;
1303 WARN_ON(buffer_info->dma != 0);
1286 buffer_info->dma = 1304 buffer_info->dma =
1287 pci_map_single(adapter->pdev, 1305 pci_map_single(adapter->pdev,
1288 skb->data + offset, 1306 skb->data + offset,
@@ -1543,6 +1561,11 @@ void
1543ixgb_update_stats(struct ixgb_adapter *adapter) 1561ixgb_update_stats(struct ixgb_adapter *adapter)
1544{ 1562{
1545 struct net_device *netdev = adapter->netdev; 1563 struct net_device *netdev = adapter->netdev;
1564 struct pci_dev *pdev = adapter->pdev;
1565
1566 /* Prevent stats update while adapter is being reset */
1567 if (pdev->error_state && pdev->error_state != pci_channel_io_normal)
1568 return;
1546 1569
1547 if((netdev->flags & IFF_PROMISC) || (netdev->flags & IFF_ALLMULTI) || 1570 if((netdev->flags & IFF_PROMISC) || (netdev->flags & IFF_ALLMULTI) ||
1548 (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES)) { 1571 (netdev->mc_count > IXGB_MAX_NUM_MULTICAST_ADDRESSES)) {
@@ -1787,7 +1810,7 @@ ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1787 if (unlikely(netif_queue_stopped(netdev))) { 1810 if (unlikely(netif_queue_stopped(netdev))) {
1788 spin_lock(&adapter->tx_lock); 1811 spin_lock(&adapter->tx_lock);
1789 if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev) && 1812 if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
1790 (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) 1813 (IXGB_DESC_UNUSED(tx_ring) >= DESC_NEEDED))
1791 netif_wake_queue(netdev); 1814 netif_wake_queue(netdev);
1792 spin_unlock(&adapter->tx_lock); 1815 spin_unlock(&adapter->tx_lock);
1793 } 1816 }
@@ -1948,10 +1971,9 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1948#define IXGB_CB_LENGTH 256 1971#define IXGB_CB_LENGTH 256
1949 if (length < IXGB_CB_LENGTH) { 1972 if (length < IXGB_CB_LENGTH) {
1950 struct sk_buff *new_skb = 1973 struct sk_buff *new_skb =
1951 dev_alloc_skb(length + NET_IP_ALIGN); 1974 netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
1952 if (new_skb) { 1975 if (new_skb) {
1953 skb_reserve(new_skb, NET_IP_ALIGN); 1976 skb_reserve(new_skb, NET_IP_ALIGN);
1954 new_skb->dev = netdev;
1955 memcpy(new_skb->data - NET_IP_ALIGN, 1977 memcpy(new_skb->data - NET_IP_ALIGN,
1956 skb->data - NET_IP_ALIGN, 1978 skb->data - NET_IP_ALIGN,
1957 length + NET_IP_ALIGN); 1979 length + NET_IP_ALIGN);
@@ -2031,14 +2053,14 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
2031 /* leave three descriptors unused */ 2053 /* leave three descriptors unused */
2032 while(--cleancount > 2) { 2054 while(--cleancount > 2) {
2033 /* recycle! its good for you */ 2055 /* recycle! its good for you */
2034 if (!(skb = buffer_info->skb)) 2056 skb = buffer_info->skb;
2035 skb = dev_alloc_skb(adapter->rx_buffer_len 2057 if (skb) {
2036 + NET_IP_ALIGN);
2037 else {
2038 skb_trim(skb, 0); 2058 skb_trim(skb, 0);
2039 goto map_skb; 2059 goto map_skb;
2040 } 2060 }
2041 2061
2062 skb = netdev_alloc_skb(netdev, adapter->rx_buffer_len
2063 + NET_IP_ALIGN);
2042 if (unlikely(!skb)) { 2064 if (unlikely(!skb)) {
2043 /* Better luck next round */ 2065 /* Better luck next round */
2044 adapter->alloc_rx_buff_failed++; 2066 adapter->alloc_rx_buff_failed++;
@@ -2051,8 +2073,6 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
2051 */ 2073 */
2052 skb_reserve(skb, NET_IP_ALIGN); 2074 skb_reserve(skb, NET_IP_ALIGN);
2053 2075
2054 skb->dev = netdev;
2055
2056 buffer_info->skb = skb; 2076 buffer_info->skb = skb;
2057 buffer_info->length = adapter->rx_buffer_len; 2077 buffer_info->length = adapter->rx_buffer_len;
2058map_skb: 2078map_skb:
@@ -2190,7 +2210,7 @@ ixgb_restore_vlan(struct ixgb_adapter *adapter)
2190 2210
2191static void ixgb_netpoll(struct net_device *dev) 2211static void ixgb_netpoll(struct net_device *dev)
2192{ 2212{
2193 struct ixgb_adapter *adapter = dev->priv; 2213 struct ixgb_adapter *adapter = netdev_priv(dev);
2194 2214
2195 disable_irq(adapter->pdev->irq); 2215 disable_irq(adapter->pdev->irq);
2196 ixgb_intr(adapter->pdev->irq, dev, NULL); 2216 ixgb_intr(adapter->pdev->irq, dev, NULL);
@@ -2198,4 +2218,98 @@ static void ixgb_netpoll(struct net_device *dev)
2198} 2218}
2199#endif 2219#endif
2200 2220
2221/**
2222 * ixgb_io_error_detected() - called when PCI error is detected
2223 * @pdev pointer to pci device with error
2224 * @state pci channel state after error
2225 *
2226 * This callback is called by the PCI subsystem whenever
2227 * a PCI bus error is detected.
2228 */
2229static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev,
2230 enum pci_channel_state state)
2231{
2232 struct net_device *netdev = pci_get_drvdata(pdev);
2233 struct ixgb_adapter *adapter = netdev->priv;
2234
2235 if(netif_running(netdev))
2236 ixgb_down(adapter, TRUE);
2237
2238 pci_disable_device(pdev);
2239
2240 /* Request a slot reset. */
2241 return PCI_ERS_RESULT_NEED_RESET;
2242}
2243
2244/**
2245 * ixgb_io_slot_reset - called after the pci bus has been reset.
2246 * @pdev pointer to pci device with error
2247 *
2248 * This callback is called after the PCI buss has been reset.
2249 * Basically, this tries to restart the card from scratch.
2250 * This is a shortened version of the device probe/discovery code,
2251 * it resembles the first-half of the ixgb_probe() routine.
2252 */
2253static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev)
2254{
2255 struct net_device *netdev = pci_get_drvdata(pdev);
2256 struct ixgb_adapter *adapter = netdev->priv;
2257
2258 if(pci_enable_device(pdev)) {
2259 DPRINTK(PROBE, ERR, "Cannot re-enable PCI device after reset.\n");
2260 return PCI_ERS_RESULT_DISCONNECT;
2261 }
2262
2263 /* Perform card reset only on one instance of the card */
2264 if (0 != PCI_FUNC (pdev->devfn))
2265 return PCI_ERS_RESULT_RECOVERED;
2266
2267 pci_set_master(pdev);
2268
2269 netif_carrier_off(netdev);
2270 netif_stop_queue(netdev);
2271 ixgb_reset(adapter);
2272
2273 /* Make sure the EEPROM is good */
2274 if(!ixgb_validate_eeprom_checksum(&adapter->hw)) {
2275 DPRINTK(PROBE, ERR, "After reset, the EEPROM checksum is not valid.\n");
2276 return PCI_ERS_RESULT_DISCONNECT;
2277 }
2278 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
2279 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
2280
2281 if(!is_valid_ether_addr(netdev->perm_addr)) {
2282 DPRINTK(PROBE, ERR, "After reset, invalid MAC address.\n");
2283 return PCI_ERS_RESULT_DISCONNECT;
2284 }
2285
2286 return PCI_ERS_RESULT_RECOVERED;
2287}
2288
2289/**
2290 * ixgb_io_resume - called when its OK to resume normal operations
2291 * @pdev pointer to pci device with error
2292 *
2293 * The error recovery driver tells us that its OK to resume
2294 * normal operation. Implementation resembles the second-half
2295 * of the ixgb_probe() routine.
2296 */
2297static void ixgb_io_resume (struct pci_dev *pdev)
2298{
2299 struct net_device *netdev = pci_get_drvdata(pdev);
2300 struct ixgb_adapter *adapter = netdev->priv;
2301
2302 pci_set_master(pdev);
2303
2304 if(netif_running(netdev)) {
2305 if(ixgb_up(adapter)) {
2306 printk ("ixgb: can't bring device back up after reset\n");
2307 return;
2308 }
2309 }
2310
2311 netif_device_attach(netdev);
2312 mod_timer(&adapter->watchdog_timer, jiffies);
2313}
2314
2201/* ixgb_main.c */ 2315/* ixgb_main.c */