Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1 | /* |
Dhananjay Phadke | 5d242f1 | 2009-02-25 15:57:56 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 - 2009 NetXen, Inc. |
Dhananjay Phadke | 13af7a6 | 2009-09-11 11:28:15 +0000 | [diff] [blame] | 3 | * Copyright (C) 2009 - QLogic Corporation. |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 4 | * All rights reserved. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 5 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 10 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 15 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 19 | * MA 02111-1307, USA. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 20 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 21 | * The full GNU General Public License is included in this distribution |
Amit Kumar Salecha | 4d21fef | 2010-01-14 01:53:23 +0000 | [diff] [blame] | 22 | * in the file called "COPYING". |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 23 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 24 | */ |
| 25 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 27 | #include <linux/vmalloc.h> |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 28 | #include <linux/interrupt.h> |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 29 | #include "netxen_nic_hw.h" |
| 30 | |
| 31 | #include "netxen_nic.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 32 | |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 33 | #include <linux/dma-mapping.h> |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 34 | #include <linux/if_vlan.h> |
Arnaldo Carvalho de Melo | c9bdd4b | 2007-03-12 20:09:15 -0300 | [diff] [blame] | 35 | #include <net/ip.h> |
Dhananjay Phadke | 0097778 | 2009-01-16 11:03:25 -0800 | [diff] [blame] | 36 | #include <linux/ipv6.h> |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 37 | #include <linux/inetdevice.h> |
Randy Dunlap | 0531d7b8 | 2009-10-26 12:09:45 +0000 | [diff] [blame] | 38 | #include <linux/sysfs.h> |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 39 | #include <linux/aer.h> |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 40 | |
Amit Kumar Salecha | 0438a1b | 2010-12-31 10:55:38 -0800 | [diff] [blame] | 41 | MODULE_DESCRIPTION("QLogic/NetXen (1/10) GbE Intelligent Ethernet Driver"); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 42 | MODULE_LICENSE("GPL"); |
| 43 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); |
Dhananjay Phadke | 7e8e5d9 | 2009-10-24 16:04:02 +0000 | [diff] [blame] | 44 | MODULE_FIRMWARE(NX_UNIFIED_ROMIMAGE_NAME); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 45 | |
dhananjay@netxen.com | ceded32 | 2007-07-19 14:41:09 +0530 | [diff] [blame] | 46 | char netxen_nic_driver_name[] = "netxen_nic"; |
Dhananjay Phadke | c25c0b9 | 2009-10-28 04:11:04 -0700 | [diff] [blame] | 47 | static char netxen_nic_driver_string[] = "QLogic/NetXen Network Driver v" |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 48 | NETXEN_NIC_LINUX_VERSIONID; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 49 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 50 | static int port_mode = NETXEN_PORT_MODE_AUTO_NEG; |
| 51 | |
| 52 | /* Default to restricted 1G auto-neg mode */ |
| 53 | static int wol_port_mode = 5; |
| 54 | |
| 55 | static int use_msi = 1; |
| 56 | |
| 57 | static int use_msi_x = 1; |
| 58 | |
Stephen Hemminger | afdafff | 2009-12-18 20:13:35 -0800 | [diff] [blame] | 59 | static int auto_fw_reset = AUTO_FW_RESET_ENABLED; |
| 60 | module_param(auto_fw_reset, int, 0644); |
| 61 | MODULE_PARM_DESC(auto_fw_reset,"Auto firmware reset (0=disabled, 1=enabled"); |
Narender Kumar | caa2dd5 | 2009-10-16 15:50:11 +0000 | [diff] [blame] | 62 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 63 | static int __devinit netxen_nic_probe(struct pci_dev *pdev, |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 64 | const struct pci_device_id *ent); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 65 | static void __devexit netxen_nic_remove(struct pci_dev *pdev); |
| 66 | static int netxen_nic_open(struct net_device *netdev); |
| 67 | static int netxen_nic_close(struct net_device *netdev); |
Stephen Hemminger | 61357325 | 2009-08-31 19:50:58 +0000 | [diff] [blame] | 68 | static netdev_tx_t netxen_nic_xmit_frame(struct sk_buff *, |
| 69 | struct net_device *); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 70 | static void netxen_tx_timeout(struct net_device *netdev); |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 71 | static void netxen_tx_timeout_task(struct work_struct *work); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 72 | static void netxen_fw_poll_work(struct work_struct *work); |
| 73 | static void netxen_schedule_work(struct netxen_adapter *adapter, |
| 74 | work_func_t func, int delay); |
| 75 | static void netxen_cancel_fw_work(struct netxen_adapter *adapter); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 76 | static int netxen_nic_poll(struct napi_struct *napi, int budget); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 77 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 78 | static void netxen_nic_poll_controller(struct net_device *netdev); |
| 79 | #endif |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 80 | |
| 81 | static void netxen_create_sysfs_entries(struct netxen_adapter *adapter); |
| 82 | static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter); |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 83 | static void netxen_create_diag_entries(struct netxen_adapter *adapter); |
| 84 | static void netxen_remove_diag_entries(struct netxen_adapter *adapter); |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 85 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 86 | static int nx_dev_request_aer(struct netxen_adapter *adapter); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 87 | static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter); |
| 88 | static int netxen_can_start_firmware(struct netxen_adapter *adapter); |
| 89 | |
Jeff Garzik | 1494a81 | 2006-11-07 05:12:16 -0500 | [diff] [blame] | 90 | static irqreturn_t netxen_intr(int irq, void *data); |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 91 | static irqreturn_t netxen_msi_intr(int irq, void *data); |
Dhananjay Phadke | b3df68f | 2009-02-08 19:20:19 -0800 | [diff] [blame] | 92 | static irqreturn_t netxen_msix_intr(int irq, void *data); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 93 | |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 94 | static void netxen_config_indev_addr(struct net_device *dev, unsigned long); |
stephen hemminger | 7e12bb0 | 2010-10-18 17:40:10 +0000 | [diff] [blame] | 95 | static struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev); |
| 96 | static int netxen_nic_set_mac(struct net_device *netdev, void *p); |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 97 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 98 | /* PCI Device ID Table */ |
Al Viro | 70081ac | 2008-06-23 02:04:50 +0100 | [diff] [blame] | 99 | #define ENTRY(device) \ |
Dhananjay Phadke | 040dec3 | 2008-09-12 06:55:14 -0700 | [diff] [blame] | 100 | {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \ |
Al Viro | 70081ac | 2008-06-23 02:04:50 +0100 | [diff] [blame] | 101 | .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0} |
| 102 | |
Alexey Dobriyan | a3aa188 | 2010-01-07 11:58:11 +0000 | [diff] [blame] | 103 | static DEFINE_PCI_DEVICE_TABLE(netxen_pci_tbl) = { |
Dhananjay Phadke | 040dec3 | 2008-09-12 06:55:14 -0700 | [diff] [blame] | 104 | ENTRY(PCI_DEVICE_ID_NX2031_10GXSR), |
| 105 | ENTRY(PCI_DEVICE_ID_NX2031_10GCX4), |
| 106 | ENTRY(PCI_DEVICE_ID_NX2031_4GCU), |
| 107 | ENTRY(PCI_DEVICE_ID_NX2031_IMEZ), |
| 108 | ENTRY(PCI_DEVICE_ID_NX2031_HMEZ), |
| 109 | ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT), |
| 110 | ENTRY(PCI_DEVICE_ID_NX2031_XG_MGMT2), |
| 111 | ENTRY(PCI_DEVICE_ID_NX3031), |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 112 | {0,} |
| 113 | }; |
| 114 | |
| 115 | MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); |
| 116 | |
Dhananjay Phadke | 7830b22 | 2008-07-21 19:44:00 -0700 | [diff] [blame] | 117 | static uint32_t crb_cmd_producer[4] = { |
| 118 | CRB_CMD_PRODUCER_OFFSET, CRB_CMD_PRODUCER_OFFSET_1, |
| 119 | CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3 |
| 120 | }; |
| 121 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 122 | void |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 123 | netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 124 | struct nx_host_tx_ring *tx_ring) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 125 | { |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 126 | NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Dhananjay Phadke | 7830b22 | 2008-07-21 19:44:00 -0700 | [diff] [blame] | 129 | static uint32_t crb_cmd_consumer[4] = { |
| 130 | CRB_CMD_CONSUMER_OFFSET, CRB_CMD_CONSUMER_OFFSET_1, |
| 131 | CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3 |
| 132 | }; |
| 133 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 134 | static inline void |
| 135 | netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 136 | struct nx_host_tx_ring *tx_ring) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 137 | { |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 138 | NXWRIO(adapter, tx_ring->crb_cmd_consumer, tx_ring->sw_consumer); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 141 | static uint32_t msi_tgt_status[8] = { |
Dhananjay Phadke | 443be79 | 2008-03-17 19:59:48 -0700 | [diff] [blame] | 142 | ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1, |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 143 | ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3, |
| 144 | ISR_INT_TARGET_STATUS_F4, ISR_INT_TARGET_STATUS_F5, |
| 145 | ISR_INT_TARGET_STATUS_F6, ISR_INT_TARGET_STATUS_F7 |
Dhananjay Phadke | 443be79 | 2008-03-17 19:59:48 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 148 | static struct netxen_legacy_intr_set legacy_intr[] = NX_LEGACY_INTR_CONFIG; |
| 149 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 150 | static inline void netxen_nic_disable_int(struct nx_host_sds_ring *sds_ring) |
Stephen Hemminger | 4638aef1 | 2007-07-05 16:13:55 -0700 | [diff] [blame] | 151 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 152 | struct netxen_adapter *adapter = sds_ring->adapter; |
| 153 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 154 | NXWRIO(adapter, sds_ring->crb_intr_mask, 0); |
Stephen Hemminger | 4638aef1 | 2007-07-05 16:13:55 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 157 | static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring) |
Stephen Hemminger | 4638aef1 | 2007-07-05 16:13:55 -0700 | [diff] [blame] | 158 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 159 | struct netxen_adapter *adapter = sds_ring->adapter; |
| 160 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 161 | NXWRIO(adapter, sds_ring->crb_intr_mask, 0x1); |
Stephen Hemminger | 4638aef1 | 2007-07-05 16:13:55 -0700 | [diff] [blame] | 162 | |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 163 | if (!NETXEN_IS_MSI_FAMILY(adapter)) |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 164 | NXWRIO(adapter, adapter->tgt_mask_reg, 0xfbff); |
Stephen Hemminger | 4638aef1 | 2007-07-05 16:13:55 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 167 | static int |
| 168 | netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count) |
| 169 | { |
| 170 | int size = sizeof(struct nx_host_sds_ring) * count; |
| 171 | |
| 172 | recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); |
| 173 | |
Eric Dumazet | 807540b | 2010-09-23 05:40:09 +0000 | [diff] [blame] | 174 | return recv_ctx->sds_rings == NULL; |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 177 | static void |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 178 | netxen_free_sds_rings(struct netxen_recv_context *recv_ctx) |
| 179 | { |
| 180 | if (recv_ctx->sds_rings != NULL) |
| 181 | kfree(recv_ctx->sds_rings); |
Dhananjay Phadke | 232e7d6 | 2009-08-13 07:03:01 +0000 | [diff] [blame] | 182 | |
| 183 | recv_ctx->sds_rings = NULL; |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | static int |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 187 | netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) |
| 188 | { |
| 189 | int ring; |
| 190 | struct nx_host_sds_ring *sds_ring; |
| 191 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 192 | |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 193 | if (netxen_alloc_sds_rings(recv_ctx, adapter->max_sds_rings)) |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 194 | return -ENOMEM; |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 195 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 196 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 197 | sds_ring = &recv_ctx->sds_rings[ring]; |
| 198 | netif_napi_add(netdev, &sds_ring->napi, |
| 199 | netxen_nic_poll, NETXEN_NETDEV_WEIGHT); |
| 200 | } |
Dhananjay Phadke | 71dcddb | 2009-04-07 22:50:43 +0000 | [diff] [blame] | 201 | |
| 202 | return 0; |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | static void |
Dhananjay Phadke | 232e7d6 | 2009-08-13 07:03:01 +0000 | [diff] [blame] | 206 | netxen_napi_del(struct netxen_adapter *adapter) |
| 207 | { |
| 208 | int ring; |
| 209 | struct nx_host_sds_ring *sds_ring; |
| 210 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 211 | |
| 212 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 213 | sds_ring = &recv_ctx->sds_rings[ring]; |
| 214 | netif_napi_del(&sds_ring->napi); |
| 215 | } |
| 216 | |
| 217 | netxen_free_sds_rings(&adapter->recv_ctx); |
| 218 | } |
| 219 | |
| 220 | static void |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 221 | netxen_napi_enable(struct netxen_adapter *adapter) |
| 222 | { |
| 223 | int ring; |
| 224 | struct nx_host_sds_ring *sds_ring; |
| 225 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 226 | |
| 227 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 228 | sds_ring = &recv_ctx->sds_rings[ring]; |
| 229 | napi_enable(&sds_ring->napi); |
| 230 | netxen_nic_enable_int(sds_ring); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | static void |
| 235 | netxen_napi_disable(struct netxen_adapter *adapter) |
| 236 | { |
| 237 | int ring; |
| 238 | struct nx_host_sds_ring *sds_ring; |
| 239 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 240 | |
| 241 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 242 | sds_ring = &recv_ctx->sds_rings[ring]; |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 243 | netxen_nic_disable_int(sds_ring); |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 244 | napi_synchronize(&sds_ring->napi); |
| 245 | napi_disable(&sds_ring->napi); |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 249 | static int nx_set_dma_mask(struct netxen_adapter *adapter) |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 250 | { |
| 251 | struct pci_dev *pdev = adapter->pdev; |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 252 | uint64_t mask, cmask; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 253 | |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 254 | adapter->pci_using_dac = 0; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 255 | |
Yang Hongyang | 6afd142 | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 256 | mask = DMA_BIT_MASK(32); |
Yang Hongyang | 6afd142 | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 257 | cmask = DMA_BIT_MASK(32); |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 258 | |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 259 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 260 | #ifndef CONFIG_IA64 |
Yang Hongyang | 6afd142 | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 261 | mask = DMA_BIT_MASK(35); |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 262 | #endif |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 263 | } else { |
| 264 | mask = DMA_BIT_MASK(39); |
| 265 | cmask = mask; |
| 266 | } |
| 267 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 268 | if (pci_set_dma_mask(pdev, mask) == 0 && |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 269 | pci_set_consistent_dma_mask(pdev, cmask) == 0) { |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 270 | adapter->pci_using_dac = 1; |
| 271 | return 0; |
| 272 | } |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 273 | |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 274 | return -EIO; |
| 275 | } |
| 276 | |
| 277 | /* Update addressable range if firmware supports it */ |
| 278 | static int |
| 279 | nx_update_dma_mask(struct netxen_adapter *adapter) |
| 280 | { |
| 281 | int change, shift, err; |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 282 | uint64_t mask, old_mask, old_cmask; |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 283 | struct pci_dev *pdev = adapter->pdev; |
| 284 | |
| 285 | change = 0; |
| 286 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 287 | shift = NXRD32(adapter, CRB_DMA_SHIFT); |
Dhananjay Phadke | f60f785 | 2009-08-04 10:39:03 +0000 | [diff] [blame] | 288 | if (shift > 32) |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 289 | return 0; |
| 290 | |
| 291 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && (shift > 9)) |
| 292 | change = 1; |
| 293 | else if ((adapter->ahw.revision_id == NX_P2_C1) && (shift <= 4)) |
| 294 | change = 1; |
| 295 | |
| 296 | if (change) { |
| 297 | old_mask = pdev->dma_mask; |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 298 | old_cmask = pdev->dev.coherent_dma_mask; |
| 299 | |
Dhananjay Phadke | f60f785 | 2009-08-04 10:39:03 +0000 | [diff] [blame] | 300 | mask = DMA_BIT_MASK(32+shift); |
Dhananjay Phadke | 1f434f6 | 2009-03-02 16:02:16 +0000 | [diff] [blame] | 301 | |
| 302 | err = pci_set_dma_mask(pdev, mask); |
| 303 | if (err) |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 304 | goto err_out; |
| 305 | |
| 306 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
| 307 | |
| 308 | err = pci_set_consistent_dma_mask(pdev, mask); |
| 309 | if (err) |
| 310 | goto err_out; |
| 311 | } |
| 312 | dev_info(&pdev->dev, "using %d-bit dma mask\n", 32+shift); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 315 | return 0; |
Dhananjay Phadke | 50c643e | 2009-08-01 21:36:16 +0000 | [diff] [blame] | 316 | |
| 317 | err_out: |
| 318 | pci_set_dma_mask(pdev, old_mask); |
| 319 | pci_set_consistent_dma_mask(pdev, old_cmask); |
| 320 | return err; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 323 | static int |
| 324 | netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot) |
| 325 | { |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 326 | u32 val, timeout; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 327 | |
| 328 | if (first_boot == 0x55555555) { |
| 329 | /* This is the first boot after power up */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 330 | NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 331 | |
| 332 | if (!NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 333 | return 0; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 334 | |
| 335 | /* PCI bus master workaround */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 336 | first_boot = NXRD32(adapter, NETXEN_PCIE_REG(0x4)); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 337 | if (!(first_boot & 0x4)) { |
| 338 | first_boot |= 0x4; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 339 | NXWR32(adapter, NETXEN_PCIE_REG(0x4), first_boot); |
Amit Kumar Salecha | 581e8ae | 2010-01-07 22:10:15 +0000 | [diff] [blame] | 340 | NXRD32(adapter, NETXEN_PCIE_REG(0x4)); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* This is the first boot after power up */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 344 | first_boot = NXRD32(adapter, NETXEN_ROMUSB_GLB_SW_RESET); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 345 | if (first_boot != 0x80000f) { |
| 346 | /* clear the register for future unloads/loads */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 347 | NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), 0); |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 348 | return -EIO; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 351 | /* Start P2 boot loader */ |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 352 | val = NXRD32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE); |
| 353 | NXWR32(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1); |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 354 | timeout = 0; |
| 355 | do { |
| 356 | msleep(1); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 357 | val = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc)); |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 358 | |
| 359 | if (++timeout > 5000) |
| 360 | return -EIO; |
| 361 | |
| 362 | } while (val == NETXEN_BDINFO_MAGIC); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 363 | } |
Dhananjay Phadke | 27c915a | 2009-01-14 20:49:00 -0800 | [diff] [blame] | 364 | return 0; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | static void netxen_set_port_mode(struct netxen_adapter *adapter) |
| 368 | { |
| 369 | u32 val, data; |
| 370 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 371 | val = adapter->ahw.board_type; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 372 | if ((val == NETXEN_BRDTYPE_P3_HMEZ) || |
| 373 | (val == NETXEN_BRDTYPE_P3_XG_LOM)) { |
| 374 | if (port_mode == NETXEN_PORT_MODE_802_3_AP) { |
| 375 | data = NETXEN_PORT_MODE_802_3_AP; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 376 | NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 377 | } else if (port_mode == NETXEN_PORT_MODE_XG) { |
| 378 | data = NETXEN_PORT_MODE_XG; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 379 | NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 380 | } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_1G) { |
| 381 | data = NETXEN_PORT_MODE_AUTO_NEG_1G; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 382 | NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 383 | } else if (port_mode == NETXEN_PORT_MODE_AUTO_NEG_XG) { |
| 384 | data = NETXEN_PORT_MODE_AUTO_NEG_XG; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 385 | NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 386 | } else { |
| 387 | data = NETXEN_PORT_MODE_AUTO_NEG; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 388 | NXWR32(adapter, NETXEN_PORT_MODE_ADDR, data); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | if ((wol_port_mode != NETXEN_PORT_MODE_802_3_AP) && |
| 392 | (wol_port_mode != NETXEN_PORT_MODE_XG) && |
| 393 | (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_1G) && |
| 394 | (wol_port_mode != NETXEN_PORT_MODE_AUTO_NEG_XG)) { |
| 395 | wol_port_mode = NETXEN_PORT_MODE_AUTO_NEG; |
| 396 | } |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 397 | NXWR32(adapter, NETXEN_WOL_PORT_MODE, wol_port_mode); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 401 | static void netxen_set_msix_bit(struct pci_dev *pdev, int enable) |
| 402 | { |
| 403 | u32 control; |
| 404 | int pos; |
| 405 | |
| 406 | pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX); |
| 407 | if (pos) { |
| 408 | pci_read_config_dword(pdev, pos, &control); |
| 409 | if (enable) |
| 410 | control |= PCI_MSIX_FLAGS_ENABLE; |
| 411 | else |
| 412 | control = 0; |
| 413 | pci_write_config_dword(pdev, pos, control); |
| 414 | } |
| 415 | } |
| 416 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 417 | static void netxen_init_msix_entries(struct netxen_adapter *adapter, int count) |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 418 | { |
| 419 | int i; |
| 420 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 421 | for (i = 0; i < count; i++) |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 422 | adapter->msix_entries[i].entry = i; |
| 423 | } |
| 424 | |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 425 | static int |
| 426 | netxen_read_mac_addr(struct netxen_adapter *adapter) |
| 427 | { |
| 428 | int i; |
| 429 | unsigned char *p; |
Amit Kumar Salecha | a03d245 | 2010-01-14 01:53:21 +0000 | [diff] [blame] | 430 | u64 mac_addr; |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 431 | struct net_device *netdev = adapter->netdev; |
| 432 | struct pci_dev *pdev = adapter->pdev; |
| 433 | |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 434 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
| 435 | if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0) |
| 436 | return -EIO; |
| 437 | } else { |
| 438 | if (netxen_get_flash_mac_addr(adapter, &mac_addr) != 0) |
| 439 | return -EIO; |
| 440 | } |
| 441 | |
| 442 | p = (unsigned char *)&mac_addr; |
| 443 | for (i = 0; i < 6; i++) |
| 444 | netdev->dev_addr[i] = *(p + 5 - i); |
| 445 | |
| 446 | memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len); |
Narender Kumar | 5d09e53 | 2009-11-20 22:08:57 +0000 | [diff] [blame] | 447 | memcpy(adapter->mac_addr, netdev->dev_addr, netdev->addr_len); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 448 | |
| 449 | /* set station address */ |
| 450 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 451 | if (!is_valid_ether_addr(netdev->perm_addr)) |
| 452 | dev_warn(&pdev->dev, "Bad MAC address %pM.\n", netdev->dev_addr); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
stephen hemminger | 7e12bb0 | 2010-10-18 17:40:10 +0000 | [diff] [blame] | 457 | static int netxen_nic_set_mac(struct net_device *netdev, void *p) |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 458 | { |
| 459 | struct netxen_adapter *adapter = netdev_priv(netdev); |
| 460 | struct sockaddr *addr = p; |
| 461 | |
| 462 | if (!is_valid_ether_addr(addr->sa_data)) |
| 463 | return -EINVAL; |
| 464 | |
| 465 | if (netif_running(netdev)) { |
| 466 | netif_device_detach(netdev); |
| 467 | netxen_napi_disable(adapter); |
| 468 | } |
| 469 | |
Narender Kumar | 5d09e53 | 2009-11-20 22:08:57 +0000 | [diff] [blame] | 470 | memcpy(adapter->mac_addr, addr->sa_data, netdev->addr_len); |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 471 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
| 472 | adapter->macaddr_set(adapter, addr->sa_data); |
| 473 | |
| 474 | if (netif_running(netdev)) { |
| 475 | netif_device_attach(netdev); |
| 476 | netxen_napi_enable(adapter); |
| 477 | } |
| 478 | return 0; |
| 479 | } |
| 480 | |
Stephen Hemminger | 1abd266 | 2008-11-21 17:32:15 -0800 | [diff] [blame] | 481 | static void netxen_set_multicast_list(struct net_device *dev) |
| 482 | { |
| 483 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 484 | |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 485 | adapter->set_multi(dev); |
Stephen Hemminger | 1abd266 | 2008-11-21 17:32:15 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 488 | static u32 netxen_fix_features(struct net_device *dev, u32 features) |
| 489 | { |
| 490 | if (!(features & NETIF_F_RXCSUM)) { |
| 491 | netdev_info(dev, "disabling LRO as RXCSUM is off\n"); |
| 492 | |
| 493 | features &= ~NETIF_F_LRO; |
| 494 | } |
| 495 | |
| 496 | return features; |
| 497 | } |
| 498 | |
| 499 | static int netxen_set_features(struct net_device *dev, u32 features) |
| 500 | { |
| 501 | struct netxen_adapter *adapter = netdev_priv(dev); |
| 502 | int hw_lro; |
| 503 | |
| 504 | if (!((dev->features ^ features) & NETIF_F_LRO)) |
| 505 | return 0; |
| 506 | |
| 507 | hw_lro = (features & NETIF_F_LRO) ? NETXEN_NIC_LRO_ENABLED |
| 508 | : NETXEN_NIC_LRO_DISABLED; |
| 509 | |
| 510 | if (netxen_config_hw_lro(adapter, hw_lro)) |
| 511 | return -EIO; |
| 512 | |
| 513 | if (!(features & NETIF_F_LRO) && netxen_send_lro_cleanup(adapter)) |
| 514 | return -EIO; |
| 515 | |
| 516 | return 0; |
| 517 | } |
| 518 | |
Stephen Hemminger | 1abd266 | 2008-11-21 17:32:15 -0800 | [diff] [blame] | 519 | static const struct net_device_ops netxen_netdev_ops = { |
| 520 | .ndo_open = netxen_nic_open, |
| 521 | .ndo_stop = netxen_nic_close, |
| 522 | .ndo_start_xmit = netxen_nic_xmit_frame, |
| 523 | .ndo_get_stats = netxen_nic_get_stats, |
| 524 | .ndo_validate_addr = eth_validate_addr, |
| 525 | .ndo_set_multicast_list = netxen_set_multicast_list, |
| 526 | .ndo_set_mac_address = netxen_nic_set_mac, |
| 527 | .ndo_change_mtu = netxen_nic_change_mtu, |
| 528 | .ndo_tx_timeout = netxen_tx_timeout, |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 529 | .ndo_fix_features = netxen_fix_features, |
| 530 | .ndo_set_features = netxen_set_features, |
Stephen Hemminger | 1abd266 | 2008-11-21 17:32:15 -0800 | [diff] [blame] | 531 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 532 | .ndo_poll_controller = netxen_nic_poll_controller, |
| 533 | #endif |
| 534 | }; |
| 535 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 536 | static void |
| 537 | netxen_setup_intr(struct netxen_adapter *adapter) |
| 538 | { |
| 539 | struct netxen_legacy_intr_set *legacy_intrp; |
| 540 | struct pci_dev *pdev = adapter->pdev; |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 541 | int err, num_msix; |
| 542 | |
| 543 | if (adapter->rss_supported) { |
| 544 | num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ? |
| 545 | MSIX_ENTRIES_PER_ADAPTER : 2; |
| 546 | } else |
| 547 | num_msix = 1; |
| 548 | |
| 549 | adapter->max_sds_rings = 1; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 550 | |
| 551 | adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 552 | |
| 553 | if (adapter->ahw.revision_id >= NX_P3_B0) |
| 554 | legacy_intrp = &legacy_intr[adapter->ahw.pci_func]; |
| 555 | else |
| 556 | legacy_intrp = &legacy_intr[0]; |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 557 | |
| 558 | adapter->int_vec_bit = legacy_intrp->int_vec_bit; |
| 559 | adapter->tgt_status_reg = netxen_get_ioaddr(adapter, |
| 560 | legacy_intrp->tgt_status_reg); |
| 561 | adapter->tgt_mask_reg = netxen_get_ioaddr(adapter, |
| 562 | legacy_intrp->tgt_mask_reg); |
| 563 | adapter->pci_int_reg = netxen_get_ioaddr(adapter, |
| 564 | legacy_intrp->pci_int_reg); |
| 565 | adapter->isr_int_vec = netxen_get_ioaddr(adapter, ISR_INT_VECTOR); |
| 566 | |
| 567 | if (adapter->ahw.revision_id >= NX_P3_B1) |
| 568 | adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, |
| 569 | ISR_INT_STATE_REG); |
| 570 | else |
| 571 | adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, |
| 572 | CRB_INT_VECTOR); |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 573 | |
| 574 | netxen_set_msix_bit(pdev, 0); |
| 575 | |
| 576 | if (adapter->msix_supported) { |
| 577 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 578 | netxen_init_msix_entries(adapter, num_msix); |
| 579 | err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); |
| 580 | if (err == 0) { |
| 581 | adapter->flags |= NETXEN_NIC_MSIX_ENABLED; |
| 582 | netxen_set_msix_bit(pdev, 1); |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 583 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 584 | if (adapter->rss_supported) |
| 585 | adapter->max_sds_rings = num_msix; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 586 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 587 | dev_info(&pdev->dev, "using msi-x interrupts\n"); |
| 588 | return; |
| 589 | } |
| 590 | |
| 591 | if (err > 0) |
| 592 | pci_disable_msix(pdev); |
| 593 | |
| 594 | /* fall through for msi */ |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 595 | } |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 596 | |
| 597 | if (use_msi && !pci_enable_msi(pdev)) { |
| 598 | adapter->flags |= NETXEN_NIC_MSI_ENABLED; |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 599 | adapter->tgt_status_reg = netxen_get_ioaddr(adapter, |
| 600 | msi_tgt_status[adapter->ahw.pci_func]); |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 601 | dev_info(&pdev->dev, "using msi interrupts\n"); |
Dhananjay Phadke | f67f340 | 2009-05-18 21:46:40 -0700 | [diff] [blame] | 602 | adapter->msix_entries[0].vector = pdev->irq; |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 603 | return; |
| 604 | } |
| 605 | |
| 606 | dev_info(&pdev->dev, "using legacy interrupts\n"); |
| 607 | adapter->msix_entries[0].vector = pdev->irq; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | static void |
| 611 | netxen_teardown_intr(struct netxen_adapter *adapter) |
| 612 | { |
| 613 | if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) |
| 614 | pci_disable_msix(adapter->pdev); |
| 615 | if (adapter->flags & NETXEN_NIC_MSI_ENABLED) |
| 616 | pci_disable_msi(adapter->pdev); |
| 617 | } |
| 618 | |
| 619 | static void |
| 620 | netxen_cleanup_pci_map(struct netxen_adapter *adapter) |
| 621 | { |
| 622 | if (adapter->ahw.db_base != NULL) |
| 623 | iounmap(adapter->ahw.db_base); |
| 624 | if (adapter->ahw.pci_base0 != NULL) |
| 625 | iounmap(adapter->ahw.pci_base0); |
| 626 | if (adapter->ahw.pci_base1 != NULL) |
| 627 | iounmap(adapter->ahw.pci_base1); |
| 628 | if (adapter->ahw.pci_base2 != NULL) |
| 629 | iounmap(adapter->ahw.pci_base2); |
| 630 | } |
| 631 | |
| 632 | static int |
| 633 | netxen_setup_pci_map(struct netxen_adapter *adapter) |
| 634 | { |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 635 | void __iomem *db_ptr = NULL; |
| 636 | |
Dhananjay Phadke | 71fb62f | 2009-10-13 00:26:04 -0700 | [diff] [blame] | 637 | resource_size_t mem_base, db_base; |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 638 | unsigned long mem_len, db_len = 0; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 639 | |
| 640 | struct pci_dev *pdev = adapter->pdev; |
| 641 | int pci_func = adapter->ahw.pci_func; |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 642 | struct netxen_hardware_context *ahw = &adapter->ahw; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 643 | |
| 644 | int err = 0; |
| 645 | |
| 646 | /* |
| 647 | * Set the CRB window to invalid. If any register in window 0 is |
| 648 | * accessed it should set the window to 0 and then reset it to 1. |
| 649 | */ |
Dhananjay Phadke | 907fa12 | 2009-10-13 05:31:43 +0000 | [diff] [blame] | 650 | adapter->ahw.crb_win = -1; |
Dhananjay Phadke | 47abe35 | 2009-10-13 05:31:42 +0000 | [diff] [blame] | 651 | adapter->ahw.ocm_win = -1; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 652 | |
| 653 | /* remap phys address */ |
| 654 | mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ |
| 655 | mem_len = pci_resource_len(pdev, 0); |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 656 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 657 | /* 128 Meg of memory */ |
| 658 | if (mem_len == NETXEN_PCI_128MB_SIZE) { |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 659 | |
| 660 | ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); |
| 661 | ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 662 | SECOND_PAGE_GROUP_SIZE); |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 663 | ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 664 | THIRD_PAGE_GROUP_SIZE); |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 665 | if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL || |
| 666 | ahw->pci_base2 == NULL) { |
| 667 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); |
| 668 | err = -EIO; |
| 669 | goto err_out; |
| 670 | } |
| 671 | |
| 672 | ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE; |
| 673 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 674 | } else if (mem_len == NETXEN_PCI_32MB_SIZE) { |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 675 | |
| 676 | ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); |
| 677 | ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 678 | SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 679 | if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) { |
| 680 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); |
| 681 | err = -EIO; |
| 682 | goto err_out; |
| 683 | } |
| 684 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 685 | } else if (mem_len == NETXEN_PCI_2MB_SIZE) { |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 686 | |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 687 | ahw->pci_base0 = pci_ioremap_bar(pdev, 0); |
| 688 | if (ahw->pci_base0 == NULL) { |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 689 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); |
| 690 | return -EIO; |
| 691 | } |
Amit Kumar Salecha | afbe5cd | 2010-03-26 00:30:09 +0000 | [diff] [blame] | 692 | ahw->pci_len0 = mem_len; |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 693 | } else { |
| 694 | return -EIO; |
| 695 | } |
| 696 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 697 | netxen_setup_hwops(adapter); |
| 698 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 699 | dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); |
| 700 | |
Amit Kumar Salecha | 6abb4b8 | 2009-10-16 15:50:09 +0000 | [diff] [blame] | 701 | if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) { |
| 702 | adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, |
| 703 | NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func))); |
| 704 | |
| 705 | } else if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
Dhananjay Phadke | 47abe35 | 2009-10-13 05:31:42 +0000 | [diff] [blame] | 706 | adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, |
| 707 | NETXEN_PCIX_PS_REG(PCIE_MN_WINDOW_REG(pci_func))); |
| 708 | } |
| 709 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 710 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 711 | goto skip_doorbell; |
| 712 | |
| 713 | db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ |
| 714 | db_len = pci_resource_len(pdev, 4); |
| 715 | |
| 716 | if (db_len == 0) { |
| 717 | printk(KERN_ERR "%s: doorbell is disabled\n", |
| 718 | netxen_nic_driver_name); |
| 719 | err = -EIO; |
| 720 | goto err_out; |
| 721 | } |
| 722 | |
| 723 | db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); |
| 724 | if (!db_ptr) { |
| 725 | printk(KERN_ERR "%s: Failed to allocate doorbell map.", |
| 726 | netxen_nic_driver_name); |
| 727 | err = -EIO; |
| 728 | goto err_out; |
| 729 | } |
| 730 | |
| 731 | skip_doorbell: |
| 732 | adapter->ahw.db_base = db_ptr; |
| 733 | adapter->ahw.db_len = db_len; |
| 734 | return 0; |
| 735 | |
| 736 | err_out: |
| 737 | netxen_cleanup_pci_map(adapter); |
| 738 | return err; |
| 739 | } |
| 740 | |
Dhananjay Phadke | 2b9e62e | 2009-09-05 17:43:11 +0000 | [diff] [blame] | 741 | static void |
| 742 | netxen_check_options(struct netxen_adapter *adapter) |
| 743 | { |
| 744 | u32 fw_major, fw_minor, fw_build; |
| 745 | char brd_name[NETXEN_MAX_SHORT_NAME]; |
| 746 | char serial_num[32]; |
| 747 | int i, offset, val; |
| 748 | int *ptr32; |
| 749 | struct pci_dev *pdev = adapter->pdev; |
| 750 | |
| 751 | adapter->driver_mismatch = 0; |
| 752 | |
| 753 | ptr32 = (int *)&serial_num; |
| 754 | offset = NX_FW_SERIAL_NUM_OFFSET; |
| 755 | for (i = 0; i < 8; i++) { |
| 756 | if (netxen_rom_fast_read(adapter, offset, &val) == -1) { |
| 757 | dev_err(&pdev->dev, "error reading board info\n"); |
| 758 | adapter->driver_mismatch = 1; |
| 759 | return; |
| 760 | } |
| 761 | ptr32[i] = cpu_to_le32(val); |
| 762 | offset += sizeof(u32); |
| 763 | } |
| 764 | |
| 765 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); |
| 766 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); |
| 767 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); |
| 768 | |
| 769 | adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); |
| 770 | |
| 771 | if (adapter->portnum == 0) { |
| 772 | get_brd_name_by_type(adapter->ahw.board_type, brd_name); |
| 773 | |
Dhananjay Phadke | c25c0b9 | 2009-10-28 04:11:04 -0700 | [diff] [blame] | 774 | pr_info("%s: %s Board S/N %s Chip rev 0x%x\n", |
| 775 | module_name(THIS_MODULE), |
Dhananjay Phadke | 2b9e62e | 2009-09-05 17:43:11 +0000 | [diff] [blame] | 776 | brd_name, serial_num, adapter->ahw.revision_id); |
| 777 | } |
| 778 | |
| 779 | if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) { |
| 780 | adapter->driver_mismatch = 1; |
| 781 | dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n", |
| 782 | fw_major, fw_minor, fw_build); |
| 783 | return; |
| 784 | } |
| 785 | |
| 786 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
| 787 | i = NXRD32(adapter, NETXEN_SRE_MISC); |
| 788 | adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; |
| 789 | } |
| 790 | |
| 791 | dev_info(&pdev->dev, "firmware v%d.%d.%d [%s]\n", |
| 792 | fw_major, fw_minor, fw_build, |
| 793 | adapter->ahw.cut_through ? "cut-through" : "legacy"); |
| 794 | |
| 795 | if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) |
| 796 | adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); |
| 797 | |
Dhananjay Phadke | 2b9e62e | 2009-09-05 17:43:11 +0000 | [diff] [blame] | 798 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { |
| 799 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; |
| 800 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; |
| 801 | } else if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
| 802 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; |
| 803 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; |
| 804 | } |
| 805 | |
| 806 | adapter->msix_supported = 0; |
| 807 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
| 808 | adapter->msix_supported = !!use_msi_x; |
| 809 | adapter->rss_supported = !!use_msi_x; |
Amit Kumar Salecha | 083ba27 | 2010-03-29 02:43:45 +0000 | [diff] [blame] | 810 | } else { |
| 811 | u32 flashed_ver = 0; |
| 812 | netxen_rom_fast_read(adapter, |
| 813 | NX_FW_VERSION_OFFSET, (int *)&flashed_ver); |
| 814 | flashed_ver = NETXEN_DECODE_VERSION(flashed_ver); |
| 815 | |
| 816 | if (flashed_ver >= NETXEN_VERSION_CODE(3, 4, 336)) { |
| 817 | switch (adapter->ahw.board_type) { |
| 818 | case NETXEN_BRDTYPE_P2_SB31_10G: |
| 819 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: |
| 820 | adapter->msix_supported = !!use_msi_x; |
| 821 | adapter->rss_supported = !!use_msi_x; |
| 822 | break; |
| 823 | default: |
| 824 | break; |
| 825 | } |
Dhananjay Phadke | 2b9e62e | 2009-09-05 17:43:11 +0000 | [diff] [blame] | 826 | } |
| 827 | } |
| 828 | |
| 829 | adapter->num_txd = MAX_CMD_DESCRIPTORS; |
| 830 | |
| 831 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
| 832 | adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS; |
| 833 | adapter->max_rds_rings = 3; |
| 834 | } else { |
| 835 | adapter->num_lro_rxd = 0; |
| 836 | adapter->max_rds_rings = 2; |
| 837 | } |
| 838 | } |
| 839 | |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 840 | static int |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 841 | netxen_start_firmware(struct netxen_adapter *adapter) |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 842 | { |
| 843 | int val, err, first_boot; |
| 844 | struct pci_dev *pdev = adapter->pdev; |
| 845 | |
Dhananjay Phadke | 2b9e62e | 2009-09-05 17:43:11 +0000 | [diff] [blame] | 846 | /* required for NX2031 dummy dma */ |
| 847 | err = nx_set_dma_mask(adapter); |
| 848 | if (err) |
| 849 | return err; |
| 850 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 851 | if (!netxen_can_start_firmware(adapter)) |
Dhananjay Phadke | 96f2ebd | 2009-06-22 20:26:21 +0000 | [diff] [blame] | 852 | goto wait_init; |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 853 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 854 | first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc)); |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 855 | |
| 856 | err = netxen_check_hw_init(adapter, first_boot); |
| 857 | if (err) { |
| 858 | dev_err(&pdev->dev, "error in init HW init sequence\n"); |
| 859 | return err; |
| 860 | } |
| 861 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 862 | netxen_request_firmware(adapter); |
Dhananjay Phadke | f7185c7 | 2009-04-28 15:29:11 +0000 | [diff] [blame] | 863 | |
Dhananjay Phadke | 67c38fc | 2009-07-01 11:41:43 +0000 | [diff] [blame] | 864 | err = netxen_need_fw_reset(adapter); |
Dhananjay Phadke | 1dbc84a | 2009-08-23 08:35:10 +0000 | [diff] [blame] | 865 | if (err < 0) |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 866 | goto err_out; |
Dhananjay Phadke | 1dbc84a | 2009-08-23 08:35:10 +0000 | [diff] [blame] | 867 | if (err == 0) |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 868 | goto wait_init; |
Dhananjay Phadke | 67c38fc | 2009-07-01 11:41:43 +0000 | [diff] [blame] | 869 | |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 870 | if (first_boot != 0x55555555) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 871 | NXWR32(adapter, CRB_CMDPEG_STATE, 0); |
Amit Kumar Salecha | 0be367b | 2009-10-16 15:50:08 +0000 | [diff] [blame] | 872 | netxen_pinit_from_rom(adapter); |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 873 | msleep(1); |
| 874 | } |
Dhananjay Phadke | 567c6c4 | 2009-03-02 16:02:17 +0000 | [diff] [blame] | 875 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 876 | NXWR32(adapter, CRB_DMA_SHIFT, 0x55555555); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 877 | NXWR32(adapter, NETXEN_PEG_HALT_STATUS1, 0); |
| 878 | NXWR32(adapter, NETXEN_PEG_HALT_STATUS2, 0); |
| 879 | |
Dhananjay Phadke | 567c6c4 | 2009-03-02 16:02:17 +0000 | [diff] [blame] | 880 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 881 | netxen_set_port_mode(adapter); |
| 882 | |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 883 | err = netxen_load_firmware(adapter); |
| 884 | if (err) |
| 885 | goto err_out; |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 886 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 887 | netxen_release_firmware(adapter); |
| 888 | |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 889 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
| 890 | |
| 891 | /* Initialize multicast addr pool owners */ |
| 892 | val = 0x7654; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 893 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 894 | val |= 0x0f000000; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 895 | NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val); |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 896 | |
| 897 | } |
| 898 | |
Dhananjay Phadke | 83ac51f | 2009-07-26 20:07:39 +0000 | [diff] [blame] | 899 | err = netxen_init_dummy_dma(adapter); |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 900 | if (err) |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 901 | goto err_out; |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 902 | |
| 903 | /* |
| 904 | * Tell the hardware our version number. |
| 905 | */ |
| 906 | val = (_NETXEN_NIC_LINUX_MAJOR << 16) |
| 907 | | ((_NETXEN_NIC_LINUX_MINOR << 8)) |
| 908 | | (_NETXEN_NIC_LINUX_SUBVERSION); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 909 | NXWR32(adapter, CRB_DRIVER_VERSION, val); |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 910 | |
Dhananjay Phadke | 96f2ebd | 2009-06-22 20:26:21 +0000 | [diff] [blame] | 911 | wait_init: |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 912 | /* Handshake with the card before we register the devices. */ |
| 913 | err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); |
| 914 | if (err) { |
Dhananjay Phadke | 83ac51f | 2009-07-26 20:07:39 +0000 | [diff] [blame] | 915 | netxen_free_dummy_dma(adapter); |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 916 | goto err_out; |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 917 | } |
| 918 | |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 919 | NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_READY); |
| 920 | |
Dhananjay Phadke | 68b3cae | 2009-07-26 20:07:36 +0000 | [diff] [blame] | 921 | nx_update_dma_mask(adapter); |
| 922 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 923 | netxen_check_options(adapter); |
Dhananjay Phadke | 68b3cae | 2009-07-26 20:07:36 +0000 | [diff] [blame] | 924 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 925 | adapter->need_fw_reset = 0; |
| 926 | |
Dhananjay Phadke | ec5c50c | 2009-09-11 11:28:13 +0000 | [diff] [blame] | 927 | /* fall through and release firmware */ |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 928 | |
| 929 | err_out: |
| 930 | netxen_release_firmware(adapter); |
| 931 | return err; |
Dhananjay Phadke | ba599d4 | 2009-02-24 16:38:22 -0800 | [diff] [blame] | 932 | } |
| 933 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 934 | static int |
| 935 | netxen_nic_request_irq(struct netxen_adapter *adapter) |
| 936 | { |
| 937 | irq_handler_t handler; |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 938 | struct nx_host_sds_ring *sds_ring; |
| 939 | int err, ring; |
| 940 | |
Javier Martinez Canillas | ab392d2 | 2011-03-28 16:27:31 +0000 | [diff] [blame] | 941 | unsigned long flags = 0; |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 942 | struct net_device *netdev = adapter->netdev; |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 943 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 944 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 945 | if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) |
| 946 | handler = netxen_msix_intr; |
| 947 | else if (adapter->flags & NETXEN_NIC_MSI_ENABLED) |
| 948 | handler = netxen_msi_intr; |
| 949 | else { |
| 950 | flags |= IRQF_SHARED; |
| 951 | handler = netxen_intr; |
| 952 | } |
| 953 | adapter->irq = netdev->irq; |
| 954 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 955 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 956 | sds_ring = &recv_ctx->sds_rings[ring]; |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 957 | sprintf(sds_ring->name, "%s[%d]", netdev->name, ring); |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 958 | err = request_irq(sds_ring->irq, handler, |
| 959 | flags, sds_ring->name, sds_ring); |
| 960 | if (err) |
| 961 | return err; |
| 962 | } |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | static void |
| 968 | netxen_nic_free_irq(struct netxen_adapter *adapter) |
| 969 | { |
| 970 | int ring; |
| 971 | struct nx_host_sds_ring *sds_ring; |
| 972 | |
| 973 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 974 | |
| 975 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 976 | sds_ring = &recv_ctx->sds_rings[ring]; |
| 977 | free_irq(sds_ring->irq, sds_ring); |
| 978 | } |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 979 | } |
| 980 | |
Dhananjay Phadke | ca2ef33 | 2009-07-26 20:07:38 +0000 | [diff] [blame] | 981 | static void |
| 982 | netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter) |
| 983 | { |
| 984 | adapter->coal.flags = NETXEN_NIC_INTR_DEFAULT; |
| 985 | adapter->coal.normal.data.rx_time_us = |
| 986 | NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US; |
| 987 | adapter->coal.normal.data.rx_packets = |
| 988 | NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS; |
| 989 | adapter->coal.normal.data.tx_time_us = |
| 990 | NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US; |
| 991 | adapter->coal.normal.data.tx_packets = |
| 992 | NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS; |
| 993 | } |
| 994 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 995 | /* with rtnl_lock */ |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 996 | static int |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 997 | __netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 998 | { |
| 999 | int err; |
| 1000 | |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 1001 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 1002 | return -EIO; |
| 1003 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1004 | err = adapter->init_port(adapter, adapter->physical_port); |
| 1005 | if (err) { |
| 1006 | printk(KERN_ERR "%s: Failed to initialize port %d\n", |
| 1007 | netxen_nic_driver_name, adapter->portnum); |
| 1008 | return err; |
| 1009 | } |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 1010 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
Narender Kumar | 5d09e53 | 2009-11-20 22:08:57 +0000 | [diff] [blame] | 1011 | adapter->macaddr_set(adapter, adapter->mac_addr); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1012 | |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 1013 | adapter->set_multi(netdev); |
| 1014 | adapter->set_mtu(adapter, netdev->mtu); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1015 | |
| 1016 | adapter->ahw.linkup = 0; |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1017 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 1018 | if (adapter->max_sds_rings > 1) |
| 1019 | netxen_config_rss(adapter, 1); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1020 | |
Dhananjay Phadke | ca2ef33 | 2009-07-26 20:07:38 +0000 | [diff] [blame] | 1021 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 1022 | netxen_config_intr_coalesce(adapter); |
| 1023 | |
Sucheta Chakraborty | e4baaf7 | 2011-01-02 21:58:44 +0000 | [diff] [blame] | 1024 | if (netdev->features & NETIF_F_LRO) |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 1025 | netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_ENABLED); |
| 1026 | |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 1027 | netxen_napi_enable(adapter); |
| 1028 | |
Dhananjay Phadke | 5103c9f | 2009-04-28 15:29:09 +0000 | [diff] [blame] | 1029 | if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION) |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 1030 | netxen_linkevent_request(adapter, 1); |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 1031 | else |
| 1032 | netxen_nic_set_link_parameters(adapter); |
| 1033 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1034 | set_bit(__NX_DEV_UP, &adapter->state); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1035 | return 0; |
| 1036 | } |
| 1037 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1038 | /* Usage: During resume and firmware recovery module.*/ |
| 1039 | |
| 1040 | static inline int |
| 1041 | netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) |
| 1042 | { |
| 1043 | int err = 0; |
| 1044 | |
| 1045 | rtnl_lock(); |
| 1046 | if (netif_running(netdev)) |
| 1047 | err = __netxen_nic_up(adapter, netdev); |
| 1048 | rtnl_unlock(); |
| 1049 | |
| 1050 | return err; |
| 1051 | } |
| 1052 | |
| 1053 | /* with rtnl_lock */ |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1054 | static void |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1055 | __netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1056 | { |
Dhananjay Phadke | db4cfd8 | 2009-09-05 17:43:07 +0000 | [diff] [blame] | 1057 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 1058 | return; |
| 1059 | |
Amit Kumar Salecha | f2251f6 | 2009-12-05 12:23:55 +0000 | [diff] [blame] | 1060 | if (!test_and_clear_bit(__NX_DEV_UP, &adapter->state)) |
| 1061 | return; |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1062 | |
Amit Kumar Salecha | f2251f6 | 2009-12-05 12:23:55 +0000 | [diff] [blame] | 1063 | smp_mb(); |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 1064 | spin_lock(&adapter->tx_clean_lock); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1065 | netif_carrier_off(netdev); |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 1066 | netif_tx_disable(netdev); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1067 | |
Sony Chacko | d478af0 | 2011-03-10 23:50:02 +0000 | [diff] [blame] | 1068 | if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION) |
| 1069 | netxen_linkevent_request(adapter, 0); |
| 1070 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1071 | if (adapter->stop_port) |
| 1072 | adapter->stop_port(adapter); |
| 1073 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 1074 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 1075 | netxen_p3_free_mac_list(adapter); |
| 1076 | |
Amit Kumar Salecha | 22b5794 | 2009-08-23 08:35:12 +0000 | [diff] [blame] | 1077 | adapter->set_promisc(adapter, NETXEN_NIU_NON_PROMISC_MODE); |
| 1078 | |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 1079 | netxen_napi_disable(adapter); |
| 1080 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1081 | netxen_release_tx_buffers(adapter); |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 1082 | spin_unlock(&adapter->tx_clean_lock); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1085 | /* Usage: During suspend and firmware recovery module */ |
| 1086 | |
| 1087 | static inline void |
| 1088 | netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) |
| 1089 | { |
| 1090 | rtnl_lock(); |
| 1091 | if (netif_running(netdev)) |
| 1092 | __netxen_nic_down(adapter, netdev); |
| 1093 | rtnl_unlock(); |
| 1094 | |
| 1095 | } |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1096 | |
| 1097 | static int |
| 1098 | netxen_nic_attach(struct netxen_adapter *adapter) |
| 1099 | { |
| 1100 | struct net_device *netdev = adapter->netdev; |
| 1101 | struct pci_dev *pdev = adapter->pdev; |
Dhananjay Phadke | becf46a | 2009-03-09 08:50:55 +0000 | [diff] [blame] | 1102 | int err, ring; |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 1103 | struct nx_host_rds_ring *rds_ring; |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 1104 | struct nx_host_tx_ring *tx_ring; |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1105 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1106 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) |
| 1107 | return 0; |
| 1108 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1109 | err = netxen_init_firmware(adapter); |
Dhananjay Phadke | 232e7d6 | 2009-08-13 07:03:01 +0000 | [diff] [blame] | 1110 | if (err) |
| 1111 | return err; |
| 1112 | |
| 1113 | err = netxen_napi_add(adapter, netdev); |
| 1114 | if (err) |
| 1115 | return err; |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1116 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1117 | err = netxen_alloc_sw_resources(adapter); |
| 1118 | if (err) { |
| 1119 | printk(KERN_ERR "%s: Error in setting sw resources\n", |
| 1120 | netdev->name); |
| 1121 | return err; |
| 1122 | } |
| 1123 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1124 | err = netxen_alloc_hw_resources(adapter); |
| 1125 | if (err) { |
| 1126 | printk(KERN_ERR "%s: Error in setting hw resources\n", |
| 1127 | netdev->name); |
| 1128 | goto err_out_free_sw; |
| 1129 | } |
| 1130 | |
Dhananjay Phadke | 4f96b98 | 2009-07-26 20:07:42 +0000 | [diff] [blame] | 1131 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
Dhananjay Phadke | 4ea528a | 2009-04-28 15:29:10 +0000 | [diff] [blame] | 1132 | tx_ring = adapter->tx_ring; |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 1133 | tx_ring->crb_cmd_producer = netxen_get_ioaddr(adapter, |
| 1134 | crb_cmd_producer[adapter->portnum]); |
| 1135 | tx_ring->crb_cmd_consumer = netxen_get_ioaddr(adapter, |
| 1136 | crb_cmd_consumer[adapter->portnum]); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1137 | |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 1138 | tx_ring->producer = 0; |
| 1139 | tx_ring->sw_consumer = 0; |
| 1140 | |
| 1141 | netxen_nic_update_cmd_producer(adapter, tx_ring); |
| 1142 | netxen_nic_update_cmd_consumer(adapter, tx_ring); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 1145 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
| 1146 | rds_ring = &adapter->recv_ctx.rds_rings[ring]; |
| 1147 | netxen_post_rx_buffers(adapter, ring, rds_ring); |
| 1148 | } |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1149 | |
| 1150 | err = netxen_nic_request_irq(adapter); |
| 1151 | if (err) { |
| 1152 | dev_err(&pdev->dev, "%s: failed to setup interrupt\n", |
| 1153 | netdev->name); |
| 1154 | goto err_out_free_rxbuf; |
| 1155 | } |
| 1156 | |
Dhananjay Phadke | ca2ef33 | 2009-07-26 20:07:38 +0000 | [diff] [blame] | 1157 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 1158 | netxen_nic_init_coalesce_defaults(adapter); |
| 1159 | |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 1160 | netxen_create_sysfs_entries(adapter); |
| 1161 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1162 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; |
| 1163 | return 0; |
| 1164 | |
| 1165 | err_out_free_rxbuf: |
| 1166 | netxen_release_rx_buffers(adapter); |
| 1167 | netxen_free_hw_resources(adapter); |
| 1168 | err_out_free_sw: |
| 1169 | netxen_free_sw_resources(adapter); |
| 1170 | return err; |
| 1171 | } |
| 1172 | |
| 1173 | static void |
| 1174 | netxen_nic_detach(struct netxen_adapter *adapter) |
| 1175 | { |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1176 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 1177 | return; |
| 1178 | |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 1179 | netxen_remove_sysfs_entries(adapter); |
| 1180 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1181 | netxen_free_hw_resources(adapter); |
Dhananjay Phadke | cf981ff | 2009-07-17 15:27:06 +0000 | [diff] [blame] | 1182 | netxen_release_rx_buffers(adapter); |
Dhananjay Phadke | be339ae | 2009-05-08 22:02:28 +0000 | [diff] [blame] | 1183 | netxen_nic_free_irq(adapter); |
Dhananjay Phadke | 232e7d6 | 2009-08-13 07:03:01 +0000 | [diff] [blame] | 1184 | netxen_napi_del(adapter); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1185 | netxen_free_sw_resources(adapter); |
| 1186 | |
| 1187 | adapter->is_up = 0; |
| 1188 | } |
| 1189 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1190 | int |
| 1191 | netxen_nic_reset_context(struct netxen_adapter *adapter) |
| 1192 | { |
| 1193 | int err = 0; |
| 1194 | struct net_device *netdev = adapter->netdev; |
| 1195 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1196 | if (test_and_set_bit(__NX_RESETTING, &adapter->state)) |
| 1197 | return -EBUSY; |
| 1198 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1199 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { |
| 1200 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1201 | netif_device_detach(netdev); |
| 1202 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1203 | if (netif_running(netdev)) |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1204 | __netxen_nic_down(adapter, netdev); |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1205 | |
| 1206 | netxen_nic_detach(adapter); |
| 1207 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1208 | if (netif_running(netdev)) { |
| 1209 | err = netxen_nic_attach(adapter); |
| 1210 | if (!err) |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1211 | err = __netxen_nic_up(adapter, netdev); |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1212 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1213 | if (err) |
| 1214 | goto done; |
| 1215 | } |
| 1216 | |
| 1217 | netif_device_attach(netdev); |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1218 | } |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1219 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1220 | done: |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1221 | clear_bit(__NX_RESETTING, &adapter->state); |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1222 | return err; |
| 1223 | } |
| 1224 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1225 | static int |
| 1226 | netxen_setup_netdev(struct netxen_adapter *adapter, |
| 1227 | struct net_device *netdev) |
| 1228 | { |
| 1229 | int err = 0; |
| 1230 | struct pci_dev *pdev = adapter->pdev; |
| 1231 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1232 | adapter->mc_enabled = 0; |
| 1233 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 1234 | adapter->max_mc_count = 38; |
| 1235 | else |
| 1236 | adapter->max_mc_count = 16; |
| 1237 | |
| 1238 | netdev->netdev_ops = &netxen_netdev_ops; |
Rajesh Borundia | 7a9905e | 2010-10-18 02:03:41 +0000 | [diff] [blame] | 1239 | netdev->watchdog_timeo = 5*HZ; |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1240 | |
| 1241 | netxen_nic_change_mtu(netdev, netdev->mtu); |
| 1242 | |
| 1243 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); |
| 1244 | |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 1245 | netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | |
| 1246 | NETIF_F_RXCSUM; |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1247 | |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 1248 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 1249 | netdev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6; |
| 1250 | |
| 1251 | netdev->vlan_features |= netdev->hw_features; |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1252 | |
| 1253 | if (adapter->pci_using_dac) { |
| 1254 | netdev->features |= NETIF_F_HIGHDMA; |
| 1255 | netdev->vlan_features |= NETIF_F_HIGHDMA; |
| 1256 | } |
| 1257 | |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1258 | if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX) |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 1259 | netdev->hw_features |= NETIF_F_HW_VLAN_TX; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1260 | |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 1261 | if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) |
Michał Mirosław | 066413d | 2011-04-05 01:36:58 +0000 | [diff] [blame] | 1262 | netdev->hw_features |= NETIF_F_LRO; |
| 1263 | |
| 1264 | netdev->features |= netdev->hw_features; |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 1265 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1266 | netdev->irq = adapter->msix_entries[0].vector; |
| 1267 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 1268 | INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task); |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1269 | |
| 1270 | if (netxen_read_mac_addr(adapter)) |
| 1271 | dev_warn(&pdev->dev, "failed to read mac addr\n"); |
| 1272 | |
| 1273 | netif_carrier_off(netdev); |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1274 | |
| 1275 | err = register_netdev(netdev); |
| 1276 | if (err) { |
| 1277 | dev_err(&pdev->dev, "failed to register net device\n"); |
| 1278 | return err; |
| 1279 | } |
| 1280 | |
| 1281 | return 0; |
| 1282 | } |
| 1283 | |
amit salecha | dce87b9 | 2010-10-18 02:03:42 +0000 | [diff] [blame] | 1284 | #ifdef CONFIG_PCIEAER |
| 1285 | static void netxen_mask_aer_correctable(struct netxen_adapter *adapter) |
| 1286 | { |
| 1287 | struct pci_dev *pdev = adapter->pdev; |
| 1288 | struct pci_dev *root = pdev->bus->self; |
| 1289 | u32 aer_pos; |
| 1290 | |
| 1291 | if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM && |
| 1292 | adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) |
| 1293 | return; |
| 1294 | |
| 1295 | if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT) |
| 1296 | return; |
| 1297 | |
| 1298 | aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR); |
| 1299 | if (!aer_pos) |
| 1300 | return; |
| 1301 | |
| 1302 | pci_write_config_dword(root, aer_pos + PCI_ERR_COR_MASK, 0xffff); |
| 1303 | } |
| 1304 | #endif |
| 1305 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1306 | static int __devinit |
| 1307 | netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 1308 | { |
| 1309 | struct net_device *netdev = NULL; |
| 1310 | struct netxen_adapter *adapter = NULL; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1311 | int i = 0, err; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1312 | int pci_func_id = PCI_FUNC(pdev->devfn); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1313 | uint8_t revision_id; |
Rajesh Borundia | 5a6f95e | 2010-11-23 03:08:27 +0000 | [diff] [blame] | 1314 | u32 val; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1315 | |
Eric W. Biederman | 688328c | 2010-03-17 22:24:39 +0000 | [diff] [blame] | 1316 | if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) { |
| 1317 | pr_warning("%s: chip revisions between 0x%x-0x%x " |
Dhananjay Phadke | 11d89d6 | 2008-08-08 00:08:45 -0700 | [diff] [blame] | 1318 | "will not be enabled.\n", |
Dhananjay Phadke | c25c0b9 | 2009-10-28 04:11:04 -0700 | [diff] [blame] | 1319 | module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1); |
Dhananjay Phadke | 11d89d6 | 2008-08-08 00:08:45 -0700 | [diff] [blame] | 1320 | return -ENODEV; |
| 1321 | } |
| 1322 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1323 | if ((err = pci_enable_device(pdev))) |
| 1324 | return err; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1325 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1326 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
| 1327 | err = -ENODEV; |
| 1328 | goto err_out_disable_pdev; |
| 1329 | } |
| 1330 | |
| 1331 | if ((err = pci_request_regions(pdev, netxen_nic_driver_name))) |
| 1332 | goto err_out_disable_pdev; |
| 1333 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 1334 | if (NX_IS_REVISION_P3(pdev->revision)) |
| 1335 | pci_enable_pcie_error_reporting(pdev); |
| 1336 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1337 | pci_set_master(pdev); |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1338 | |
| 1339 | netdev = alloc_etherdev(sizeof(struct netxen_adapter)); |
| 1340 | if(!netdev) { |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1341 | dev_err(&pdev->dev, "failed to allocate net_device\n"); |
| 1342 | err = -ENOMEM; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1343 | goto err_out_free_res; |
| 1344 | } |
| 1345 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1346 | SET_NETDEV_DEV(netdev, &pdev->dev); |
| 1347 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1348 | adapter = netdev_priv(netdev); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1349 | adapter->netdev = netdev; |
| 1350 | adapter->pdev = pdev; |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 1351 | adapter->ahw.pci_func = pci_func_id; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1352 | |
| 1353 | revision_id = pdev->revision; |
| 1354 | adapter->ahw.revision_id = revision_id; |
| 1355 | |
Dhananjay Phadke | f03b0eb | 2009-10-13 05:31:44 +0000 | [diff] [blame] | 1356 | rwlock_init(&adapter->ahw.crb_lock); |
| 1357 | spin_lock_init(&adapter->ahw.mem_lock); |
| 1358 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 1359 | spin_lock_init(&adapter->tx_clean_lock); |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 1360 | INIT_LIST_HEAD(&adapter->mac_list); |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 1361 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1362 | err = netxen_setup_pci_map(adapter); |
| 1363 | if (err) |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1364 | goto err_out_free_netdev; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1365 | |
dhananjay.phadke@gmail.com | 2d1a3bb | 2007-07-02 00:26:00 +0530 | [diff] [blame] | 1366 | /* This will be reset for mezz cards */ |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1367 | adapter->portnum = pci_func_id; |
| 1368 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1369 | err = netxen_nic_get_board_info(adapter); |
| 1370 | if (err) { |
| 1371 | dev_err(&pdev->dev, "Error getting board config info.\n"); |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 1372 | goto err_out_iounmap; |
| 1373 | } |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1374 | |
amit salecha | dce87b9 | 2010-10-18 02:03:42 +0000 | [diff] [blame] | 1375 | #ifdef CONFIG_PCIEAER |
| 1376 | netxen_mask_aer_correctable(adapter); |
| 1377 | #endif |
| 1378 | |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 1379 | /* Mezz cards have PCI function 0,2,3 enabled */ |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 1380 | switch (adapter->ahw.board_type) { |
Dhananjay Phadke | dc515f2 | 2008-06-15 22:59:43 -0700 | [diff] [blame] | 1381 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
| 1382 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
| 1383 | if (pci_func_id >= 2) |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 1384 | adapter->portnum = pci_func_id - 2; |
Dhananjay Phadke | dc515f2 | 2008-06-15 22:59:43 -0700 | [diff] [blame] | 1385 | break; |
| 1386 | default: |
| 1387 | break; |
| 1388 | } |
Mithlesh Thukral | 13ba9c7 | 2007-04-20 07:53:05 -0700 | [diff] [blame] | 1389 | |
Rajesh Borundia | 5a6f95e | 2010-11-23 03:08:27 +0000 | [diff] [blame] | 1390 | if (adapter->portnum == 0) { |
| 1391 | val = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); |
| 1392 | if (val != 0xffffffff && val != 0) { |
Rajesh Borundia | 683b65f | 2010-10-26 22:51:50 +0000 | [diff] [blame] | 1393 | NXWR32(adapter, NX_CRB_DEV_REF_COUNT, 0); |
| 1394 | adapter->need_fw_reset = 1; |
| 1395 | } |
| 1396 | } |
| 1397 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1398 | err = netxen_start_firmware(adapter); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1399 | if (err) |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 1400 | goto err_out_decr_ref; |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1401 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1402 | /* |
| 1403 | * See if the firmware gave us a virtual-physical port mapping. |
| 1404 | */ |
| 1405 | adapter->physical_port = adapter->portnum; |
Dhananjay Phadke | 4f96b98 | 2009-07-26 20:07:42 +0000 | [diff] [blame] | 1406 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1407 | i = NXRD32(adapter, CRB_V2P(adapter->portnum)); |
Dhananjay Phadke | 044fad0 | 2009-02-24 03:42:59 -0800 | [diff] [blame] | 1408 | if (i != 0x55555555) |
| 1409 | adapter->physical_port = i; |
| 1410 | } |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1411 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1412 | netxen_nic_clear_stats(adapter); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1413 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1414 | netxen_setup_intr(adapter); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1415 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 1416 | err = netxen_setup_netdev(adapter, netdev); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 1417 | if (err) |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1418 | goto err_out_disable_msi; |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1419 | |
| 1420 | pci_set_drvdata(pdev, adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1421 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1422 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); |
| 1423 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 1424 | switch (adapter->ahw.port_type) { |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1425 | case NETXEN_NIC_GBE: |
| 1426 | dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", |
| 1427 | adapter->netdev->name); |
| 1428 | break; |
| 1429 | case NETXEN_NIC_XGBE: |
| 1430 | dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n", |
| 1431 | adapter->netdev->name); |
| 1432 | break; |
| 1433 | } |
| 1434 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 1435 | netxen_create_diag_entries(adapter); |
| 1436 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1437 | return 0; |
| 1438 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1439 | err_out_disable_msi: |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1440 | netxen_teardown_intr(adapter); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1441 | |
Dhananjay Phadke | 83ac51f | 2009-07-26 20:07:39 +0000 | [diff] [blame] | 1442 | netxen_free_dummy_dma(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1443 | |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 1444 | err_out_decr_ref: |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1445 | nx_decr_dev_ref_cnt(adapter); |
| 1446 | |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1447 | err_out_iounmap: |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1448 | netxen_cleanup_pci_map(adapter); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1449 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1450 | err_out_free_netdev: |
| 1451 | free_netdev(netdev); |
| 1452 | |
| 1453 | err_out_free_res: |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1454 | pci_release_regions(pdev); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1455 | |
| 1456 | err_out_disable_pdev: |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1457 | pci_set_drvdata(pdev, NULL); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1458 | pci_disable_device(pdev); |
| 1459 | return err; |
| 1460 | } |
| 1461 | |
| 1462 | static void __devexit netxen_nic_remove(struct pci_dev *pdev) |
| 1463 | { |
| 1464 | struct netxen_adapter *adapter; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1465 | struct net_device *netdev; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1466 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1467 | adapter = pci_get_drvdata(pdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1468 | if (adapter == NULL) |
| 1469 | return; |
| 1470 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1471 | netdev = adapter->netdev; |
| 1472 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1473 | netxen_cancel_fw_work(adapter); |
| 1474 | |
Dhananjay Phadke | 96acb6e | 2007-07-02 09:37:57 +0530 | [diff] [blame] | 1475 | unregister_netdev(netdev); |
| 1476 | |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 1477 | cancel_work_sync(&adapter->tx_timeout_task); |
| 1478 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1479 | netxen_nic_detach(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1480 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1481 | nx_decr_dev_ref_cnt(adapter); |
| 1482 | |
Dhananjay Phadke | 439b454 | 2008-06-15 22:59:46 -0700 | [diff] [blame] | 1483 | if (adapter->portnum == 0) |
Dhananjay Phadke | 83ac51f | 2009-07-26 20:07:39 +0000 | [diff] [blame] | 1484 | netxen_free_dummy_dma(adapter); |
Dhananjay Phadke | 96acb6e | 2007-07-02 09:37:57 +0530 | [diff] [blame] | 1485 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1486 | clear_bit(__NX_RESETTING, &adapter->state); |
| 1487 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1488 | netxen_teardown_intr(adapter); |
dhananjay@netxen.com | 3052246 | 2007-08-28 17:23:26 +0530 | [diff] [blame] | 1489 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 1490 | netxen_remove_diag_entries(adapter); |
| 1491 | |
Dhananjay Phadke | 97daee8 | 2009-02-24 16:39:21 -0800 | [diff] [blame] | 1492 | netxen_cleanup_pci_map(adapter); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 1493 | |
Dhananjay Phadke | f7185c7 | 2009-04-28 15:29:11 +0000 | [diff] [blame] | 1494 | netxen_release_firmware(adapter); |
| 1495 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 1496 | if (NX_IS_REVISION_P3(pdev->revision)) |
| 1497 | pci_disable_pcie_error_reporting(pdev); |
| 1498 | |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 1499 | pci_release_regions(pdev); |
dhananjay@netxen.com | 3052246 | 2007-08-28 17:23:26 +0530 | [diff] [blame] | 1500 | pci_disable_device(pdev); |
Mithlesh Thukral | 595e3fb | 2007-04-20 07:53:52 -0700 | [diff] [blame] | 1501 | pci_set_drvdata(pdev, NULL); |
| 1502 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1503 | free_netdev(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1504 | } |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 1505 | |
| 1506 | static void netxen_nic_detach_func(struct netxen_adapter *adapter) |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1507 | { |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1508 | struct net_device *netdev = adapter->netdev; |
| 1509 | |
| 1510 | netif_device_detach(netdev); |
| 1511 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1512 | netxen_cancel_fw_work(adapter); |
| 1513 | |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1514 | if (netif_running(netdev)) |
| 1515 | netxen_nic_down(adapter, netdev); |
| 1516 | |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 1517 | cancel_work_sync(&adapter->tx_timeout_task); |
| 1518 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1519 | netxen_nic_detach(adapter); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1520 | |
Amit Kumar Salecha | 22b5794 | 2009-08-23 08:35:12 +0000 | [diff] [blame] | 1521 | if (adapter->portnum == 0) |
| 1522 | netxen_free_dummy_dma(adapter); |
| 1523 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1524 | nx_decr_dev_ref_cnt(adapter); |
| 1525 | |
| 1526 | clear_bit(__NX_RESETTING, &adapter->state); |
Amit Kumar Salecha | 22b5794 | 2009-08-23 08:35:12 +0000 | [diff] [blame] | 1527 | } |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1528 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 1529 | static int netxen_nic_attach_func(struct pci_dev *pdev) |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1530 | { |
| 1531 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
| 1532 | struct net_device *netdev = adapter->netdev; |
| 1533 | int err; |
| 1534 | |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1535 | err = pci_enable_device(pdev); |
| 1536 | if (err) |
| 1537 | return err; |
| 1538 | |
Amit Kumar Salecha | bc86fcb | 2009-12-08 20:40:54 +0000 | [diff] [blame] | 1539 | pci_set_power_state(pdev, PCI_D0); |
| 1540 | pci_set_master(pdev); |
| 1541 | pci_restore_state(pdev); |
| 1542 | |
Dhananjay Phadke | 907fa12 | 2009-10-13 05:31:43 +0000 | [diff] [blame] | 1543 | adapter->ahw.crb_win = -1; |
Dhananjay Phadke | 47abe35 | 2009-10-13 05:31:42 +0000 | [diff] [blame] | 1544 | adapter->ahw.ocm_win = -1; |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1545 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1546 | err = netxen_start_firmware(adapter); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1547 | if (err) { |
| 1548 | dev_err(&pdev->dev, "failed to start firmware\n"); |
| 1549 | return err; |
| 1550 | } |
| 1551 | |
| 1552 | if (netif_running(netdev)) { |
| 1553 | err = netxen_nic_attach(adapter); |
| 1554 | if (err) |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1555 | goto err_out; |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1556 | |
| 1557 | err = netxen_nic_up(adapter, netdev); |
| 1558 | if (err) |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1559 | goto err_out_detach; |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1560 | |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 1561 | netxen_config_indev_addr(netdev, NETDEV_UP); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1562 | } |
| 1563 | |
Amit Kumar Salecha | bc86fcb | 2009-12-08 20:40:54 +0000 | [diff] [blame] | 1564 | netif_device_attach(netdev); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1565 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); |
Dhananjay Phadke | 07653aa | 2009-09-20 19:20:39 +0000 | [diff] [blame] | 1566 | return 0; |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 1567 | |
| 1568 | err_out_detach: |
| 1569 | netxen_nic_detach(adapter); |
| 1570 | err_out: |
| 1571 | nx_decr_dev_ref_cnt(adapter); |
| 1572 | return err; |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1573 | } |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 1574 | |
| 1575 | static pci_ers_result_t netxen_io_error_detected(struct pci_dev *pdev, |
| 1576 | pci_channel_state_t state) |
| 1577 | { |
| 1578 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
| 1579 | |
| 1580 | if (state == pci_channel_io_perm_failure) |
| 1581 | return PCI_ERS_RESULT_DISCONNECT; |
| 1582 | |
| 1583 | if (nx_dev_request_aer(adapter)) |
| 1584 | return PCI_ERS_RESULT_RECOVERED; |
| 1585 | |
| 1586 | netxen_nic_detach_func(adapter); |
| 1587 | |
| 1588 | pci_disable_device(pdev); |
| 1589 | |
| 1590 | return PCI_ERS_RESULT_NEED_RESET; |
| 1591 | } |
| 1592 | |
| 1593 | static pci_ers_result_t netxen_io_slot_reset(struct pci_dev *pdev) |
| 1594 | { |
| 1595 | int err = 0; |
| 1596 | |
| 1597 | err = netxen_nic_attach_func(pdev); |
| 1598 | |
| 1599 | return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; |
| 1600 | } |
| 1601 | |
| 1602 | static void netxen_io_resume(struct pci_dev *pdev) |
| 1603 | { |
| 1604 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 1605 | } |
| 1606 | |
| 1607 | static void netxen_nic_shutdown(struct pci_dev *pdev) |
| 1608 | { |
| 1609 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
| 1610 | |
| 1611 | netxen_nic_detach_func(adapter); |
| 1612 | |
| 1613 | if (pci_save_state(pdev)) |
| 1614 | return; |
| 1615 | |
| 1616 | if (netxen_nic_wol_supported(adapter)) { |
| 1617 | pci_enable_wake(pdev, PCI_D3cold, 1); |
| 1618 | pci_enable_wake(pdev, PCI_D3hot, 1); |
| 1619 | } |
| 1620 | |
| 1621 | pci_disable_device(pdev); |
| 1622 | } |
| 1623 | |
| 1624 | #ifdef CONFIG_PM |
| 1625 | static int |
| 1626 | netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state) |
| 1627 | { |
| 1628 | struct netxen_adapter *adapter = pci_get_drvdata(pdev); |
| 1629 | int retval; |
| 1630 | |
| 1631 | netxen_nic_detach_func(adapter); |
| 1632 | |
| 1633 | retval = pci_save_state(pdev); |
| 1634 | if (retval) |
| 1635 | return retval; |
| 1636 | |
| 1637 | if (netxen_nic_wol_supported(adapter)) { |
| 1638 | pci_enable_wake(pdev, PCI_D3cold, 1); |
| 1639 | pci_enable_wake(pdev, PCI_D3hot, 1); |
| 1640 | } |
| 1641 | |
| 1642 | pci_disable_device(pdev); |
| 1643 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
| 1644 | |
| 1645 | return 0; |
| 1646 | } |
| 1647 | |
| 1648 | static int |
| 1649 | netxen_nic_resume(struct pci_dev *pdev) |
| 1650 | { |
| 1651 | return netxen_nic_attach_func(pdev); |
| 1652 | } |
Dhananjay Phadke | 01542cd | 2009-06-22 20:26:20 +0000 | [diff] [blame] | 1653 | #endif |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 1654 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1655 | static int netxen_nic_open(struct net_device *netdev) |
| 1656 | { |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1657 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1658 | int err = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1659 | |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 1660 | if (adapter->driver_mismatch) |
| 1661 | return -EIO; |
| 1662 | |
Amit Kumar Salecha | 7042cd8 | 2009-07-27 11:15:54 -0700 | [diff] [blame] | 1663 | err = netxen_nic_attach(adapter); |
| 1664 | if (err) |
| 1665 | return err; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1666 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1667 | err = __netxen_nic_up(adapter, netdev); |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1668 | if (err) |
| 1669 | goto err_out; |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 1670 | |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 1671 | netif_start_queue(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1672 | |
| 1673 | return 0; |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1674 | |
Dhananjay Phadke | 9f5bc7f | 2009-03-09 08:50:54 +0000 | [diff] [blame] | 1675 | err_out: |
| 1676 | netxen_nic_detach(adapter); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 1677 | return err; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1678 | } |
| 1679 | |
| 1680 | /* |
| 1681 | * netxen_nic_close - Disables a network interface entry point |
| 1682 | */ |
| 1683 | static int netxen_nic_close(struct net_device *netdev) |
| 1684 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1685 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1686 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 1687 | __netxen_nic_down(adapter, netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1688 | return 0; |
| 1689 | } |
| 1690 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1691 | static void |
| 1692 | netxen_tso_check(struct net_device *netdev, |
| 1693 | struct nx_host_tx_ring *tx_ring, |
| 1694 | struct cmd_desc_type0 *first_desc, |
| 1695 | struct sk_buff *skb) |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 1696 | { |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1697 | u8 opcode = TX_ETHER_PKT; |
Dhananjay Phadke | cdff103 | 2009-01-26 12:34:57 -0800 | [diff] [blame] | 1698 | __be16 protocol = skb->protocol; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1699 | u16 flags = 0, vid = 0; |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1700 | u32 producer; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1701 | int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0; |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1702 | struct cmd_desc_type0 *hwdesc; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1703 | struct vlan_ethhdr *vh; |
Dhananjay Phadke | cdff103 | 2009-01-26 12:34:57 -0800 | [diff] [blame] | 1704 | |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 1705 | if (protocol == cpu_to_be16(ETH_P_8021Q)) { |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1706 | |
| 1707 | vh = (struct vlan_ethhdr *)skb->data; |
Dhananjay Phadke | cdff103 | 2009-01-26 12:34:57 -0800 | [diff] [blame] | 1708 | protocol = vh->h_vlan_encapsulated_proto; |
| 1709 | flags = FLAGS_VLAN_TAGGED; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1710 | |
| 1711 | } else if (vlan_tx_tag_present(skb)) { |
| 1712 | |
| 1713 | flags = FLAGS_VLAN_OOB; |
| 1714 | vid = vlan_tx_tag_get(skb); |
| 1715 | netxen_set_tx_vlan_tci(first_desc, vid); |
| 1716 | vlan_oob = 1; |
Dhananjay Phadke | cdff103 | 2009-01-26 12:34:57 -0800 | [diff] [blame] | 1717 | } |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 1718 | |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1719 | if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && |
| 1720 | skb_shinfo(skb)->gso_size > 0) { |
| 1721 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1722 | hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); |
| 1723 | |
| 1724 | first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); |
| 1725 | first_desc->total_hdr_length = hdr_len; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1726 | if (vlan_oob) { |
| 1727 | first_desc->total_hdr_length += VLAN_HLEN; |
| 1728 | first_desc->tcp_hdr_offset = VLAN_HLEN; |
| 1729 | first_desc->ip_hdr_offset = VLAN_HLEN; |
| 1730 | /* Only in case of TSO on vlan device */ |
| 1731 | flags |= FLAGS_VLAN_TAGGED; |
| 1732 | } |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1733 | |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 1734 | opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ? |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1735 | TX_TCP_LSO6 : TX_TCP_LSO; |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1736 | tso = 1; |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 1737 | |
| 1738 | } else if (skb->ip_summed == CHECKSUM_PARTIAL) { |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1739 | u8 l4proto; |
| 1740 | |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 1741 | if (protocol == cpu_to_be16(ETH_P_IP)) { |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1742 | l4proto = ip_hdr(skb)->protocol; |
| 1743 | |
| 1744 | if (l4proto == IPPROTO_TCP) |
| 1745 | opcode = TX_TCP_PKT; |
| 1746 | else if(l4proto == IPPROTO_UDP) |
| 1747 | opcode = TX_UDP_PKT; |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 1748 | } else if (protocol == cpu_to_be16(ETH_P_IPV6)) { |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1749 | l4proto = ipv6_hdr(skb)->nexthdr; |
| 1750 | |
| 1751 | if (l4proto == IPPROTO_TCP) |
| 1752 | opcode = TX_TCPV6_PKT; |
| 1753 | else if(l4proto == IPPROTO_UDP) |
| 1754 | opcode = TX_UDPV6_PKT; |
| 1755 | } |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 1756 | } |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1757 | |
| 1758 | first_desc->tcp_hdr_offset += skb_transport_offset(skb); |
| 1759 | first_desc->ip_hdr_offset += skb_network_offset(skb); |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1760 | netxen_set_tx_flags_opcode(first_desc, flags, opcode); |
| 1761 | |
| 1762 | if (!tso) |
| 1763 | return; |
| 1764 | |
| 1765 | /* For LSO, we need to copy the MAC/IP/TCP headers into |
| 1766 | * the descriptor ring |
| 1767 | */ |
| 1768 | producer = tx_ring->producer; |
| 1769 | copied = 0; |
| 1770 | offset = 2; |
| 1771 | |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1772 | if (vlan_oob) { |
| 1773 | /* Create a TSO vlan header template for firmware */ |
| 1774 | |
| 1775 | hwdesc = &tx_ring->desc_head[producer]; |
| 1776 | tx_ring->cmd_buf_arr[producer].skb = NULL; |
| 1777 | |
| 1778 | copy_len = min((int)sizeof(struct cmd_desc_type0) - offset, |
| 1779 | hdr_len + VLAN_HLEN); |
| 1780 | |
| 1781 | vh = (struct vlan_ethhdr *)((char *)hwdesc + 2); |
| 1782 | skb_copy_from_linear_data(skb, vh, 12); |
| 1783 | vh->h_vlan_proto = htons(ETH_P_8021Q); |
| 1784 | vh->h_vlan_TCI = htons(vid); |
| 1785 | skb_copy_from_linear_data_offset(skb, 12, |
| 1786 | (char *)vh + 16, copy_len - 16); |
| 1787 | |
Dhananjay Phadke | 545eb37 | 2009-08-05 07:34:07 +0000 | [diff] [blame] | 1788 | copied = copy_len - VLAN_HLEN; |
Dhananjay Phadke | 028afe7 | 2009-07-26 20:07:45 +0000 | [diff] [blame] | 1789 | offset = 0; |
| 1790 | |
| 1791 | producer = get_next_index(producer, tx_ring->num_desc); |
| 1792 | } |
| 1793 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1794 | while (copied < hdr_len) { |
| 1795 | |
| 1796 | copy_len = min((int)sizeof(struct cmd_desc_type0) - offset, |
| 1797 | (hdr_len - copied)); |
| 1798 | |
| 1799 | hwdesc = &tx_ring->desc_head[producer]; |
| 1800 | tx_ring->cmd_buf_arr[producer].skb = NULL; |
| 1801 | |
| 1802 | skb_copy_from_linear_data_offset(skb, copied, |
| 1803 | (char *)hwdesc + offset, copy_len); |
| 1804 | |
| 1805 | copied += copy_len; |
| 1806 | offset = 0; |
| 1807 | |
| 1808 | producer = get_next_index(producer, tx_ring->num_desc); |
| 1809 | } |
| 1810 | |
| 1811 | tx_ring->producer = producer; |
| 1812 | barrier(); |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 1813 | } |
| 1814 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1815 | static int |
| 1816 | netxen_map_tx_skb(struct pci_dev *pdev, |
| 1817 | struct sk_buff *skb, struct netxen_cmd_buffer *pbuf) |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1818 | { |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1819 | struct netxen_skb_frag *nf; |
| 1820 | struct skb_frag_struct *frag; |
| 1821 | int i, nr_frags; |
| 1822 | dma_addr_t map; |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1823 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1824 | nr_frags = skb_shinfo(skb)->nr_frags; |
| 1825 | nf = &pbuf->frag_array[0]; |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1826 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1827 | map = pci_map_single(pdev, skb->data, |
| 1828 | skb_headlen(skb), PCI_DMA_TODEVICE); |
| 1829 | if (pci_dma_mapping_error(pdev, map)) |
| 1830 | goto out_err; |
| 1831 | |
| 1832 | nf->dma = map; |
| 1833 | nf->length = skb_headlen(skb); |
| 1834 | |
| 1835 | for (i = 0; i < nr_frags; i++) { |
| 1836 | frag = &skb_shinfo(skb)->frags[i]; |
| 1837 | nf = &pbuf->frag_array[i+1]; |
| 1838 | |
| 1839 | map = pci_map_page(pdev, frag->page, frag->page_offset, |
| 1840 | frag->size, PCI_DMA_TODEVICE); |
| 1841 | if (pci_dma_mapping_error(pdev, map)) |
| 1842 | goto unwind; |
| 1843 | |
| 1844 | nf->dma = map; |
| 1845 | nf->length = frag->size; |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1846 | } |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1847 | |
| 1848 | return 0; |
| 1849 | |
| 1850 | unwind: |
Dhananjay Phadke | cf503e8 | 2009-09-03 13:10:55 +0000 | [diff] [blame] | 1851 | while (--i >= 0) { |
| 1852 | nf = &pbuf->frag_array[i+1]; |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1853 | pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE); |
| 1854 | } |
| 1855 | |
| 1856 | nf = &pbuf->frag_array[0]; |
| 1857 | pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE); |
| 1858 | |
| 1859 | out_err: |
| 1860 | return -ENOMEM; |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1861 | } |
| 1862 | |
Dhananjay Phadke | d32cc3d | 2009-03-09 08:50:53 +0000 | [diff] [blame] | 1863 | static inline void |
| 1864 | netxen_clear_cmddesc(u64 *desc) |
| 1865 | { |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1866 | desc[0] = 0ULL; |
| 1867 | desc[2] = 0ULL; |
Dhananjay Phadke | d32cc3d | 2009-03-09 08:50:53 +0000 | [diff] [blame] | 1868 | } |
| 1869 | |
Stephen Hemminger | 61357325 | 2009-08-31 19:50:58 +0000 | [diff] [blame] | 1870 | static netdev_tx_t |
Dhananjay Phadke | d32cc3d | 2009-03-09 08:50:53 +0000 | [diff] [blame] | 1871 | netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1872 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 1873 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Dhananjay Phadke | 4ea528a | 2009-04-28 15:29:10 +0000 | [diff] [blame] | 1874 | struct nx_host_tx_ring *tx_ring = adapter->tx_ring; |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1875 | struct netxen_cmd_buffer *pbuf; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1876 | struct netxen_skb_frag *buffrag; |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1877 | struct cmd_desc_type0 *hwdesc, *first_desc; |
| 1878 | struct pci_dev *pdev; |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1879 | int i, k; |
amit salecha | c968bdf | 2011-04-11 02:10:22 +0000 | [diff] [blame] | 1880 | int delta = 0; |
| 1881 | struct skb_frag_struct *frag; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1882 | |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 1883 | u32 producer; |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1884 | int frag_count, no_of_desc; |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 1885 | u32 num_txd = tx_ring->num_desc; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1886 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1887 | frag_count = skb_shinfo(skb)->nr_frags + 1; |
| 1888 | |
amit salecha | c968bdf | 2011-04-11 02:10:22 +0000 | [diff] [blame] | 1889 | /* 14 frags supported for normal packet and |
| 1890 | * 32 frags supported for TSO packet |
| 1891 | */ |
| 1892 | if (!skb_is_gso(skb) && frag_count > NETXEN_MAX_FRAGS_PER_TX) { |
| 1893 | |
| 1894 | for (i = 0; i < (frag_count - NETXEN_MAX_FRAGS_PER_TX); i++) { |
| 1895 | frag = &skb_shinfo(skb)->frags[i]; |
| 1896 | delta += frag->size; |
| 1897 | } |
| 1898 | |
| 1899 | if (!__pskb_pull_tail(skb, delta)) |
| 1900 | goto drop_packet; |
| 1901 | |
| 1902 | frag_count = 1 + skb_shinfo(skb)->nr_frags; |
| 1903 | } |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 1904 | /* 4 fragments per cmd des */ |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1905 | no_of_desc = (frag_count + 3) >> 2; |
dhananjay@netxen.com | 53a01e0 | 2007-12-26 10:23:58 -0800 | [diff] [blame] | 1906 | |
Rajesh Borundia | 7a9905e | 2010-10-18 02:03:41 +0000 | [diff] [blame] | 1907 | if (unlikely(netxen_tx_avail(tx_ring) <= TX_STOP_THRESH)) { |
Dhananjay Phadke | ba53e6b | 2008-03-17 19:59:50 -0700 | [diff] [blame] | 1908 | netif_stop_queue(netdev); |
Rajesh Borundia | 7a9905e | 2010-10-18 02:03:41 +0000 | [diff] [blame] | 1909 | smp_mb(); |
| 1910 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) |
| 1911 | netif_start_queue(netdev); |
| 1912 | else |
| 1913 | return NETDEV_TX_BUSY; |
dhananjay@netxen.com | 53a01e0 | 2007-12-26 10:23:58 -0800 | [diff] [blame] | 1914 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1915 | |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 1916 | producer = tx_ring->producer; |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1917 | pbuf = &tx_ring->cmd_buf_arr[producer]; |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 1918 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1919 | pdev = adapter->pdev; |
Dhananjay Phadke | 391587c | 2009-01-14 20:48:11 -0800 | [diff] [blame] | 1920 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1921 | if (netxen_map_tx_skb(pdev, skb, pbuf)) |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1922 | goto drop_packet; |
| 1923 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1924 | pbuf->skb = skb; |
| 1925 | pbuf->frag_count = frag_count; |
| 1926 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1927 | first_desc = hwdesc = &tx_ring->desc_head[producer]; |
| 1928 | netxen_clear_cmddesc((u64 *)hwdesc); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1929 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1930 | netxen_set_tx_frags_len(first_desc, frag_count, skb->len); |
| 1931 | netxen_set_tx_port(first_desc, adapter->portnum); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1932 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1933 | for (i = 0; i < frag_count; i++) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1934 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1935 | k = i % 4; |
| 1936 | |
| 1937 | if ((k == 0) && (i > 0)) { |
| 1938 | /* move to next desc.*/ |
Dhananjay Phadke | ba53e6b | 2008-03-17 19:59:50 -0700 | [diff] [blame] | 1939 | producer = get_next_index(producer, num_txd); |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 1940 | hwdesc = &tx_ring->desc_head[producer]; |
Dhananjay Phadke | d32cc3d | 2009-03-09 08:50:53 +0000 | [diff] [blame] | 1941 | netxen_clear_cmddesc((u64 *)hwdesc); |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1942 | tx_ring->cmd_buf_arr[producer].skb = NULL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1943 | } |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1944 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1945 | buffrag = &pbuf->frag_array[i]; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1946 | |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1947 | hwdesc->buffer_length[k] = cpu_to_le16(buffrag->length); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1948 | switch (k) { |
| 1949 | case 0: |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1950 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1951 | break; |
| 1952 | case 1: |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1953 | hwdesc->addr_buffer2 = cpu_to_le64(buffrag->dma); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1954 | break; |
| 1955 | case 2: |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1956 | hwdesc->addr_buffer3 = cpu_to_le64(buffrag->dma); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1957 | break; |
| 1958 | case 3: |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1959 | hwdesc->addr_buffer4 = cpu_to_le64(buffrag->dma); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1960 | break; |
| 1961 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1962 | } |
Dhananjay Phadke | ce644ed | 2009-08-23 08:35:11 +0000 | [diff] [blame] | 1963 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1964 | tx_ring->producer = get_next_index(producer, num_txd); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1965 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1966 | netxen_tso_check(netdev, tx_ring, first_desc, skb); |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1967 | |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 1968 | netxen_nic_update_cmd_producer(adapter, tx_ring); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1969 | |
Dhananjay Phadke | 1bcfd79 | 2009-07-26 20:07:40 +0000 | [diff] [blame] | 1970 | adapter->stats.txbytes += skb->len; |
Dhananjay Phadke | ba53e6b | 2008-03-17 19:59:50 -0700 | [diff] [blame] | 1971 | adapter->stats.xmitcalled++; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1972 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1973 | return NETDEV_TX_OK; |
Dhananjay Phadke | 6f70340 | 2009-01-14 20:50:00 -0800 | [diff] [blame] | 1974 | |
| 1975 | drop_packet: |
| 1976 | adapter->stats.txdropped++; |
| 1977 | dev_kfree_skb_any(skb); |
| 1978 | return NETDEV_TX_OK; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1979 | } |
| 1980 | |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 1981 | static int netxen_nic_check_temp(struct netxen_adapter *adapter) |
| 1982 | { |
| 1983 | struct net_device *netdev = adapter->netdev; |
| 1984 | uint32_t temp, temp_state, temp_val; |
| 1985 | int rv = 0; |
| 1986 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1987 | temp = NXRD32(adapter, CRB_TEMP_STATE); |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 1988 | |
| 1989 | temp_state = nx_get_temp_state(temp); |
| 1990 | temp_val = nx_get_temp_val(temp); |
| 1991 | |
| 1992 | if (temp_state == NX_TEMP_PANIC) { |
| 1993 | printk(KERN_ALERT |
| 1994 | "%s: Device temperature %d degrees C exceeds" |
| 1995 | " maximum allowed. Hardware has been shut down.\n", |
Dhananjay Phadke | e4135c2 | 2009-07-17 15:27:08 +0000 | [diff] [blame] | 1996 | netdev->name, temp_val); |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 1997 | rv = 1; |
| 1998 | } else if (temp_state == NX_TEMP_WARN) { |
| 1999 | if (adapter->temp == NX_TEMP_NORMAL) { |
| 2000 | printk(KERN_ALERT |
| 2001 | "%s: Device temperature %d degrees C " |
| 2002 | "exceeds operating range." |
| 2003 | " Immediate action needed.\n", |
Dhananjay Phadke | e4135c2 | 2009-07-17 15:27:08 +0000 | [diff] [blame] | 2004 | netdev->name, temp_val); |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2005 | } |
| 2006 | } else { |
| 2007 | if (adapter->temp == NX_TEMP_WARN) { |
| 2008 | printk(KERN_INFO |
| 2009 | "%s: Device temperature is now %d degrees C" |
Dhananjay Phadke | e4135c2 | 2009-07-17 15:27:08 +0000 | [diff] [blame] | 2010 | " in normal range.\n", netdev->name, |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2011 | temp_val); |
| 2012 | } |
| 2013 | } |
| 2014 | adapter->temp = temp_state; |
| 2015 | return rv; |
| 2016 | } |
| 2017 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 2018 | void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup) |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2019 | { |
| 2020 | struct net_device *netdev = adapter->netdev; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 2021 | |
| 2022 | if (adapter->ahw.linkup && !linkup) { |
| 2023 | printk(KERN_INFO "%s: %s NIC Link is down\n", |
| 2024 | netxen_nic_driver_name, netdev->name); |
| 2025 | adapter->ahw.linkup = 0; |
| 2026 | if (netif_running(netdev)) { |
| 2027 | netif_carrier_off(netdev); |
| 2028 | netif_stop_queue(netdev); |
| 2029 | } |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 2030 | adapter->link_changed = !adapter->has_link_events; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 2031 | } else if (!adapter->ahw.linkup && linkup) { |
| 2032 | printk(KERN_INFO "%s: %s NIC Link is up\n", |
| 2033 | netxen_nic_driver_name, netdev->name); |
| 2034 | adapter->ahw.linkup = 1; |
| 2035 | if (netif_running(netdev)) { |
| 2036 | netif_carrier_on(netdev); |
| 2037 | netif_wake_queue(netdev); |
| 2038 | } |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 2039 | adapter->link_changed = !adapter->has_link_events; |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter) |
| 2044 | { |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2045 | u32 val, port, linkup; |
| 2046 | |
| 2047 | port = adapter->physical_port; |
| 2048 | |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2049 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2050 | val = NXRD32(adapter, CRB_XG_STATE_P3); |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2051 | val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val); |
| 2052 | linkup = (val == XG_LINK_UP_P3); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 2053 | } else { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2054 | val = NXRD32(adapter, CRB_XG_STATE); |
Sucheta Chakraborty | a4b751d | 2010-01-02 03:25:19 +0000 | [diff] [blame] | 2055 | val = (val >> port*8) & 0xff; |
| 2056 | linkup = (val == XG_LINK_UP); |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2057 | } |
| 2058 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 2059 | netxen_advert_link_change(adapter, linkup); |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2060 | } |
| 2061 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2062 | static void netxen_tx_timeout(struct net_device *netdev) |
| 2063 | { |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 2064 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 2065 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2066 | if (test_bit(__NX_RESETTING, &adapter->state)) |
| 2067 | return; |
| 2068 | |
Dhananjay Phadke | f17443f | 2009-07-26 20:07:43 +0000 | [diff] [blame] | 2069 | dev_err(&netdev->dev, "transmit timeout, resetting.\n"); |
Amit Kumar Salecha | e424fa9 | 2009-08-13 07:03:00 +0000 | [diff] [blame] | 2070 | schedule_work(&adapter->tx_timeout_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2071 | } |
| 2072 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2073 | static void netxen_tx_timeout_task(struct work_struct *work) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2074 | { |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 2075 | struct netxen_adapter *adapter = |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2076 | container_of(work, struct netxen_adapter, tx_timeout_task); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2077 | |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 2078 | if (!netif_running(adapter->netdev)) |
| 2079 | return; |
| 2080 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2081 | if (test_and_set_bit(__NX_RESETTING, &adapter->state)) |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2082 | return; |
| 2083 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2084 | if (++adapter->tx_timeo_cnt >= NX_MAX_TX_TIMEOUTS) |
| 2085 | goto request_reset; |
Dhananjay Phadke | ba53e6b | 2008-03-17 19:59:50 -0700 | [diff] [blame] | 2086 | |
Amit Kumar Salecha | 16d884b | 2010-08-07 23:05:23 -0700 | [diff] [blame] | 2087 | rtnl_lock(); |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2088 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
| 2089 | /* try to scrub interrupt */ |
| 2090 | netxen_napi_disable(adapter); |
Dhananjay Phadke | ba53e6b | 2008-03-17 19:59:50 -0700 | [diff] [blame] | 2091 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2092 | netxen_napi_enable(adapter); |
| 2093 | |
| 2094 | netif_wake_queue(adapter->netdev); |
| 2095 | |
Dhananjay Phadke | a598ae1 | 2009-09-20 19:20:38 +0000 | [diff] [blame] | 2096 | clear_bit(__NX_RESETTING, &adapter->state); |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2097 | } else { |
Dhananjay Phadke | a598ae1 | 2009-09-20 19:20:38 +0000 | [diff] [blame] | 2098 | clear_bit(__NX_RESETTING, &adapter->state); |
Amit Kumar Salecha | 16d884b | 2010-08-07 23:05:23 -0700 | [diff] [blame] | 2099 | if (netxen_nic_reset_context(adapter)) { |
| 2100 | rtnl_unlock(); |
| 2101 | goto request_reset; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2102 | } |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2103 | } |
Amit Kumar Salecha | 16d884b | 2010-08-07 23:05:23 -0700 | [diff] [blame] | 2104 | adapter->netdev->trans_start = jiffies; |
| 2105 | rtnl_unlock(); |
| 2106 | return; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2107 | |
| 2108 | request_reset: |
| 2109 | adapter->need_fw_reset = 1; |
Amit Kumar Salecha | ff8a306 | 2009-10-21 19:39:02 +0000 | [diff] [blame] | 2110 | clear_bit(__NX_RESETTING, &adapter->state); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2111 | } |
| 2112 | |
stephen hemminger | 7e12bb0 | 2010-10-18 17:40:10 +0000 | [diff] [blame] | 2113 | static struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2114 | { |
| 2115 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Ajit Khaparde | 5a4d631 | 2009-10-07 02:45:34 +0000 | [diff] [blame] | 2116 | struct net_device_stats *stats = &netdev->stats; |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2117 | |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 2118 | stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts; |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 2119 | stats->tx_packets = adapter->stats.xmitfinished; |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2120 | stats->rx_bytes = adapter->stats.rxbytes; |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2121 | stats->tx_bytes = adapter->stats.txbytes; |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2122 | stats->rx_dropped = adapter->stats.rxdropped; |
Dhananjay Phadke | a97342f | 2008-07-21 19:44:05 -0700 | [diff] [blame] | 2123 | stats->tx_dropped = adapter->stats.txdropped; |
| 2124 | |
| 2125 | return stats; |
| 2126 | } |
| 2127 | |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 2128 | static irqreturn_t netxen_intr(int irq, void *data) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2129 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2130 | struct nx_host_sds_ring *sds_ring = data; |
| 2131 | struct netxen_adapter *adapter = sds_ring->adapter; |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2132 | u32 status = 0; |
| 2133 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2134 | status = readl(adapter->isr_int_vec); |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2135 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2136 | if (!(status & adapter->int_vec_bit)) |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2137 | return IRQ_NONE; |
dhananjay@netxen.com | e01872af | 2007-07-25 20:13:12 +0530 | [diff] [blame] | 2138 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2139 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2140 | /* check interrupt state machine, to be sure */ |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2141 | status = readl(adapter->crb_int_state_reg); |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2142 | if (!ISR_LEGACY_INT_TRIGGERED(status)) |
| 2143 | return IRQ_NONE; |
| 2144 | |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2145 | } else { |
| 2146 | unsigned long our_int = 0; |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2147 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2148 | our_int = readl(adapter->crb_int_state_reg); |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2149 | |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2150 | /* not our interrupt */ |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2151 | if (!test_and_clear_bit((7 + adapter->portnum), &our_int)) |
Dhananjay Phadke | d71e1be | 2008-08-01 03:14:57 -0700 | [diff] [blame] | 2152 | return IRQ_NONE; |
| 2153 | |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2154 | /* claim interrupt */ |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2155 | writel((our_int & 0xffffffff), adapter->crb_int_state_reg); |
| 2156 | |
| 2157 | /* clear interrupt */ |
| 2158 | netxen_nic_disable_int(sds_ring); |
dhananjay@netxen.com | e01872af | 2007-07-25 20:13:12 +0530 | [diff] [blame] | 2159 | } |
| 2160 | |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2161 | writel(0xffffffff, adapter->tgt_status_reg); |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2162 | /* read twice to ensure write is flushed */ |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2163 | readl(adapter->isr_int_vec); |
| 2164 | readl(adapter->isr_int_vec); |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2165 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2166 | napi_schedule(&sds_ring->napi); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2167 | |
| 2168 | return IRQ_HANDLED; |
| 2169 | } |
| 2170 | |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 2171 | static irqreturn_t netxen_msi_intr(int irq, void *data) |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2172 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2173 | struct nx_host_sds_ring *sds_ring = data; |
| 2174 | struct netxen_adapter *adapter = sds_ring->adapter; |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2175 | |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2176 | /* clear interrupt */ |
Amit Kumar Salecha | 195c5f9 | 2009-09-05 17:43:10 +0000 | [diff] [blame] | 2177 | writel(0xffffffff, adapter->tgt_status_reg); |
Dhananjay Phadke | 092bc57 | 2008-08-08 00:08:43 -0700 | [diff] [blame] | 2178 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2179 | napi_schedule(&sds_ring->napi); |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2180 | return IRQ_HANDLED; |
| 2181 | } |
| 2182 | |
Dhananjay Phadke | b3df68f | 2009-02-08 19:20:19 -0800 | [diff] [blame] | 2183 | static irqreturn_t netxen_msix_intr(int irq, void *data) |
| 2184 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2185 | struct nx_host_sds_ring *sds_ring = data; |
Dhananjay Phadke | b3df68f | 2009-02-08 19:20:19 -0800 | [diff] [blame] | 2186 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2187 | napi_schedule(&sds_ring->napi); |
Dhananjay Phadke | b3df68f | 2009-02-08 19:20:19 -0800 | [diff] [blame] | 2188 | return IRQ_HANDLED; |
| 2189 | } |
| 2190 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2191 | static int netxen_nic_poll(struct napi_struct *napi, int budget) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2192 | { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2193 | struct nx_host_sds_ring *sds_ring = |
| 2194 | container_of(napi, struct nx_host_sds_ring, napi); |
| 2195 | |
| 2196 | struct netxen_adapter *adapter = sds_ring->adapter; |
| 2197 | |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2198 | int tx_complete; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2199 | int work_done; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2200 | |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2201 | tx_complete = netxen_process_cmd_ring(adapter); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2202 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2203 | work_done = netxen_process_rcv_ring(sds_ring, budget); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2204 | |
Dhananjay Phadke | 05aaa02 | 2008-03-17 19:59:49 -0700 | [diff] [blame] | 2205 | if ((work_done < budget) && tx_complete) { |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 2206 | napi_complete(&sds_ring->napi); |
Amit Kumar Salecha | f2251f6 | 2009-12-05 12:23:55 +0000 | [diff] [blame] | 2207 | if (test_bit(__NX_DEV_UP, &adapter->state)) |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 2208 | netxen_nic_enable_int(sds_ring); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2209 | } |
| 2210 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2211 | return work_done; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 2215 | static void netxen_nic_poll_controller(struct net_device *netdev) |
| 2216 | { |
Yinglin Luan | 7b589a3 | 2010-08-22 21:56:19 +0000 | [diff] [blame] | 2217 | int ring; |
| 2218 | struct nx_host_sds_ring *sds_ring; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2219 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Yinglin Luan | 7b589a3 | 2010-08-22 21:56:19 +0000 | [diff] [blame] | 2220 | struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; |
| 2221 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2222 | disable_irq(adapter->irq); |
Yinglin Luan | 7b589a3 | 2010-08-22 21:56:19 +0000 | [diff] [blame] | 2223 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
| 2224 | sds_ring = &recv_ctx->sds_rings[ring]; |
| 2225 | netxen_intr(adapter->irq, sds_ring); |
| 2226 | } |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2227 | enable_irq(adapter->irq); |
| 2228 | } |
| 2229 | #endif |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2230 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2231 | static int |
| 2232 | nx_incr_dev_ref_cnt(struct netxen_adapter *adapter) |
| 2233 | { |
| 2234 | int count; |
| 2235 | if (netxen_api_lock(adapter)) |
| 2236 | return -EIO; |
| 2237 | |
| 2238 | count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); |
| 2239 | |
| 2240 | NXWR32(adapter, NX_CRB_DEV_REF_COUNT, ++count); |
| 2241 | |
| 2242 | netxen_api_unlock(adapter); |
| 2243 | return count; |
| 2244 | } |
| 2245 | |
| 2246 | static int |
| 2247 | nx_decr_dev_ref_cnt(struct netxen_adapter *adapter) |
| 2248 | { |
| 2249 | int count; |
| 2250 | if (netxen_api_lock(adapter)) |
| 2251 | return -EIO; |
| 2252 | |
| 2253 | count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); |
| 2254 | WARN_ON(count == 0); |
| 2255 | |
| 2256 | NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count); |
| 2257 | |
| 2258 | if (count == 0) |
| 2259 | NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD); |
| 2260 | |
| 2261 | netxen_api_unlock(adapter); |
| 2262 | return count; |
| 2263 | } |
| 2264 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2265 | static int |
| 2266 | nx_dev_request_aer(struct netxen_adapter *adapter) |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2267 | { |
| 2268 | u32 state; |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2269 | int ret = -EINVAL; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2270 | |
| 2271 | if (netxen_api_lock(adapter)) |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2272 | return ret; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2273 | |
| 2274 | state = NXRD32(adapter, NX_CRB_DEV_STATE); |
| 2275 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2276 | if (state == NX_DEV_NEED_AER) |
| 2277 | ret = 0; |
| 2278 | else if (state == NX_DEV_READY) { |
| 2279 | NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_AER); |
| 2280 | ret = 0; |
| 2281 | } |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2282 | |
| 2283 | netxen_api_unlock(adapter); |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2284 | return ret; |
| 2285 | } |
| 2286 | |
| 2287 | static int |
| 2288 | nx_dev_request_reset(struct netxen_adapter *adapter) |
| 2289 | { |
| 2290 | u32 state; |
| 2291 | int ret = -EINVAL; |
| 2292 | |
| 2293 | if (netxen_api_lock(adapter)) |
| 2294 | return ret; |
| 2295 | |
| 2296 | state = NXRD32(adapter, NX_CRB_DEV_STATE); |
| 2297 | |
| 2298 | if (state == NX_DEV_NEED_RESET) |
| 2299 | ret = 0; |
| 2300 | else if (state != NX_DEV_INITALIZING && state != NX_DEV_NEED_AER) { |
| 2301 | NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_RESET); |
| 2302 | ret = 0; |
| 2303 | } |
| 2304 | |
| 2305 | netxen_api_unlock(adapter); |
| 2306 | |
| 2307 | return ret; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2308 | } |
| 2309 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2310 | static int |
| 2311 | netxen_can_start_firmware(struct netxen_adapter *adapter) |
| 2312 | { |
| 2313 | int count; |
| 2314 | int can_start = 0; |
| 2315 | |
| 2316 | if (netxen_api_lock(adapter)) |
| 2317 | return 0; |
| 2318 | |
| 2319 | count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); |
| 2320 | |
| 2321 | if ((count < 0) || (count >= NX_MAX_PCI_FUNC)) |
| 2322 | count = 0; |
| 2323 | |
| 2324 | if (count == 0) { |
| 2325 | can_start = 1; |
| 2326 | NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_INITALIZING); |
| 2327 | } |
| 2328 | |
| 2329 | NXWR32(adapter, NX_CRB_DEV_REF_COUNT, ++count); |
| 2330 | |
| 2331 | netxen_api_unlock(adapter); |
| 2332 | |
| 2333 | return can_start; |
| 2334 | } |
| 2335 | |
| 2336 | static void |
| 2337 | netxen_schedule_work(struct netxen_adapter *adapter, |
| 2338 | work_func_t func, int delay) |
| 2339 | { |
| 2340 | INIT_DELAYED_WORK(&adapter->fw_work, func); |
| 2341 | schedule_delayed_work(&adapter->fw_work, delay); |
| 2342 | } |
| 2343 | |
| 2344 | static void |
| 2345 | netxen_cancel_fw_work(struct netxen_adapter *adapter) |
| 2346 | { |
| 2347 | while (test_and_set_bit(__NX_RESETTING, &adapter->state)) |
| 2348 | msleep(10); |
| 2349 | |
| 2350 | cancel_delayed_work_sync(&adapter->fw_work); |
| 2351 | } |
| 2352 | |
| 2353 | static void |
| 2354 | netxen_attach_work(struct work_struct *work) |
| 2355 | { |
| 2356 | struct netxen_adapter *adapter = container_of(work, |
| 2357 | struct netxen_adapter, fw_work.work); |
| 2358 | struct net_device *netdev = adapter->netdev; |
| 2359 | int err = 0; |
| 2360 | |
| 2361 | if (netif_running(netdev)) { |
| 2362 | err = netxen_nic_attach(adapter); |
| 2363 | if (err) |
| 2364 | goto done; |
| 2365 | |
| 2366 | err = netxen_nic_up(adapter, netdev); |
| 2367 | if (err) { |
| 2368 | netxen_nic_detach(adapter); |
| 2369 | goto done; |
| 2370 | } |
| 2371 | |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2372 | netxen_config_indev_addr(netdev, NETDEV_UP); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2373 | } |
| 2374 | |
| 2375 | netif_device_attach(netdev); |
| 2376 | |
| 2377 | done: |
| 2378 | adapter->fw_fail_cnt = 0; |
| 2379 | clear_bit(__NX_RESETTING, &adapter->state); |
| 2380 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); |
| 2381 | } |
| 2382 | |
| 2383 | static void |
| 2384 | netxen_fwinit_work(struct work_struct *work) |
| 2385 | { |
| 2386 | struct netxen_adapter *adapter = container_of(work, |
| 2387 | struct netxen_adapter, fw_work.work); |
| 2388 | int dev_state; |
| 2389 | |
| 2390 | dev_state = NXRD32(adapter, NX_CRB_DEV_STATE); |
| 2391 | |
| 2392 | switch (dev_state) { |
| 2393 | case NX_DEV_COLD: |
| 2394 | case NX_DEV_READY: |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2395 | if (!netxen_start_firmware(adapter)) { |
| 2396 | netxen_schedule_work(adapter, netxen_attach_work, 0); |
| 2397 | return; |
| 2398 | } |
| 2399 | break; |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2400 | |
Amit Kumar Salecha | 6b50ea1 | 2010-03-29 02:43:42 +0000 | [diff] [blame] | 2401 | case NX_DEV_NEED_RESET: |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2402 | case NX_DEV_INITALIZING: |
| 2403 | if (++adapter->fw_wait_cnt < FW_POLL_THRESH) { |
| 2404 | netxen_schedule_work(adapter, |
| 2405 | netxen_fwinit_work, 2 * FW_POLL_DELAY); |
| 2406 | return; |
| 2407 | } |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2408 | |
| 2409 | case NX_DEV_FAILED: |
| 2410 | default: |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 2411 | nx_incr_dev_ref_cnt(adapter); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2412 | break; |
| 2413 | } |
| 2414 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2415 | clear_bit(__NX_RESETTING, &adapter->state); |
| 2416 | } |
| 2417 | |
| 2418 | static void |
| 2419 | netxen_detach_work(struct work_struct *work) |
| 2420 | { |
| 2421 | struct netxen_adapter *adapter = container_of(work, |
| 2422 | struct netxen_adapter, fw_work.work); |
| 2423 | struct net_device *netdev = adapter->netdev; |
| 2424 | int ref_cnt, delay; |
| 2425 | u32 status; |
| 2426 | |
| 2427 | netif_device_detach(netdev); |
| 2428 | |
Amit Kumar Salecha | 6f77141 | 2009-12-05 12:23:54 +0000 | [diff] [blame] | 2429 | netxen_nic_down(adapter, netdev); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2430 | |
Amit Kumar Salecha | e15eec2 | 2010-02-02 04:16:21 +0000 | [diff] [blame] | 2431 | rtnl_lock(); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2432 | netxen_nic_detach(adapter); |
Amit Kumar Salecha | e15eec2 | 2010-02-02 04:16:21 +0000 | [diff] [blame] | 2433 | rtnl_unlock(); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2434 | |
| 2435 | status = NXRD32(adapter, NETXEN_PEG_HALT_STATUS1); |
| 2436 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2437 | if (status & NX_RCODE_FATAL_ERROR) |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 2438 | goto err_ret; |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2439 | |
| 2440 | if (adapter->temp == NX_TEMP_PANIC) |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 2441 | goto err_ret; |
| 2442 | |
| 2443 | ref_cnt = nx_decr_dev_ref_cnt(adapter); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2444 | |
Amit Kumar Salecha | 6b50ea1 | 2010-03-29 02:43:42 +0000 | [diff] [blame] | 2445 | if (ref_cnt == -EIO) |
| 2446 | goto err_ret; |
| 2447 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2448 | delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY); |
| 2449 | |
| 2450 | adapter->fw_wait_cnt = 0; |
| 2451 | netxen_schedule_work(adapter, netxen_fwinit_work, delay); |
Amit Kumar Salecha | 8f9b3f6 | 2009-12-02 15:46:19 +0000 | [diff] [blame] | 2452 | |
| 2453 | return; |
| 2454 | |
| 2455 | err_ret: |
| 2456 | clear_bit(__NX_RESETTING, &adapter->state); |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2457 | } |
| 2458 | |
| 2459 | static int |
| 2460 | netxen_check_health(struct netxen_adapter *adapter) |
| 2461 | { |
| 2462 | u32 state, heartbit; |
| 2463 | struct net_device *netdev = adapter->netdev; |
| 2464 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2465 | state = NXRD32(adapter, NX_CRB_DEV_STATE); |
| 2466 | if (state == NX_DEV_NEED_AER) |
| 2467 | return 0; |
| 2468 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2469 | if (netxen_nic_check_temp(adapter)) |
| 2470 | goto detach; |
| 2471 | |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2472 | if (adapter->need_fw_reset) { |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2473 | if (nx_dev_request_reset(adapter)) |
| 2474 | return 0; |
Amit Kumar Salecha | 74c520d | 2009-09-11 11:28:14 +0000 | [diff] [blame] | 2475 | goto detach; |
| 2476 | } |
| 2477 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2478 | /* NX_DEV_NEED_RESET, this state can be marked in two cases |
| 2479 | * 1. Tx timeout 2. Fw hang |
| 2480 | * Send request to destroy context in case of tx timeout only |
| 2481 | * and doesn't required in case of Fw hang |
| 2482 | */ |
Amit Kumar Salecha | 6a808c6 | 2009-12-08 20:40:55 +0000 | [diff] [blame] | 2483 | if (state == NX_DEV_NEED_RESET) { |
| 2484 | adapter->need_fw_reset = 1; |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2485 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 2486 | goto detach; |
Amit Kumar Salecha | 6a808c6 | 2009-12-08 20:40:55 +0000 | [diff] [blame] | 2487 | } |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2488 | |
| 2489 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 2490 | return 0; |
| 2491 | |
| 2492 | heartbit = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER); |
| 2493 | if (heartbit != adapter->heartbit) { |
| 2494 | adapter->heartbit = heartbit; |
| 2495 | adapter->fw_fail_cnt = 0; |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2496 | if (adapter->need_fw_reset) |
| 2497 | goto detach; |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2498 | return 0; |
| 2499 | } |
| 2500 | |
| 2501 | if (++adapter->fw_fail_cnt < FW_FAIL_THRESH) |
| 2502 | return 0; |
| 2503 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2504 | if (nx_dev_request_reset(adapter)) |
| 2505 | return 0; |
| 2506 | |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2507 | clear_bit(__NX_FW_ATTACHED, &adapter->state); |
| 2508 | |
| 2509 | dev_info(&netdev->dev, "firmware hang detected\n"); |
| 2510 | |
| 2511 | detach: |
Narender Kumar | caa2dd5 | 2009-10-16 15:50:11 +0000 | [diff] [blame] | 2512 | if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && |
| 2513 | !test_and_set_bit(__NX_RESETTING, &adapter->state)) |
Dhananjay Phadke | 6a581e9 | 2009-09-05 17:43:08 +0000 | [diff] [blame] | 2514 | netxen_schedule_work(adapter, netxen_detach_work, 0); |
| 2515 | return 1; |
| 2516 | } |
| 2517 | |
| 2518 | static void |
| 2519 | netxen_fw_poll_work(struct work_struct *work) |
| 2520 | { |
| 2521 | struct netxen_adapter *adapter = container_of(work, |
| 2522 | struct netxen_adapter, fw_work.work); |
| 2523 | |
| 2524 | if (test_bit(__NX_RESETTING, &adapter->state)) |
| 2525 | goto reschedule; |
| 2526 | |
| 2527 | if (test_bit(__NX_DEV_UP, &adapter->state)) { |
| 2528 | if (!adapter->has_link_events) { |
| 2529 | |
| 2530 | netxen_nic_handle_phy_intr(adapter); |
| 2531 | |
| 2532 | if (adapter->link_changed) |
| 2533 | netxen_nic_set_link_parameters(adapter); |
| 2534 | } |
| 2535 | } |
| 2536 | |
| 2537 | if (netxen_check_health(adapter)) |
| 2538 | return; |
| 2539 | |
| 2540 | reschedule: |
| 2541 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); |
| 2542 | } |
| 2543 | |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 2544 | static ssize_t |
| 2545 | netxen_store_bridged_mode(struct device *dev, |
| 2546 | struct device_attribute *attr, const char *buf, size_t len) |
| 2547 | { |
| 2548 | struct net_device *net = to_net_dev(dev); |
| 2549 | struct netxen_adapter *adapter = netdev_priv(net); |
| 2550 | unsigned long new; |
| 2551 | int ret = -EINVAL; |
| 2552 | |
| 2553 | if (!(adapter->capabilities & NX_FW_CAPABILITY_BDG)) |
| 2554 | goto err_out; |
| 2555 | |
| 2556 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 2557 | goto err_out; |
| 2558 | |
| 2559 | if (strict_strtoul(buf, 2, &new)) |
| 2560 | goto err_out; |
| 2561 | |
| 2562 | if (!netxen_config_bridged_mode(adapter, !!new)) |
| 2563 | ret = len; |
| 2564 | |
| 2565 | err_out: |
| 2566 | return ret; |
| 2567 | } |
| 2568 | |
| 2569 | static ssize_t |
| 2570 | netxen_show_bridged_mode(struct device *dev, |
| 2571 | struct device_attribute *attr, char *buf) |
| 2572 | { |
| 2573 | struct net_device *net = to_net_dev(dev); |
| 2574 | struct netxen_adapter *adapter; |
| 2575 | int bridged_mode = 0; |
| 2576 | |
| 2577 | adapter = netdev_priv(net); |
| 2578 | |
| 2579 | if (adapter->capabilities & NX_FW_CAPABILITY_BDG) |
| 2580 | bridged_mode = !!(adapter->flags & NETXEN_NIC_BRIDGE_ENABLED); |
| 2581 | |
| 2582 | return sprintf(buf, "%d\n", bridged_mode); |
| 2583 | } |
| 2584 | |
| 2585 | static struct device_attribute dev_attr_bridged_mode = { |
| 2586 | .attr = {.name = "bridged_mode", .mode = (S_IRUGO | S_IWUSR)}, |
| 2587 | .show = netxen_show_bridged_mode, |
| 2588 | .store = netxen_store_bridged_mode, |
| 2589 | }; |
| 2590 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2591 | static ssize_t |
| 2592 | netxen_store_diag_mode(struct device *dev, |
| 2593 | struct device_attribute *attr, const char *buf, size_t len) |
| 2594 | { |
| 2595 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2596 | unsigned long new; |
| 2597 | |
| 2598 | if (strict_strtoul(buf, 2, &new)) |
| 2599 | return -EINVAL; |
| 2600 | |
| 2601 | if (!!new != !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)) |
| 2602 | adapter->flags ^= NETXEN_NIC_DIAG_ENABLED; |
| 2603 | |
| 2604 | return len; |
| 2605 | } |
| 2606 | |
| 2607 | static ssize_t |
| 2608 | netxen_show_diag_mode(struct device *dev, |
| 2609 | struct device_attribute *attr, char *buf) |
| 2610 | { |
| 2611 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2612 | |
| 2613 | return sprintf(buf, "%d\n", |
| 2614 | !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)); |
| 2615 | } |
| 2616 | |
| 2617 | static struct device_attribute dev_attr_diag_mode = { |
| 2618 | .attr = {.name = "diag_mode", .mode = (S_IRUGO | S_IWUSR)}, |
| 2619 | .show = netxen_show_diag_mode, |
| 2620 | .store = netxen_store_diag_mode, |
| 2621 | }; |
| 2622 | |
| 2623 | static int |
| 2624 | netxen_sysfs_validate_crb(struct netxen_adapter *adapter, |
| 2625 | loff_t offset, size_t size) |
| 2626 | { |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2627 | size_t crb_size = 4; |
| 2628 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2629 | if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)) |
| 2630 | return -EIO; |
| 2631 | |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2632 | if (offset < NETXEN_PCI_CRBSPACE) { |
| 2633 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 2634 | return -EINVAL; |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2635 | |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2636 | if (ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
| 2637 | NETXEN_PCI_CAMQM_2M_END)) |
| 2638 | crb_size = 8; |
| 2639 | else |
| 2640 | return -EINVAL; |
| 2641 | } |
| 2642 | |
| 2643 | if ((size != crb_size) || (offset & (crb_size-1))) |
| 2644 | return -EINVAL; |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2645 | |
| 2646 | return 0; |
| 2647 | } |
| 2648 | |
| 2649 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2650 | netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, |
| 2651 | struct bin_attribute *attr, |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2652 | char *buf, loff_t offset, size_t size) |
| 2653 | { |
| 2654 | struct device *dev = container_of(kobj, struct device, kobj); |
| 2655 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2656 | u32 data; |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2657 | u64 qmdata; |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2658 | int ret; |
| 2659 | |
| 2660 | ret = netxen_sysfs_validate_crb(adapter, offset, size); |
| 2661 | if (ret != 0) |
| 2662 | return ret; |
| 2663 | |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2664 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && |
| 2665 | ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
| 2666 | NETXEN_PCI_CAMQM_2M_END)) { |
| 2667 | netxen_pci_camqm_read_2M(adapter, offset, &qmdata); |
| 2668 | memcpy(buf, &qmdata, size); |
| 2669 | } else { |
| 2670 | data = NXRD32(adapter, offset); |
| 2671 | memcpy(buf, &data, size); |
| 2672 | } |
| 2673 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2674 | return size; |
| 2675 | } |
| 2676 | |
| 2677 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2678 | netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj, |
| 2679 | struct bin_attribute *attr, |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2680 | char *buf, loff_t offset, size_t size) |
| 2681 | { |
| 2682 | struct device *dev = container_of(kobj, struct device, kobj); |
| 2683 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2684 | u32 data; |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2685 | u64 qmdata; |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2686 | int ret; |
| 2687 | |
| 2688 | ret = netxen_sysfs_validate_crb(adapter, offset, size); |
| 2689 | if (ret != 0) |
| 2690 | return ret; |
| 2691 | |
Amit Kumar Salecha | 0b9715e | 2010-05-11 23:53:05 +0000 | [diff] [blame] | 2692 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && |
| 2693 | ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
| 2694 | NETXEN_PCI_CAMQM_2M_END)) { |
| 2695 | memcpy(&qmdata, buf, size); |
| 2696 | netxen_pci_camqm_write_2M(adapter, offset, qmdata); |
| 2697 | } else { |
| 2698 | memcpy(&data, buf, size); |
| 2699 | NXWR32(adapter, offset, data); |
| 2700 | } |
| 2701 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2702 | return size; |
| 2703 | } |
| 2704 | |
| 2705 | static int |
| 2706 | netxen_sysfs_validate_mem(struct netxen_adapter *adapter, |
| 2707 | loff_t offset, size_t size) |
| 2708 | { |
| 2709 | if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)) |
| 2710 | return -EIO; |
| 2711 | |
| 2712 | if ((size != 8) || (offset & 0x7)) |
| 2713 | return -EIO; |
| 2714 | |
| 2715 | return 0; |
| 2716 | } |
| 2717 | |
| 2718 | static ssize_t |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2719 | netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, |
| 2720 | struct bin_attribute *attr, |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2721 | char *buf, loff_t offset, size_t size) |
| 2722 | { |
| 2723 | struct device *dev = container_of(kobj, struct device, kobj); |
| 2724 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2725 | u64 data; |
| 2726 | int ret; |
| 2727 | |
| 2728 | ret = netxen_sysfs_validate_mem(adapter, offset, size); |
| 2729 | if (ret != 0) |
| 2730 | return ret; |
| 2731 | |
| 2732 | if (adapter->pci_mem_read(adapter, offset, &data)) |
| 2733 | return -EIO; |
| 2734 | |
| 2735 | memcpy(buf, &data, size); |
| 2736 | |
| 2737 | return size; |
| 2738 | } |
| 2739 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 2740 | static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2741 | struct bin_attribute *attr, char *buf, |
| 2742 | loff_t offset, size_t size) |
| 2743 | { |
| 2744 | struct device *dev = container_of(kobj, struct device, kobj); |
| 2745 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
| 2746 | u64 data; |
| 2747 | int ret; |
| 2748 | |
| 2749 | ret = netxen_sysfs_validate_mem(adapter, offset, size); |
| 2750 | if (ret != 0) |
| 2751 | return ret; |
| 2752 | |
| 2753 | memcpy(&data, buf, size); |
| 2754 | |
| 2755 | if (adapter->pci_mem_write(adapter, offset, data)) |
| 2756 | return -EIO; |
| 2757 | |
| 2758 | return size; |
| 2759 | } |
| 2760 | |
| 2761 | |
| 2762 | static struct bin_attribute bin_attr_crb = { |
| 2763 | .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)}, |
| 2764 | .size = 0, |
| 2765 | .read = netxen_sysfs_read_crb, |
| 2766 | .write = netxen_sysfs_write_crb, |
| 2767 | }; |
| 2768 | |
| 2769 | static struct bin_attribute bin_attr_mem = { |
| 2770 | .attr = {.name = "mem", .mode = (S_IRUGO | S_IWUSR)}, |
| 2771 | .size = 0, |
| 2772 | .read = netxen_sysfs_read_mem, |
| 2773 | .write = netxen_sysfs_write_mem, |
| 2774 | }; |
| 2775 | |
Narender Kumar | caa2dd5 | 2009-10-16 15:50:11 +0000 | [diff] [blame] | 2776 | |
Narender Kumar | fa3ce35 | 2009-08-24 19:23:28 +0000 | [diff] [blame] | 2777 | static void |
| 2778 | netxen_create_sysfs_entries(struct netxen_adapter *adapter) |
| 2779 | { |
| 2780 | struct net_device *netdev = adapter->netdev; |
| 2781 | struct device *dev = &netdev->dev; |
| 2782 | |
| 2783 | if (adapter->capabilities & NX_FW_CAPABILITY_BDG) { |
| 2784 | /* bridged_mode control */ |
| 2785 | if (device_create_file(dev, &dev_attr_bridged_mode)) { |
| 2786 | dev_warn(&netdev->dev, |
| 2787 | "failed to create bridged_mode sysfs entry\n"); |
| 2788 | } |
| 2789 | } |
| 2790 | } |
| 2791 | |
| 2792 | static void |
| 2793 | netxen_remove_sysfs_entries(struct netxen_adapter *adapter) |
| 2794 | { |
| 2795 | struct net_device *netdev = adapter->netdev; |
| 2796 | struct device *dev = &netdev->dev; |
| 2797 | |
| 2798 | if (adapter->capabilities & NX_FW_CAPABILITY_BDG) |
| 2799 | device_remove_file(dev, &dev_attr_bridged_mode); |
| 2800 | } |
| 2801 | |
Dhananjay Phadke | 70f9cf8 | 2009-10-13 05:31:45 +0000 | [diff] [blame] | 2802 | static void |
| 2803 | netxen_create_diag_entries(struct netxen_adapter *adapter) |
| 2804 | { |
| 2805 | struct pci_dev *pdev = adapter->pdev; |
| 2806 | struct device *dev; |
| 2807 | |
| 2808 | dev = &pdev->dev; |
| 2809 | if (device_create_file(dev, &dev_attr_diag_mode)) |
| 2810 | dev_info(dev, "failed to create diag_mode sysfs entry\n"); |
| 2811 | if (device_create_bin_file(dev, &bin_attr_crb)) |
| 2812 | dev_info(dev, "failed to create crb sysfs entry\n"); |
| 2813 | if (device_create_bin_file(dev, &bin_attr_mem)) |
| 2814 | dev_info(dev, "failed to create mem sysfs entry\n"); |
| 2815 | } |
| 2816 | |
| 2817 | |
| 2818 | static void |
| 2819 | netxen_remove_diag_entries(struct netxen_adapter *adapter) |
| 2820 | { |
| 2821 | struct pci_dev *pdev = adapter->pdev; |
| 2822 | struct device *dev = &pdev->dev; |
| 2823 | |
| 2824 | device_remove_file(dev, &dev_attr_diag_mode); |
| 2825 | device_remove_bin_file(dev, &bin_attr_crb); |
| 2826 | device_remove_bin_file(dev, &bin_attr_mem); |
| 2827 | } |
| 2828 | |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 2829 | #ifdef CONFIG_INET |
| 2830 | |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2831 | #define is_netxen_netdev(dev) (dev->netdev_ops == &netxen_netdev_ops) |
| 2832 | |
| 2833 | static int |
| 2834 | netxen_destip_supported(struct netxen_adapter *adapter) |
| 2835 | { |
| 2836 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 2837 | return 0; |
| 2838 | |
| 2839 | if (adapter->ahw.cut_through) |
| 2840 | return 0; |
| 2841 | |
| 2842 | return 1; |
| 2843 | } |
| 2844 | |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2845 | static void |
| 2846 | netxen_config_indev_addr(struct net_device *dev, unsigned long event) |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2847 | { |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2848 | struct in_device *indev; |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2849 | struct netxen_adapter *adapter = netdev_priv(dev); |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2850 | |
Amit Kumar Salecha | 3db7675 | 2009-09-09 18:12:37 -0700 | [diff] [blame] | 2851 | if (!netxen_destip_supported(adapter)) |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2852 | return; |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2853 | |
| 2854 | indev = in_dev_get(dev); |
| 2855 | if (!indev) |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2856 | return; |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2857 | |
| 2858 | for_ifa(indev) { |
| 2859 | switch (event) { |
| 2860 | case NETDEV_UP: |
| 2861 | netxen_config_ipaddr(adapter, |
| 2862 | ifa->ifa_address, NX_IP_UP); |
| 2863 | break; |
| 2864 | case NETDEV_DOWN: |
| 2865 | netxen_config_ipaddr(adapter, |
| 2866 | ifa->ifa_address, NX_IP_DOWN); |
| 2867 | break; |
| 2868 | default: |
| 2869 | break; |
| 2870 | } |
| 2871 | } endfor_ifa(indev); |
| 2872 | |
| 2873 | in_dev_put(indev); |
Amit Kumar Salecha | d0725e4 | 2009-09-05 17:43:09 +0000 | [diff] [blame] | 2874 | } |
| 2875 | |
| 2876 | static int netxen_netdev_event(struct notifier_block *this, |
| 2877 | unsigned long event, void *ptr) |
| 2878 | { |
| 2879 | struct netxen_adapter *adapter; |
| 2880 | struct net_device *dev = (struct net_device *)ptr; |
| 2881 | |
| 2882 | recheck: |
| 2883 | if (dev == NULL) |
| 2884 | goto done; |
| 2885 | |
| 2886 | if (dev->priv_flags & IFF_802_1Q_VLAN) { |
| 2887 | dev = vlan_dev_real_dev(dev); |
| 2888 | goto recheck; |
| 2889 | } |
| 2890 | |
| 2891 | if (!is_netxen_netdev(dev)) |
| 2892 | goto done; |
| 2893 | |
| 2894 | adapter = netdev_priv(dev); |
| 2895 | |
| 2896 | if (!adapter) |
| 2897 | goto done; |
| 2898 | |
| 2899 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 2900 | goto done; |
| 2901 | |
| 2902 | netxen_config_indev_addr(dev, event); |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2903 | done: |
| 2904 | return NOTIFY_DONE; |
| 2905 | } |
| 2906 | |
| 2907 | static int |
| 2908 | netxen_inetaddr_event(struct notifier_block *this, |
| 2909 | unsigned long event, void *ptr) |
| 2910 | { |
| 2911 | struct netxen_adapter *adapter; |
| 2912 | struct net_device *dev; |
| 2913 | |
| 2914 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; |
| 2915 | |
| 2916 | dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL; |
| 2917 | |
| 2918 | recheck: |
| 2919 | if (dev == NULL || !netif_running(dev)) |
| 2920 | goto done; |
| 2921 | |
| 2922 | if (dev->priv_flags & IFF_802_1Q_VLAN) { |
| 2923 | dev = vlan_dev_real_dev(dev); |
| 2924 | goto recheck; |
| 2925 | } |
| 2926 | |
| 2927 | if (!is_netxen_netdev(dev)) |
| 2928 | goto done; |
| 2929 | |
| 2930 | adapter = netdev_priv(dev); |
| 2931 | |
| 2932 | if (!adapter || !netxen_destip_supported(adapter)) |
| 2933 | goto done; |
| 2934 | |
| 2935 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
| 2936 | goto done; |
| 2937 | |
| 2938 | switch (event) { |
| 2939 | case NETDEV_UP: |
| 2940 | netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_UP); |
| 2941 | break; |
| 2942 | case NETDEV_DOWN: |
| 2943 | netxen_config_ipaddr(adapter, ifa->ifa_address, NX_IP_DOWN); |
| 2944 | break; |
| 2945 | default: |
| 2946 | break; |
| 2947 | } |
| 2948 | |
| 2949 | done: |
| 2950 | return NOTIFY_DONE; |
| 2951 | } |
| 2952 | |
| 2953 | static struct notifier_block netxen_netdev_cb = { |
| 2954 | .notifier_call = netxen_netdev_event, |
| 2955 | }; |
| 2956 | |
| 2957 | static struct notifier_block netxen_inetaddr_cb = { |
| 2958 | .notifier_call = netxen_inetaddr_event, |
| 2959 | }; |
Randy Dunlap | 9feae56 | 2009-09-11 12:41:04 +0000 | [diff] [blame] | 2960 | #else |
| 2961 | static void |
| 2962 | netxen_config_indev_addr(struct net_device *dev, unsigned long event) |
| 2963 | { } |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 2964 | #endif |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2965 | |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2966 | static struct pci_error_handlers netxen_err_handler = { |
| 2967 | .error_detected = netxen_io_error_detected, |
| 2968 | .slot_reset = netxen_io_slot_reset, |
| 2969 | .resume = netxen_io_resume, |
| 2970 | }; |
| 2971 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2972 | static struct pci_driver netxen_driver = { |
| 2973 | .name = netxen_nic_driver_name, |
| 2974 | .id_table = netxen_pci_tbl, |
| 2975 | .probe = netxen_nic_probe, |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 2976 | .remove = __devexit_p(netxen_nic_remove), |
Dhananjay Phadke | 01542cd | 2009-06-22 20:26:20 +0000 | [diff] [blame] | 2977 | #ifdef CONFIG_PM |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 2978 | .suspend = netxen_nic_suspend, |
Amit Kumar Salecha | 22b5794 | 2009-08-23 08:35:12 +0000 | [diff] [blame] | 2979 | .resume = netxen_nic_resume, |
Dhananjay Phadke | 01542cd | 2009-06-22 20:26:20 +0000 | [diff] [blame] | 2980 | #endif |
Amit Kumar Salecha | e87ad55 | 2009-12-08 20:40:56 +0000 | [diff] [blame] | 2981 | .shutdown = netxen_nic_shutdown, |
| 2982 | .err_handler = &netxen_err_handler |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2983 | }; |
| 2984 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2985 | static int __init netxen_init_module(void) |
| 2986 | { |
Dhananjay Phadke | ff4fbd4 | 2009-03-13 14:52:06 +0000 | [diff] [blame] | 2987 | printk(KERN_INFO "%s\n", netxen_nic_driver_string); |
| 2988 | |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 2989 | #ifdef CONFIG_INET |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 2990 | register_netdevice_notifier(&netxen_netdev_cb); |
| 2991 | register_inetaddr_notifier(&netxen_inetaddr_cb); |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 2992 | #endif |
Amit S. Kale | 184231b | 2007-01-22 06:52:53 -0800 | [diff] [blame] | 2993 | return pci_register_driver(&netxen_driver); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2994 | } |
| 2995 | |
| 2996 | module_init(netxen_init_module); |
| 2997 | |
| 2998 | static void __exit netxen_exit_module(void) |
| 2999 | { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 3000 | pci_unregister_driver(&netxen_driver); |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 3001 | |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 3002 | #ifdef CONFIG_INET |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 3003 | unregister_inetaddr_notifier(&netxen_inetaddr_cb); |
| 3004 | unregister_netdevice_notifier(&netxen_netdev_cb); |
Dhananjay Phadke | 044824d | 2009-07-28 09:10:03 +0000 | [diff] [blame] | 3005 | #endif |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 3006 | } |
| 3007 | |
| 3008 | module_exit(netxen_exit_module); |