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