Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/net/ehea/ehea_main.c |
| 3 | * |
| 4 | * eHEA ethernet device driver for IBM eServer System p |
| 5 | * |
| 6 | * (C) Copyright IBM Corp. 2006 |
| 7 | * |
| 8 | * Authors: |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 9 | * Christoph Raisch <raisch@de.ibm.com> |
| 10 | * Jan-Bernd Themann <themann@de.ibm.com> |
| 11 | * Thomas Klein <tklein@de.ibm.com> |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 12 | * |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2, or (at your option) |
| 17 | * any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | */ |
| 28 | |
| 29 | #include <linux/in.h> |
| 30 | #include <linux/ip.h> |
| 31 | #include <linux/tcp.h> |
| 32 | #include <linux/udp.h> |
| 33 | #include <linux/if.h> |
| 34 | #include <linux/list.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 35 | #include <linux/slab.h> |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 36 | #include <linux/if_ether.h> |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 37 | #include <linux/notifier.h> |
| 38 | #include <linux/reboot.h> |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 39 | #include <linux/memory.h> |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 40 | #include <asm/kexec.h> |
Daniel Walker | 06f89ed | 2008-03-28 14:41:26 -0700 | [diff] [blame] | 41 | #include <linux/mutex.h> |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 42 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 43 | #include <net/ip.h> |
| 44 | |
| 45 | #include "ehea.h" |
| 46 | #include "ehea_qmr.h" |
| 47 | #include "ehea_phyp.h" |
| 48 | |
| 49 | |
| 50 | MODULE_LICENSE("GPL"); |
| 51 | MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); |
| 52 | MODULE_DESCRIPTION("IBM eServer HEA Driver"); |
| 53 | MODULE_VERSION(DRV_VERSION); |
| 54 | |
| 55 | |
| 56 | static int msg_level = -1; |
| 57 | static int rq1_entries = EHEA_DEF_ENTRIES_RQ1; |
| 58 | static int rq2_entries = EHEA_DEF_ENTRIES_RQ2; |
| 59 | static int rq3_entries = EHEA_DEF_ENTRIES_RQ3; |
| 60 | static int sq_entries = EHEA_DEF_ENTRIES_SQ; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 61 | static int use_mcs; |
| 62 | static int use_lro; |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 63 | static int lro_max_aggr = EHEA_LRO_MAX_AGGR; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 64 | static int num_tx_qps = EHEA_NUM_TX_QP; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 65 | static int prop_carrier_state; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 66 | |
| 67 | module_param(msg_level, int, 0); |
| 68 | module_param(rq1_entries, int, 0); |
| 69 | module_param(rq2_entries, int, 0); |
| 70 | module_param(rq3_entries, int, 0); |
| 71 | module_param(sq_entries, int, 0); |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 72 | module_param(prop_carrier_state, int, 0); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 73 | module_param(use_mcs, int, 0); |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 74 | module_param(use_lro, int, 0); |
| 75 | module_param(lro_max_aggr, int, 0); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 76 | module_param(num_tx_qps, int, 0); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 77 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 78 | MODULE_PARM_DESC(num_tx_qps, "Number of TX-QPS"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 79 | MODULE_PARM_DESC(msg_level, "msg_level"); |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 80 | MODULE_PARM_DESC(prop_carrier_state, "Propagate carrier state of physical " |
| 81 | "port to stack. 1:yes, 0:no. Default = 0 "); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 82 | MODULE_PARM_DESC(rq3_entries, "Number of entries for Receive Queue 3 " |
| 83 | "[2^x - 1], x = [6..14]. Default = " |
| 84 | __MODULE_STRING(EHEA_DEF_ENTRIES_RQ3) ")"); |
| 85 | MODULE_PARM_DESC(rq2_entries, "Number of entries for Receive Queue 2 " |
| 86 | "[2^x - 1], x = [6..14]. Default = " |
| 87 | __MODULE_STRING(EHEA_DEF_ENTRIES_RQ2) ")"); |
| 88 | MODULE_PARM_DESC(rq1_entries, "Number of entries for Receive Queue 1 " |
| 89 | "[2^x - 1], x = [6..14]. Default = " |
| 90 | __MODULE_STRING(EHEA_DEF_ENTRIES_RQ1) ")"); |
| 91 | MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue " |
| 92 | "[2^x - 1], x = [6..14]. Default = " |
| 93 | __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")"); |
Jan-Bernd Themann | 18072a5 | 2007-08-22 16:21:24 +0200 | [diff] [blame] | 94 | MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 0 "); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 95 | |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 96 | MODULE_PARM_DESC(lro_max_aggr, " LRO: Max packets to be aggregated. Default = " |
| 97 | __MODULE_STRING(EHEA_LRO_MAX_AGGR)); |
| 98 | MODULE_PARM_DESC(use_lro, " Large Receive Offload, 1: enable, 0: disable, " |
| 99 | "Default = 0"); |
| 100 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 101 | static int port_name_cnt; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 102 | static LIST_HEAD(adapter_list); |
Stephen Rothwell | 48e4cc7 | 2009-01-05 16:06:02 -0800 | [diff] [blame] | 103 | static unsigned long ehea_driver_flags; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 104 | struct work_struct ehea_rereg_mr_task; |
Daniel Walker | 06f89ed | 2008-03-28 14:41:26 -0700 | [diff] [blame] | 105 | static DEFINE_MUTEX(dlpar_mem_lock); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 106 | struct ehea_fw_handle_array ehea_fw_handles; |
| 107 | struct ehea_bcmc_reg_array ehea_bcmc_regs; |
| 108 | |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 109 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 110 | static int __devinit ehea_probe_adapter(struct platform_device *dev, |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 111 | const struct of_device_id *id); |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 112 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 113 | static int __devexit ehea_remove(struct platform_device *dev); |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 114 | |
| 115 | static struct of_device_id ehea_device_table[] = { |
| 116 | { |
| 117 | .name = "lhea", |
| 118 | .compatible = "IBM,lhea", |
| 119 | }, |
| 120 | {}, |
| 121 | }; |
Jan-Bernd Themann | b0afffe | 2008-07-03 15:18:48 +0100 | [diff] [blame] | 122 | MODULE_DEVICE_TABLE(of, ehea_device_table); |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 123 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 124 | static struct of_platform_driver ehea_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 125 | .driver = { |
| 126 | .name = "ehea", |
| 127 | .owner = THIS_MODULE, |
| 128 | .of_match_table = ehea_device_table, |
| 129 | }, |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 130 | .probe = ehea_probe_adapter, |
| 131 | .remove = ehea_remove, |
| 132 | }; |
| 133 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 134 | void ehea_dump(void *adr, int len, char *msg) |
| 135 | { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 136 | int x; |
| 137 | unsigned char *deb = adr; |
| 138 | for (x = 0; x < len; x += 16) { |
Stephen Rothwell | a1c5a89 | 2009-01-06 14:40:06 +0000 | [diff] [blame] | 139 | printk(DRV_NAME " %s adr=%p ofs=%04x %016llx %016llx\n", msg, |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 140 | deb, x, *((u64 *)&deb[0]), *((u64 *)&deb[8])); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 141 | deb += 16; |
| 142 | } |
| 143 | } |
| 144 | |
Jan-Bernd Themann | 2f69ae0 | 2008-07-03 15:18:51 +0100 | [diff] [blame] | 145 | void ehea_schedule_port_reset(struct ehea_port *port) |
| 146 | { |
| 147 | if (!test_bit(__EHEA_DISABLE_PORT_RESET, &port->flags)) |
| 148 | schedule_work(&port->reset_task); |
| 149 | } |
| 150 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 151 | static void ehea_update_firmware_handles(void) |
| 152 | { |
| 153 | struct ehea_fw_handle_entry *arr = NULL; |
| 154 | struct ehea_adapter *adapter; |
| 155 | int num_adapters = 0; |
| 156 | int num_ports = 0; |
| 157 | int num_portres = 0; |
| 158 | int i = 0; |
| 159 | int num_fw_handles, k, l; |
| 160 | |
| 161 | /* Determine number of handles */ |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 162 | mutex_lock(&ehea_fw_handles.lock); |
| 163 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 164 | list_for_each_entry(adapter, &adapter_list, list) { |
| 165 | num_adapters++; |
| 166 | |
| 167 | for (k = 0; k < EHEA_MAX_PORTS; k++) { |
| 168 | struct ehea_port *port = adapter->port[k]; |
| 169 | |
| 170 | if (!port || (port->state != EHEA_PORT_UP)) |
| 171 | continue; |
| 172 | |
| 173 | num_ports++; |
| 174 | num_portres += port->num_def_qps + port->num_add_tx_qps; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | num_fw_handles = num_adapters * EHEA_NUM_ADAPTER_FW_HANDLES + |
| 179 | num_ports * EHEA_NUM_PORT_FW_HANDLES + |
| 180 | num_portres * EHEA_NUM_PORTRES_FW_HANDLES; |
| 181 | |
| 182 | if (num_fw_handles) { |
Joe Perches | baeb2ff | 2010-08-11 07:02:48 +0000 | [diff] [blame] | 183 | arr = kcalloc(num_fw_handles, sizeof(*arr), GFP_KERNEL); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 184 | if (!arr) |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 185 | goto out; /* Keep the existing array */ |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 186 | } else |
| 187 | goto out_update; |
| 188 | |
| 189 | list_for_each_entry(adapter, &adapter_list, list) { |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 190 | if (num_adapters == 0) |
| 191 | break; |
| 192 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 193 | for (k = 0; k < EHEA_MAX_PORTS; k++) { |
| 194 | struct ehea_port *port = adapter->port[k]; |
| 195 | |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 196 | if (!port || (port->state != EHEA_PORT_UP) || |
| 197 | (num_ports == 0)) |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 198 | continue; |
| 199 | |
| 200 | for (l = 0; |
| 201 | l < port->num_def_qps + port->num_add_tx_qps; |
| 202 | l++) { |
| 203 | struct ehea_port_res *pr = &port->port_res[l]; |
| 204 | |
| 205 | arr[i].adh = adapter->handle; |
| 206 | arr[i++].fwh = pr->qp->fw_handle; |
| 207 | arr[i].adh = adapter->handle; |
| 208 | arr[i++].fwh = pr->send_cq->fw_handle; |
| 209 | arr[i].adh = adapter->handle; |
| 210 | arr[i++].fwh = pr->recv_cq->fw_handle; |
| 211 | arr[i].adh = adapter->handle; |
| 212 | arr[i++].fwh = pr->eq->fw_handle; |
| 213 | arr[i].adh = adapter->handle; |
| 214 | arr[i++].fwh = pr->send_mr.handle; |
| 215 | arr[i].adh = adapter->handle; |
| 216 | arr[i++].fwh = pr->recv_mr.handle; |
| 217 | } |
| 218 | arr[i].adh = adapter->handle; |
| 219 | arr[i++].fwh = port->qp_eq->fw_handle; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 220 | num_ports--; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | arr[i].adh = adapter->handle; |
| 224 | arr[i++].fwh = adapter->neq->fw_handle; |
| 225 | |
| 226 | if (adapter->mr.handle) { |
| 227 | arr[i].adh = adapter->handle; |
| 228 | arr[i++].fwh = adapter->mr.handle; |
| 229 | } |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 230 | num_adapters--; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | out_update: |
| 234 | kfree(ehea_fw_handles.arr); |
| 235 | ehea_fw_handles.arr = arr; |
| 236 | ehea_fw_handles.num_entries = i; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 237 | out: |
| 238 | mutex_unlock(&ehea_fw_handles.lock); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static void ehea_update_bcmc_registrations(void) |
| 242 | { |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 243 | unsigned long flags; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 244 | struct ehea_bcmc_reg_entry *arr = NULL; |
| 245 | struct ehea_adapter *adapter; |
| 246 | struct ehea_mc_list *mc_entry; |
| 247 | int num_registrations = 0; |
| 248 | int i = 0; |
| 249 | int k; |
| 250 | |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 251 | spin_lock_irqsave(&ehea_bcmc_regs.lock, flags); |
| 252 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 253 | /* Determine number of registrations */ |
| 254 | list_for_each_entry(adapter, &adapter_list, list) |
| 255 | for (k = 0; k < EHEA_MAX_PORTS; k++) { |
| 256 | struct ehea_port *port = adapter->port[k]; |
| 257 | |
| 258 | if (!port || (port->state != EHEA_PORT_UP)) |
| 259 | continue; |
| 260 | |
| 261 | num_registrations += 2; /* Broadcast registrations */ |
| 262 | |
| 263 | list_for_each_entry(mc_entry, &port->mc_list->list,list) |
| 264 | num_registrations += 2; |
| 265 | } |
| 266 | |
| 267 | if (num_registrations) { |
Joe Perches | baeb2ff | 2010-08-11 07:02:48 +0000 | [diff] [blame] | 268 | arr = kcalloc(num_registrations, sizeof(*arr), GFP_ATOMIC); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 269 | if (!arr) |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 270 | goto out; /* Keep the existing array */ |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 271 | } else |
| 272 | goto out_update; |
| 273 | |
| 274 | list_for_each_entry(adapter, &adapter_list, list) { |
| 275 | for (k = 0; k < EHEA_MAX_PORTS; k++) { |
| 276 | struct ehea_port *port = adapter->port[k]; |
| 277 | |
| 278 | if (!port || (port->state != EHEA_PORT_UP)) |
| 279 | continue; |
| 280 | |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 281 | if (num_registrations == 0) |
| 282 | goto out_update; |
| 283 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 284 | arr[i].adh = adapter->handle; |
| 285 | arr[i].port_id = port->logical_port_id; |
| 286 | arr[i].reg_type = EHEA_BCMC_BROADCAST | |
| 287 | EHEA_BCMC_UNTAGGED; |
| 288 | arr[i++].macaddr = port->mac_addr; |
| 289 | |
| 290 | arr[i].adh = adapter->handle; |
| 291 | arr[i].port_id = port->logical_port_id; |
| 292 | arr[i].reg_type = EHEA_BCMC_BROADCAST | |
| 293 | EHEA_BCMC_VLANID_ALL; |
| 294 | arr[i++].macaddr = port->mac_addr; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 295 | num_registrations -= 2; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 296 | |
| 297 | list_for_each_entry(mc_entry, |
| 298 | &port->mc_list->list, list) { |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 299 | if (num_registrations == 0) |
| 300 | goto out_update; |
| 301 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 302 | arr[i].adh = adapter->handle; |
| 303 | arr[i].port_id = port->logical_port_id; |
| 304 | arr[i].reg_type = EHEA_BCMC_SCOPE_ALL | |
| 305 | EHEA_BCMC_MULTICAST | |
| 306 | EHEA_BCMC_UNTAGGED; |
| 307 | arr[i++].macaddr = mc_entry->macaddr; |
| 308 | |
| 309 | arr[i].adh = adapter->handle; |
| 310 | arr[i].port_id = port->logical_port_id; |
| 311 | arr[i].reg_type = EHEA_BCMC_SCOPE_ALL | |
| 312 | EHEA_BCMC_MULTICAST | |
| 313 | EHEA_BCMC_VLANID_ALL; |
| 314 | arr[i++].macaddr = mc_entry->macaddr; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 315 | num_registrations -= 2; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | out_update: |
| 321 | kfree(ehea_bcmc_regs.arr); |
| 322 | ehea_bcmc_regs.arr = arr; |
| 323 | ehea_bcmc_regs.num_entries = i; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 324 | out: |
| 325 | spin_unlock_irqrestore(&ehea_bcmc_regs.lock, flags); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 328 | static struct net_device_stats *ehea_get_stats(struct net_device *dev) |
| 329 | { |
| 330 | struct ehea_port *port = netdev_priv(dev); |
| 331 | struct net_device_stats *stats = &port->stats; |
| 332 | struct hcp_ehea_port_cb2 *cb2; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 333 | u64 hret, rx_packets, tx_packets, rx_bytes = 0, tx_bytes = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 334 | int i; |
| 335 | |
| 336 | memset(stats, 0, sizeof(*stats)); |
| 337 | |
Brian King | 3d8009c | 2010-06-30 11:59:12 +0000 | [diff] [blame] | 338 | cb2 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 339 | if (!cb2) { |
| 340 | ehea_error("no mem for cb2"); |
| 341 | goto out; |
| 342 | } |
| 343 | |
| 344 | hret = ehea_h_query_ehea_port(port->adapter->handle, |
| 345 | port->logical_port_id, |
| 346 | H_PORT_CB2, H_PORT_CB2_ALL, cb2); |
| 347 | if (hret != H_SUCCESS) { |
| 348 | ehea_error("query_ehea_port failed"); |
| 349 | goto out_herr; |
| 350 | } |
| 351 | |
| 352 | if (netif_msg_hw(port)) |
| 353 | ehea_dump(cb2, sizeof(*cb2), "net_device_stats"); |
| 354 | |
| 355 | rx_packets = 0; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 356 | for (i = 0; i < port->num_def_qps; i++) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 357 | rx_packets += port->port_res[i].rx_packets; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 358 | rx_bytes += port->port_res[i].rx_bytes; |
| 359 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 360 | |
Thomas Klein | 7393b87 | 2007-11-21 17:37:58 +0100 | [diff] [blame] | 361 | tx_packets = 0; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 362 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
Thomas Klein | 7393b87 | 2007-11-21 17:37:58 +0100 | [diff] [blame] | 363 | tx_packets += port->port_res[i].tx_packets; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 364 | tx_bytes += port->port_res[i].tx_bytes; |
| 365 | } |
Thomas Klein | 7393b87 | 2007-11-21 17:37:58 +0100 | [diff] [blame] | 366 | |
| 367 | stats->tx_packets = tx_packets; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 368 | stats->multicast = cb2->rxmcp; |
| 369 | stats->rx_errors = cb2->rxuerr; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 370 | stats->rx_bytes = rx_bytes; |
| 371 | stats->tx_bytes = tx_bytes; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 372 | stats->rx_packets = rx_packets; |
| 373 | |
| 374 | out_herr: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 375 | free_page((unsigned long)cb2); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 376 | out: |
| 377 | return stats; |
| 378 | } |
| 379 | |
| 380 | static void ehea_refill_rq1(struct ehea_port_res *pr, int index, int nr_of_wqes) |
| 381 | { |
| 382 | struct sk_buff **skb_arr_rq1 = pr->rq1_skba.arr; |
| 383 | struct net_device *dev = pr->port->netdev; |
| 384 | int max_index_mask = pr->rq1_skba.len - 1; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 385 | int fill_wqes = pr->rq1_skba.os_skbs + nr_of_wqes; |
| 386 | int adder = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 387 | int i; |
| 388 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 389 | pr->rq1_skba.os_skbs = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 390 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 391 | if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) { |
Thomas Klein | 44fb312 | 2008-04-04 15:04:53 +0200 | [diff] [blame] | 392 | if (nr_of_wqes > 0) |
| 393 | pr->rq1_skba.index = index; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 394 | pr->rq1_skba.os_skbs = fill_wqes; |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | for (i = 0; i < fill_wqes; i++) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 399 | if (!skb_arr_rq1[index]) { |
| 400 | skb_arr_rq1[index] = netdev_alloc_skb(dev, |
| 401 | EHEA_L_PKT_SIZE); |
| 402 | if (!skb_arr_rq1[index]) { |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 403 | ehea_info("Unable to allocate enough skb in the array\n"); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 404 | pr->rq1_skba.os_skbs = fill_wqes - i; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 405 | break; |
| 406 | } |
| 407 | } |
| 408 | index--; |
| 409 | index &= max_index_mask; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 410 | adder++; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 411 | } |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 412 | |
| 413 | if (adder == 0) |
| 414 | return; |
| 415 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 416 | /* Ring doorbell */ |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 417 | ehea_update_rq1a(pr->qp, adder); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 418 | } |
| 419 | |
Thomas Klein | e287880 | 2009-01-21 14:45:57 -0800 | [diff] [blame] | 420 | static void ehea_init_fill_rq1(struct ehea_port_res *pr, int nr_rq1a) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 421 | { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 422 | struct sk_buff **skb_arr_rq1 = pr->rq1_skba.arr; |
| 423 | struct net_device *dev = pr->port->netdev; |
| 424 | int i; |
| 425 | |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 426 | if (nr_rq1a > pr->rq1_skba.len) { |
| 427 | ehea_error("NR_RQ1A bigger than skb array len\n"); |
| 428 | return; |
| 429 | } |
| 430 | |
| 431 | for (i = 0; i < nr_rq1a; i++) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 432 | skb_arr_rq1[i] = netdev_alloc_skb(dev, EHEA_L_PKT_SIZE); |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 433 | if (!skb_arr_rq1[i]) { |
| 434 | ehea_info("No enough memory to allocate skb array\n"); |
Thomas Klein | e287880 | 2009-01-21 14:45:57 -0800 | [diff] [blame] | 435 | break; |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 436 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 437 | } |
| 438 | /* Ring doorbell */ |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 439 | ehea_update_rq1a(pr->qp, i); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | static int ehea_refill_rq_def(struct ehea_port_res *pr, |
| 443 | struct ehea_q_skb_arr *q_skba, int rq_nr, |
| 444 | int num_wqes, int wqe_type, int packet_size) |
| 445 | { |
| 446 | struct net_device *dev = pr->port->netdev; |
| 447 | struct ehea_qp *qp = pr->qp; |
| 448 | struct sk_buff **skb_arr = q_skba->arr; |
| 449 | struct ehea_rwqe *rwqe; |
| 450 | int i, index, max_index_mask, fill_wqes; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 451 | int adder = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 452 | int ret = 0; |
| 453 | |
| 454 | fill_wqes = q_skba->os_skbs + num_wqes; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 455 | q_skba->os_skbs = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 456 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 457 | if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) { |
| 458 | q_skba->os_skbs = fill_wqes; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 459 | return ret; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 460 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 461 | |
| 462 | index = q_skba->index; |
| 463 | max_index_mask = q_skba->len - 1; |
| 464 | for (i = 0; i < fill_wqes; i++) { |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 465 | u64 tmp_addr; |
Eric Dumazet | 89d71a6 | 2009-10-13 05:34:20 +0000 | [diff] [blame] | 466 | struct sk_buff *skb; |
| 467 | |
| 468 | skb = netdev_alloc_skb_ip_align(dev, packet_size); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 469 | if (!skb) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 470 | q_skba->os_skbs = fill_wqes - i; |
Thomas Klein | e287880 | 2009-01-21 14:45:57 -0800 | [diff] [blame] | 471 | if (q_skba->os_skbs == q_skba->len - 2) { |
| 472 | ehea_info("%s: rq%i ran dry - no mem for skb", |
| 473 | pr->port->netdev->name, rq_nr); |
| 474 | ret = -ENOMEM; |
| 475 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 476 | break; |
| 477 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 478 | |
| 479 | skb_arr[index] = skb; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 480 | tmp_addr = ehea_map_vaddr(skb->data); |
| 481 | if (tmp_addr == -1) { |
| 482 | dev_kfree_skb(skb); |
| 483 | q_skba->os_skbs = fill_wqes - i; |
| 484 | ret = 0; |
| 485 | break; |
| 486 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 487 | |
| 488 | rwqe = ehea_get_next_rwqe(qp, rq_nr); |
| 489 | rwqe->wr_id = EHEA_BMASK_SET(EHEA_WR_ID_TYPE, wqe_type) |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 490 | | EHEA_BMASK_SET(EHEA_WR_ID_INDEX, index); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 491 | rwqe->sg_list[0].l_key = pr->recv_mr.lkey; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 492 | rwqe->sg_list[0].vaddr = tmp_addr; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 493 | rwqe->sg_list[0].len = packet_size; |
| 494 | rwqe->data_segments = 1; |
| 495 | |
| 496 | index++; |
| 497 | index &= max_index_mask; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 498 | adder++; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 499 | } |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 500 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 501 | q_skba->index = index; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 502 | if (adder == 0) |
| 503 | goto out; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 504 | |
| 505 | /* Ring doorbell */ |
| 506 | iosync(); |
| 507 | if (rq_nr == 2) |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 508 | ehea_update_rq2a(pr->qp, adder); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 509 | else |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 510 | ehea_update_rq3a(pr->qp, adder); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 511 | out: |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 512 | return ret; |
| 513 | } |
| 514 | |
| 515 | |
| 516 | static int ehea_refill_rq2(struct ehea_port_res *pr, int nr_of_wqes) |
| 517 | { |
| 518 | return ehea_refill_rq_def(pr, &pr->rq2_skba, 2, |
| 519 | nr_of_wqes, EHEA_RWQE2_TYPE, |
Eric Dumazet | 89d71a6 | 2009-10-13 05:34:20 +0000 | [diff] [blame] | 520 | EHEA_RQ2_PKT_SIZE); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | |
| 524 | static int ehea_refill_rq3(struct ehea_port_res *pr, int nr_of_wqes) |
| 525 | { |
| 526 | return ehea_refill_rq_def(pr, &pr->rq3_skba, 3, |
| 527 | nr_of_wqes, EHEA_RWQE3_TYPE, |
Eric Dumazet | 89d71a6 | 2009-10-13 05:34:20 +0000 | [diff] [blame] | 528 | EHEA_MAX_PACKET_SIZE); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | static inline int ehea_check_cqe(struct ehea_cqe *cqe, int *rq_num) |
| 532 | { |
| 533 | *rq_num = (cqe->type & EHEA_CQE_TYPE_RQ) >> 5; |
| 534 | if ((cqe->status & EHEA_CQE_STAT_ERR_MASK) == 0) |
| 535 | return 0; |
| 536 | if (((cqe->status & EHEA_CQE_STAT_ERR_TCP) != 0) && |
| 537 | (cqe->header_length == 0)) |
| 538 | return 0; |
| 539 | return -EINVAL; |
| 540 | } |
| 541 | |
| 542 | static inline void ehea_fill_skb(struct net_device *dev, |
| 543 | struct sk_buff *skb, struct ehea_cqe *cqe) |
| 544 | { |
| 545 | int length = cqe->num_bytes_transfered - 4; /*remove CRC */ |
| 546 | |
| 547 | skb_put(skb, length); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 548 | skb->protocol = eth_type_trans(skb, dev); |
Breno Leitao | 71085ce | 2010-10-07 13:17:33 +0000 | [diff] [blame] | 549 | |
| 550 | /* The packet was not an IPV4 packet so a complemented checksum was |
| 551 | calculated. The value is found in the Internet Checksum field. */ |
| 552 | if (cqe->status & EHEA_CQE_BLIND_CKSUM) { |
| 553 | skb->ip_summed = CHECKSUM_COMPLETE; |
| 554 | skb->csum = csum_unfold(~cqe->inet_checksum_value); |
| 555 | } else |
| 556 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | static inline struct sk_buff *get_skb_by_index(struct sk_buff **skb_array, |
| 560 | int arr_len, |
| 561 | struct ehea_cqe *cqe) |
| 562 | { |
| 563 | int skb_index = EHEA_BMASK_GET(EHEA_WR_ID_INDEX, cqe->wr_id); |
| 564 | struct sk_buff *skb; |
| 565 | void *pref; |
| 566 | int x; |
| 567 | |
| 568 | x = skb_index + 1; |
| 569 | x &= (arr_len - 1); |
| 570 | |
| 571 | pref = skb_array[x]; |
Hannes Hering | 0b2febf | 2009-05-04 11:06:37 -0700 | [diff] [blame] | 572 | if (pref) { |
| 573 | prefetchw(pref); |
| 574 | prefetchw(pref + EHEA_CACHE_LINE); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 575 | |
Hannes Hering | 0b2febf | 2009-05-04 11:06:37 -0700 | [diff] [blame] | 576 | pref = (skb_array[x]->data); |
| 577 | prefetch(pref); |
| 578 | prefetch(pref + EHEA_CACHE_LINE); |
| 579 | prefetch(pref + EHEA_CACHE_LINE * 2); |
| 580 | prefetch(pref + EHEA_CACHE_LINE * 3); |
| 581 | } |
| 582 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 583 | skb = skb_array[skb_index]; |
| 584 | skb_array[skb_index] = NULL; |
| 585 | return skb; |
| 586 | } |
| 587 | |
| 588 | static inline struct sk_buff *get_skb_by_index_ll(struct sk_buff **skb_array, |
| 589 | int arr_len, int wqe_index) |
| 590 | { |
| 591 | struct sk_buff *skb; |
| 592 | void *pref; |
| 593 | int x; |
| 594 | |
| 595 | x = wqe_index + 1; |
| 596 | x &= (arr_len - 1); |
| 597 | |
| 598 | pref = skb_array[x]; |
Hannes Hering | 0b2febf | 2009-05-04 11:06:37 -0700 | [diff] [blame] | 599 | if (pref) { |
| 600 | prefetchw(pref); |
| 601 | prefetchw(pref + EHEA_CACHE_LINE); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 602 | |
Hannes Hering | 0b2febf | 2009-05-04 11:06:37 -0700 | [diff] [blame] | 603 | pref = (skb_array[x]->data); |
| 604 | prefetchw(pref); |
| 605 | prefetchw(pref + EHEA_CACHE_LINE); |
| 606 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 607 | |
| 608 | skb = skb_array[wqe_index]; |
| 609 | skb_array[wqe_index] = NULL; |
| 610 | return skb; |
| 611 | } |
| 612 | |
| 613 | static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, |
| 614 | struct ehea_cqe *cqe, int *processed_rq2, |
| 615 | int *processed_rq3) |
| 616 | { |
| 617 | struct sk_buff *skb; |
| 618 | |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 619 | if (cqe->status & EHEA_CQE_STAT_ERR_TCP) |
| 620 | pr->p_stats.err_tcp_cksum++; |
| 621 | if (cqe->status & EHEA_CQE_STAT_ERR_IP) |
| 622 | pr->p_stats.err_ip_cksum++; |
| 623 | if (cqe->status & EHEA_CQE_STAT_ERR_CRC) |
| 624 | pr->p_stats.err_frame_crc++; |
| 625 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 626 | if (rq == 2) { |
| 627 | *processed_rq2 += 1; |
| 628 | skb = get_skb_by_index(pr->rq2_skba.arr, pr->rq2_skba.len, cqe); |
| 629 | dev_kfree_skb(skb); |
| 630 | } else if (rq == 3) { |
| 631 | *processed_rq3 += 1; |
| 632 | skb = get_skb_by_index(pr->rq3_skba.arr, pr->rq3_skba.len, cqe); |
| 633 | dev_kfree_skb(skb); |
| 634 | } |
| 635 | |
| 636 | if (cqe->status & EHEA_CQE_STAT_FAT_ERR_MASK) { |
Thomas Klein | 58dd825 | 2007-11-21 17:42:27 +0100 | [diff] [blame] | 637 | if (netif_msg_rx_err(pr->port)) { |
| 638 | ehea_error("Critical receive error for QP %d. " |
| 639 | "Resetting port.", pr->qp->init_attr.qp_nr); |
| 640 | ehea_dump(cqe, sizeof(*cqe), "CQE"); |
| 641 | } |
Jan-Bernd Themann | 2f69ae0 | 2008-07-03 15:18:51 +0100 | [diff] [blame] | 642 | ehea_schedule_port_reset(pr->port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 643 | return 1; |
| 644 | } |
| 645 | |
| 646 | return 0; |
| 647 | } |
| 648 | |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 649 | static int get_skb_hdr(struct sk_buff *skb, void **iphdr, |
| 650 | void **tcph, u64 *hdr_flags, void *priv) |
| 651 | { |
| 652 | struct ehea_cqe *cqe = priv; |
| 653 | unsigned int ip_len; |
| 654 | struct iphdr *iph; |
| 655 | |
| 656 | /* non tcp/udp packets */ |
| 657 | if (!cqe->header_length) |
| 658 | return -1; |
| 659 | |
| 660 | /* non tcp packet */ |
| 661 | skb_reset_network_header(skb); |
| 662 | iph = ip_hdr(skb); |
| 663 | if (iph->protocol != IPPROTO_TCP) |
| 664 | return -1; |
| 665 | |
| 666 | ip_len = ip_hdrlen(skb); |
| 667 | skb_set_transport_header(skb, ip_len); |
| 668 | *tcph = tcp_hdr(skb); |
| 669 | |
| 670 | /* check if ip header and tcp header are complete */ |
Roland Dreier | 3ff2cd2 | 2008-07-01 10:20:33 -0700 | [diff] [blame] | 671 | if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb)) |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 672 | return -1; |
| 673 | |
| 674 | *hdr_flags = LRO_IPV4 | LRO_TCP; |
| 675 | *iphdr = iph; |
| 676 | |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | static void ehea_proc_skb(struct ehea_port_res *pr, struct ehea_cqe *cqe, |
| 681 | struct sk_buff *skb) |
| 682 | { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 683 | int vlan_extracted = ((cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) && |
| 684 | pr->port->vgrp); |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 685 | |
Breno Leitao | c7757fd | 2010-12-08 12:19:14 -0800 | [diff] [blame^] | 686 | if (skb->dev->features & NETIF_F_LRO) { |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 687 | if (vlan_extracted) |
| 688 | lro_vlan_hwaccel_receive_skb(&pr->lro_mgr, skb, |
| 689 | pr->port->vgrp, |
| 690 | cqe->vlan_tag, |
| 691 | cqe); |
| 692 | else |
| 693 | lro_receive_skb(&pr->lro_mgr, skb, cqe); |
| 694 | } else { |
| 695 | if (vlan_extracted) |
| 696 | vlan_hwaccel_receive_skb(skb, pr->port->vgrp, |
| 697 | cqe->vlan_tag); |
| 698 | else |
| 699 | netif_receive_skb(skb); |
| 700 | } |
| 701 | } |
| 702 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 703 | static int ehea_proc_rwqes(struct net_device *dev, |
| 704 | struct ehea_port_res *pr, |
| 705 | int budget) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 706 | { |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 707 | struct ehea_port *port = pr->port; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 708 | struct ehea_qp *qp = pr->qp; |
| 709 | struct ehea_cqe *cqe; |
| 710 | struct sk_buff *skb; |
| 711 | struct sk_buff **skb_arr_rq1 = pr->rq1_skba.arr; |
| 712 | struct sk_buff **skb_arr_rq2 = pr->rq2_skba.arr; |
| 713 | struct sk_buff **skb_arr_rq3 = pr->rq3_skba.arr; |
| 714 | int skb_arr_rq1_len = pr->rq1_skba.len; |
| 715 | int skb_arr_rq2_len = pr->rq2_skba.len; |
| 716 | int skb_arr_rq3_len = pr->rq3_skba.len; |
| 717 | int processed, processed_rq1, processed_rq2, processed_rq3; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 718 | u64 processed_bytes = 0; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 719 | int wqe_index, last_wqe_index, rq, port_reset; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 720 | |
| 721 | processed = processed_rq1 = processed_rq2 = processed_rq3 = 0; |
| 722 | last_wqe_index = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 723 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 724 | cqe = ehea_poll_rq1(qp, &wqe_index); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 725 | while ((processed < budget) && cqe) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 726 | ehea_inc_rq1(qp); |
| 727 | processed_rq1++; |
| 728 | processed++; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 729 | if (netif_msg_rx_status(port)) |
| 730 | ehea_dump(cqe, sizeof(*cqe), "CQE"); |
| 731 | |
| 732 | last_wqe_index = wqe_index; |
| 733 | rmb(); |
| 734 | if (!ehea_check_cqe(cqe, &rq)) { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 735 | if (rq == 1) { |
| 736 | /* LL RQ1 */ |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 737 | skb = get_skb_by_index_ll(skb_arr_rq1, |
| 738 | skb_arr_rq1_len, |
| 739 | wqe_index); |
| 740 | if (unlikely(!skb)) { |
| 741 | if (netif_msg_rx_err(port)) |
| 742 | ehea_error("LL rq1: skb=NULL"); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 743 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 744 | skb = netdev_alloc_skb(dev, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 745 | EHEA_L_PKT_SIZE); |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 746 | if (!skb) { |
| 747 | ehea_info("Not enough memory to allocate skb\n"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 748 | break; |
Breno Leitao | 5c7e57f | 2010-11-26 07:26:27 +0000 | [diff] [blame] | 749 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 750 | } |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 751 | skb_copy_to_linear_data(skb, ((char *)cqe) + 64, |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 752 | cqe->num_bytes_transfered - 4); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 753 | ehea_fill_skb(dev, skb, cqe); |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 754 | } else if (rq == 2) { |
| 755 | /* RQ2 */ |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 756 | skb = get_skb_by_index(skb_arr_rq2, |
| 757 | skb_arr_rq2_len, cqe); |
| 758 | if (unlikely(!skb)) { |
| 759 | if (netif_msg_rx_err(port)) |
| 760 | ehea_error("rq2: skb=NULL"); |
| 761 | break; |
| 762 | } |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 763 | ehea_fill_skb(dev, skb, cqe); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 764 | processed_rq2++; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 765 | } else { |
| 766 | /* RQ3 */ |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 767 | skb = get_skb_by_index(skb_arr_rq3, |
| 768 | skb_arr_rq3_len, cqe); |
| 769 | if (unlikely(!skb)) { |
| 770 | if (netif_msg_rx_err(port)) |
| 771 | ehea_error("rq3: skb=NULL"); |
| 772 | break; |
| 773 | } |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 774 | ehea_fill_skb(dev, skb, cqe); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 775 | processed_rq3++; |
| 776 | } |
| 777 | |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 778 | processed_bytes += skb->len; |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 779 | ehea_proc_skb(pr, cqe, skb); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 780 | } else { |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 781 | pr->p_stats.poll_receive_errors++; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 782 | port_reset = ehea_treat_poll_error(pr, rq, cqe, |
| 783 | &processed_rq2, |
| 784 | &processed_rq3); |
| 785 | if (port_reset) |
| 786 | break; |
| 787 | } |
| 788 | cqe = ehea_poll_rq1(qp, &wqe_index); |
| 789 | } |
Breno Leitao | c7757fd | 2010-12-08 12:19:14 -0800 | [diff] [blame^] | 790 | if (dev->features & NETIF_F_LRO) |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 791 | lro_flush_all(&pr->lro_mgr); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 792 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 793 | pr->rx_packets += processed; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 794 | pr->rx_bytes += processed_bytes; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 795 | |
| 796 | ehea_refill_rq1(pr, last_wqe_index, processed_rq1); |
| 797 | ehea_refill_rq2(pr, processed_rq2); |
| 798 | ehea_refill_rq3(pr, processed_rq3); |
| 799 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 800 | return processed; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 801 | } |
| 802 | |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 803 | #define SWQE_RESTART_CHECK 0xdeadbeaff00d0000ull |
| 804 | |
| 805 | static void reset_sq_restart_flag(struct ehea_port *port) |
| 806 | { |
| 807 | int i; |
| 808 | |
| 809 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
| 810 | struct ehea_port_res *pr = &port->port_res[i]; |
| 811 | pr->sq_restart_flag = 0; |
| 812 | } |
Breno Leitao | a8bb69f | 2010-10-05 13:16:23 +0000 | [diff] [blame] | 813 | wake_up(&port->restart_wq); |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | static void check_sqs(struct ehea_port *port) |
| 817 | { |
| 818 | struct ehea_swqe *swqe; |
| 819 | int swqe_index; |
| 820 | int i, k; |
| 821 | |
| 822 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
| 823 | struct ehea_port_res *pr = &port->port_res[i]; |
Breno Leitao | a8bb69f | 2010-10-05 13:16:23 +0000 | [diff] [blame] | 824 | int ret; |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 825 | k = 0; |
| 826 | swqe = ehea_get_swqe(pr->qp, &swqe_index); |
| 827 | memset(swqe, 0, SWQE_HEADER_SIZE); |
| 828 | atomic_dec(&pr->swqe_avail); |
| 829 | |
| 830 | swqe->tx_control |= EHEA_SWQE_PURGE; |
| 831 | swqe->wr_id = SWQE_RESTART_CHECK; |
| 832 | swqe->tx_control |= EHEA_SWQE_SIGNALLED_COMPLETION; |
| 833 | swqe->tx_control |= EHEA_SWQE_IMM_DATA_PRESENT; |
| 834 | swqe->immediate_data_length = 80; |
| 835 | |
| 836 | ehea_post_swqe(pr->qp, swqe); |
| 837 | |
Breno Leitao | a8bb69f | 2010-10-05 13:16:23 +0000 | [diff] [blame] | 838 | ret = wait_event_timeout(port->restart_wq, |
| 839 | pr->sq_restart_flag == 0, |
| 840 | msecs_to_jiffies(100)); |
| 841 | |
| 842 | if (!ret) { |
| 843 | ehea_error("HW/SW queues out of sync"); |
| 844 | ehea_schedule_port_reset(pr->port); |
| 845 | return; |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 846 | } |
| 847 | } |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 851 | static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 852 | { |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 853 | struct sk_buff *skb; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 854 | struct ehea_cq *send_cq = pr->send_cq; |
| 855 | struct ehea_cqe *cqe; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 856 | int quota = my_quota; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 857 | int cqe_counter = 0; |
| 858 | int swqe_av = 0; |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 859 | int index; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 860 | unsigned long flags; |
| 861 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 862 | cqe = ehea_poll_cq(send_cq); |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 863 | while (cqe && (quota > 0)) { |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 864 | ehea_inc_cq(send_cq); |
| 865 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 866 | cqe_counter++; |
| 867 | rmb(); |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 868 | |
| 869 | if (cqe->wr_id == SWQE_RESTART_CHECK) { |
| 870 | pr->sq_restart_flag = 1; |
| 871 | swqe_av++; |
| 872 | break; |
| 873 | } |
| 874 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 875 | if (cqe->status & EHEA_CQE_STAT_ERR_MASK) { |
Thomas Klein | ea96cea | 2010-04-20 23:10:55 +0000 | [diff] [blame] | 876 | ehea_error("Bad send completion status=0x%04X", |
| 877 | cqe->status); |
| 878 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 879 | if (netif_msg_tx_err(pr->port)) |
| 880 | ehea_dump(cqe, sizeof(*cqe), "Send CQE"); |
Thomas Klein | ea96cea | 2010-04-20 23:10:55 +0000 | [diff] [blame] | 881 | |
| 882 | if (cqe->status & EHEA_CQE_STAT_RESET_MASK) { |
| 883 | ehea_error("Resetting port"); |
| 884 | ehea_schedule_port_reset(pr->port); |
| 885 | break; |
| 886 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | if (netif_msg_tx_done(pr->port)) |
| 890 | ehea_dump(cqe, sizeof(*cqe), "CQE"); |
| 891 | |
| 892 | if (likely(EHEA_BMASK_GET(EHEA_WR_ID_TYPE, cqe->wr_id) |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 893 | == EHEA_SWQE2_TYPE)) { |
| 894 | |
| 895 | index = EHEA_BMASK_GET(EHEA_WR_ID_INDEX, cqe->wr_id); |
| 896 | skb = pr->sq_skba.arr[index]; |
| 897 | dev_kfree_skb(skb); |
| 898 | pr->sq_skba.arr[index] = NULL; |
| 899 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 900 | |
| 901 | swqe_av += EHEA_BMASK_GET(EHEA_WR_ID_REFILL, cqe->wr_id); |
| 902 | quota--; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 903 | |
| 904 | cqe = ehea_poll_cq(send_cq); |
Joe Perches | ee289b6 | 2010-05-17 22:47:34 -0700 | [diff] [blame] | 905 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 906 | |
| 907 | ehea_update_feca(send_cq, cqe_counter); |
| 908 | atomic_add(swqe_av, &pr->swqe_avail); |
| 909 | |
| 910 | spin_lock_irqsave(&pr->netif_queue, flags); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 911 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 912 | if (pr->queue_stopped && (atomic_read(&pr->swqe_avail) |
| 913 | >= pr->swqe_refill_th)) { |
| 914 | netif_wake_queue(pr->port->netdev); |
| 915 | pr->queue_stopped = 0; |
| 916 | } |
| 917 | spin_unlock_irqrestore(&pr->netif_queue, flags); |
Breno Leitao | 5b27d42 | 2010-10-05 13:16:22 +0000 | [diff] [blame] | 918 | wake_up(&pr->port->swqe_avail_wq); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 919 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 920 | return cqe; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 921 | } |
| 922 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 923 | #define EHEA_NAPI_POLL_NUM_BEFORE_IRQ 16 |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 924 | #define EHEA_POLL_MAX_CQES 65535 |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 925 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 926 | static int ehea_poll(struct napi_struct *napi, int budget) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 927 | { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 928 | struct ehea_port_res *pr = container_of(napi, struct ehea_port_res, |
| 929 | napi); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 930 | struct net_device *dev = pr->port->netdev; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 931 | struct ehea_cqe *cqe; |
| 932 | struct ehea_cqe *cqe_skb = NULL; |
| 933 | int force_irq, wqe_index; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 934 | int rx = 0; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 935 | |
| 936 | force_irq = (pr->poll_counter > EHEA_NAPI_POLL_NUM_BEFORE_IRQ); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 937 | cqe_skb = ehea_proc_cqes(pr, EHEA_POLL_MAX_CQES); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 938 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 939 | if (!force_irq) |
| 940 | rx += ehea_proc_rwqes(dev, pr, budget - rx); |
| 941 | |
| 942 | while ((rx != budget) || force_irq) { |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 943 | pr->poll_counter = 0; |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 944 | force_irq = 0; |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 945 | napi_complete(napi); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 946 | ehea_reset_cq_ep(pr->recv_cq); |
| 947 | ehea_reset_cq_ep(pr->send_cq); |
| 948 | ehea_reset_cq_n1(pr->recv_cq); |
| 949 | ehea_reset_cq_n1(pr->send_cq); |
Jan-Bernd Themann | a91fb14 | 2010-06-15 05:35:16 +0000 | [diff] [blame] | 950 | rmb(); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 951 | cqe = ehea_poll_rq1(pr->qp, &wqe_index); |
| 952 | cqe_skb = ehea_poll_cq(pr->send_cq); |
| 953 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 954 | if (!cqe && !cqe_skb) |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 955 | return rx; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 956 | |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 957 | if (!napi_reschedule(napi)) |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 958 | return rx; |
| 959 | |
| 960 | cqe_skb = ehea_proc_cqes(pr, EHEA_POLL_MAX_CQES); |
| 961 | rx += ehea_proc_rwqes(dev, pr, budget - rx); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 962 | } |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 963 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 964 | pr->poll_counter++; |
| 965 | return rx; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 966 | } |
| 967 | |
Jan-Bernd Themann | 8d22c97 | 2007-07-23 16:05:03 +0200 | [diff] [blame] | 968 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 969 | static void ehea_netpoll(struct net_device *dev) |
| 970 | { |
| 971 | struct ehea_port *port = netdev_priv(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 972 | int i; |
Jan-Bernd Themann | 8d22c97 | 2007-07-23 16:05:03 +0200 | [diff] [blame] | 973 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 974 | for (i = 0; i < port->num_def_qps; i++) |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 975 | napi_schedule(&port->port_res[i].napi); |
Jan-Bernd Themann | 8d22c97 | 2007-07-23 16:05:03 +0200 | [diff] [blame] | 976 | } |
| 977 | #endif |
| 978 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 979 | static irqreturn_t ehea_recv_irq_handler(int irq, void *param) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 980 | { |
| 981 | struct ehea_port_res *pr = param; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 982 | |
Ben Hutchings | 288379f | 2009-01-19 16:43:59 -0800 | [diff] [blame] | 983 | napi_schedule(&pr->napi); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 984 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 985 | return IRQ_HANDLED; |
| 986 | } |
| 987 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 988 | static irqreturn_t ehea_qp_aff_irq_handler(int irq, void *param) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 989 | { |
| 990 | struct ehea_port *port = param; |
| 991 | struct ehea_eqe *eqe; |
Jan-Bernd Themann | d2db9ee | 2007-02-09 09:10:51 +0100 | [diff] [blame] | 992 | struct ehea_qp *qp; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 993 | u32 qp_token; |
Thomas Klein | ea96cea | 2010-04-20 23:10:55 +0000 | [diff] [blame] | 994 | u64 resource_type, aer, aerr; |
| 995 | int reset_port = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 996 | |
| 997 | eqe = ehea_poll_eq(port->qp_eq); |
Thomas Klein | bb3a644 | 2007-01-22 12:54:50 +0100 | [diff] [blame] | 998 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 999 | while (eqe) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1000 | qp_token = EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN, eqe->entry); |
Stephen Rothwell | a1c5a89 | 2009-01-06 14:40:06 +0000 | [diff] [blame] | 1001 | ehea_error("QP aff_err: entry=0x%llx, token=0x%x", |
Thomas Klein | bb3a644 | 2007-01-22 12:54:50 +0100 | [diff] [blame] | 1002 | eqe->entry, qp_token); |
Jan-Bernd Themann | d2db9ee | 2007-02-09 09:10:51 +0100 | [diff] [blame] | 1003 | |
| 1004 | qp = port->port_res[qp_token].qp; |
Thomas Klein | ea96cea | 2010-04-20 23:10:55 +0000 | [diff] [blame] | 1005 | |
| 1006 | resource_type = ehea_error_data(port->adapter, qp->fw_handle, |
| 1007 | &aer, &aerr); |
| 1008 | |
| 1009 | if (resource_type == EHEA_AER_RESTYPE_QP) { |
| 1010 | if ((aer & EHEA_AER_RESET_MASK) || |
| 1011 | (aerr & EHEA_AERR_RESET_MASK)) |
| 1012 | reset_port = 1; |
| 1013 | } else |
| 1014 | reset_port = 1; /* Reset in case of CQ or EQ error */ |
| 1015 | |
Thomas Klein | bb3a644 | 2007-01-22 12:54:50 +0100 | [diff] [blame] | 1016 | eqe = ehea_poll_eq(port->qp_eq); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1017 | } |
| 1018 | |
Thomas Klein | ea96cea | 2010-04-20 23:10:55 +0000 | [diff] [blame] | 1019 | if (reset_port) { |
| 1020 | ehea_error("Resetting port"); |
| 1021 | ehea_schedule_port_reset(port); |
| 1022 | } |
Jan-Bernd Themann | d2db9ee | 2007-02-09 09:10:51 +0100 | [diff] [blame] | 1023 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1024 | return IRQ_HANDLED; |
| 1025 | } |
| 1026 | |
| 1027 | static struct ehea_port *ehea_get_port(struct ehea_adapter *adapter, |
| 1028 | int logical_port) |
| 1029 | { |
| 1030 | int i; |
| 1031 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 1032 | for (i = 0; i < EHEA_MAX_PORTS; i++) |
Thomas Klein | 41b69c7 | 2007-01-22 12:55:20 +0100 | [diff] [blame] | 1033 | if (adapter->port[i]) |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 1034 | if (adapter->port[i]->logical_port_id == logical_port) |
Thomas Klein | 41b69c7 | 2007-01-22 12:55:20 +0100 | [diff] [blame] | 1035 | return adapter->port[i]; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1036 | return NULL; |
| 1037 | } |
| 1038 | |
| 1039 | int ehea_sense_port_attr(struct ehea_port *port) |
| 1040 | { |
| 1041 | int ret; |
| 1042 | u64 hret; |
| 1043 | struct hcp_ehea_port_cb0 *cb0; |
| 1044 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1045 | /* may be called via ehea_neq_tasklet() */ |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1046 | cb0 = (void *)get_zeroed_page(GFP_ATOMIC); |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1047 | if (!cb0) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1048 | ehea_error("no mem for cb0"); |
| 1049 | ret = -ENOMEM; |
| 1050 | goto out; |
| 1051 | } |
| 1052 | |
| 1053 | hret = ehea_h_query_ehea_port(port->adapter->handle, |
| 1054 | port->logical_port_id, H_PORT_CB0, |
| 1055 | EHEA_BMASK_SET(H_PORT_CB0_ALL, 0xFFFF), |
| 1056 | cb0); |
| 1057 | if (hret != H_SUCCESS) { |
| 1058 | ret = -EIO; |
| 1059 | goto out_free; |
| 1060 | } |
| 1061 | |
| 1062 | /* MAC address */ |
| 1063 | port->mac_addr = cb0->port_mac_addr << 16; |
| 1064 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1065 | if (!is_valid_ether_addr((u8 *)&port->mac_addr)) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1066 | ret = -EADDRNOTAVAIL; |
| 1067 | goto out_free; |
| 1068 | } |
| 1069 | |
| 1070 | /* Port speed */ |
| 1071 | switch (cb0->port_speed) { |
| 1072 | case H_SPEED_10M_H: |
| 1073 | port->port_speed = EHEA_SPEED_10M; |
| 1074 | port->full_duplex = 0; |
| 1075 | break; |
| 1076 | case H_SPEED_10M_F: |
| 1077 | port->port_speed = EHEA_SPEED_10M; |
| 1078 | port->full_duplex = 1; |
| 1079 | break; |
| 1080 | case H_SPEED_100M_H: |
| 1081 | port->port_speed = EHEA_SPEED_100M; |
| 1082 | port->full_duplex = 0; |
| 1083 | break; |
| 1084 | case H_SPEED_100M_F: |
| 1085 | port->port_speed = EHEA_SPEED_100M; |
| 1086 | port->full_duplex = 1; |
| 1087 | break; |
| 1088 | case H_SPEED_1G_F: |
| 1089 | port->port_speed = EHEA_SPEED_1G; |
| 1090 | port->full_duplex = 1; |
| 1091 | break; |
| 1092 | case H_SPEED_10G_F: |
| 1093 | port->port_speed = EHEA_SPEED_10G; |
| 1094 | port->full_duplex = 1; |
| 1095 | break; |
| 1096 | default: |
| 1097 | port->port_speed = 0; |
| 1098 | port->full_duplex = 0; |
| 1099 | break; |
| 1100 | } |
| 1101 | |
Thomas Klein | e919b59 | 2007-01-22 12:53:20 +0100 | [diff] [blame] | 1102 | port->autoneg = 1; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1103 | port->num_mcs = cb0->num_default_qps; |
Thomas Klein | e919b59 | 2007-01-22 12:53:20 +0100 | [diff] [blame] | 1104 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1105 | /* Number of default QPs */ |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1106 | if (use_mcs) |
| 1107 | port->num_def_qps = cb0->num_default_qps; |
| 1108 | else |
| 1109 | port->num_def_qps = 1; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1110 | |
| 1111 | if (!port->num_def_qps) { |
| 1112 | ret = -EINVAL; |
| 1113 | goto out_free; |
| 1114 | } |
| 1115 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1116 | port->num_tx_qps = num_tx_qps; |
| 1117 | |
| 1118 | if (port->num_def_qps >= port->num_tx_qps) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1119 | port->num_add_tx_qps = 0; |
| 1120 | else |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1121 | port->num_add_tx_qps = port->num_tx_qps - port->num_def_qps; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1122 | |
| 1123 | ret = 0; |
| 1124 | out_free: |
| 1125 | if (ret || netif_msg_probe(port)) |
| 1126 | ehea_dump(cb0, sizeof(*cb0), "ehea_sense_port_attr"); |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1127 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1128 | out: |
| 1129 | return ret; |
| 1130 | } |
| 1131 | |
| 1132 | int ehea_set_portspeed(struct ehea_port *port, u32 port_speed) |
| 1133 | { |
| 1134 | struct hcp_ehea_port_cb4 *cb4; |
| 1135 | u64 hret; |
| 1136 | int ret = 0; |
| 1137 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1138 | cb4 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1139 | if (!cb4) { |
| 1140 | ehea_error("no mem for cb4"); |
| 1141 | ret = -ENOMEM; |
| 1142 | goto out; |
| 1143 | } |
| 1144 | |
| 1145 | cb4->port_speed = port_speed; |
| 1146 | |
| 1147 | netif_carrier_off(port->netdev); |
| 1148 | |
| 1149 | hret = ehea_h_modify_ehea_port(port->adapter->handle, |
| 1150 | port->logical_port_id, |
| 1151 | H_PORT_CB4, H_PORT_CB4_SPEED, cb4); |
| 1152 | if (hret == H_SUCCESS) { |
| 1153 | port->autoneg = port_speed == EHEA_SPEED_AUTONEG ? 1 : 0; |
| 1154 | |
| 1155 | hret = ehea_h_query_ehea_port(port->adapter->handle, |
| 1156 | port->logical_port_id, |
| 1157 | H_PORT_CB4, H_PORT_CB4_SPEED, |
| 1158 | cb4); |
| 1159 | if (hret == H_SUCCESS) { |
| 1160 | switch (cb4->port_speed) { |
| 1161 | case H_SPEED_10M_H: |
| 1162 | port->port_speed = EHEA_SPEED_10M; |
| 1163 | port->full_duplex = 0; |
| 1164 | break; |
| 1165 | case H_SPEED_10M_F: |
| 1166 | port->port_speed = EHEA_SPEED_10M; |
| 1167 | port->full_duplex = 1; |
| 1168 | break; |
| 1169 | case H_SPEED_100M_H: |
| 1170 | port->port_speed = EHEA_SPEED_100M; |
| 1171 | port->full_duplex = 0; |
| 1172 | break; |
| 1173 | case H_SPEED_100M_F: |
| 1174 | port->port_speed = EHEA_SPEED_100M; |
| 1175 | port->full_duplex = 1; |
| 1176 | break; |
| 1177 | case H_SPEED_1G_F: |
| 1178 | port->port_speed = EHEA_SPEED_1G; |
| 1179 | port->full_duplex = 1; |
| 1180 | break; |
| 1181 | case H_SPEED_10G_F: |
| 1182 | port->port_speed = EHEA_SPEED_10G; |
| 1183 | port->full_duplex = 1; |
| 1184 | break; |
| 1185 | default: |
| 1186 | port->port_speed = 0; |
| 1187 | port->full_duplex = 0; |
| 1188 | break; |
| 1189 | } |
| 1190 | } else { |
| 1191 | ehea_error("Failed sensing port speed"); |
| 1192 | ret = -EIO; |
| 1193 | } |
| 1194 | } else { |
| 1195 | if (hret == H_AUTHORITY) { |
Thomas Klein | 7674a58 | 2007-01-22 12:54:20 +0100 | [diff] [blame] | 1196 | ehea_info("Hypervisor denied setting port speed"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1197 | ret = -EPERM; |
| 1198 | } else { |
| 1199 | ret = -EIO; |
| 1200 | ehea_error("Failed setting port speed"); |
| 1201 | } |
| 1202 | } |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 1203 | if (!prop_carrier_state || (port->phy_link == EHEA_PHY_LINK_UP)) |
| 1204 | netif_carrier_on(port->netdev); |
| 1205 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1206 | free_page((unsigned long)cb4); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1207 | out: |
| 1208 | return ret; |
| 1209 | } |
| 1210 | |
| 1211 | static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe) |
| 1212 | { |
| 1213 | int ret; |
| 1214 | u8 ec; |
| 1215 | u8 portnum; |
| 1216 | struct ehea_port *port; |
| 1217 | |
| 1218 | ec = EHEA_BMASK_GET(NEQE_EVENT_CODE, eqe); |
| 1219 | portnum = EHEA_BMASK_GET(NEQE_PORTNUM, eqe); |
| 1220 | port = ehea_get_port(adapter, portnum); |
| 1221 | |
| 1222 | switch (ec) { |
| 1223 | case EHEA_EC_PORTSTATE_CHG: /* port state change */ |
| 1224 | |
| 1225 | if (!port) { |
| 1226 | ehea_error("unknown portnum %x", portnum); |
| 1227 | break; |
| 1228 | } |
| 1229 | |
| 1230 | if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { |
| 1231 | if (!netif_carrier_ok(port->netdev)) { |
Jan-Bernd Themann | 1e1675c | 2006-10-25 13:11:42 +0200 | [diff] [blame] | 1232 | ret = ehea_sense_port_attr(port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1233 | if (ret) { |
| 1234 | ehea_error("failed resensing port " |
| 1235 | "attributes"); |
| 1236 | break; |
| 1237 | } |
| 1238 | |
| 1239 | if (netif_msg_link(port)) |
| 1240 | ehea_info("%s: Logical port up: %dMbps " |
| 1241 | "%s Duplex", |
| 1242 | port->netdev->name, |
| 1243 | port->port_speed, |
| 1244 | port->full_duplex == |
| 1245 | 1 ? "Full" : "Half"); |
| 1246 | |
| 1247 | netif_carrier_on(port->netdev); |
| 1248 | netif_wake_queue(port->netdev); |
| 1249 | } |
| 1250 | } else |
| 1251 | if (netif_carrier_ok(port->netdev)) { |
| 1252 | if (netif_msg_link(port)) |
| 1253 | ehea_info("%s: Logical port down", |
| 1254 | port->netdev->name); |
| 1255 | netif_carrier_off(port->netdev); |
| 1256 | netif_stop_queue(port->netdev); |
| 1257 | } |
| 1258 | |
| 1259 | if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PORT_UP, eqe)) { |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 1260 | port->phy_link = EHEA_PHY_LINK_UP; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1261 | if (netif_msg_link(port)) |
| 1262 | ehea_info("%s: Physical port up", |
| 1263 | port->netdev->name); |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 1264 | if (prop_carrier_state) |
| 1265 | netif_carrier_on(port->netdev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1266 | } else { |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 1267 | port->phy_link = EHEA_PHY_LINK_DOWN; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1268 | if (netif_msg_link(port)) |
| 1269 | ehea_info("%s: Physical port down", |
| 1270 | port->netdev->name); |
Jan-Bernd Themann | 8759cf7 | 2007-09-07 12:30:17 +0200 | [diff] [blame] | 1271 | if (prop_carrier_state) |
| 1272 | netif_carrier_off(port->netdev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PRIMARY, eqe)) |
| 1276 | ehea_info("External switch port is primary port"); |
| 1277 | else |
| 1278 | ehea_info("External switch port is backup port"); |
| 1279 | |
| 1280 | break; |
| 1281 | case EHEA_EC_ADAPTER_MALFUNC: |
| 1282 | ehea_error("Adapter malfunction"); |
| 1283 | break; |
| 1284 | case EHEA_EC_PORT_MALFUNC: |
| 1285 | ehea_info("Port malfunction: Device: %s", port->netdev->name); |
| 1286 | netif_carrier_off(port->netdev); |
| 1287 | netif_stop_queue(port->netdev); |
| 1288 | break; |
| 1289 | default: |
Stephen Rothwell | a1c5a89 | 2009-01-06 14:40:06 +0000 | [diff] [blame] | 1290 | ehea_error("unknown event code %x, eqe=0x%llX", ec, eqe); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1291 | break; |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | static void ehea_neq_tasklet(unsigned long data) |
| 1296 | { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1297 | struct ehea_adapter *adapter = (struct ehea_adapter *)data; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1298 | struct ehea_eqe *eqe; |
| 1299 | u64 event_mask; |
| 1300 | |
| 1301 | eqe = ehea_poll_eq(adapter->neq); |
| 1302 | ehea_debug("eqe=%p", eqe); |
| 1303 | |
| 1304 | while (eqe) { |
| 1305 | ehea_debug("*eqe=%lx", eqe->entry); |
| 1306 | ehea_parse_eqe(adapter, eqe->entry); |
| 1307 | eqe = ehea_poll_eq(adapter->neq); |
| 1308 | ehea_debug("next eqe=%p", eqe); |
| 1309 | } |
| 1310 | |
| 1311 | event_mask = EHEA_BMASK_SET(NELR_PORTSTATE_CHG, 1) |
| 1312 | | EHEA_BMASK_SET(NELR_ADAPTER_MALFUNC, 1) |
| 1313 | | EHEA_BMASK_SET(NELR_PORT_MALFUNC, 1); |
| 1314 | |
| 1315 | ehea_h_reset_events(adapter->handle, |
| 1316 | adapter->neq->fw_handle, event_mask); |
| 1317 | } |
| 1318 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1319 | static irqreturn_t ehea_interrupt_neq(int irq, void *param) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1320 | { |
| 1321 | struct ehea_adapter *adapter = param; |
| 1322 | tasklet_hi_schedule(&adapter->neq_tasklet); |
| 1323 | return IRQ_HANDLED; |
| 1324 | } |
| 1325 | |
| 1326 | |
| 1327 | static int ehea_fill_port_res(struct ehea_port_res *pr) |
| 1328 | { |
| 1329 | int ret; |
| 1330 | struct ehea_qp_init_attr *init_attr = &pr->qp->init_attr; |
| 1331 | |
Thomas Klein | e287880 | 2009-01-21 14:45:57 -0800 | [diff] [blame] | 1332 | ehea_init_fill_rq1(pr, init_attr->act_nr_rwqes_rq1 |
| 1333 | - init_attr->act_nr_rwqes_rq2 |
| 1334 | - init_attr->act_nr_rwqes_rq3 - 1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1335 | |
Thomas Klein | e287880 | 2009-01-21 14:45:57 -0800 | [diff] [blame] | 1336 | ret = ehea_refill_rq2(pr, init_attr->act_nr_rwqes_rq2 - 1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1337 | |
| 1338 | ret |= ehea_refill_rq3(pr, init_attr->act_nr_rwqes_rq3 - 1); |
| 1339 | |
| 1340 | return ret; |
| 1341 | } |
| 1342 | |
| 1343 | static int ehea_reg_interrupts(struct net_device *dev) |
| 1344 | { |
| 1345 | struct ehea_port *port = netdev_priv(dev); |
| 1346 | struct ehea_port_res *pr; |
| 1347 | int i, ret; |
| 1348 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1349 | |
| 1350 | snprintf(port->int_aff_name, EHEA_IRQ_NAME_SIZE - 1, "%s-aff", |
| 1351 | dev->name); |
| 1352 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1353 | ret = ibmebus_request_irq(port->qp_eq->attr.ist1, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1354 | ehea_qp_aff_irq_handler, |
Thomas Gleixner | 38515e9 | 2007-02-14 00:33:16 -0800 | [diff] [blame] | 1355 | IRQF_DISABLED, port->int_aff_name, port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1356 | if (ret) { |
| 1357 | ehea_error("failed registering irq for qp_aff_irq_handler:" |
| 1358 | "ist=%X", port->qp_eq->attr.ist1); |
| 1359 | goto out_free_qpeq; |
| 1360 | } |
| 1361 | |
| 1362 | if (netif_msg_ifup(port)) |
| 1363 | ehea_info("irq_handle 0x%X for function qp_aff_irq_handler " |
| 1364 | "registered", port->qp_eq->attr.ist1); |
| 1365 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1366 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1367 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
| 1368 | pr = &port->port_res[i]; |
| 1369 | snprintf(pr->int_send_name, EHEA_IRQ_NAME_SIZE - 1, |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1370 | "%s-queue%d", dev->name, i); |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1371 | ret = ibmebus_request_irq(pr->eq->attr.ist1, |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1372 | ehea_recv_irq_handler, |
Thomas Gleixner | 38515e9 | 2007-02-14 00:33:16 -0800 | [diff] [blame] | 1373 | IRQF_DISABLED, pr->int_send_name, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1374 | pr); |
| 1375 | if (ret) { |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1376 | ehea_error("failed registering irq for ehea_queue " |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1377 | "port_res_nr:%d, ist=%X", i, |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1378 | pr->eq->attr.ist1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1379 | goto out_free_req; |
| 1380 | } |
| 1381 | if (netif_msg_ifup(port)) |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1382 | ehea_info("irq_handle 0x%X for function ehea_queue_int " |
| 1383 | "%d registered", pr->eq->attr.ist1, i); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1384 | } |
| 1385 | out: |
| 1386 | return ret; |
| 1387 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1388 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1389 | out_free_req: |
| 1390 | while (--i >= 0) { |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1391 | u32 ist = port->port_res[i].eq->attr.ist1; |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1392 | ibmebus_free_irq(ist, &port->port_res[i]); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1393 | } |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1394 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1395 | out_free_qpeq: |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1396 | ibmebus_free_irq(port->qp_eq->attr.ist1, port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1397 | i = port->num_def_qps; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1398 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1399 | goto out; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1400 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | static void ehea_free_interrupts(struct net_device *dev) |
| 1404 | { |
| 1405 | struct ehea_port *port = netdev_priv(dev); |
| 1406 | struct ehea_port_res *pr; |
| 1407 | int i; |
| 1408 | |
| 1409 | /* send */ |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1410 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1411 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
| 1412 | pr = &port->port_res[i]; |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1413 | ibmebus_free_irq(pr->eq->attr.ist1, pr); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1414 | if (netif_msg_intr(port)) |
| 1415 | ehea_info("free send irq for res %d with handle 0x%X", |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1416 | i, pr->eq->attr.ist1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | /* associated events */ |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 1420 | ibmebus_free_irq(port->qp_eq->attr.ist1, port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1421 | if (netif_msg_intr(port)) |
| 1422 | ehea_info("associated event interrupt for handle 0x%X freed", |
| 1423 | port->qp_eq->attr.ist1); |
| 1424 | } |
| 1425 | |
| 1426 | static int ehea_configure_port(struct ehea_port *port) |
| 1427 | { |
| 1428 | int ret, i; |
| 1429 | u64 hret, mask; |
| 1430 | struct hcp_ehea_port_cb0 *cb0; |
| 1431 | |
| 1432 | ret = -ENOMEM; |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1433 | cb0 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1434 | if (!cb0) |
| 1435 | goto out; |
| 1436 | |
| 1437 | cb0->port_rc = EHEA_BMASK_SET(PXLY_RC_VALID, 1) |
| 1438 | | EHEA_BMASK_SET(PXLY_RC_IP_CHKSUM, 1) |
| 1439 | | EHEA_BMASK_SET(PXLY_RC_TCP_UDP_CHKSUM, 1) |
| 1440 | | EHEA_BMASK_SET(PXLY_RC_VLAN_XTRACT, 1) |
| 1441 | | EHEA_BMASK_SET(PXLY_RC_VLAN_TAG_FILTER, |
| 1442 | PXLY_RC_VLAN_FILTER) |
| 1443 | | EHEA_BMASK_SET(PXLY_RC_JUMBO_FRAME, 1); |
| 1444 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1445 | for (i = 0; i < port->num_mcs; i++) |
| 1446 | if (use_mcs) |
| 1447 | cb0->default_qpn_arr[i] = |
| 1448 | port->port_res[i].qp->init_attr.qp_nr; |
| 1449 | else |
| 1450 | cb0->default_qpn_arr[i] = |
| 1451 | port->port_res[0].qp->init_attr.qp_nr; |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1452 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1453 | if (netif_msg_ifup(port)) |
| 1454 | ehea_dump(cb0, sizeof(*cb0), "ehea_configure_port"); |
| 1455 | |
| 1456 | mask = EHEA_BMASK_SET(H_PORT_CB0_PRC, 1) |
| 1457 | | EHEA_BMASK_SET(H_PORT_CB0_DEFQPNARRAY, 1); |
| 1458 | |
| 1459 | hret = ehea_h_modify_ehea_port(port->adapter->handle, |
| 1460 | port->logical_port_id, |
| 1461 | H_PORT_CB0, mask, cb0); |
| 1462 | ret = -EIO; |
| 1463 | if (hret != H_SUCCESS) |
| 1464 | goto out_free; |
| 1465 | |
| 1466 | ret = 0; |
| 1467 | |
| 1468 | out_free: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1469 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1470 | out: |
| 1471 | return ret; |
| 1472 | } |
| 1473 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1474 | int ehea_gen_smrs(struct ehea_port_res *pr) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1475 | { |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1476 | int ret; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1477 | struct ehea_adapter *adapter = pr->port->adapter; |
| 1478 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1479 | ret = ehea_gen_smr(adapter, &adapter->mr, &pr->send_mr); |
| 1480 | if (ret) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1481 | goto out; |
| 1482 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1483 | ret = ehea_gen_smr(adapter, &adapter->mr, &pr->recv_mr); |
| 1484 | if (ret) |
| 1485 | goto out_free; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1486 | |
| 1487 | return 0; |
| 1488 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1489 | out_free: |
| 1490 | ehea_rem_mr(&pr->send_mr); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1491 | out: |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1492 | ehea_error("Generating SMRS failed\n"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1493 | return -EIO; |
| 1494 | } |
| 1495 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1496 | int ehea_rem_smrs(struct ehea_port_res *pr) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1497 | { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 1498 | if ((ehea_rem_mr(&pr->send_mr)) || |
| 1499 | (ehea_rem_mr(&pr->recv_mr))) |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 1500 | return -EIO; |
| 1501 | else |
| 1502 | return 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | static int ehea_init_q_skba(struct ehea_q_skb_arr *q_skba, int max_q_entries) |
| 1506 | { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1507 | int arr_size = sizeof(void *) * max_q_entries; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1508 | |
| 1509 | q_skba->arr = vmalloc(arr_size); |
| 1510 | if (!q_skba->arr) |
| 1511 | return -ENOMEM; |
| 1512 | |
| 1513 | memset(q_skba->arr, 0, arr_size); |
| 1514 | |
| 1515 | q_skba->len = max_q_entries; |
| 1516 | q_skba->index = 0; |
| 1517 | q_skba->os_skbs = 0; |
| 1518 | |
| 1519 | return 0; |
| 1520 | } |
| 1521 | |
| 1522 | static int ehea_init_port_res(struct ehea_port *port, struct ehea_port_res *pr, |
| 1523 | struct port_res_cfg *pr_cfg, int queue_token) |
| 1524 | { |
| 1525 | struct ehea_adapter *adapter = port->adapter; |
| 1526 | enum ehea_eq_type eq_type = EHEA_EQ; |
| 1527 | struct ehea_qp_init_attr *init_attr = NULL; |
| 1528 | int ret = -EIO; |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 1529 | u64 tx_bytes, rx_bytes, tx_packets, rx_packets; |
| 1530 | |
| 1531 | tx_bytes = pr->tx_bytes; |
| 1532 | tx_packets = pr->tx_packets; |
| 1533 | rx_bytes = pr->rx_bytes; |
| 1534 | rx_packets = pr->rx_packets; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1535 | |
| 1536 | memset(pr, 0, sizeof(struct ehea_port_res)); |
| 1537 | |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 1538 | pr->tx_bytes = rx_bytes; |
| 1539 | pr->tx_packets = tx_packets; |
| 1540 | pr->rx_bytes = rx_bytes; |
| 1541 | pr->rx_packets = rx_packets; |
| 1542 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1543 | pr->port = port; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1544 | spin_lock_init(&pr->xmit_lock); |
| 1545 | spin_lock_init(&pr->netif_queue); |
| 1546 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1547 | pr->eq = ehea_create_eq(adapter, eq_type, EHEA_MAX_ENTRIES_EQ, 0); |
| 1548 | if (!pr->eq) { |
| 1549 | ehea_error("create_eq failed (eq)"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1550 | goto out_free; |
| 1551 | } |
| 1552 | |
| 1553 | pr->recv_cq = ehea_create_cq(adapter, pr_cfg->max_entries_rcq, |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1554 | pr->eq->fw_handle, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1555 | port->logical_port_id); |
| 1556 | if (!pr->recv_cq) { |
| 1557 | ehea_error("create_cq failed (cq_recv)"); |
| 1558 | goto out_free; |
| 1559 | } |
| 1560 | |
| 1561 | pr->send_cq = ehea_create_cq(adapter, pr_cfg->max_entries_scq, |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1562 | pr->eq->fw_handle, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1563 | port->logical_port_id); |
| 1564 | if (!pr->send_cq) { |
| 1565 | ehea_error("create_cq failed (cq_send)"); |
| 1566 | goto out_free; |
| 1567 | } |
| 1568 | |
| 1569 | if (netif_msg_ifup(port)) |
| 1570 | ehea_info("Send CQ: act_nr_cqes=%d, Recv CQ: act_nr_cqes=%d", |
| 1571 | pr->send_cq->attr.act_nr_of_cqes, |
| 1572 | pr->recv_cq->attr.act_nr_of_cqes); |
| 1573 | |
| 1574 | init_attr = kzalloc(sizeof(*init_attr), GFP_KERNEL); |
| 1575 | if (!init_attr) { |
| 1576 | ret = -ENOMEM; |
| 1577 | ehea_error("no mem for ehea_qp_init_attr"); |
| 1578 | goto out_free; |
| 1579 | } |
| 1580 | |
| 1581 | init_attr->low_lat_rq1 = 1; |
| 1582 | init_attr->signalingtype = 1; /* generate CQE if specified in WQE */ |
| 1583 | init_attr->rq_count = 3; |
| 1584 | init_attr->qp_token = queue_token; |
| 1585 | init_attr->max_nr_send_wqes = pr_cfg->max_entries_sq; |
| 1586 | init_attr->max_nr_rwqes_rq1 = pr_cfg->max_entries_rq1; |
| 1587 | init_attr->max_nr_rwqes_rq2 = pr_cfg->max_entries_rq2; |
| 1588 | init_attr->max_nr_rwqes_rq3 = pr_cfg->max_entries_rq3; |
| 1589 | init_attr->wqe_size_enc_sq = EHEA_SG_SQ; |
| 1590 | init_attr->wqe_size_enc_rq1 = EHEA_SG_RQ1; |
| 1591 | init_attr->wqe_size_enc_rq2 = EHEA_SG_RQ2; |
| 1592 | init_attr->wqe_size_enc_rq3 = EHEA_SG_RQ3; |
| 1593 | init_attr->rq2_threshold = EHEA_RQ2_THRESHOLD; |
| 1594 | init_attr->rq3_threshold = EHEA_RQ3_THRESHOLD; |
| 1595 | init_attr->port_nr = port->logical_port_id; |
| 1596 | init_attr->send_cq_handle = pr->send_cq->fw_handle; |
| 1597 | init_attr->recv_cq_handle = pr->recv_cq->fw_handle; |
| 1598 | init_attr->aff_eq_handle = port->qp_eq->fw_handle; |
| 1599 | |
| 1600 | pr->qp = ehea_create_qp(adapter, adapter->pd, init_attr); |
| 1601 | if (!pr->qp) { |
| 1602 | ehea_error("create_qp failed"); |
| 1603 | ret = -EIO; |
| 1604 | goto out_free; |
| 1605 | } |
| 1606 | |
| 1607 | if (netif_msg_ifup(port)) |
| 1608 | ehea_info("QP: qp_nr=%d\n act_nr_snd_wqe=%d\n nr_rwqe_rq1=%d\n " |
| 1609 | "nr_rwqe_rq2=%d\n nr_rwqe_rq3=%d", init_attr->qp_nr, |
| 1610 | init_attr->act_nr_send_wqes, |
| 1611 | init_attr->act_nr_rwqes_rq1, |
| 1612 | init_attr->act_nr_rwqes_rq2, |
| 1613 | init_attr->act_nr_rwqes_rq3); |
| 1614 | |
Thomas Klein | 44fb312 | 2008-04-04 15:04:53 +0200 | [diff] [blame] | 1615 | pr->sq_skba_size = init_attr->act_nr_send_wqes + 1; |
| 1616 | |
| 1617 | ret = ehea_init_q_skba(&pr->sq_skba, pr->sq_skba_size); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1618 | ret |= ehea_init_q_skba(&pr->rq1_skba, init_attr->act_nr_rwqes_rq1 + 1); |
| 1619 | ret |= ehea_init_q_skba(&pr->rq2_skba, init_attr->act_nr_rwqes_rq2 + 1); |
| 1620 | ret |= ehea_init_q_skba(&pr->rq3_skba, init_attr->act_nr_rwqes_rq3 + 1); |
| 1621 | if (ret) |
| 1622 | goto out_free; |
| 1623 | |
| 1624 | pr->swqe_refill_th = init_attr->act_nr_send_wqes / 10; |
| 1625 | if (ehea_gen_smrs(pr) != 0) { |
| 1626 | ret = -EIO; |
| 1627 | goto out_free; |
| 1628 | } |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1629 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1630 | atomic_set(&pr->swqe_avail, init_attr->act_nr_send_wqes - 1); |
| 1631 | |
| 1632 | kfree(init_attr); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1633 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 1634 | netif_napi_add(pr->port->netdev, &pr->napi, ehea_poll, 64); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1635 | |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 1636 | pr->lro_mgr.max_aggr = pr->port->lro_max_aggr; |
| 1637 | pr->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS; |
| 1638 | pr->lro_mgr.lro_arr = pr->lro_desc; |
| 1639 | pr->lro_mgr.get_skb_header = get_skb_hdr; |
| 1640 | pr->lro_mgr.features = LRO_F_NAPI | LRO_F_EXTRACT_VLAN_ID; |
| 1641 | pr->lro_mgr.dev = port->netdev; |
| 1642 | pr->lro_mgr.ip_summed = CHECKSUM_UNNECESSARY; |
| 1643 | pr->lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY; |
| 1644 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1645 | ret = 0; |
| 1646 | goto out; |
| 1647 | |
| 1648 | out_free: |
| 1649 | kfree(init_attr); |
| 1650 | vfree(pr->sq_skba.arr); |
| 1651 | vfree(pr->rq1_skba.arr); |
| 1652 | vfree(pr->rq2_skba.arr); |
| 1653 | vfree(pr->rq3_skba.arr); |
| 1654 | ehea_destroy_qp(pr->qp); |
| 1655 | ehea_destroy_cq(pr->send_cq); |
| 1656 | ehea_destroy_cq(pr->recv_cq); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1657 | ehea_destroy_eq(pr->eq); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1658 | out: |
| 1659 | return ret; |
| 1660 | } |
| 1661 | |
| 1662 | static int ehea_clean_portres(struct ehea_port *port, struct ehea_port_res *pr) |
| 1663 | { |
| 1664 | int ret, i; |
| 1665 | |
Hannes Hering | 357eb46 | 2009-08-04 11:48:39 -0700 | [diff] [blame] | 1666 | if (pr->qp) |
| 1667 | netif_napi_del(&pr->napi); |
| 1668 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1669 | ret = ehea_destroy_qp(pr->qp); |
| 1670 | |
| 1671 | if (!ret) { |
| 1672 | ehea_destroy_cq(pr->send_cq); |
| 1673 | ehea_destroy_cq(pr->recv_cq); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 1674 | ehea_destroy_eq(pr->eq); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1675 | |
| 1676 | for (i = 0; i < pr->rq1_skba.len; i++) |
| 1677 | if (pr->rq1_skba.arr[i]) |
| 1678 | dev_kfree_skb(pr->rq1_skba.arr[i]); |
| 1679 | |
| 1680 | for (i = 0; i < pr->rq2_skba.len; i++) |
| 1681 | if (pr->rq2_skba.arr[i]) |
| 1682 | dev_kfree_skb(pr->rq2_skba.arr[i]); |
| 1683 | |
| 1684 | for (i = 0; i < pr->rq3_skba.len; i++) |
| 1685 | if (pr->rq3_skba.arr[i]) |
| 1686 | dev_kfree_skb(pr->rq3_skba.arr[i]); |
| 1687 | |
| 1688 | for (i = 0; i < pr->sq_skba.len; i++) |
| 1689 | if (pr->sq_skba.arr[i]) |
| 1690 | dev_kfree_skb(pr->sq_skba.arr[i]); |
| 1691 | |
| 1692 | vfree(pr->rq1_skba.arr); |
| 1693 | vfree(pr->rq2_skba.arr); |
| 1694 | vfree(pr->rq3_skba.arr); |
| 1695 | vfree(pr->sq_skba.arr); |
| 1696 | ret = ehea_rem_smrs(pr); |
| 1697 | } |
| 1698 | return ret; |
| 1699 | } |
| 1700 | |
| 1701 | /* |
| 1702 | * The write_* functions store information in swqe which is used by |
| 1703 | * the hardware to calculate the ip/tcp/udp checksum |
| 1704 | */ |
| 1705 | |
| 1706 | static inline void write_ip_start_end(struct ehea_swqe *swqe, |
| 1707 | const struct sk_buff *skb) |
| 1708 | { |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 1709 | swqe->ip_start = skb_network_offset(skb); |
Arnaldo Carvalho de Melo | c9bdd4b | 2007-03-12 20:09:15 -0300 | [diff] [blame] | 1710 | swqe->ip_end = (u8)(swqe->ip_start + ip_hdrlen(skb) - 1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1711 | } |
| 1712 | |
| 1713 | static inline void write_tcp_offset_end(struct ehea_swqe *swqe, |
| 1714 | const struct sk_buff *skb) |
| 1715 | { |
| 1716 | swqe->tcp_offset = |
| 1717 | (u8)(swqe->ip_end + 1 + offsetof(struct tcphdr, check)); |
| 1718 | |
| 1719 | swqe->tcp_end = (u16)skb->len - 1; |
| 1720 | } |
| 1721 | |
| 1722 | static inline void write_udp_offset_end(struct ehea_swqe *swqe, |
| 1723 | const struct sk_buff *skb) |
| 1724 | { |
| 1725 | swqe->tcp_offset = |
| 1726 | (u8)(swqe->ip_end + 1 + offsetof(struct udphdr, check)); |
| 1727 | |
| 1728 | swqe->tcp_end = (u16)skb->len - 1; |
| 1729 | } |
| 1730 | |
| 1731 | |
| 1732 | static void write_swqe2_TSO(struct sk_buff *skb, |
| 1733 | struct ehea_swqe *swqe, u32 lkey) |
| 1734 | { |
| 1735 | struct ehea_vsgentry *sg1entry = &swqe->u.immdata_desc.sg_entry; |
| 1736 | u8 *imm_data = &swqe->u.immdata_desc.immediate_data[0]; |
Eric Dumazet | e743d31 | 2010-04-14 15:59:40 -0700 | [diff] [blame] | 1737 | int skb_data_size = skb_headlen(skb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1738 | int headersize; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1739 | |
| 1740 | /* Packet is TCP with TSO enabled */ |
| 1741 | swqe->tx_control |= EHEA_SWQE_TSO; |
| 1742 | swqe->mss = skb_shinfo(skb)->gso_size; |
| 1743 | /* copy only eth/ip/tcp headers to immediate data and |
| 1744 | * the rest of skb->data to sg1entry |
| 1745 | */ |
Arnaldo Carvalho de Melo | ab6a5bb | 2007-03-18 17:43:48 -0700 | [diff] [blame] | 1746 | headersize = ETH_HLEN + ip_hdrlen(skb) + tcp_hdrlen(skb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1747 | |
Eric Dumazet | e743d31 | 2010-04-14 15:59:40 -0700 | [diff] [blame] | 1748 | skb_data_size = skb_headlen(skb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1749 | |
| 1750 | if (skb_data_size >= headersize) { |
| 1751 | /* copy immediate data */ |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 1752 | skb_copy_from_linear_data(skb, imm_data, headersize); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1753 | swqe->immediate_data_length = headersize; |
| 1754 | |
| 1755 | if (skb_data_size > headersize) { |
| 1756 | /* set sg1entry data */ |
| 1757 | sg1entry->l_key = lkey; |
| 1758 | sg1entry->len = skb_data_size - headersize; |
Thomas Klein | 44a5b3d | 2007-08-06 13:55:44 +0200 | [diff] [blame] | 1759 | sg1entry->vaddr = |
| 1760 | ehea_map_vaddr(skb->data + headersize); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1761 | swqe->descriptors++; |
| 1762 | } |
| 1763 | } else |
| 1764 | ehea_error("cannot handle fragmented headers"); |
| 1765 | } |
| 1766 | |
| 1767 | static void write_swqe2_nonTSO(struct sk_buff *skb, |
| 1768 | struct ehea_swqe *swqe, u32 lkey) |
| 1769 | { |
Eric Dumazet | e743d31 | 2010-04-14 15:59:40 -0700 | [diff] [blame] | 1770 | int skb_data_size = skb_headlen(skb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1771 | u8 *imm_data = &swqe->u.immdata_desc.immediate_data[0]; |
| 1772 | struct ehea_vsgentry *sg1entry = &swqe->u.immdata_desc.sg_entry; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1773 | |
| 1774 | /* Packet is any nonTSO type |
| 1775 | * |
| 1776 | * Copy as much as possible skb->data to immediate data and |
| 1777 | * the rest to sg1entry |
| 1778 | */ |
| 1779 | if (skb_data_size >= SWQE2_MAX_IMM) { |
| 1780 | /* copy immediate data */ |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 1781 | skb_copy_from_linear_data(skb, imm_data, SWQE2_MAX_IMM); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1782 | |
| 1783 | swqe->immediate_data_length = SWQE2_MAX_IMM; |
| 1784 | |
| 1785 | if (skb_data_size > SWQE2_MAX_IMM) { |
| 1786 | /* copy sg1entry data */ |
| 1787 | sg1entry->l_key = lkey; |
| 1788 | sg1entry->len = skb_data_size - SWQE2_MAX_IMM; |
Thomas Klein | 44a5b3d | 2007-08-06 13:55:44 +0200 | [diff] [blame] | 1789 | sg1entry->vaddr = |
| 1790 | ehea_map_vaddr(skb->data + SWQE2_MAX_IMM); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1791 | swqe->descriptors++; |
| 1792 | } |
| 1793 | } else { |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 1794 | skb_copy_from_linear_data(skb, imm_data, skb_data_size); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1795 | swqe->immediate_data_length = skb_data_size; |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | static inline void write_swqe2_data(struct sk_buff *skb, struct net_device *dev, |
| 1800 | struct ehea_swqe *swqe, u32 lkey) |
| 1801 | { |
| 1802 | struct ehea_vsgentry *sg_list, *sg1entry, *sgentry; |
| 1803 | skb_frag_t *frag; |
| 1804 | int nfrags, sg1entry_contains_frag_data, i; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1805 | |
| 1806 | nfrags = skb_shinfo(skb)->nr_frags; |
| 1807 | sg1entry = &swqe->u.immdata_desc.sg_entry; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1808 | sg_list = (struct ehea_vsgentry *)&swqe->u.immdata_desc.sg_list; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1809 | swqe->descriptors = 0; |
| 1810 | sg1entry_contains_frag_data = 0; |
| 1811 | |
| 1812 | if ((dev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size) |
| 1813 | write_swqe2_TSO(skb, swqe, lkey); |
| 1814 | else |
| 1815 | write_swqe2_nonTSO(skb, swqe, lkey); |
| 1816 | |
| 1817 | /* write descriptors */ |
| 1818 | if (nfrags > 0) { |
| 1819 | if (swqe->descriptors == 0) { |
| 1820 | /* sg1entry not yet used */ |
| 1821 | frag = &skb_shinfo(skb)->frags[0]; |
| 1822 | |
| 1823 | /* copy sg1entry data */ |
| 1824 | sg1entry->l_key = lkey; |
| 1825 | sg1entry->len = frag->size; |
Thomas Klein | 44a5b3d | 2007-08-06 13:55:44 +0200 | [diff] [blame] | 1826 | sg1entry->vaddr = |
| 1827 | ehea_map_vaddr(page_address(frag->page) |
| 1828 | + frag->page_offset); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1829 | swqe->descriptors++; |
| 1830 | sg1entry_contains_frag_data = 1; |
| 1831 | } |
| 1832 | |
| 1833 | for (i = sg1entry_contains_frag_data; i < nfrags; i++) { |
| 1834 | |
| 1835 | frag = &skb_shinfo(skb)->frags[i]; |
| 1836 | sgentry = &sg_list[i - sg1entry_contains_frag_data]; |
| 1837 | |
| 1838 | sgentry->l_key = lkey; |
| 1839 | sgentry->len = frag->size; |
Thomas Klein | 44a5b3d | 2007-08-06 13:55:44 +0200 | [diff] [blame] | 1840 | sgentry->vaddr = |
| 1841 | ehea_map_vaddr(page_address(frag->page) |
| 1842 | + frag->page_offset); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1843 | swqe->descriptors++; |
| 1844 | } |
| 1845 | } |
| 1846 | } |
| 1847 | |
| 1848 | static int ehea_broadcast_reg_helper(struct ehea_port *port, u32 hcallid) |
| 1849 | { |
| 1850 | int ret = 0; |
| 1851 | u64 hret; |
| 1852 | u8 reg_type; |
| 1853 | |
| 1854 | /* De/Register untagged packets */ |
| 1855 | reg_type = EHEA_BCMC_BROADCAST | EHEA_BCMC_UNTAGGED; |
| 1856 | hret = ehea_h_reg_dereg_bcmc(port->adapter->handle, |
| 1857 | port->logical_port_id, |
| 1858 | reg_type, port->mac_addr, 0, hcallid); |
| 1859 | if (hret != H_SUCCESS) { |
Thomas Klein | f9e2922 | 2007-07-18 17:34:09 +0200 | [diff] [blame] | 1860 | ehea_error("%sregistering bc address failed (tagged)", |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 1861 | hcallid == H_REG_BCMC ? "" : "de"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1862 | ret = -EIO; |
| 1863 | goto out_herr; |
| 1864 | } |
| 1865 | |
| 1866 | /* De/Register VLAN packets */ |
| 1867 | reg_type = EHEA_BCMC_BROADCAST | EHEA_BCMC_VLANID_ALL; |
| 1868 | hret = ehea_h_reg_dereg_bcmc(port->adapter->handle, |
| 1869 | port->logical_port_id, |
| 1870 | reg_type, port->mac_addr, 0, hcallid); |
| 1871 | if (hret != H_SUCCESS) { |
Thomas Klein | f9e2922 | 2007-07-18 17:34:09 +0200 | [diff] [blame] | 1872 | ehea_error("%sregistering bc address failed (vlan)", |
| 1873 | hcallid == H_REG_BCMC ? "" : "de"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1874 | ret = -EIO; |
| 1875 | } |
| 1876 | out_herr: |
| 1877 | return ret; |
| 1878 | } |
| 1879 | |
| 1880 | static int ehea_set_mac_addr(struct net_device *dev, void *sa) |
| 1881 | { |
| 1882 | struct ehea_port *port = netdev_priv(dev); |
| 1883 | struct sockaddr *mac_addr = sa; |
| 1884 | struct hcp_ehea_port_cb0 *cb0; |
| 1885 | int ret; |
| 1886 | u64 hret; |
| 1887 | |
| 1888 | if (!is_valid_ether_addr(mac_addr->sa_data)) { |
| 1889 | ret = -EADDRNOTAVAIL; |
| 1890 | goto out; |
| 1891 | } |
| 1892 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1893 | cb0 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1894 | if (!cb0) { |
| 1895 | ehea_error("no mem for cb0"); |
| 1896 | ret = -ENOMEM; |
| 1897 | goto out; |
| 1898 | } |
| 1899 | |
| 1900 | memcpy(&(cb0->port_mac_addr), &(mac_addr->sa_data[0]), ETH_ALEN); |
| 1901 | |
| 1902 | cb0->port_mac_addr = cb0->port_mac_addr >> 16; |
| 1903 | |
| 1904 | hret = ehea_h_modify_ehea_port(port->adapter->handle, |
| 1905 | port->logical_port_id, H_PORT_CB0, |
| 1906 | EHEA_BMASK_SET(H_PORT_CB0_MAC, 1), cb0); |
| 1907 | if (hret != H_SUCCESS) { |
| 1908 | ret = -EIO; |
| 1909 | goto out_free; |
| 1910 | } |
| 1911 | |
| 1912 | memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); |
| 1913 | |
| 1914 | /* Deregister old MAC in pHYP */ |
Jan-Bernd Themann | 00aaea2 | 2008-06-09 15:17:37 +0100 | [diff] [blame] | 1915 | if (port->state == EHEA_PORT_UP) { |
| 1916 | ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC); |
| 1917 | if (ret) |
| 1918 | goto out_upregs; |
| 1919 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1920 | |
| 1921 | port->mac_addr = cb0->port_mac_addr << 16; |
| 1922 | |
| 1923 | /* Register new MAC in pHYP */ |
Jan-Bernd Themann | 00aaea2 | 2008-06-09 15:17:37 +0100 | [diff] [blame] | 1924 | if (port->state == EHEA_PORT_UP) { |
| 1925 | ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); |
| 1926 | if (ret) |
| 1927 | goto out_upregs; |
| 1928 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1929 | |
| 1930 | ret = 0; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 1931 | |
| 1932 | out_upregs: |
| 1933 | ehea_update_bcmc_registrations(); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1934 | out_free: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1935 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1936 | out: |
| 1937 | return ret; |
| 1938 | } |
| 1939 | |
| 1940 | static void ehea_promiscuous_error(u64 hret, int enable) |
| 1941 | { |
Thomas Klein | 7674a58 | 2007-01-22 12:54:20 +0100 | [diff] [blame] | 1942 | if (hret == H_AUTHORITY) |
| 1943 | ehea_info("Hypervisor denied %sabling promiscuous mode", |
| 1944 | enable == 1 ? "en" : "dis"); |
| 1945 | else |
| 1946 | ehea_error("failed %sabling promiscuous mode", |
| 1947 | enable == 1 ? "en" : "dis"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | static void ehea_promiscuous(struct net_device *dev, int enable) |
| 1951 | { |
| 1952 | struct ehea_port *port = netdev_priv(dev); |
| 1953 | struct hcp_ehea_port_cb7 *cb7; |
| 1954 | u64 hret; |
| 1955 | |
Nicolas Kaiser | aa3bc6c | 2010-10-07 13:14:50 +0000 | [diff] [blame] | 1956 | if (enable == port->promisc) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1957 | return; |
| 1958 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1959 | cb7 = (void *)get_zeroed_page(GFP_ATOMIC); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1960 | if (!cb7) { |
| 1961 | ehea_error("no mem for cb7"); |
| 1962 | goto out; |
| 1963 | } |
| 1964 | |
| 1965 | /* Modify Pxs_DUCQPN in CB7 */ |
| 1966 | cb7->def_uc_qpn = enable == 1 ? port->port_res[0].qp->fw_handle : 0; |
| 1967 | |
| 1968 | hret = ehea_h_modify_ehea_port(port->adapter->handle, |
| 1969 | port->logical_port_id, |
| 1970 | H_PORT_CB7, H_PORT_CB7_DUCQPN, cb7); |
| 1971 | if (hret) { |
| 1972 | ehea_promiscuous_error(hret, enable); |
| 1973 | goto out; |
| 1974 | } |
| 1975 | |
| 1976 | port->promisc = enable; |
| 1977 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 1978 | free_page((unsigned long)cb7); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | static u64 ehea_multicast_reg_helper(struct ehea_port *port, u64 mc_mac_addr, |
| 1982 | u32 hcallid) |
| 1983 | { |
| 1984 | u64 hret; |
| 1985 | u8 reg_type; |
| 1986 | |
| 1987 | reg_type = EHEA_BCMC_SCOPE_ALL | EHEA_BCMC_MULTICAST |
| 1988 | | EHEA_BCMC_UNTAGGED; |
| 1989 | |
| 1990 | hret = ehea_h_reg_dereg_bcmc(port->adapter->handle, |
| 1991 | port->logical_port_id, |
| 1992 | reg_type, mc_mac_addr, 0, hcallid); |
| 1993 | if (hret) |
| 1994 | goto out; |
| 1995 | |
| 1996 | reg_type = EHEA_BCMC_SCOPE_ALL | EHEA_BCMC_MULTICAST |
| 1997 | | EHEA_BCMC_VLANID_ALL; |
| 1998 | |
| 1999 | hret = ehea_h_reg_dereg_bcmc(port->adapter->handle, |
| 2000 | port->logical_port_id, |
| 2001 | reg_type, mc_mac_addr, 0, hcallid); |
| 2002 | out: |
| 2003 | return hret; |
| 2004 | } |
| 2005 | |
| 2006 | static int ehea_drop_multicast_list(struct net_device *dev) |
| 2007 | { |
| 2008 | struct ehea_port *port = netdev_priv(dev); |
| 2009 | struct ehea_mc_list *mc_entry = port->mc_list; |
| 2010 | struct list_head *pos; |
| 2011 | struct list_head *temp; |
| 2012 | int ret = 0; |
| 2013 | u64 hret; |
| 2014 | |
| 2015 | list_for_each_safe(pos, temp, &(port->mc_list->list)) { |
| 2016 | mc_entry = list_entry(pos, struct ehea_mc_list, list); |
| 2017 | |
| 2018 | hret = ehea_multicast_reg_helper(port, mc_entry->macaddr, |
| 2019 | H_DEREG_BCMC); |
| 2020 | if (hret) { |
| 2021 | ehea_error("failed deregistering mcast MAC"); |
| 2022 | ret = -EIO; |
| 2023 | } |
| 2024 | |
| 2025 | list_del(pos); |
| 2026 | kfree(mc_entry); |
| 2027 | } |
| 2028 | return ret; |
| 2029 | } |
| 2030 | |
| 2031 | static void ehea_allmulti(struct net_device *dev, int enable) |
| 2032 | { |
| 2033 | struct ehea_port *port = netdev_priv(dev); |
| 2034 | u64 hret; |
| 2035 | |
| 2036 | if (!port->allmulti) { |
| 2037 | if (enable) { |
| 2038 | /* Enable ALLMULTI */ |
| 2039 | ehea_drop_multicast_list(dev); |
| 2040 | hret = ehea_multicast_reg_helper(port, 0, H_REG_BCMC); |
| 2041 | if (!hret) |
| 2042 | port->allmulti = 1; |
| 2043 | else |
| 2044 | ehea_error("failed enabling IFF_ALLMULTI"); |
| 2045 | } |
| 2046 | } else |
| 2047 | if (!enable) { |
| 2048 | /* Disable ALLMULTI */ |
| 2049 | hret = ehea_multicast_reg_helper(port, 0, H_DEREG_BCMC); |
| 2050 | if (!hret) |
| 2051 | port->allmulti = 0; |
| 2052 | else |
| 2053 | ehea_error("failed disabling IFF_ALLMULTI"); |
| 2054 | } |
| 2055 | } |
| 2056 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2057 | static void ehea_add_multicast_entry(struct ehea_port *port, u8 *mc_mac_addr) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2058 | { |
| 2059 | struct ehea_mc_list *ehea_mcl_entry; |
| 2060 | u64 hret; |
| 2061 | |
Jan-Bernd Themann | 1e1675c | 2006-10-25 13:11:42 +0200 | [diff] [blame] | 2062 | ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2063 | if (!ehea_mcl_entry) { |
| 2064 | ehea_error("no mem for mcl_entry"); |
| 2065 | return; |
| 2066 | } |
| 2067 | |
| 2068 | INIT_LIST_HEAD(&ehea_mcl_entry->list); |
| 2069 | |
| 2070 | memcpy(&ehea_mcl_entry->macaddr, mc_mac_addr, ETH_ALEN); |
| 2071 | |
| 2072 | hret = ehea_multicast_reg_helper(port, ehea_mcl_entry->macaddr, |
| 2073 | H_REG_BCMC); |
| 2074 | if (!hret) |
| 2075 | list_add(&ehea_mcl_entry->list, &port->mc_list->list); |
| 2076 | else { |
| 2077 | ehea_error("failed registering mcast MAC"); |
| 2078 | kfree(ehea_mcl_entry); |
| 2079 | } |
| 2080 | } |
| 2081 | |
| 2082 | static void ehea_set_multicast_list(struct net_device *dev) |
| 2083 | { |
| 2084 | struct ehea_port *port = netdev_priv(dev); |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2085 | struct netdev_hw_addr *ha; |
Jiri Pirko | 48e2f18 | 2010-02-22 09:22:26 +0000 | [diff] [blame] | 2086 | int ret; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2087 | |
| 2088 | if (dev->flags & IFF_PROMISC) { |
| 2089 | ehea_promiscuous(dev, 1); |
| 2090 | return; |
| 2091 | } |
| 2092 | ehea_promiscuous(dev, 0); |
| 2093 | |
| 2094 | if (dev->flags & IFF_ALLMULTI) { |
| 2095 | ehea_allmulti(dev, 1); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2096 | goto out; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2097 | } |
| 2098 | ehea_allmulti(dev, 0); |
| 2099 | |
Jiri Pirko | 4cd24ea | 2010-02-08 04:30:35 +0000 | [diff] [blame] | 2100 | if (!netdev_mc_empty(dev)) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2101 | ret = ehea_drop_multicast_list(dev); |
| 2102 | if (ret) { |
| 2103 | /* Dropping the current multicast list failed. |
| 2104 | * Enabling ALL_MULTI is the best we can do. |
| 2105 | */ |
| 2106 | ehea_allmulti(dev, 1); |
| 2107 | } |
| 2108 | |
Jiri Pirko | 4cd24ea | 2010-02-08 04:30:35 +0000 | [diff] [blame] | 2109 | if (netdev_mc_count(dev) > port->adapter->max_mc_mac) { |
Stephen Rothwell | a1c5a89 | 2009-01-06 14:40:06 +0000 | [diff] [blame] | 2110 | ehea_info("Mcast registration limit reached (0x%llx). " |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2111 | "Use ALLMULTI!", |
| 2112 | port->adapter->max_mc_mac); |
| 2113 | goto out; |
| 2114 | } |
| 2115 | |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2116 | netdev_for_each_mc_addr(ha, dev) |
| 2117 | ehea_add_multicast_entry(port, ha->addr); |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2118 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2119 | } |
| 2120 | out: |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2121 | ehea_update_bcmc_registrations(); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2122 | } |
| 2123 | |
| 2124 | static int ehea_change_mtu(struct net_device *dev, int new_mtu) |
| 2125 | { |
| 2126 | if ((new_mtu < 68) || (new_mtu > EHEA_MAX_PACKET_SIZE)) |
| 2127 | return -EINVAL; |
| 2128 | dev->mtu = new_mtu; |
| 2129 | return 0; |
| 2130 | } |
| 2131 | |
| 2132 | static void ehea_xmit2(struct sk_buff *skb, struct net_device *dev, |
| 2133 | struct ehea_swqe *swqe, u32 lkey) |
| 2134 | { |
| 2135 | if (skb->protocol == htons(ETH_P_IP)) { |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2136 | const struct iphdr *iph = ip_hdr(skb); |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 2137 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2138 | /* IPv4 */ |
| 2139 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2140 | | EHEA_SWQE_IP_CHECKSUM |
| 2141 | | EHEA_SWQE_TCP_CHECKSUM |
| 2142 | | EHEA_SWQE_IMM_DATA_PRESENT |
| 2143 | | EHEA_SWQE_DESCRIPTORS_PRESENT; |
| 2144 | |
| 2145 | write_ip_start_end(swqe, skb); |
| 2146 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2147 | if (iph->protocol == IPPROTO_UDP) { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 2148 | if ((iph->frag_off & IP_MF) || |
| 2149 | (iph->frag_off & IP_OFFSET)) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2150 | /* IP fragment, so don't change cs */ |
| 2151 | swqe->tx_control &= ~EHEA_SWQE_TCP_CHECKSUM; |
| 2152 | else |
| 2153 | write_udp_offset_end(swqe, skb); |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2154 | } else if (iph->protocol == IPPROTO_TCP) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2155 | write_tcp_offset_end(swqe, skb); |
| 2156 | } |
| 2157 | |
| 2158 | /* icmp (big data) and ip segmentation packets (all other ip |
| 2159 | packets) do not require any special handling */ |
| 2160 | |
| 2161 | } else { |
| 2162 | /* Other Ethernet Protocol */ |
| 2163 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2164 | | EHEA_SWQE_IMM_DATA_PRESENT |
| 2165 | | EHEA_SWQE_DESCRIPTORS_PRESENT; |
| 2166 | } |
| 2167 | |
| 2168 | write_swqe2_data(skb, dev, swqe, lkey); |
| 2169 | } |
| 2170 | |
| 2171 | static void ehea_xmit3(struct sk_buff *skb, struct net_device *dev, |
| 2172 | struct ehea_swqe *swqe) |
| 2173 | { |
| 2174 | int nfrags = skb_shinfo(skb)->nr_frags; |
| 2175 | u8 *imm_data = &swqe->u.immdata_nodesc.immediate_data[0]; |
| 2176 | skb_frag_t *frag; |
| 2177 | int i; |
| 2178 | |
| 2179 | if (skb->protocol == htons(ETH_P_IP)) { |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2180 | const struct iphdr *iph = ip_hdr(skb); |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 2181 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2182 | /* IPv4 */ |
| 2183 | write_ip_start_end(swqe, skb); |
| 2184 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2185 | if (iph->protocol == IPPROTO_TCP) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2186 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2187 | | EHEA_SWQE_IP_CHECKSUM |
| 2188 | | EHEA_SWQE_TCP_CHECKSUM |
| 2189 | | EHEA_SWQE_IMM_DATA_PRESENT; |
| 2190 | |
| 2191 | write_tcp_offset_end(swqe, skb); |
| 2192 | |
Arnaldo Carvalho de Melo | eddc9ec | 2007-04-20 22:47:35 -0700 | [diff] [blame] | 2193 | } else if (iph->protocol == IPPROTO_UDP) { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 2194 | if ((iph->frag_off & IP_MF) || |
| 2195 | (iph->frag_off & IP_OFFSET)) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2196 | /* IP fragment, so don't change cs */ |
| 2197 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2198 | | EHEA_SWQE_IMM_DATA_PRESENT; |
| 2199 | else { |
| 2200 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2201 | | EHEA_SWQE_IP_CHECKSUM |
| 2202 | | EHEA_SWQE_TCP_CHECKSUM |
| 2203 | | EHEA_SWQE_IMM_DATA_PRESENT; |
| 2204 | |
| 2205 | write_udp_offset_end(swqe, skb); |
| 2206 | } |
| 2207 | } else { |
| 2208 | /* icmp (big data) and |
| 2209 | ip segmentation packets (all other ip packets) */ |
| 2210 | swqe->tx_control |= EHEA_SWQE_CRC |
| 2211 | | EHEA_SWQE_IP_CHECKSUM |
| 2212 | | EHEA_SWQE_IMM_DATA_PRESENT; |
| 2213 | } |
| 2214 | } else { |
| 2215 | /* Other Ethernet Protocol */ |
| 2216 | swqe->tx_control |= EHEA_SWQE_CRC | EHEA_SWQE_IMM_DATA_PRESENT; |
| 2217 | } |
| 2218 | /* copy (immediate) data */ |
| 2219 | if (nfrags == 0) { |
| 2220 | /* data is in a single piece */ |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 2221 | skb_copy_from_linear_data(skb, imm_data, skb->len); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2222 | } else { |
| 2223 | /* first copy data from the skb->data buffer ... */ |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 2224 | skb_copy_from_linear_data(skb, imm_data, |
Eric Dumazet | e743d31 | 2010-04-14 15:59:40 -0700 | [diff] [blame] | 2225 | skb_headlen(skb)); |
| 2226 | imm_data += skb_headlen(skb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2227 | |
| 2228 | /* ... then copy data from the fragments */ |
| 2229 | for (i = 0; i < nfrags; i++) { |
| 2230 | frag = &skb_shinfo(skb)->frags[i]; |
| 2231 | memcpy(imm_data, |
| 2232 | page_address(frag->page) + frag->page_offset, |
| 2233 | frag->size); |
| 2234 | imm_data += frag->size; |
| 2235 | } |
| 2236 | } |
| 2237 | swqe->immediate_data_length = skb->len; |
| 2238 | dev_kfree_skb(skb); |
| 2239 | } |
| 2240 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2241 | static inline int ehea_hash_skb(struct sk_buff *skb, int num_qps) |
| 2242 | { |
| 2243 | struct tcphdr *tcp; |
| 2244 | u32 tmp; |
| 2245 | |
| 2246 | if ((skb->protocol == htons(ETH_P_IP)) && |
Thomas Klein | 88ca2d0 | 2007-05-02 16:07:05 +0200 | [diff] [blame] | 2247 | (ip_hdr(skb)->protocol == IPPROTO_TCP)) { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2248 | tcp = (struct tcphdr *)(skb_network_header(skb) + |
| 2249 | (ip_hdr(skb)->ihl * 4)); |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2250 | tmp = (tcp->source + (tcp->dest << 16)) % 31; |
Thomas Klein | 88ca2d0 | 2007-05-02 16:07:05 +0200 | [diff] [blame] | 2251 | tmp += ip_hdr(skb)->daddr % 31; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2252 | return tmp % num_qps; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2253 | } else |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2254 | return 0; |
| 2255 | } |
| 2256 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2257 | static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 2258 | { |
| 2259 | struct ehea_port *port = netdev_priv(dev); |
| 2260 | struct ehea_swqe *swqe; |
| 2261 | unsigned long flags; |
| 2262 | u32 lkey; |
| 2263 | int swqe_index; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2264 | struct ehea_port_res *pr; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2265 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2266 | pr = &port->port_res[ehea_hash_skb(skb, port->num_tx_qps)]; |
| 2267 | |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2268 | if (!spin_trylock(&pr->xmit_lock)) |
| 2269 | return NETDEV_TX_BUSY; |
| 2270 | |
| 2271 | if (pr->queue_stopped) { |
| 2272 | spin_unlock(&pr->xmit_lock); |
| 2273 | return NETDEV_TX_BUSY; |
| 2274 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2275 | |
| 2276 | swqe = ehea_get_swqe(pr->qp, &swqe_index); |
| 2277 | memset(swqe, 0, SWQE_HEADER_SIZE); |
| 2278 | atomic_dec(&pr->swqe_avail); |
| 2279 | |
Eric Dumazet | e5ccd96 | 2010-10-26 19:21:07 +0000 | [diff] [blame] | 2280 | if (vlan_tx_tag_present(skb)) { |
| 2281 | swqe->tx_control |= EHEA_SWQE_VLAN_INSERT; |
| 2282 | swqe->vlan_tag = vlan_tx_tag_get(skb); |
| 2283 | } |
| 2284 | |
Breno Leitao | ce45b87 | 2010-10-27 08:45:14 +0000 | [diff] [blame] | 2285 | pr->tx_packets++; |
| 2286 | pr->tx_bytes += skb->len; |
| 2287 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2288 | if (skb->len <= SWQE3_MAX_IMM) { |
| 2289 | u32 sig_iv = port->sig_comp_iv; |
| 2290 | u32 swqe_num = pr->swqe_id_counter; |
| 2291 | ehea_xmit3(skb, dev, swqe); |
| 2292 | swqe->wr_id = EHEA_BMASK_SET(EHEA_WR_ID_TYPE, EHEA_SWQE3_TYPE) |
| 2293 | | EHEA_BMASK_SET(EHEA_WR_ID_COUNT, swqe_num); |
| 2294 | if (pr->swqe_ll_count >= (sig_iv - 1)) { |
| 2295 | swqe->wr_id |= EHEA_BMASK_SET(EHEA_WR_ID_REFILL, |
| 2296 | sig_iv); |
| 2297 | swqe->tx_control |= EHEA_SWQE_SIGNALLED_COMPLETION; |
| 2298 | pr->swqe_ll_count = 0; |
| 2299 | } else |
| 2300 | pr->swqe_ll_count += 1; |
| 2301 | } else { |
| 2302 | swqe->wr_id = |
| 2303 | EHEA_BMASK_SET(EHEA_WR_ID_TYPE, EHEA_SWQE2_TYPE) |
| 2304 | | EHEA_BMASK_SET(EHEA_WR_ID_COUNT, pr->swqe_id_counter) |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 2305 | | EHEA_BMASK_SET(EHEA_WR_ID_REFILL, 1) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2306 | | EHEA_BMASK_SET(EHEA_WR_ID_INDEX, pr->sq_skba.index); |
| 2307 | pr->sq_skba.arr[pr->sq_skba.index] = skb; |
| 2308 | |
| 2309 | pr->sq_skba.index++; |
| 2310 | pr->sq_skba.index &= (pr->sq_skba.len - 1); |
| 2311 | |
| 2312 | lkey = pr->send_mr.lkey; |
| 2313 | ehea_xmit2(skb, dev, swqe, lkey); |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 2314 | swqe->tx_control |= EHEA_SWQE_SIGNALLED_COMPLETION; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2315 | } |
| 2316 | pr->swqe_id_counter += 1; |
| 2317 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2318 | if (netif_msg_tx_queued(port)) { |
| 2319 | ehea_info("post swqe on QP %d", pr->qp->init_attr.qp_nr); |
Jan-Bernd Themann | bff0a55 | 2006-10-05 16:53:14 +0200 | [diff] [blame] | 2320 | ehea_dump(swqe, 512, "swqe"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2321 | } |
| 2322 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2323 | if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) { |
| 2324 | netif_stop_queue(dev); |
| 2325 | swqe->tx_control |= EHEA_SWQE_PURGE; |
| 2326 | } |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2327 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2328 | ehea_post_swqe(pr->qp, swqe); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2329 | |
| 2330 | if (unlikely(atomic_read(&pr->swqe_avail) <= 1)) { |
| 2331 | spin_lock_irqsave(&pr->netif_queue, flags); |
| 2332 | if (unlikely(atomic_read(&pr->swqe_avail) <= 1)) { |
Jan-Bernd Themann | acbddb5 | 2007-03-23 17:18:53 +0100 | [diff] [blame] | 2333 | pr->p_stats.queue_stopped++; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2334 | netif_stop_queue(dev); |
| 2335 | pr->queue_stopped = 1; |
| 2336 | } |
| 2337 | spin_unlock_irqrestore(&pr->netif_queue, flags); |
| 2338 | } |
Eric Dumazet | 1ae5dc3 | 2010-05-10 05:01:31 -0700 | [diff] [blame] | 2339 | dev->trans_start = jiffies; /* NETIF_F_LLTX driver :( */ |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2340 | spin_unlock(&pr->xmit_lock); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2341 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2342 | return NETDEV_TX_OK; |
| 2343 | } |
| 2344 | |
| 2345 | static void ehea_vlan_rx_register(struct net_device *dev, |
| 2346 | struct vlan_group *grp) |
| 2347 | { |
| 2348 | struct ehea_port *port = netdev_priv(dev); |
| 2349 | struct ehea_adapter *adapter = port->adapter; |
| 2350 | struct hcp_ehea_port_cb1 *cb1; |
| 2351 | u64 hret; |
| 2352 | |
| 2353 | port->vgrp = grp; |
| 2354 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2355 | cb1 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2356 | if (!cb1) { |
| 2357 | ehea_error("no mem for cb1"); |
| 2358 | goto out; |
| 2359 | } |
| 2360 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2361 | hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, |
| 2362 | H_PORT_CB1, H_PORT_CB1_ALL, cb1); |
| 2363 | if (hret != H_SUCCESS) |
| 2364 | ehea_error("modify_ehea_port failed"); |
| 2365 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2366 | free_page((unsigned long)cb1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2367 | out: |
| 2368 | return; |
| 2369 | } |
| 2370 | |
| 2371 | static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) |
| 2372 | { |
| 2373 | struct ehea_port *port = netdev_priv(dev); |
| 2374 | struct ehea_adapter *adapter = port->adapter; |
| 2375 | struct hcp_ehea_port_cb1 *cb1; |
| 2376 | int index; |
| 2377 | u64 hret; |
| 2378 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2379 | cb1 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2380 | if (!cb1) { |
| 2381 | ehea_error("no mem for cb1"); |
| 2382 | goto out; |
| 2383 | } |
| 2384 | |
| 2385 | hret = ehea_h_query_ehea_port(adapter->handle, port->logical_port_id, |
| 2386 | H_PORT_CB1, H_PORT_CB1_ALL, cb1); |
| 2387 | if (hret != H_SUCCESS) { |
| 2388 | ehea_error("query_ehea_port failed"); |
| 2389 | goto out; |
| 2390 | } |
| 2391 | |
| 2392 | index = (vid / 64); |
Thomas Klein | dec590c | 2007-06-06 20:53:16 +0200 | [diff] [blame] | 2393 | cb1->vlan_filter[index] |= ((u64)(0x8000000000000000 >> (vid & 0x3F))); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2394 | |
| 2395 | hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, |
| 2396 | H_PORT_CB1, H_PORT_CB1_ALL, cb1); |
| 2397 | if (hret != H_SUCCESS) |
| 2398 | ehea_error("modify_ehea_port failed"); |
| 2399 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2400 | free_page((unsigned long)cb1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2401 | return; |
| 2402 | } |
| 2403 | |
| 2404 | static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) |
| 2405 | { |
| 2406 | struct ehea_port *port = netdev_priv(dev); |
| 2407 | struct ehea_adapter *adapter = port->adapter; |
| 2408 | struct hcp_ehea_port_cb1 *cb1; |
| 2409 | int index; |
| 2410 | u64 hret; |
| 2411 | |
Dan Aloni | 5c15bde | 2007-03-02 20:44:51 -0800 | [diff] [blame] | 2412 | vlan_group_set_device(port->vgrp, vid, NULL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2413 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2414 | cb1 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2415 | if (!cb1) { |
| 2416 | ehea_error("no mem for cb1"); |
| 2417 | goto out; |
| 2418 | } |
| 2419 | |
| 2420 | hret = ehea_h_query_ehea_port(adapter->handle, port->logical_port_id, |
| 2421 | H_PORT_CB1, H_PORT_CB1_ALL, cb1); |
| 2422 | if (hret != H_SUCCESS) { |
| 2423 | ehea_error("query_ehea_port failed"); |
| 2424 | goto out; |
| 2425 | } |
| 2426 | |
| 2427 | index = (vid / 64); |
Thomas Klein | dec590c | 2007-06-06 20:53:16 +0200 | [diff] [blame] | 2428 | cb1->vlan_filter[index] &= ~((u64)(0x8000000000000000 >> (vid & 0x3F))); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2429 | |
| 2430 | hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id, |
| 2431 | H_PORT_CB1, H_PORT_CB1_ALL, cb1); |
| 2432 | if (hret != H_SUCCESS) |
| 2433 | ehea_error("modify_ehea_port failed"); |
| 2434 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2435 | free_page((unsigned long)cb1); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2436 | } |
| 2437 | |
| 2438 | int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp) |
| 2439 | { |
| 2440 | int ret = -EIO; |
| 2441 | u64 hret; |
| 2442 | u16 dummy16 = 0; |
| 2443 | u64 dummy64 = 0; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2444 | struct hcp_modify_qp_cb0 *cb0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2445 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2446 | cb0 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2447 | if (!cb0) { |
| 2448 | ret = -ENOMEM; |
| 2449 | goto out; |
| 2450 | } |
| 2451 | |
| 2452 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2453 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), cb0); |
| 2454 | if (hret != H_SUCCESS) { |
| 2455 | ehea_error("query_ehea_qp failed (1)"); |
| 2456 | goto out; |
| 2457 | } |
| 2458 | |
| 2459 | cb0->qp_ctl_reg = H_QP_CR_STATE_INITIALIZED; |
| 2460 | hret = ehea_h_modify_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2461 | EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG, 1), cb0, |
| 2462 | &dummy64, &dummy64, &dummy16, &dummy16); |
| 2463 | if (hret != H_SUCCESS) { |
| 2464 | ehea_error("modify_ehea_qp failed (1)"); |
| 2465 | goto out; |
| 2466 | } |
| 2467 | |
| 2468 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2469 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), cb0); |
| 2470 | if (hret != H_SUCCESS) { |
| 2471 | ehea_error("query_ehea_qp failed (2)"); |
| 2472 | goto out; |
| 2473 | } |
| 2474 | |
| 2475 | cb0->qp_ctl_reg = H_QP_CR_ENABLED | H_QP_CR_STATE_INITIALIZED; |
| 2476 | hret = ehea_h_modify_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2477 | EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG, 1), cb0, |
| 2478 | &dummy64, &dummy64, &dummy16, &dummy16); |
| 2479 | if (hret != H_SUCCESS) { |
| 2480 | ehea_error("modify_ehea_qp failed (2)"); |
| 2481 | goto out; |
| 2482 | } |
| 2483 | |
| 2484 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2485 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), cb0); |
| 2486 | if (hret != H_SUCCESS) { |
| 2487 | ehea_error("query_ehea_qp failed (3)"); |
| 2488 | goto out; |
| 2489 | } |
| 2490 | |
| 2491 | cb0->qp_ctl_reg = H_QP_CR_ENABLED | H_QP_CR_STATE_RDY2SND; |
| 2492 | hret = ehea_h_modify_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2493 | EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG, 1), cb0, |
| 2494 | &dummy64, &dummy64, &dummy16, &dummy16); |
| 2495 | if (hret != H_SUCCESS) { |
| 2496 | ehea_error("modify_ehea_qp failed (3)"); |
| 2497 | goto out; |
| 2498 | } |
| 2499 | |
| 2500 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2501 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), cb0); |
| 2502 | if (hret != H_SUCCESS) { |
| 2503 | ehea_error("query_ehea_qp failed (4)"); |
| 2504 | goto out; |
| 2505 | } |
| 2506 | |
| 2507 | ret = 0; |
| 2508 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2509 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2510 | return ret; |
| 2511 | } |
| 2512 | |
| 2513 | static int ehea_port_res_setup(struct ehea_port *port, int def_qps, |
| 2514 | int add_tx_qps) |
| 2515 | { |
| 2516 | int ret, i; |
| 2517 | struct port_res_cfg pr_cfg, pr_cfg_small_rx; |
| 2518 | enum ehea_eq_type eq_type = EHEA_EQ; |
| 2519 | |
| 2520 | port->qp_eq = ehea_create_eq(port->adapter, eq_type, |
| 2521 | EHEA_MAX_ENTRIES_EQ, 1); |
| 2522 | if (!port->qp_eq) { |
| 2523 | ret = -EINVAL; |
| 2524 | ehea_error("ehea_create_eq failed (qp_eq)"); |
| 2525 | goto out_kill_eq; |
| 2526 | } |
| 2527 | |
| 2528 | pr_cfg.max_entries_rcq = rq1_entries + rq2_entries + rq3_entries; |
Jan-Bernd Themann | 18604c5 | 2007-02-28 18:34:10 +0100 | [diff] [blame] | 2529 | pr_cfg.max_entries_scq = sq_entries * 2; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2530 | pr_cfg.max_entries_sq = sq_entries; |
| 2531 | pr_cfg.max_entries_rq1 = rq1_entries; |
| 2532 | pr_cfg.max_entries_rq2 = rq2_entries; |
| 2533 | pr_cfg.max_entries_rq3 = rq3_entries; |
| 2534 | |
| 2535 | pr_cfg_small_rx.max_entries_rcq = 1; |
| 2536 | pr_cfg_small_rx.max_entries_scq = sq_entries; |
| 2537 | pr_cfg_small_rx.max_entries_sq = sq_entries; |
| 2538 | pr_cfg_small_rx.max_entries_rq1 = 1; |
| 2539 | pr_cfg_small_rx.max_entries_rq2 = 1; |
| 2540 | pr_cfg_small_rx.max_entries_rq3 = 1; |
| 2541 | |
| 2542 | for (i = 0; i < def_qps; i++) { |
| 2543 | ret = ehea_init_port_res(port, &port->port_res[i], &pr_cfg, i); |
| 2544 | if (ret) |
| 2545 | goto out_clean_pr; |
| 2546 | } |
| 2547 | for (i = def_qps; i < def_qps + add_tx_qps; i++) { |
| 2548 | ret = ehea_init_port_res(port, &port->port_res[i], |
| 2549 | &pr_cfg_small_rx, i); |
| 2550 | if (ret) |
| 2551 | goto out_clean_pr; |
| 2552 | } |
| 2553 | |
| 2554 | return 0; |
| 2555 | |
| 2556 | out_clean_pr: |
| 2557 | while (--i >= 0) |
| 2558 | ehea_clean_portres(port, &port->port_res[i]); |
| 2559 | |
| 2560 | out_kill_eq: |
| 2561 | ehea_destroy_eq(port->qp_eq); |
| 2562 | return ret; |
| 2563 | } |
| 2564 | |
| 2565 | static int ehea_clean_all_portres(struct ehea_port *port) |
| 2566 | { |
| 2567 | int ret = 0; |
| 2568 | int i; |
| 2569 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2570 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2571 | ret |= ehea_clean_portres(port, &port->port_res[i]); |
| 2572 | |
| 2573 | ret |= ehea_destroy_eq(port->qp_eq); |
| 2574 | |
| 2575 | return ret; |
| 2576 | } |
| 2577 | |
Thomas Klein | 35cf2e2 | 2007-08-06 13:55:14 +0200 | [diff] [blame] | 2578 | static void ehea_remove_adapter_mr(struct ehea_adapter *adapter) |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 2579 | { |
Thomas Klein | 35cf2e2 | 2007-08-06 13:55:14 +0200 | [diff] [blame] | 2580 | if (adapter->active_ports) |
| 2581 | return; |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 2582 | |
| 2583 | ehea_rem_mr(&adapter->mr); |
| 2584 | } |
| 2585 | |
Thomas Klein | 35cf2e2 | 2007-08-06 13:55:14 +0200 | [diff] [blame] | 2586 | static int ehea_add_adapter_mr(struct ehea_adapter *adapter) |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 2587 | { |
Thomas Klein | 35cf2e2 | 2007-08-06 13:55:14 +0200 | [diff] [blame] | 2588 | if (adapter->active_ports) |
| 2589 | return 0; |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 2590 | |
| 2591 | return ehea_reg_kernel_mr(adapter, &adapter->mr); |
| 2592 | } |
| 2593 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2594 | static int ehea_up(struct net_device *dev) |
| 2595 | { |
| 2596 | int ret, i; |
| 2597 | struct ehea_port *port = netdev_priv(dev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2598 | |
| 2599 | if (port->state == EHEA_PORT_UP) |
| 2600 | return 0; |
| 2601 | |
| 2602 | ret = ehea_port_res_setup(port, port->num_def_qps, |
| 2603 | port->num_add_tx_qps); |
| 2604 | if (ret) { |
| 2605 | ehea_error("port_res_failed"); |
| 2606 | goto out; |
| 2607 | } |
| 2608 | |
| 2609 | /* Set default QP for this port */ |
| 2610 | ret = ehea_configure_port(port); |
| 2611 | if (ret) { |
| 2612 | ehea_error("ehea_configure_port failed. ret:%d", ret); |
| 2613 | goto out_clean_pr; |
| 2614 | } |
| 2615 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2616 | ret = ehea_reg_interrupts(dev); |
| 2617 | if (ret) { |
Thomas Klein | f9e2922 | 2007-07-18 17:34:09 +0200 | [diff] [blame] | 2618 | ehea_error("reg_interrupts failed. ret:%d", ret); |
| 2619 | goto out_clean_pr; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2620 | } |
| 2621 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2622 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2623 | ret = ehea_activate_qp(port->adapter, port->port_res[i].qp); |
| 2624 | if (ret) { |
| 2625 | ehea_error("activate_qp failed"); |
| 2626 | goto out_free_irqs; |
| 2627 | } |
| 2628 | } |
| 2629 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2630 | for (i = 0; i < port->num_def_qps; i++) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2631 | ret = ehea_fill_port_res(&port->port_res[i]); |
| 2632 | if (ret) { |
| 2633 | ehea_error("out_free_irqs"); |
| 2634 | goto out_free_irqs; |
| 2635 | } |
| 2636 | } |
| 2637 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2638 | ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); |
| 2639 | if (ret) { |
| 2640 | ret = -EIO; |
| 2641 | goto out_free_irqs; |
| 2642 | } |
| 2643 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2644 | port->state = EHEA_PORT_UP; |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2645 | |
| 2646 | ret = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2647 | goto out; |
| 2648 | |
| 2649 | out_free_irqs: |
| 2650 | ehea_free_interrupts(dev); |
| 2651 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2652 | out_clean_pr: |
| 2653 | ehea_clean_all_portres(port); |
| 2654 | out: |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2655 | if (ret) |
| 2656 | ehea_info("Failed starting %s. ret=%i", dev->name, ret); |
| 2657 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2658 | ehea_update_bcmc_registrations(); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2659 | ehea_update_firmware_handles(); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2660 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2661 | return ret; |
| 2662 | } |
| 2663 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2664 | static void port_napi_disable(struct ehea_port *port) |
| 2665 | { |
| 2666 | int i; |
| 2667 | |
Jan-Bernd Themann | 0173b79 | 2007-10-24 11:53:34 +0200 | [diff] [blame] | 2668 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2669 | napi_disable(&port->port_res[i].napi); |
| 2670 | } |
| 2671 | |
| 2672 | static void port_napi_enable(struct ehea_port *port) |
| 2673 | { |
| 2674 | int i; |
| 2675 | |
Jan-Bernd Themann | 0173b79 | 2007-10-24 11:53:34 +0200 | [diff] [blame] | 2676 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2677 | napi_enable(&port->port_res[i].napi); |
| 2678 | } |
| 2679 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2680 | static int ehea_open(struct net_device *dev) |
| 2681 | { |
| 2682 | int ret; |
| 2683 | struct ehea_port *port = netdev_priv(dev); |
| 2684 | |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2685 | mutex_lock(&port->port_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2686 | |
| 2687 | if (netif_msg_ifup(port)) |
| 2688 | ehea_info("enabling port %s", dev->name); |
| 2689 | |
| 2690 | ret = ehea_up(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2691 | if (!ret) { |
| 2692 | port_napi_enable(port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2693 | netif_start_queue(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2694 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2695 | |
Breno Leitao | 5b27d42 | 2010-10-05 13:16:22 +0000 | [diff] [blame] | 2696 | init_waitqueue_head(&port->swqe_avail_wq); |
Breno Leitao | a8bb69f | 2010-10-05 13:16:23 +0000 | [diff] [blame] | 2697 | init_waitqueue_head(&port->restart_wq); |
Breno Leitao | 5b27d42 | 2010-10-05 13:16:22 +0000 | [diff] [blame] | 2698 | |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2699 | mutex_unlock(&port->port_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2700 | |
| 2701 | return ret; |
| 2702 | } |
| 2703 | |
| 2704 | static int ehea_down(struct net_device *dev) |
| 2705 | { |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2706 | int ret; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2707 | struct ehea_port *port = netdev_priv(dev); |
| 2708 | |
| 2709 | if (port->state == EHEA_PORT_DOWN) |
| 2710 | return 0; |
| 2711 | |
| 2712 | ehea_drop_multicast_list(dev); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2713 | ehea_broadcast_reg_helper(port, H_DEREG_BCMC); |
| 2714 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2715 | ehea_free_interrupts(dev); |
| 2716 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2717 | port->state = EHEA_PORT_DOWN; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2718 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2719 | ehea_update_bcmc_registrations(); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2720 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2721 | ret = ehea_clean_all_portres(port); |
| 2722 | if (ret) |
| 2723 | ehea_info("Failed freeing resources for %s. ret=%i", |
| 2724 | dev->name, ret); |
| 2725 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2726 | ehea_update_firmware_handles(); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 2727 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2728 | return ret; |
| 2729 | } |
| 2730 | |
| 2731 | static int ehea_stop(struct net_device *dev) |
| 2732 | { |
| 2733 | int ret; |
| 2734 | struct ehea_port *port = netdev_priv(dev); |
| 2735 | |
| 2736 | if (netif_msg_ifdown(port)) |
| 2737 | ehea_info("disabling port %s", dev->name); |
| 2738 | |
Jan-Bernd Themann | 2f69ae0 | 2008-07-03 15:18:51 +0100 | [diff] [blame] | 2739 | set_bit(__EHEA_DISABLE_PORT_RESET, &port->flags); |
David S. Miller | 4bb073c | 2008-06-12 02:22:02 -0700 | [diff] [blame] | 2740 | cancel_work_sync(&port->reset_task); |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2741 | mutex_lock(&port->port_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2742 | netif_stop_queue(dev); |
Jan-Bernd Themann | 0173b79 | 2007-10-24 11:53:34 +0200 | [diff] [blame] | 2743 | port_napi_disable(port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2744 | ret = ehea_down(dev); |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2745 | mutex_unlock(&port->port_lock); |
Jan-Bernd Themann | 2f69ae0 | 2008-07-03 15:18:51 +0100 | [diff] [blame] | 2746 | clear_bit(__EHEA_DISABLE_PORT_RESET, &port->flags); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2747 | return ret; |
| 2748 | } |
| 2749 | |
Andrew Morton | 22559c5 | 2008-04-18 13:50:39 -0700 | [diff] [blame] | 2750 | static void ehea_purge_sq(struct ehea_qp *orig_qp) |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2751 | { |
| 2752 | struct ehea_qp qp = *orig_qp; |
| 2753 | struct ehea_qp_init_attr *init_attr = &qp.init_attr; |
| 2754 | struct ehea_swqe *swqe; |
| 2755 | int wqe_index; |
| 2756 | int i; |
| 2757 | |
| 2758 | for (i = 0; i < init_attr->act_nr_send_wqes; i++) { |
| 2759 | swqe = ehea_get_swqe(&qp, &wqe_index); |
| 2760 | swqe->tx_control |= EHEA_SWQE_PURGE; |
| 2761 | } |
| 2762 | } |
| 2763 | |
Andrew Morton | 22559c5 | 2008-04-18 13:50:39 -0700 | [diff] [blame] | 2764 | static void ehea_flush_sq(struct ehea_port *port) |
Thomas Klein | 44fb312 | 2008-04-04 15:04:53 +0200 | [diff] [blame] | 2765 | { |
| 2766 | int i; |
| 2767 | |
| 2768 | for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) { |
| 2769 | struct ehea_port_res *pr = &port->port_res[i]; |
| 2770 | int swqe_max = pr->sq_skba_size - 2 - pr->swqe_ll_count; |
Breno Leitao | 5b27d42 | 2010-10-05 13:16:22 +0000 | [diff] [blame] | 2771 | int ret; |
| 2772 | |
| 2773 | ret = wait_event_timeout(port->swqe_avail_wq, |
| 2774 | atomic_read(&pr->swqe_avail) >= swqe_max, |
| 2775 | msecs_to_jiffies(100)); |
| 2776 | |
| 2777 | if (!ret) { |
| 2778 | ehea_error("WARNING: sq not flushed completely"); |
| 2779 | break; |
Thomas Klein | 44fb312 | 2008-04-04 15:04:53 +0200 | [diff] [blame] | 2780 | } |
| 2781 | } |
| 2782 | } |
| 2783 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2784 | int ehea_stop_qps(struct net_device *dev) |
| 2785 | { |
| 2786 | struct ehea_port *port = netdev_priv(dev); |
| 2787 | struct ehea_adapter *adapter = port->adapter; |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2788 | struct hcp_modify_qp_cb0 *cb0; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2789 | int ret = -EIO; |
| 2790 | int dret; |
| 2791 | int i; |
| 2792 | u64 hret; |
| 2793 | u64 dummy64 = 0; |
| 2794 | u16 dummy16 = 0; |
| 2795 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2796 | cb0 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2797 | if (!cb0) { |
| 2798 | ret = -ENOMEM; |
| 2799 | goto out; |
| 2800 | } |
| 2801 | |
| 2802 | for (i = 0; i < (port->num_def_qps + port->num_add_tx_qps); i++) { |
| 2803 | struct ehea_port_res *pr = &port->port_res[i]; |
| 2804 | struct ehea_qp *qp = pr->qp; |
| 2805 | |
| 2806 | /* Purge send queue */ |
| 2807 | ehea_purge_sq(qp); |
| 2808 | |
| 2809 | /* Disable queue pair */ |
| 2810 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2811 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), |
| 2812 | cb0); |
| 2813 | if (hret != H_SUCCESS) { |
| 2814 | ehea_error("query_ehea_qp failed (1)"); |
| 2815 | goto out; |
| 2816 | } |
| 2817 | |
| 2818 | cb0->qp_ctl_reg = (cb0->qp_ctl_reg & H_QP_CR_RES_STATE) << 8; |
| 2819 | cb0->qp_ctl_reg &= ~H_QP_CR_ENABLED; |
| 2820 | |
| 2821 | hret = ehea_h_modify_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2822 | EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG, |
| 2823 | 1), cb0, &dummy64, |
| 2824 | &dummy64, &dummy16, &dummy16); |
| 2825 | if (hret != H_SUCCESS) { |
| 2826 | ehea_error("modify_ehea_qp failed (1)"); |
| 2827 | goto out; |
| 2828 | } |
| 2829 | |
| 2830 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2831 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), |
| 2832 | cb0); |
| 2833 | if (hret != H_SUCCESS) { |
| 2834 | ehea_error("query_ehea_qp failed (2)"); |
| 2835 | goto out; |
| 2836 | } |
| 2837 | |
| 2838 | /* deregister shared memory regions */ |
| 2839 | dret = ehea_rem_smrs(pr); |
| 2840 | if (dret) { |
| 2841 | ehea_error("unreg shared memory region failed"); |
| 2842 | goto out; |
| 2843 | } |
| 2844 | } |
| 2845 | |
| 2846 | ret = 0; |
| 2847 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2848 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2849 | |
| 2850 | return ret; |
| 2851 | } |
| 2852 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2853 | void ehea_update_rqs(struct ehea_qp *orig_qp, struct ehea_port_res *pr) |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2854 | { |
| 2855 | struct ehea_qp qp = *orig_qp; |
| 2856 | struct ehea_qp_init_attr *init_attr = &qp.init_attr; |
| 2857 | struct ehea_rwqe *rwqe; |
| 2858 | struct sk_buff **skba_rq2 = pr->rq2_skba.arr; |
| 2859 | struct sk_buff **skba_rq3 = pr->rq3_skba.arr; |
| 2860 | struct sk_buff *skb; |
| 2861 | u32 lkey = pr->recv_mr.lkey; |
| 2862 | |
| 2863 | |
| 2864 | int i; |
| 2865 | int index; |
| 2866 | |
| 2867 | for (i = 0; i < init_attr->act_nr_rwqes_rq2 + 1; i++) { |
| 2868 | rwqe = ehea_get_next_rwqe(&qp, 2); |
| 2869 | rwqe->sg_list[0].l_key = lkey; |
| 2870 | index = EHEA_BMASK_GET(EHEA_WR_ID_INDEX, rwqe->wr_id); |
| 2871 | skb = skba_rq2[index]; |
| 2872 | if (skb) |
| 2873 | rwqe->sg_list[0].vaddr = ehea_map_vaddr(skb->data); |
| 2874 | } |
| 2875 | |
| 2876 | for (i = 0; i < init_attr->act_nr_rwqes_rq3 + 1; i++) { |
| 2877 | rwqe = ehea_get_next_rwqe(&qp, 3); |
| 2878 | rwqe->sg_list[0].l_key = lkey; |
| 2879 | index = EHEA_BMASK_GET(EHEA_WR_ID_INDEX, rwqe->wr_id); |
| 2880 | skb = skba_rq3[index]; |
| 2881 | if (skb) |
| 2882 | rwqe->sg_list[0].vaddr = ehea_map_vaddr(skb->data); |
| 2883 | } |
| 2884 | } |
| 2885 | |
| 2886 | int ehea_restart_qps(struct net_device *dev) |
| 2887 | { |
| 2888 | struct ehea_port *port = netdev_priv(dev); |
| 2889 | struct ehea_adapter *adapter = port->adapter; |
| 2890 | int ret = 0; |
| 2891 | int i; |
| 2892 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 2893 | struct hcp_modify_qp_cb0 *cb0; |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2894 | u64 hret; |
| 2895 | u64 dummy64 = 0; |
| 2896 | u16 dummy16 = 0; |
| 2897 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2898 | cb0 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2899 | if (!cb0) { |
| 2900 | ret = -ENOMEM; |
| 2901 | goto out; |
| 2902 | } |
| 2903 | |
| 2904 | for (i = 0; i < (port->num_def_qps + port->num_add_tx_qps); i++) { |
| 2905 | struct ehea_port_res *pr = &port->port_res[i]; |
| 2906 | struct ehea_qp *qp = pr->qp; |
| 2907 | |
| 2908 | ret = ehea_gen_smrs(pr); |
| 2909 | if (ret) { |
| 2910 | ehea_error("creation of shared memory regions failed"); |
| 2911 | goto out; |
| 2912 | } |
| 2913 | |
| 2914 | ehea_update_rqs(qp, pr); |
| 2915 | |
| 2916 | /* Enable queue pair */ |
| 2917 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2918 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), |
| 2919 | cb0); |
| 2920 | if (hret != H_SUCCESS) { |
| 2921 | ehea_error("query_ehea_qp failed (1)"); |
| 2922 | goto out; |
| 2923 | } |
| 2924 | |
| 2925 | cb0->qp_ctl_reg = (cb0->qp_ctl_reg & H_QP_CR_RES_STATE) << 8; |
| 2926 | cb0->qp_ctl_reg |= H_QP_CR_ENABLED; |
| 2927 | |
| 2928 | hret = ehea_h_modify_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2929 | EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG, |
| 2930 | 1), cb0, &dummy64, |
| 2931 | &dummy64, &dummy16, &dummy16); |
| 2932 | if (hret != H_SUCCESS) { |
| 2933 | ehea_error("modify_ehea_qp failed (1)"); |
| 2934 | goto out; |
| 2935 | } |
| 2936 | |
| 2937 | hret = ehea_h_query_ehea_qp(adapter->handle, 0, qp->fw_handle, |
| 2938 | EHEA_BMASK_SET(H_QPCB0_ALL, 0xFFFF), |
| 2939 | cb0); |
| 2940 | if (hret != H_SUCCESS) { |
| 2941 | ehea_error("query_ehea_qp failed (2)"); |
| 2942 | goto out; |
| 2943 | } |
| 2944 | |
| 2945 | /* refill entire queue */ |
| 2946 | ehea_refill_rq1(pr, pr->rq1_skba.index, 0); |
| 2947 | ehea_refill_rq2(pr, 0); |
| 2948 | ehea_refill_rq3(pr, 0); |
| 2949 | } |
| 2950 | out: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 2951 | free_page((unsigned long)cb0); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2952 | |
| 2953 | return ret; |
| 2954 | } |
| 2955 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 2956 | static void ehea_reset_port(struct work_struct *work) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2957 | { |
| 2958 | int ret; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 2959 | struct ehea_port *port = |
| 2960 | container_of(work, struct ehea_port, reset_task); |
| 2961 | struct net_device *dev = port->netdev; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2962 | |
Jan-Bernd Themann | 099473c | 2010-06-15 05:35:42 +0000 | [diff] [blame] | 2963 | mutex_lock(&dlpar_mem_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2964 | port->resets++; |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2965 | mutex_lock(&port->port_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2966 | netif_stop_queue(dev); |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2967 | |
| 2968 | port_napi_disable(port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2969 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2970 | ehea_down(dev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2971 | |
| 2972 | ret = ehea_up(dev); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2973 | if (ret) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2974 | goto out; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2975 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 2976 | ehea_set_multicast_list(dev); |
| 2977 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2978 | if (netif_msg_timer(port)) |
| 2979 | ehea_info("Device %s resetted successfully", dev->name); |
| 2980 | |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 2981 | port_napi_enable(port); |
| 2982 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2983 | netif_wake_queue(dev); |
| 2984 | out: |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 2985 | mutex_unlock(&port->port_lock); |
Jan-Bernd Themann | 099473c | 2010-06-15 05:35:42 +0000 | [diff] [blame] | 2986 | mutex_unlock(&dlpar_mem_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 2987 | } |
| 2988 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2989 | static void ehea_rereg_mrs(struct work_struct *work) |
| 2990 | { |
| 2991 | int ret, i; |
| 2992 | struct ehea_adapter *adapter; |
| 2993 | |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 2994 | ehea_info("LPAR memory changed - re-initializing driver"); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 2995 | |
| 2996 | list_for_each_entry(adapter, &adapter_list, list) |
| 2997 | if (adapter->active_ports) { |
| 2998 | /* Shutdown all ports */ |
| 2999 | for (i = 0; i < EHEA_MAX_PORTS; i++) { |
| 3000 | struct ehea_port *port = adapter->port[i]; |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3001 | struct net_device *dev; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3002 | |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3003 | if (!port) |
| 3004 | continue; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3005 | |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3006 | dev = port->netdev; |
| 3007 | |
| 3008 | if (dev->flags & IFF_UP) { |
| 3009 | mutex_lock(&port->port_lock); |
| 3010 | netif_stop_queue(dev); |
David S. Miller | df39e8b | 2008-04-14 02:30:23 -0700 | [diff] [blame] | 3011 | ehea_flush_sq(port); |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3012 | ret = ehea_stop_qps(dev); |
| 3013 | if (ret) { |
| 3014 | mutex_unlock(&port->port_lock); |
| 3015 | goto out; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3016 | } |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3017 | port_napi_disable(port); |
| 3018 | mutex_unlock(&port->port_lock); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3019 | } |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 3020 | reset_sq_restart_flag(port); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3021 | } |
| 3022 | |
| 3023 | /* Unregister old memory region */ |
| 3024 | ret = ehea_rem_mr(&adapter->mr); |
| 3025 | if (ret) { |
| 3026 | ehea_error("unregister MR failed - driver" |
| 3027 | " inoperable!"); |
| 3028 | goto out; |
| 3029 | } |
| 3030 | } |
| 3031 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3032 | clear_bit(__EHEA_STOP_XFER, &ehea_driver_flags); |
| 3033 | |
| 3034 | list_for_each_entry(adapter, &adapter_list, list) |
| 3035 | if (adapter->active_ports) { |
| 3036 | /* Register new memory region */ |
| 3037 | ret = ehea_reg_kernel_mr(adapter, &adapter->mr); |
| 3038 | if (ret) { |
| 3039 | ehea_error("register MR failed - driver" |
| 3040 | " inoperable!"); |
| 3041 | goto out; |
| 3042 | } |
| 3043 | |
| 3044 | /* Restart all ports */ |
| 3045 | for (i = 0; i < EHEA_MAX_PORTS; i++) { |
| 3046 | struct ehea_port *port = adapter->port[i]; |
| 3047 | |
| 3048 | if (port) { |
| 3049 | struct net_device *dev = port->netdev; |
| 3050 | |
| 3051 | if (dev->flags & IFF_UP) { |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3052 | mutex_lock(&port->port_lock); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 3053 | port_napi_enable(port); |
| 3054 | ret = ehea_restart_qps(dev); |
Andre Detsch | 2928db4 | 2010-08-17 05:49:12 +0000 | [diff] [blame] | 3055 | check_sqs(port); |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 3056 | if (!ret) |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3057 | netif_wake_queue(dev); |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3058 | mutex_unlock(&port->port_lock); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3059 | } |
| 3060 | } |
| 3061 | } |
| 3062 | } |
Julia Lawall | 68905eb | 2008-07-21 09:57:26 +0200 | [diff] [blame] | 3063 | ehea_info("re-initializing driver complete"); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3064 | out: |
| 3065 | return; |
| 3066 | } |
| 3067 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3068 | static void ehea_tx_watchdog(struct net_device *dev) |
| 3069 | { |
| 3070 | struct ehea_port *port = netdev_priv(dev); |
| 3071 | |
Jan-Bernd Themann | 2c69448 | 2007-10-01 16:33:18 +0200 | [diff] [blame] | 3072 | if (netif_carrier_ok(dev) && |
| 3073 | !test_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) |
Jan-Bernd Themann | 2f69ae0 | 2008-07-03 15:18:51 +0100 | [diff] [blame] | 3074 | ehea_schedule_port_reset(port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3075 | } |
| 3076 | |
| 3077 | int ehea_sense_adapter_attr(struct ehea_adapter *adapter) |
| 3078 | { |
| 3079 | struct hcp_query_ehea *cb; |
| 3080 | u64 hret; |
| 3081 | int ret; |
| 3082 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 3083 | cb = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3084 | if (!cb) { |
| 3085 | ret = -ENOMEM; |
| 3086 | goto out; |
| 3087 | } |
| 3088 | |
| 3089 | hret = ehea_h_query_ehea(adapter->handle, cb); |
| 3090 | |
| 3091 | if (hret != H_SUCCESS) { |
| 3092 | ret = -EIO; |
| 3093 | goto out_herr; |
| 3094 | } |
| 3095 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3096 | adapter->max_mc_mac = cb->max_mc_mac - 1; |
| 3097 | ret = 0; |
| 3098 | |
| 3099 | out_herr: |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 3100 | free_page((unsigned long)cb); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3101 | out: |
| 3102 | return ret; |
| 3103 | } |
| 3104 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3105 | int ehea_get_jumboframe_status(struct ehea_port *port, int *jumbo) |
| 3106 | { |
| 3107 | struct hcp_ehea_port_cb4 *cb4; |
| 3108 | u64 hret; |
| 3109 | int ret = 0; |
| 3110 | |
| 3111 | *jumbo = 0; |
| 3112 | |
| 3113 | /* (Try to) enable *jumbo frames */ |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 3114 | cb4 = (void *)get_zeroed_page(GFP_KERNEL); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3115 | if (!cb4) { |
| 3116 | ehea_error("no mem for cb4"); |
| 3117 | ret = -ENOMEM; |
| 3118 | goto out; |
| 3119 | } else { |
| 3120 | hret = ehea_h_query_ehea_port(port->adapter->handle, |
| 3121 | port->logical_port_id, |
| 3122 | H_PORT_CB4, |
| 3123 | H_PORT_CB4_JUMBO, cb4); |
| 3124 | if (hret == H_SUCCESS) { |
| 3125 | if (cb4->jumbo_frame) |
| 3126 | *jumbo = 1; |
| 3127 | else { |
| 3128 | cb4->jumbo_frame = 1; |
| 3129 | hret = ehea_h_modify_ehea_port(port->adapter-> |
| 3130 | handle, |
| 3131 | port-> |
| 3132 | logical_port_id, |
| 3133 | H_PORT_CB4, |
| 3134 | H_PORT_CB4_JUMBO, |
| 3135 | cb4); |
| 3136 | if (hret == H_SUCCESS) |
| 3137 | *jumbo = 1; |
| 3138 | } |
| 3139 | } else |
| 3140 | ret = -EINVAL; |
| 3141 | |
Thomas Klein | 3faf269 | 2009-01-21 14:45:33 -0800 | [diff] [blame] | 3142 | free_page((unsigned long)cb4); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3143 | } |
| 3144 | out: |
| 3145 | return ret; |
| 3146 | } |
| 3147 | |
| 3148 | static ssize_t ehea_show_port_id(struct device *dev, |
| 3149 | struct device_attribute *attr, char *buf) |
| 3150 | { |
| 3151 | struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); |
Jan-Bernd Themann | a8e34fd | 2007-08-22 16:20:58 +0200 | [diff] [blame] | 3152 | return sprintf(buf, "%d", port->logical_port_id); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id, |
| 3156 | NULL); |
| 3157 | |
| 3158 | static void __devinit logical_port_release(struct device *dev) |
| 3159 | { |
| 3160 | struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3161 | of_node_put(port->ofdev.dev.of_node); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3162 | } |
| 3163 | |
| 3164 | static struct device *ehea_register_port(struct ehea_port *port, |
| 3165 | struct device_node *dn) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3166 | { |
| 3167 | int ret; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3168 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3169 | port->ofdev.dev.of_node = of_node_get(dn); |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3170 | port->ofdev.dev.parent = &port->adapter->ofdev->dev; |
Thomas Klein | d1dea38 | 2007-04-26 11:56:13 +0200 | [diff] [blame] | 3171 | port->ofdev.dev.bus = &ibmebus_bus_type; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3172 | |
Kay Sievers | db1d7bf | 2009-01-26 21:12:58 -0800 | [diff] [blame] | 3173 | dev_set_name(&port->ofdev.dev, "port%d", port_name_cnt++); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3174 | port->ofdev.dev.release = logical_port_release; |
| 3175 | |
| 3176 | ret = of_device_register(&port->ofdev); |
| 3177 | if (ret) { |
| 3178 | ehea_error("failed to register device. ret=%d", ret); |
| 3179 | goto out; |
| 3180 | } |
| 3181 | |
| 3182 | ret = device_create_file(&port->ofdev.dev, &dev_attr_log_port_id); |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 3183 | if (ret) { |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3184 | ehea_error("failed to register attributes, ret=%d", ret); |
| 3185 | goto out_unreg_of_dev; |
| 3186 | } |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3187 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3188 | return &port->ofdev.dev; |
| 3189 | |
| 3190 | out_unreg_of_dev: |
| 3191 | of_device_unregister(&port->ofdev); |
| 3192 | out: |
| 3193 | return NULL; |
| 3194 | } |
| 3195 | |
| 3196 | static void ehea_unregister_port(struct ehea_port *port) |
| 3197 | { |
| 3198 | device_remove_file(&port->ofdev.dev, &dev_attr_log_port_id); |
| 3199 | of_device_unregister(&port->ofdev); |
| 3200 | } |
| 3201 | |
Thomas Klein | 086c1b2 | 2009-01-21 14:43:59 -0800 | [diff] [blame] | 3202 | static const struct net_device_ops ehea_netdev_ops = { |
| 3203 | .ndo_open = ehea_open, |
| 3204 | .ndo_stop = ehea_stop, |
| 3205 | .ndo_start_xmit = ehea_start_xmit, |
| 3206 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 3207 | .ndo_poll_controller = ehea_netpoll, |
| 3208 | #endif |
| 3209 | .ndo_get_stats = ehea_get_stats, |
| 3210 | .ndo_set_mac_address = ehea_set_mac_addr, |
Ben Hutchings | 240c102 | 2009-07-09 17:54:35 +0000 | [diff] [blame] | 3211 | .ndo_validate_addr = eth_validate_addr, |
Thomas Klein | 086c1b2 | 2009-01-21 14:43:59 -0800 | [diff] [blame] | 3212 | .ndo_set_multicast_list = ehea_set_multicast_list, |
| 3213 | .ndo_change_mtu = ehea_change_mtu, |
| 3214 | .ndo_vlan_rx_register = ehea_vlan_rx_register, |
| 3215 | .ndo_vlan_rx_add_vid = ehea_vlan_rx_add_vid, |
Alexander Beregalov | 32e8f9a | 2009-04-14 15:18:00 -0700 | [diff] [blame] | 3216 | .ndo_vlan_rx_kill_vid = ehea_vlan_rx_kill_vid, |
| 3217 | .ndo_tx_timeout = ehea_tx_watchdog, |
Thomas Klein | 086c1b2 | 2009-01-21 14:43:59 -0800 | [diff] [blame] | 3218 | }; |
| 3219 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3220 | struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter, |
| 3221 | u32 logical_port_id, |
| 3222 | struct device_node *dn) |
| 3223 | { |
| 3224 | int ret; |
| 3225 | struct net_device *dev; |
| 3226 | struct ehea_port *port; |
| 3227 | struct device *port_dev; |
| 3228 | int jumbo; |
| 3229 | |
| 3230 | /* allocate memory for the port structures */ |
| 3231 | dev = alloc_etherdev(sizeof(struct ehea_port)); |
| 3232 | |
| 3233 | if (!dev) { |
| 3234 | ehea_error("no mem for net_device"); |
| 3235 | ret = -ENOMEM; |
| 3236 | goto out_err; |
| 3237 | } |
| 3238 | |
| 3239 | port = netdev_priv(dev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3240 | |
Daniel Walker | a5af6ad | 2008-03-28 14:41:28 -0700 | [diff] [blame] | 3241 | mutex_init(&port->port_lock); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3242 | port->state = EHEA_PORT_DOWN; |
| 3243 | port->sig_comp_iv = sq_entries / 10; |
| 3244 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3245 | port->adapter = adapter; |
| 3246 | port->netdev = dev; |
| 3247 | port->logical_port_id = logical_port_id; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3248 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3249 | port->msg_enable = netif_msg_init(msg_level, EHEA_MSG_DEFAULT); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3250 | |
| 3251 | port->mc_list = kzalloc(sizeof(struct ehea_mc_list), GFP_KERNEL); |
| 3252 | if (!port->mc_list) { |
| 3253 | ret = -ENOMEM; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3254 | goto out_free_ethdev; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3255 | } |
| 3256 | |
| 3257 | INIT_LIST_HEAD(&port->mc_list->list); |
| 3258 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3259 | ret = ehea_sense_port_attr(port); |
| 3260 | if (ret) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3261 | goto out_free_mc_list; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3262 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3263 | port_dev = ehea_register_port(port, dn); |
| 3264 | if (!port_dev) |
| 3265 | goto out_free_mc_list; |
Thomas Klein | 9c750b7 | 2007-01-29 18:44:01 +0100 | [diff] [blame] | 3266 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3267 | SET_NETDEV_DEV(dev, port_dev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3268 | |
| 3269 | /* initialize net_device structure */ |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3270 | memcpy(dev->dev_addr, &port->mac_addr, ETH_ALEN); |
| 3271 | |
Thomas Klein | 086c1b2 | 2009-01-21 14:43:59 -0800 | [diff] [blame] | 3272 | dev->netdev_ops = &ehea_netdev_ops; |
| 3273 | ehea_set_ethtool_ops(dev); |
| 3274 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3275 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO |
Thomas Klein | dc01c44 | 2008-03-19 13:55:43 +0100 | [diff] [blame] | 3276 | | NETIF_F_HIGHDMA | NETIF_F_IP_CSUM | NETIF_F_HW_VLAN_TX |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3277 | | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER |
| 3278 | | NETIF_F_LLTX; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3279 | dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; |
| 3280 | |
Breno Leitao | c7757fd | 2010-12-08 12:19:14 -0800 | [diff] [blame^] | 3281 | if (use_lro) |
| 3282 | dev->features |= NETIF_F_LRO; |
| 3283 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 3284 | INIT_WORK(&port->reset_task, ehea_reset_port); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3285 | |
| 3286 | ret = register_netdev(dev); |
| 3287 | if (ret) { |
| 3288 | ehea_error("register_netdev failed. ret=%d", ret); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3289 | goto out_unreg_port; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3290 | } |
| 3291 | |
Jan-Bernd Themann | d4dc4ec | 2007-09-25 16:16:34 -0700 | [diff] [blame] | 3292 | port->lro_max_aggr = lro_max_aggr; |
| 3293 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3294 | ret = ehea_get_jumboframe_status(port, &jumbo); |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3295 | if (ret) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3296 | ehea_error("failed determining jumbo frame status for %s", |
| 3297 | port->netdev->name); |
| 3298 | |
Thomas Klein | 9c750b7 | 2007-01-29 18:44:01 +0100 | [diff] [blame] | 3299 | ehea_info("%s: Jumbo frames are %sabled", dev->name, |
| 3300 | jumbo == 1 ? "en" : "dis"); |
| 3301 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3302 | adapter->active_ports++; |
| 3303 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3304 | return port; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3305 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3306 | out_unreg_port: |
| 3307 | ehea_unregister_port(port); |
| 3308 | |
| 3309 | out_free_mc_list: |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3310 | kfree(port->mc_list); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3311 | |
| 3312 | out_free_ethdev: |
| 3313 | free_netdev(dev); |
| 3314 | |
| 3315 | out_err: |
| 3316 | ehea_error("setting up logical port with id=%d failed, ret=%d", |
| 3317 | logical_port_id, ret); |
| 3318 | return NULL; |
| 3319 | } |
| 3320 | |
| 3321 | static void ehea_shutdown_single_port(struct ehea_port *port) |
| 3322 | { |
Brian King | 7fb1c2a | 2008-05-14 09:48:25 -0500 | [diff] [blame] | 3323 | struct ehea_adapter *adapter = port->adapter; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3324 | unregister_netdev(port->netdev); |
| 3325 | ehea_unregister_port(port); |
| 3326 | kfree(port->mc_list); |
| 3327 | free_netdev(port->netdev); |
Brian King | 7fb1c2a | 2008-05-14 09:48:25 -0500 | [diff] [blame] | 3328 | adapter->active_ports--; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3329 | } |
| 3330 | |
| 3331 | static int ehea_setup_ports(struct ehea_adapter *adapter) |
| 3332 | { |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3333 | struct device_node *lhea_dn; |
| 3334 | struct device_node *eth_dn = NULL; |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 3335 | |
Stephen Rothwell | 9f9a3b8 | 2007-05-01 13:51:32 +1000 | [diff] [blame] | 3336 | const u32 *dn_log_port_id; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3337 | int i = 0; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3338 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3339 | lhea_dn = adapter->ofdev->dev.of_node; |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3340 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3341 | |
Stephen Rothwell | 40cd3a4 | 2007-05-01 13:54:02 +1000 | [diff] [blame] | 3342 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 3343 | NULL); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3344 | if (!dn_log_port_id) { |
| 3345 | ehea_error("bad device node: eth_dn name=%s", |
| 3346 | eth_dn->full_name); |
| 3347 | continue; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3348 | } |
| 3349 | |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3350 | if (ehea_add_adapter_mr(adapter)) { |
| 3351 | ehea_error("creating MR failed"); |
| 3352 | of_node_put(eth_dn); |
| 3353 | return -EIO; |
| 3354 | } |
| 3355 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3356 | adapter->port[i] = ehea_setup_single_port(adapter, |
| 3357 | *dn_log_port_id, |
| 3358 | eth_dn); |
| 3359 | if (adapter->port[i]) |
| 3360 | ehea_info("%s -> logical port id #%d", |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3361 | adapter->port[i]->netdev->name, |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3362 | *dn_log_port_id); |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3363 | else |
| 3364 | ehea_remove_adapter_mr(adapter); |
| 3365 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3366 | i++; |
Joe Perches | ee289b6 | 2010-05-17 22:47:34 -0700 | [diff] [blame] | 3367 | } |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3368 | return 0; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3369 | } |
| 3370 | |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3371 | static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter, |
| 3372 | u32 logical_port_id) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3373 | { |
| 3374 | struct device_node *lhea_dn; |
| 3375 | struct device_node *eth_dn = NULL; |
Stephen Rothwell | 9f9a3b8 | 2007-05-01 13:51:32 +1000 | [diff] [blame] | 3376 | const u32 *dn_log_port_id; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3377 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3378 | lhea_dn = adapter->ofdev->dev.of_node; |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3379 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3380 | |
Stephen Rothwell | 40cd3a4 | 2007-05-01 13:54:02 +1000 | [diff] [blame] | 3381 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 3382 | NULL); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3383 | if (dn_log_port_id) |
| 3384 | if (*dn_log_port_id == logical_port_id) |
| 3385 | return eth_dn; |
Joe Perches | ee289b6 | 2010-05-17 22:47:34 -0700 | [diff] [blame] | 3386 | } |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3387 | |
| 3388 | return NULL; |
| 3389 | } |
| 3390 | |
| 3391 | static ssize_t ehea_probe_port(struct device *dev, |
| 3392 | struct device_attribute *attr, |
| 3393 | const char *buf, size_t count) |
| 3394 | { |
Greg Kroah-Hartman | c7ae011 | 2009-05-04 21:33:19 -0700 | [diff] [blame] | 3395 | struct ehea_adapter *adapter = dev_get_drvdata(dev); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3396 | struct ehea_port *port; |
| 3397 | struct device_node *eth_dn = NULL; |
| 3398 | int i; |
| 3399 | |
| 3400 | u32 logical_port_id; |
| 3401 | |
Jan-Bernd Themann | a8e34fd | 2007-08-22 16:20:58 +0200 | [diff] [blame] | 3402 | sscanf(buf, "%d", &logical_port_id); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3403 | |
| 3404 | port = ehea_get_port(adapter, logical_port_id); |
| 3405 | |
| 3406 | if (port) { |
| 3407 | ehea_info("adding port with logical port id=%d failed. port " |
| 3408 | "already configured as %s.", logical_port_id, |
| 3409 | port->netdev->name); |
| 3410 | return -EINVAL; |
| 3411 | } |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3412 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3413 | eth_dn = ehea_get_eth_dn(adapter, logical_port_id); |
| 3414 | |
| 3415 | if (!eth_dn) { |
| 3416 | ehea_info("no logical port with id %d found", logical_port_id); |
| 3417 | return -EINVAL; |
| 3418 | } |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3419 | |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3420 | if (ehea_add_adapter_mr(adapter)) { |
| 3421 | ehea_error("creating MR failed"); |
| 3422 | return -EIO; |
| 3423 | } |
| 3424 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3425 | port = ehea_setup_single_port(adapter, logical_port_id, eth_dn); |
| 3426 | |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3427 | of_node_put(eth_dn); |
| 3428 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3429 | if (port) { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 3430 | for (i = 0; i < EHEA_MAX_PORTS; i++) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3431 | if (!adapter->port[i]) { |
| 3432 | adapter->port[i] = port; |
| 3433 | break; |
| 3434 | } |
| 3435 | |
| 3436 | ehea_info("added %s (logical port id=%d)", port->netdev->name, |
| 3437 | logical_port_id); |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3438 | } else { |
| 3439 | ehea_remove_adapter_mr(adapter); |
Jan-Bernd Themann | e542aa6 | 2007-03-22 17:50:24 +0100 | [diff] [blame] | 3440 | return -EIO; |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3441 | } |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3442 | |
| 3443 | return (ssize_t) count; |
| 3444 | } |
| 3445 | |
| 3446 | static ssize_t ehea_remove_port(struct device *dev, |
| 3447 | struct device_attribute *attr, |
| 3448 | const char *buf, size_t count) |
| 3449 | { |
Greg Kroah-Hartman | c7ae011 | 2009-05-04 21:33:19 -0700 | [diff] [blame] | 3450 | struct ehea_adapter *adapter = dev_get_drvdata(dev); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3451 | struct ehea_port *port; |
| 3452 | int i; |
| 3453 | u32 logical_port_id; |
| 3454 | |
Jan-Bernd Themann | a8e34fd | 2007-08-22 16:20:58 +0200 | [diff] [blame] | 3455 | sscanf(buf, "%d", &logical_port_id); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3456 | |
| 3457 | port = ehea_get_port(adapter, logical_port_id); |
| 3458 | |
| 3459 | if (port) { |
| 3460 | ehea_info("removed %s (logical port id=%d)", port->netdev->name, |
| 3461 | logical_port_id); |
| 3462 | |
| 3463 | ehea_shutdown_single_port(port); |
| 3464 | |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 3465 | for (i = 0; i < EHEA_MAX_PORTS; i++) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3466 | if (adapter->port[i] == port) { |
| 3467 | adapter->port[i] = NULL; |
| 3468 | break; |
| 3469 | } |
| 3470 | } else { |
| 3471 | ehea_error("removing port with logical port id=%d failed. port " |
| 3472 | "not configured.", logical_port_id); |
| 3473 | return -EINVAL; |
| 3474 | } |
| 3475 | |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3476 | ehea_remove_adapter_mr(adapter); |
| 3477 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3478 | return (ssize_t) count; |
| 3479 | } |
| 3480 | |
| 3481 | static DEVICE_ATTR(probe_port, S_IWUSR, NULL, ehea_probe_port); |
| 3482 | static DEVICE_ATTR(remove_port, S_IWUSR, NULL, ehea_remove_port); |
| 3483 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 3484 | int ehea_create_device_sysfs(struct platform_device *dev) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3485 | { |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3486 | int ret = device_create_file(&dev->dev, &dev_attr_probe_port); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3487 | if (ret) |
| 3488 | goto out; |
| 3489 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3490 | ret = device_create_file(&dev->dev, &dev_attr_remove_port); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3491 | out: |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3492 | return ret; |
| 3493 | } |
| 3494 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 3495 | void ehea_remove_device_sysfs(struct platform_device *dev) |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3496 | { |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3497 | device_remove_file(&dev->dev, &dev_attr_probe_port); |
| 3498 | device_remove_file(&dev->dev, &dev_attr_remove_port); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3499 | } |
| 3500 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 3501 | static int __devinit ehea_probe_adapter(struct platform_device *dev, |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3502 | const struct of_device_id *id) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3503 | { |
| 3504 | struct ehea_adapter *adapter; |
Stephen Rothwell | 9f9a3b8 | 2007-05-01 13:51:32 +1000 | [diff] [blame] | 3505 | const u64 *adapter_handle; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3506 | int ret; |
| 3507 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3508 | if (!dev || !dev->dev.of_node) { |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3509 | ehea_error("Invalid ibmebus device probed"); |
| 3510 | return -EINVAL; |
| 3511 | } |
| 3512 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3513 | adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); |
| 3514 | if (!adapter) { |
| 3515 | ret = -ENOMEM; |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3516 | dev_err(&dev->dev, "no mem for ehea_adapter\n"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3517 | goto out; |
| 3518 | } |
| 3519 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3520 | list_add(&adapter->list, &adapter_list); |
| 3521 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3522 | adapter->ofdev = dev; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3523 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3524 | adapter_handle = of_get_property(dev->dev.of_node, "ibm,hea-handle", |
Jan-Bernd Themann | d1d25aa | 2007-07-02 13:00:46 +0200 | [diff] [blame] | 3525 | NULL); |
Thomas Klein | 061bf3c | 2007-01-22 12:52:20 +0100 | [diff] [blame] | 3526 | if (adapter_handle) |
| 3527 | adapter->handle = *adapter_handle; |
| 3528 | |
| 3529 | if (!adapter->handle) { |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3530 | dev_err(&dev->dev, "failed getting handle for adapter" |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 3531 | " '%s'\n", dev->dev.of_node->full_name); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3532 | ret = -ENODEV; |
| 3533 | goto out_free_ad; |
| 3534 | } |
| 3535 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3536 | adapter->pd = EHEA_PD_ID; |
| 3537 | |
Greg Kroah-Hartman | c7ae011 | 2009-05-04 21:33:19 -0700 | [diff] [blame] | 3538 | dev_set_drvdata(&dev->dev, adapter); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3539 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3540 | |
| 3541 | /* initialize adapter and ports */ |
| 3542 | /* get adapter properties */ |
| 3543 | ret = ehea_sense_adapter_attr(adapter); |
| 3544 | if (ret) { |
Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 3545 | dev_err(&dev->dev, "sense_adapter_attr failed: %d\n", ret); |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3546 | goto out_free_ad; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3547 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3548 | |
| 3549 | adapter->neq = ehea_create_eq(adapter, |
| 3550 | EHEA_NEQ, EHEA_MAX_ENTRIES_EQ, 1); |
| 3551 | if (!adapter->neq) { |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3552 | ret = -EIO; |
Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 3553 | dev_err(&dev->dev, "NEQ creation failed\n"); |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3554 | goto out_free_ad; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3555 | } |
| 3556 | |
| 3557 | tasklet_init(&adapter->neq_tasklet, ehea_neq_tasklet, |
| 3558 | (unsigned long)adapter); |
| 3559 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3560 | ret = ibmebus_request_irq(adapter->neq->attr.ist1, |
Thomas Gleixner | 38515e9 | 2007-02-14 00:33:16 -0800 | [diff] [blame] | 3561 | ehea_interrupt_neq, IRQF_DISABLED, |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3562 | "ehea_neq", adapter); |
| 3563 | if (ret) { |
Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 3564 | dev_err(&dev->dev, "requesting NEQ IRQ failed\n"); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3565 | goto out_kill_eq; |
| 3566 | } |
| 3567 | |
Jan-Bernd Themann | 1eef4e0 | 2007-03-22 17:49:42 +0100 | [diff] [blame] | 3568 | ret = ehea_create_device_sysfs(dev); |
| 3569 | if (ret) |
Jan-Bernd Themann | 3bf76b8 | 2007-10-08 16:01:33 +0200 | [diff] [blame] | 3570 | goto out_free_irq; |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3571 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3572 | ret = ehea_setup_ports(adapter); |
| 3573 | if (ret) { |
Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 3574 | dev_err(&dev->dev, "setup_ports failed\n"); |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3575 | goto out_rem_dev_sysfs; |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3576 | } |
| 3577 | |
| 3578 | ret = 0; |
| 3579 | goto out; |
| 3580 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3581 | out_rem_dev_sysfs: |
| 3582 | ehea_remove_device_sysfs(dev); |
| 3583 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3584 | out_free_irq: |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3585 | ibmebus_free_irq(adapter->neq->attr.ist1, adapter); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3586 | |
| 3587 | out_kill_eq: |
| 3588 | ehea_destroy_eq(adapter->neq); |
| 3589 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3590 | out_free_ad: |
Hannes Hering | 51621fb | 2009-02-11 13:47:57 -0800 | [diff] [blame] | 3591 | list_del(&adapter->list); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3592 | kfree(adapter); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3593 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3594 | out: |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3595 | ehea_update_firmware_handles(); |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 3596 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3597 | return ret; |
| 3598 | } |
| 3599 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 3600 | static int __devexit ehea_remove(struct platform_device *dev) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3601 | { |
Greg Kroah-Hartman | c7ae011 | 2009-05-04 21:33:19 -0700 | [diff] [blame] | 3602 | struct ehea_adapter *adapter = dev_get_drvdata(&dev->dev); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3603 | int i; |
| 3604 | |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3605 | for (i = 0; i < EHEA_MAX_PORTS; i++) |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3606 | if (adapter->port[i]) { |
| 3607 | ehea_shutdown_single_port(adapter->port[i]); |
| 3608 | adapter->port[i] = NULL; |
| 3609 | } |
Jan-Bernd Themann | 1acf231 | 2007-02-28 18:34:02 +0100 | [diff] [blame] | 3610 | |
| 3611 | ehea_remove_device_sysfs(dev); |
| 3612 | |
Jan-Bernd Themann | 3bf76b8 | 2007-10-08 16:01:33 +0200 | [diff] [blame] | 3613 | flush_scheduled_work(); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3614 | |
Joachim Fenkes | 6b08f3a | 2007-09-26 19:45:51 +1000 | [diff] [blame] | 3615 | ibmebus_free_irq(adapter->neq->attr.ist1, adapter); |
Thomas Klein | d4150a2 | 2007-01-29 18:44:41 +0100 | [diff] [blame] | 3616 | tasklet_kill(&adapter->neq_tasklet); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3617 | |
| 3618 | ehea_destroy_eq(adapter->neq); |
Thomas Klein | 1211bb6 | 2007-04-26 11:56:43 +0200 | [diff] [blame] | 3619 | ehea_remove_adapter_mr(adapter); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3620 | list_del(&adapter->list); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3621 | kfree(adapter); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3622 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3623 | ehea_update_firmware_handles(); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3624 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3625 | return 0; |
| 3626 | } |
| 3627 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3628 | void ehea_crash_handler(void) |
| 3629 | { |
| 3630 | int i; |
| 3631 | |
| 3632 | if (ehea_fw_handles.arr) |
| 3633 | for (i = 0; i < ehea_fw_handles.num_entries; i++) |
| 3634 | ehea_h_free_resource(ehea_fw_handles.arr[i].adh, |
| 3635 | ehea_fw_handles.arr[i].fwh, |
| 3636 | FORCE_FREE); |
| 3637 | |
| 3638 | if (ehea_bcmc_regs.arr) |
| 3639 | for (i = 0; i < ehea_bcmc_regs.num_entries; i++) |
| 3640 | ehea_h_reg_dereg_bcmc(ehea_bcmc_regs.arr[i].adh, |
| 3641 | ehea_bcmc_regs.arr[i].port_id, |
| 3642 | ehea_bcmc_regs.arr[i].reg_type, |
| 3643 | ehea_bcmc_regs.arr[i].macaddr, |
| 3644 | 0, H_DEREG_BCMC); |
| 3645 | } |
| 3646 | |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3647 | static int ehea_mem_notifier(struct notifier_block *nb, |
| 3648 | unsigned long action, void *data) |
| 3649 | { |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3650 | int ret = NOTIFY_BAD; |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 3651 | struct memory_notify *arg = data; |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3652 | |
Jan-Bernd Themann | 099473c | 2010-06-15 05:35:42 +0000 | [diff] [blame] | 3653 | mutex_lock(&dlpar_mem_lock); |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3654 | |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3655 | switch (action) { |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 3656 | case MEM_CANCEL_OFFLINE: |
| 3657 | ehea_info("memory offlining canceled"); |
| 3658 | /* Readd canceled memory block */ |
| 3659 | case MEM_ONLINE: |
| 3660 | ehea_info("memory is going online"); |
Thomas Klein | 3876732 | 2009-02-20 00:42:01 -0800 | [diff] [blame] | 3661 | set_bit(__EHEA_STOP_XFER, &ehea_driver_flags); |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 3662 | if (ehea_add_sect_bmap(arg->start_pfn, arg->nr_pages)) |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3663 | goto out_unlock; |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 3664 | ehea_rereg_mrs(NULL); |
| 3665 | break; |
| 3666 | case MEM_GOING_OFFLINE: |
| 3667 | ehea_info("memory is going offline"); |
Thomas Klein | 3876732 | 2009-02-20 00:42:01 -0800 | [diff] [blame] | 3668 | set_bit(__EHEA_STOP_XFER, &ehea_driver_flags); |
Hannes Hering | d4f12da | 2008-10-16 11:36:42 +0200 | [diff] [blame] | 3669 | if (ehea_rem_sect_bmap(arg->start_pfn, arg->nr_pages)) |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3670 | goto out_unlock; |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3671 | ehea_rereg_mrs(NULL); |
| 3672 | break; |
| 3673 | default: |
| 3674 | break; |
| 3675 | } |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 3676 | |
| 3677 | ehea_update_firmware_handles(); |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3678 | ret = NOTIFY_OK; |
Jan-Bernd Themann | 52e21b1 | 2009-03-13 13:50:40 -0700 | [diff] [blame] | 3679 | |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3680 | out_unlock: |
| 3681 | mutex_unlock(&dlpar_mem_lock); |
Thomas Klein | a7c561f2 | 2010-04-20 23:11:31 +0000 | [diff] [blame] | 3682 | return ret; |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3683 | } |
| 3684 | |
| 3685 | static struct notifier_block ehea_mem_nb = { |
| 3686 | .notifier_call = ehea_mem_notifier, |
| 3687 | }; |
| 3688 | |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 3689 | static int ehea_reboot_notifier(struct notifier_block *nb, |
| 3690 | unsigned long action, void *unused) |
| 3691 | { |
| 3692 | if (action == SYS_RESTART) { |
| 3693 | ehea_info("Reboot: freeing all eHEA resources"); |
| 3694 | ibmebus_unregister_driver(&ehea_driver); |
| 3695 | } |
| 3696 | return NOTIFY_DONE; |
| 3697 | } |
| 3698 | |
| 3699 | static struct notifier_block ehea_reboot_nb = { |
Doug Maxey | 508d2b5 | 2008-01-31 20:20:49 -0600 | [diff] [blame] | 3700 | .notifier_call = ehea_reboot_notifier, |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 3701 | }; |
| 3702 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3703 | static int check_module_parm(void) |
| 3704 | { |
| 3705 | int ret = 0; |
| 3706 | |
| 3707 | if ((rq1_entries < EHEA_MIN_ENTRIES_QP) || |
| 3708 | (rq1_entries > EHEA_MAX_ENTRIES_RQ1)) { |
| 3709 | ehea_info("Bad parameter: rq1_entries"); |
| 3710 | ret = -EINVAL; |
| 3711 | } |
| 3712 | if ((rq2_entries < EHEA_MIN_ENTRIES_QP) || |
| 3713 | (rq2_entries > EHEA_MAX_ENTRIES_RQ2)) { |
| 3714 | ehea_info("Bad parameter: rq2_entries"); |
| 3715 | ret = -EINVAL; |
| 3716 | } |
| 3717 | if ((rq3_entries < EHEA_MIN_ENTRIES_QP) || |
| 3718 | (rq3_entries > EHEA_MAX_ENTRIES_RQ3)) { |
| 3719 | ehea_info("Bad parameter: rq3_entries"); |
| 3720 | ret = -EINVAL; |
| 3721 | } |
| 3722 | if ((sq_entries < EHEA_MIN_ENTRIES_QP) || |
| 3723 | (sq_entries > EHEA_MAX_ENTRIES_SQ)) { |
| 3724 | ehea_info("Bad parameter: sq_entries"); |
| 3725 | ret = -EINVAL; |
| 3726 | } |
| 3727 | |
| 3728 | return ret; |
| 3729 | } |
| 3730 | |
Jan-Bernd Themann | 4c3ca4d | 2007-07-05 09:26:25 +0200 | [diff] [blame] | 3731 | static ssize_t ehea_show_capabilities(struct device_driver *drv, |
| 3732 | char *buf) |
| 3733 | { |
| 3734 | return sprintf(buf, "%d", EHEA_CAPABILITIES); |
| 3735 | } |
| 3736 | |
| 3737 | static DRIVER_ATTR(capabilities, S_IRUSR | S_IRGRP | S_IROTH, |
| 3738 | ehea_show_capabilities, NULL); |
| 3739 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3740 | int __init ehea_module_init(void) |
| 3741 | { |
| 3742 | int ret; |
| 3743 | |
| 3744 | printk(KERN_INFO "IBM eHEA ethernet device driver (Release %s)\n", |
| 3745 | DRV_VERSION); |
| 3746 | |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3747 | |
| 3748 | INIT_WORK(&ehea_rereg_mr_task, ehea_rereg_mrs); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3749 | memset(&ehea_fw_handles, 0, sizeof(ehea_fw_handles)); |
| 3750 | memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs)); |
| 3751 | |
Daniel Walker | 9f71a56 | 2008-03-28 14:41:26 -0700 | [diff] [blame] | 3752 | mutex_init(&ehea_fw_handles.lock); |
Jan-Bernd Themann | 5c2cec1 | 2008-07-03 15:18:45 +0100 | [diff] [blame] | 3753 | spin_lock_init(&ehea_bcmc_regs.lock); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3754 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3755 | ret = check_module_parm(); |
| 3756 | if (ret) |
| 3757 | goto out; |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3758 | |
| 3759 | ret = ehea_create_busmap(); |
| 3760 | if (ret) |
| 3761 | goto out; |
| 3762 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3763 | ret = register_reboot_notifier(&ehea_reboot_nb); |
| 3764 | if (ret) |
| 3765 | ehea_info("failed registering reboot notifier"); |
| 3766 | |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3767 | ret = register_memory_notifier(&ehea_mem_nb); |
| 3768 | if (ret) |
| 3769 | ehea_info("failed registering memory remove notifier"); |
| 3770 | |
Joe Perches | c061b18 | 2010-08-23 18:20:03 +0000 | [diff] [blame] | 3771 | ret = crash_shutdown_register(ehea_crash_handler); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3772 | if (ret) |
| 3773 | ehea_info("failed registering crash handler"); |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 3774 | |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3775 | ret = ibmebus_register_driver(&ehea_driver); |
Jan-Bernd Themann | 4c3ca4d | 2007-07-05 09:26:25 +0200 | [diff] [blame] | 3776 | if (ret) { |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3777 | ehea_error("failed registering eHEA device driver on ebus"); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3778 | goto out2; |
Jan-Bernd Themann | 4c3ca4d | 2007-07-05 09:26:25 +0200 | [diff] [blame] | 3779 | } |
| 3780 | |
| 3781 | ret = driver_create_file(&ehea_driver.driver, |
| 3782 | &driver_attr_capabilities); |
| 3783 | if (ret) { |
| 3784 | ehea_error("failed to register capabilities attribute, ret=%d", |
| 3785 | ret); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3786 | goto out3; |
Jan-Bernd Themann | 4c3ca4d | 2007-07-05 09:26:25 +0200 | [diff] [blame] | 3787 | } |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3788 | |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3789 | return ret; |
| 3790 | |
| 3791 | out3: |
| 3792 | ibmebus_unregister_driver(&ehea_driver); |
| 3793 | out2: |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3794 | unregister_memory_notifier(&ehea_mem_nb); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3795 | unregister_reboot_notifier(&ehea_reboot_nb); |
Joe Perches | c061b18 | 2010-08-23 18:20:03 +0000 | [diff] [blame] | 3796 | crash_shutdown_unregister(ehea_crash_handler); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3797 | out: |
| 3798 | return ret; |
| 3799 | } |
| 3800 | |
| 3801 | static void __exit ehea_module_exit(void) |
| 3802 | { |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3803 | int ret; |
| 3804 | |
Jan-Bernd Themann | 3bf76b8 | 2007-10-08 16:01:33 +0200 | [diff] [blame] | 3805 | flush_scheduled_work(); |
Jan-Bernd Themann | 4c3ca4d | 2007-07-05 09:26:25 +0200 | [diff] [blame] | 3806 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3807 | ibmebus_unregister_driver(&ehea_driver); |
Jan-Bernd Themann | 2a6f4e4 | 2007-10-26 14:37:28 +0200 | [diff] [blame] | 3808 | unregister_reboot_notifier(&ehea_reboot_nb); |
Joe Perches | c061b18 | 2010-08-23 18:20:03 +0000 | [diff] [blame] | 3809 | ret = crash_shutdown_unregister(ehea_crash_handler); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3810 | if (ret) |
| 3811 | ehea_info("failed unregistering crash handler"); |
Hannes Hering | 48cfb14 | 2008-05-07 14:43:36 +0200 | [diff] [blame] | 3812 | unregister_memory_notifier(&ehea_mem_nb); |
Thomas Klein | 21eee2d | 2008-02-13 16:18:33 +0100 | [diff] [blame] | 3813 | kfree(ehea_fw_handles.arr); |
| 3814 | kfree(ehea_bcmc_regs.arr); |
Thomas Klein | 44c8215 | 2007-07-11 16:32:00 +0200 | [diff] [blame] | 3815 | ehea_destroy_busmap(); |
Jan-Bernd Themann | 7a29108 | 2006-09-13 17:44:31 +0200 | [diff] [blame] | 3816 | } |
| 3817 | |
| 3818 | module_init(ehea_module_init); |
| 3819 | module_exit(ehea_module_exit); |