net: convert print_mac to %pM
[linux-2.6.git] / drivers / infiniband / hw / nes / nes.c
1 /*
2  * Copyright (c) 2006 - 2008 NetEffect, Inc. All rights reserved.
3  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
4  *
5  * This software is available to you under a choice of one of two
6  * licenses.  You may choose to be licensed under the terms of the GNU
7  * General Public License (GPL) Version 2, available from the file
8  * COPYING in the main directory of this source tree, or the
9  * OpenIB.org BSD license below:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      - Redistributions of source code must retain the above
16  *        copyright notice, this list of conditions and the following
17  *        disclaimer.
18  *
19  *      - Redistributions in binary form must reproduce the above
20  *        copyright notice, this list of conditions and the following
21  *        disclaimer in the documentation and/or other materials
22  *        provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
33
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
36 #include <linux/netdevice.h>
37 #include <linux/etherdevice.h>
38 #include <linux/ethtool.h>
39 #include <linux/mii.h>
40 #include <linux/if_vlan.h>
41 #include <linux/crc32.h>
42 #include <linux/in.h>
43 #include <linux/fs.h>
44 #include <linux/init.h>
45 #include <linux/if_arp.h>
46 #include <linux/highmem.h>
47 #include <asm/io.h>
48 #include <asm/irq.h>
49 #include <asm/byteorder.h>
50 #include <rdma/ib_smi.h>
51 #include <rdma/ib_verbs.h>
52 #include <rdma/ib_pack.h>
53 #include <rdma/iw_cm.h>
54
55 #include "nes.h"
56
57 #include <net/netevent.h>
58 #include <net/neighbour.h>
59 #include <linux/route.h>
60 #include <net/ip_fib.h>
61
62 MODULE_AUTHOR("NetEffect");
63 MODULE_DESCRIPTION("NetEffect RNIC Low-level iWARP Driver");
64 MODULE_LICENSE("Dual BSD/GPL");
65 MODULE_VERSION(DRV_VERSION);
66
67 int max_mtu = 9000;
68 int interrupt_mod_interval = 0;
69
70
71 /* Interoperability */
72 int mpa_version = 1;
73 module_param(mpa_version, int, 0644);
74 MODULE_PARM_DESC(mpa_version, "MPA version to be used int MPA Req/Resp (0 or 1)");
75
76 /* Interoperability */
77 int disable_mpa_crc = 0;
78 module_param(disable_mpa_crc, int, 0644);
79 MODULE_PARM_DESC(disable_mpa_crc, "Disable checking of MPA CRC");
80
81 unsigned int send_first = 0;
82 module_param(send_first, int, 0644);
83 MODULE_PARM_DESC(send_first, "Send RDMA Message First on Active Connection");
84
85
86 unsigned int nes_drv_opt = 0;
87 module_param(nes_drv_opt, int, 0644);
88 MODULE_PARM_DESC(nes_drv_opt, "Driver option parameters");
89
90 unsigned int nes_debug_level = 0;
91 module_param_named(debug_level, nes_debug_level, uint, 0644);
92 MODULE_PARM_DESC(debug_level, "Enable debug output level");
93
94 unsigned int wqm_quanta = 0x10000;
95 module_param(wqm_quanta, int, 0644);
96 MODULE_PARM_DESC(wqm_quanta, "WQM quanta");
97
98 LIST_HEAD(nes_adapter_list);
99 static LIST_HEAD(nes_dev_list);
100
101 atomic_t qps_destroyed;
102
103 static unsigned int ee_flsh_adapter;
104 static unsigned int sysfs_nonidx_addr;
105 static unsigned int sysfs_idx_addr;
106
107 static struct pci_device_id nes_pci_table[] = {
108         {PCI_VENDOR_ID_NETEFFECT, PCI_DEVICE_ID_NETEFFECT_NE020, PCI_ANY_ID, PCI_ANY_ID},
109         {0}
110 };
111
112 MODULE_DEVICE_TABLE(pci, nes_pci_table);
113
114 static int nes_inetaddr_event(struct notifier_block *, unsigned long, void *);
115 static int nes_net_event(struct notifier_block *, unsigned long, void *);
116 static int nes_notifiers_registered;
117
118
119 static struct notifier_block nes_inetaddr_notifier = {
120         .notifier_call = nes_inetaddr_event
121 };
122
123 static struct notifier_block nes_net_notifier = {
124         .notifier_call = nes_net_event
125 };
126
127
128
129
130 /**
131  * nes_inetaddr_event
132  */
133 static int nes_inetaddr_event(struct notifier_block *notifier,
134                 unsigned long event, void *ptr)
135 {
136         struct in_ifaddr *ifa = ptr;
137         struct net_device *event_netdev = ifa->ifa_dev->dev;
138         struct nes_device *nesdev;
139         struct net_device *netdev;
140         struct nes_vnic *nesvnic;
141         unsigned int addr;
142         unsigned int mask;
143
144         addr = ntohl(ifa->ifa_address);
145         mask = ntohl(ifa->ifa_mask);
146         nes_debug(NES_DBG_NETDEV, "nes_inetaddr_event: ip address " NIPQUAD_FMT
147                   ", netmask " NIPQUAD_FMT ".\n",
148                   HIPQUAD(addr), HIPQUAD(mask));
149         list_for_each_entry(nesdev, &nes_dev_list, list) {
150                 nes_debug(NES_DBG_NETDEV, "Nesdev list entry = 0x%p. (%s)\n",
151                                 nesdev, nesdev->netdev[0]->name);
152                 netdev = nesdev->netdev[0];
153                 nesvnic = netdev_priv(netdev);
154                 if (netdev == event_netdev) {
155                         if (nesvnic->rdma_enabled == 0) {
156                                 nes_debug(NES_DBG_NETDEV, "Returning without processing event for %s since"
157                                                 " RDMA is not enabled.\n",
158                                                 netdev->name);
159                                 return NOTIFY_OK;
160                         }
161                         /* we have ifa->ifa_address/mask here if we need it */
162                         switch (event) {
163                                 case NETDEV_DOWN:
164                                         nes_debug(NES_DBG_NETDEV, "event:DOWN\n");
165                                         nes_write_indexed(nesdev,
166                                                         NES_IDX_DST_IP_ADDR+(0x10*PCI_FUNC(nesdev->pcidev->devfn)), 0);
167
168                                         nes_manage_arp_cache(netdev, netdev->dev_addr,
169                                                         ntohl(nesvnic->local_ipaddr), NES_ARP_DELETE);
170                                         nesvnic->local_ipaddr = 0;
171                                         return NOTIFY_OK;
172                                         break;
173                                 case NETDEV_UP:
174                                         nes_debug(NES_DBG_NETDEV, "event:UP\n");
175
176                                         if (nesvnic->local_ipaddr != 0) {
177                                                 nes_debug(NES_DBG_NETDEV, "Interface already has local_ipaddr\n");
178                                                 return NOTIFY_OK;
179                                         }
180                                         /* Add the address to the IP table */
181                                         nesvnic->local_ipaddr = ifa->ifa_address;
182
183                                         nes_write_indexed(nesdev,
184                                                         NES_IDX_DST_IP_ADDR+(0x10*PCI_FUNC(nesdev->pcidev->devfn)),
185                                                         ntohl(ifa->ifa_address));
186                                         nes_manage_arp_cache(netdev, netdev->dev_addr,
187                                                         ntohl(nesvnic->local_ipaddr), NES_ARP_ADD);
188                                         return NOTIFY_OK;
189                                         break;
190                                 default:
191                                         break;
192                         }
193                 }
194         }
195
196         return NOTIFY_DONE;
197 }
198
199
200 /**
201  * nes_net_event
202  */
203 static int nes_net_event(struct notifier_block *notifier,
204                 unsigned long event, void *ptr)
205 {
206         struct neighbour *neigh = ptr;
207         struct nes_device *nesdev;
208         struct net_device *netdev;
209         struct nes_vnic *nesvnic;
210
211         switch (event) {
212                 case NETEVENT_NEIGH_UPDATE:
213                         list_for_each_entry(nesdev, &nes_dev_list, list) {
214                                 /* nes_debug(NES_DBG_NETDEV, "Nesdev list entry = 0x%p.\n", nesdev); */
215                                 netdev = nesdev->netdev[0];
216                                 nesvnic = netdev_priv(netdev);
217                                 if (netdev == neigh->dev) {
218                                         if (nesvnic->rdma_enabled == 0) {
219                                                 nes_debug(NES_DBG_NETDEV, "Skipping device %s since no RDMA\n",
220                                                                 netdev->name);
221                                         } else {
222                                                 if (neigh->nud_state & NUD_VALID) {
223                                                         nes_manage_arp_cache(neigh->dev, neigh->ha,
224                                                                         ntohl(*(__be32 *)neigh->primary_key), NES_ARP_ADD);
225                                                 } else {
226                                                         nes_manage_arp_cache(neigh->dev, neigh->ha,
227                                                                         ntohl(*(__be32 *)neigh->primary_key), NES_ARP_DELETE);
228                                                 }
229                                         }
230                                         return NOTIFY_OK;
231                                 }
232                         }
233                         break;
234                 default:
235                         nes_debug(NES_DBG_NETDEV, "NETEVENT_ %lu undefined\n", event);
236                         break;
237         }
238
239         return NOTIFY_DONE;
240 }
241
242
243 /**
244  * nes_add_ref
245  */
246 void nes_add_ref(struct ib_qp *ibqp)
247 {
248         struct nes_qp *nesqp;
249
250         nesqp = to_nesqp(ibqp);
251         nes_debug(NES_DBG_QP, "Bumping refcount for QP%u.  Pre-inc value = %u\n",
252                         ibqp->qp_num, atomic_read(&nesqp->refcount));
253         atomic_inc(&nesqp->refcount);
254 }
255
256 static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_request *cqp_request)
257 {
258         unsigned long flags;
259         struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
260         struct nes_adapter *nesadapter = nesdev->nesadapter;
261         u32 qp_id;
262
263         atomic_inc(&qps_destroyed);
264
265         /* Free the control structures */
266
267         qp_id = nesqp->hwqp.qp_id;
268         if (nesqp->pbl_vbase) {
269                 pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size,
270                                 nesqp->hwqp.q2_vbase, nesqp->hwqp.q2_pbase);
271                 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
272                 nesadapter->free_256pbl++;
273                 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
274                 pci_free_consistent(nesdev->pcidev, 256, nesqp->pbl_vbase, nesqp->pbl_pbase);
275                 nesqp->pbl_vbase = NULL;
276
277         } else {
278                 pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size,
279                                 nesqp->hwqp.sq_vbase, nesqp->hwqp.sq_pbase);
280         }
281         nes_free_resource(nesadapter, nesadapter->allocated_qps, nesqp->hwqp.qp_id);
282
283         nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL;
284         kfree(nesqp->allocated_buffer);
285
286 }
287
288 /**
289  * nes_rem_ref
290  */
291 void nes_rem_ref(struct ib_qp *ibqp)
292 {
293         u64 u64temp;
294         struct nes_qp *nesqp;
295         struct nes_vnic *nesvnic = to_nesvnic(ibqp->device);
296         struct nes_device *nesdev = nesvnic->nesdev;
297         struct nes_hw_cqp_wqe *cqp_wqe;
298         struct nes_cqp_request *cqp_request;
299         u32 opcode;
300
301         nesqp = to_nesqp(ibqp);
302
303         if (atomic_read(&nesqp->refcount) == 0) {
304                 printk(KERN_INFO PFX "%s: Reference count already 0 for QP%d, last aeq = 0x%04X.\n",
305                                 __func__, ibqp->qp_num, nesqp->last_aeq);
306                 BUG();
307         }
308
309         if (atomic_dec_and_test(&nesqp->refcount)) {
310                 /* Destroy the QP */
311                 cqp_request = nes_get_cqp_request(nesdev);
312                 if (cqp_request == NULL) {
313                         nes_debug(NES_DBG_QP, "Failed to get a cqp_request.\n");
314                         return;
315                 }
316                 cqp_request->waiting = 0;
317                 cqp_request->callback = 1;
318                 cqp_request->cqp_callback = nes_cqp_rem_ref_callback;
319                 cqp_request->cqp_callback_pointer = nesqp;
320                 cqp_wqe = &cqp_request->cqp_wqe;
321
322                 nes_fill_init_cqp_wqe(cqp_wqe, nesdev);
323                 opcode = NES_CQP_DESTROY_QP | NES_CQP_QP_TYPE_IWARP;
324
325                 if (nesqp->hte_added) {
326                         opcode  |= NES_CQP_QP_DEL_HTE;
327                         nesqp->hte_added = 0;
328                 }
329                 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX, opcode);
330                 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, nesqp->hwqp.qp_id);
331                 u64temp = (u64)nesqp->nesqp_context_pbase;
332                 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp);
333                 nes_post_cqp_request(nesdev, cqp_request);
334         }
335 }
336
337
338 /**
339  * nes_get_qp
340  */
341 struct ib_qp *nes_get_qp(struct ib_device *device, int qpn)
342 {
343         struct nes_vnic *nesvnic = to_nesvnic(device);
344         struct nes_device *nesdev = nesvnic->nesdev;
345         struct nes_adapter *nesadapter = nesdev->nesadapter;
346
347         if ((qpn < NES_FIRST_QPN) || (qpn >= (NES_FIRST_QPN + nesadapter->max_qp)))
348                 return NULL;
349
350         return &nesadapter->qp_table[qpn - NES_FIRST_QPN]->ibqp;
351 }
352
353
354 /**
355  * nes_print_macaddr
356  */
357 static void nes_print_macaddr(struct net_device *netdev)
358 {
359         nes_debug(NES_DBG_INIT, "%s: %pM, IRQ %u\n",
360                   netdev->name, netdev->dev_addr, netdev->irq);
361 }
362
363 /**
364  * nes_interrupt - handle interrupts
365  */
366 static irqreturn_t nes_interrupt(int irq, void *dev_id)
367 {
368         struct nes_device *nesdev = (struct nes_device *)dev_id;
369         int handled = 0;
370         u32 int_mask;
371         u32 int_req;
372         u32 int_stat;
373         u32 intf_int_stat;
374         u32 timer_stat;
375
376         if (nesdev->msi_enabled) {
377                 /* No need to read the interrupt pending register if msi is enabled */
378                 handled = 1;
379         } else {
380                 if (unlikely(nesdev->nesadapter->hw_rev == NE020_REV)) {
381                         /* Master interrupt enable provides synchronization for kicking off bottom half
382                           when interrupt sharing is going on */
383                         int_mask = nes_read32(nesdev->regs + NES_INT_MASK);
384                         if (int_mask & 0x80000000) {
385                                 /* Check interrupt status to see if this might be ours */
386                                 int_stat = nes_read32(nesdev->regs + NES_INT_STAT);
387                                 int_req = nesdev->int_req;
388                                 if (int_stat&int_req) {
389                                         /* if interesting CEQ or AEQ is pending, claim the interrupt */
390                                         if ((int_stat&int_req) & (~(NES_INT_TIMER|NES_INT_INTF))) {
391                                                 handled = 1;
392                                         } else {
393                                                 if (((int_stat & int_req) & NES_INT_TIMER) == NES_INT_TIMER) {
394                                                         /* Timer might be running but might be for another function */
395                                                         timer_stat = nes_read32(nesdev->regs + NES_TIMER_STAT);
396                                                         if ((timer_stat & nesdev->timer_int_req) != 0) {
397                                                                 handled = 1;
398                                                         }
399                                                 }
400                                                 if ((((int_stat & int_req) & NES_INT_INTF) == NES_INT_INTF) &&
401                                                                 (handled == 0)) {
402                                                         intf_int_stat = nes_read32(nesdev->regs+NES_INTF_INT_STAT);
403                                                         if ((intf_int_stat & nesdev->intf_int_req) != 0) {
404                                                                 handled = 1;
405                                                         }
406                                                 }
407                                         }
408                                         if (handled) {
409                                                 nes_write32(nesdev->regs+NES_INT_MASK, int_mask & (~0x80000000));
410                                                 int_mask = nes_read32(nesdev->regs+NES_INT_MASK);
411                                                 /* Save off the status to save an additional read */
412                                                 nesdev->int_stat = int_stat;
413                                                 nesdev->napi_isr_ran = 1;
414                                         }
415                                 }
416                         }
417                 } else {
418                         handled = nes_read32(nesdev->regs+NES_INT_PENDING);
419                 }
420         }
421
422         if (handled) {
423
424                 if (nes_napi_isr(nesdev) == 0) {
425                         tasklet_schedule(&nesdev->dpc_tasklet);
426
427                 }
428                 return IRQ_HANDLED;
429         } else {
430                 return IRQ_NONE;
431         }
432 }
433
434
435 /**
436  * nes_probe - Device initialization
437  */
438 static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
439 {
440         struct net_device *netdev = NULL;
441         struct nes_device *nesdev = NULL;
442         int ret = 0;
443         struct nes_vnic *nesvnic = NULL;
444         void __iomem *mmio_regs = NULL;
445         u8 hw_rev;
446
447         assert(pcidev != NULL);
448         assert(ent != NULL);
449
450         printk(KERN_INFO PFX "NetEffect RNIC driver v%s loading. (%s)\n",
451                         DRV_VERSION, pci_name(pcidev));
452
453         ret = pci_enable_device(pcidev);
454         if (ret) {
455                 printk(KERN_ERR PFX "Unable to enable PCI device. (%s)\n", pci_name(pcidev));
456                 goto bail0;
457         }
458
459         nes_debug(NES_DBG_INIT, "BAR0 (@0x%08lX) size = 0x%lX bytes\n",
460                         (long unsigned int)pci_resource_start(pcidev, BAR_0),
461                         (long unsigned int)pci_resource_len(pcidev, BAR_0));
462         nes_debug(NES_DBG_INIT, "BAR1 (@0x%08lX) size = 0x%lX bytes\n",
463                         (long unsigned int)pci_resource_start(pcidev, BAR_1),
464                         (long unsigned int)pci_resource_len(pcidev, BAR_1));
465
466         /* Make sure PCI base addr are MMIO */
467         if (!(pci_resource_flags(pcidev, BAR_0) & IORESOURCE_MEM) ||
468                         !(pci_resource_flags(pcidev, BAR_1) & IORESOURCE_MEM)) {
469                 printk(KERN_ERR PFX "PCI regions not an MMIO resource\n");
470                 ret = -ENODEV;
471                 goto bail1;
472         }
473
474         /* Reserve PCI I/O and memory resources */
475         ret = pci_request_regions(pcidev, DRV_NAME);
476         if (ret) {
477                 printk(KERN_ERR PFX "Unable to request regions. (%s)\n", pci_name(pcidev));
478                 goto bail1;
479         }
480
481         if ((sizeof(dma_addr_t) > 4)) {
482                 ret = pci_set_dma_mask(pcidev, DMA_64BIT_MASK);
483                 if (ret < 0) {
484                         printk(KERN_ERR PFX "64b DMA mask configuration failed\n");
485                         goto bail2;
486                 }
487                 ret = pci_set_consistent_dma_mask(pcidev, DMA_64BIT_MASK);
488                 if (ret) {
489                         printk(KERN_ERR PFX "64b DMA consistent mask configuration failed\n");
490                         goto bail2;
491                 }
492         } else {
493                 ret = pci_set_dma_mask(pcidev, DMA_32BIT_MASK);
494                 if (ret < 0) {
495                         printk(KERN_ERR PFX "32b DMA mask configuration failed\n");
496                         goto bail2;
497                 }
498                 ret = pci_set_consistent_dma_mask(pcidev, DMA_32BIT_MASK);
499                 if (ret) {
500                         printk(KERN_ERR PFX "32b DMA consistent mask configuration failed\n");
501                         goto bail2;
502                 }
503         }
504
505         pci_set_master(pcidev);
506
507         /* Allocate hardware structure */
508         nesdev = kzalloc(sizeof(struct nes_device), GFP_KERNEL);
509         if (!nesdev) {
510                 printk(KERN_ERR PFX "%s: Unable to alloc hardware struct\n", pci_name(pcidev));
511                 ret = -ENOMEM;
512                 goto bail2;
513         }
514
515         nes_debug(NES_DBG_INIT, "Allocated nes device at %p\n", nesdev);
516         nesdev->pcidev = pcidev;
517         pci_set_drvdata(pcidev, nesdev);
518
519         pci_read_config_byte(pcidev, 0x0008, &hw_rev);
520         nes_debug(NES_DBG_INIT, "hw_rev=%u\n", hw_rev);
521
522         spin_lock_init(&nesdev->indexed_regs_lock);
523
524         /* Remap the PCI registers in adapter BAR0 to kernel VA space */
525         mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0), sizeof(mmio_regs));
526         if (mmio_regs == NULL) {
527                 printk(KERN_ERR PFX "Unable to remap BAR0\n");
528                 ret = -EIO;
529                 goto bail3;
530         }
531         nesdev->regs = mmio_regs;
532         nesdev->index_reg = 0x50 + (PCI_FUNC(pcidev->devfn)*8) + mmio_regs;
533
534         /* Ensure interrupts are disabled */
535         nes_write32(nesdev->regs+NES_INT_MASK, 0x7fffffff);
536
537         if (nes_drv_opt & NES_DRV_OPT_ENABLE_MSI) {
538                 if (!pci_enable_msi(nesdev->pcidev)) {
539                         nesdev->msi_enabled = 1;
540                         nes_debug(NES_DBG_INIT, "MSI is enabled for device %s\n",
541                                         pci_name(pcidev));
542                 } else {
543                         nes_debug(NES_DBG_INIT, "MSI is disabled by linux for device %s\n",
544                                         pci_name(pcidev));
545                 }
546         } else {
547                 nes_debug(NES_DBG_INIT, "MSI not requested due to driver options for device %s\n",
548                                 pci_name(pcidev));
549         }
550
551         nesdev->csr_start = pci_resource_start(nesdev->pcidev, BAR_0);
552         nesdev->doorbell_region = pci_resource_start(nesdev->pcidev, BAR_1);
553
554         /* Init the adapter */
555         nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev);
556         if (!nesdev->nesadapter) {
557                 printk(KERN_ERR PFX "Unable to initialize adapter.\n");
558                 ret = -ENOMEM;
559                 goto bail5;
560         }
561         nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
562         nesdev->nesadapter->wqm_quanta = wqm_quanta;
563
564         /* nesdev->base_doorbell_index =
565                         nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */
566         nesdev->base_doorbell_index = 1;
567         nesdev->doorbell_start = nesdev->nesadapter->doorbell_start;
568         if (nesdev->nesadapter->phy_type[0] == NES_PHY_TYPE_PUMA_1G) {
569                 switch (PCI_FUNC(nesdev->pcidev->devfn) %
570                         nesdev->nesadapter->port_count) {
571                 case 1:
572                         nesdev->mac_index = 2;
573                         break;
574                 case 2:
575                         nesdev->mac_index = 1;
576                         break;
577                 case 3:
578                         nesdev->mac_index = 3;
579                         break;
580                 case 0:
581                 default:
582                         nesdev->mac_index = 0;
583                 }
584         } else {
585                 nesdev->mac_index = PCI_FUNC(nesdev->pcidev->devfn) %
586                                                 nesdev->nesadapter->port_count;
587         }
588
589         tasklet_init(&nesdev->dpc_tasklet, nes_dpc, (unsigned long)nesdev);
590
591         /* bring up the Control QP */
592         if (nes_init_cqp(nesdev)) {
593                 ret = -ENODEV;
594                 goto bail6;
595         }
596
597         /* Arm the CCQ */
598         nes_write32(nesdev->regs+NES_CQE_ALLOC, NES_CQE_ALLOC_NOTIFY_NEXT |
599                         PCI_FUNC(nesdev->pcidev->devfn));
600         nes_read32(nesdev->regs+NES_CQE_ALLOC);
601
602         /* Enable the interrupts */
603         nesdev->int_req = (0x101 << PCI_FUNC(nesdev->pcidev->devfn)) |
604                         (1 << (PCI_FUNC(nesdev->pcidev->devfn)+16));
605         if (PCI_FUNC(nesdev->pcidev->devfn) < 4) {
606                 nesdev->int_req |= (1 << (PCI_FUNC(nesdev->mac_index)+24));
607         }
608
609         /* TODO: This really should be the first driver to load, not function 0 */
610         if (PCI_FUNC(nesdev->pcidev->devfn) == 0) {
611                 /* pick up PCI and critical errors if the first driver to load */
612                 nesdev->intf_int_req = NES_INTF_INT_PCIERR | NES_INTF_INT_CRITERR;
613                 nesdev->int_req |= NES_INT_INTF;
614         } else {
615                 nesdev->intf_int_req = 0;
616         }
617         nesdev->intf_int_req |= (1 << (PCI_FUNC(nesdev->pcidev->devfn)+16));
618         nes_write_indexed(nesdev, NES_IDX_DEBUG_ERROR_MASKS0, 0);
619         nes_write_indexed(nesdev, NES_IDX_DEBUG_ERROR_MASKS1, 0);
620         nes_write_indexed(nesdev, NES_IDX_DEBUG_ERROR_MASKS2, 0x00001265);
621         nes_write_indexed(nesdev, NES_IDX_DEBUG_ERROR_MASKS4, 0x18021804);
622
623         nes_write_indexed(nesdev, NES_IDX_DEBUG_ERROR_MASKS3, 0x17801790);
624
625         /* deal with both periodic and one_shot */
626         nesdev->timer_int_req = 0x101 << PCI_FUNC(nesdev->pcidev->devfn);
627         nesdev->nesadapter->timer_int_req |= nesdev->timer_int_req;
628         nes_debug(NES_DBG_INIT, "setting int_req for function %u, nesdev = 0x%04X, adapter = 0x%04X\n",
629                         PCI_FUNC(nesdev->pcidev->devfn),
630                         nesdev->timer_int_req, nesdev->nesadapter->timer_int_req);
631
632         nes_write32(nesdev->regs+NES_INTF_INT_MASK, ~(nesdev->intf_int_req));
633
634         list_add_tail(&nesdev->list, &nes_dev_list);
635
636         /* Request an interrupt line for the driver */
637         ret = request_irq(pcidev->irq, nes_interrupt, IRQF_SHARED, DRV_NAME, nesdev);
638         if (ret) {
639                 printk(KERN_ERR PFX "%s: requested IRQ %u is busy\n",
640                                 pci_name(pcidev), pcidev->irq);
641                 goto bail65;
642         }
643
644         nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
645
646         if (nes_notifiers_registered == 0) {
647                 register_inetaddr_notifier(&nes_inetaddr_notifier);
648                 register_netevent_notifier(&nes_net_notifier);
649         }
650         nes_notifiers_registered++;
651
652         /* Initialize network devices */
653                 if ((netdev = nes_netdev_init(nesdev, mmio_regs)) == NULL) {
654                         goto bail7;
655                 }
656
657                 /* Register network device */
658                 ret = register_netdev(netdev);
659                 if (ret) {
660                         printk(KERN_ERR PFX "Unable to register netdev, ret = %d\n", ret);
661                         nes_netdev_destroy(netdev);
662                         goto bail7;
663                 }
664
665                 nes_print_macaddr(netdev);
666                 /* create a CM core for this netdev */
667                 nesvnic = netdev_priv(netdev);
668
669                 nesdev->netdev_count++;
670                 nesdev->nesadapter->netdev_count++;
671
672
673         printk(KERN_ERR PFX "%s: NetEffect RNIC driver successfully loaded.\n",
674                         pci_name(pcidev));
675         return 0;
676
677         bail7:
678         printk(KERN_ERR PFX "bail7\n");
679         while (nesdev->netdev_count > 0) {
680                 nesdev->netdev_count--;
681                 nesdev->nesadapter->netdev_count--;
682
683                 unregister_netdev(nesdev->netdev[nesdev->netdev_count]);
684                 nes_netdev_destroy(nesdev->netdev[nesdev->netdev_count]);
685         }
686
687         nes_debug(NES_DBG_INIT, "netdev_count=%d, nesadapter->netdev_count=%d\n",
688                         nesdev->netdev_count, nesdev->nesadapter->netdev_count);
689
690         nes_notifiers_registered--;
691         if (nes_notifiers_registered == 0) {
692                 unregister_netevent_notifier(&nes_net_notifier);
693                 unregister_inetaddr_notifier(&nes_inetaddr_notifier);
694         }
695
696         list_del(&nesdev->list);
697         nes_destroy_cqp(nesdev);
698
699         bail65:
700         printk(KERN_ERR PFX "bail65\n");
701         free_irq(pcidev->irq, nesdev);
702         if (nesdev->msi_enabled) {
703                 pci_disable_msi(pcidev);
704         }
705         bail6:
706         printk(KERN_ERR PFX "bail6\n");
707         tasklet_kill(&nesdev->dpc_tasklet);
708         /* Deallocate the Adapter Structure */
709         nes_destroy_adapter(nesdev->nesadapter);
710
711         bail5:
712         printk(KERN_ERR PFX "bail5\n");
713         iounmap(nesdev->regs);
714
715         bail3:
716         printk(KERN_ERR PFX "bail3\n");
717         kfree(nesdev);
718
719         bail2:
720         pci_release_regions(pcidev);
721
722         bail1:
723         pci_disable_device(pcidev);
724
725         bail0:
726         return ret;
727 }
728
729
730 /**
731  * nes_remove - unload from kernel
732  */
733 static void __devexit nes_remove(struct pci_dev *pcidev)
734 {
735         struct nes_device *nesdev = pci_get_drvdata(pcidev);
736         struct net_device *netdev;
737         int netdev_index = 0;
738
739                 if (nesdev->netdev_count) {
740                         netdev = nesdev->netdev[netdev_index];
741                         if (netdev) {
742                                 netif_stop_queue(netdev);
743                                 unregister_netdev(netdev);
744                                 nes_netdev_destroy(netdev);
745
746                                 nesdev->netdev[netdev_index] = NULL;
747                                 nesdev->netdev_count--;
748                                 nesdev->nesadapter->netdev_count--;
749                         }
750                 }
751
752         nes_notifiers_registered--;
753         if (nes_notifiers_registered == 0) {
754                 unregister_netevent_notifier(&nes_net_notifier);
755                 unregister_inetaddr_notifier(&nes_inetaddr_notifier);
756         }
757
758         list_del(&nesdev->list);
759         nes_destroy_cqp(nesdev);
760
761         free_irq(pcidev->irq, nesdev);
762         tasklet_kill(&nesdev->dpc_tasklet);
763
764         /* Deallocate the Adapter Structure */
765         nes_destroy_adapter(nesdev->nesadapter);
766
767         if (nesdev->msi_enabled) {
768                 pci_disable_msi(pcidev);
769         }
770
771         iounmap(nesdev->regs);
772         kfree(nesdev);
773
774         /* nes_debug(NES_DBG_SHUTDOWN, "calling pci_release_regions.\n"); */
775         pci_release_regions(pcidev);
776         pci_disable_device(pcidev);
777         pci_set_drvdata(pcidev, NULL);
778 }
779
780
781 static struct pci_driver nes_pci_driver = {
782         .name = DRV_NAME,
783         .id_table = nes_pci_table,
784         .probe = nes_probe,
785         .remove = __devexit_p(nes_remove),
786 };
787
788 static ssize_t nes_show_adapter(struct device_driver *ddp, char *buf)
789 {
790         unsigned int  devfn = 0xffffffff;
791         unsigned char bus_number = 0xff;
792         unsigned int  i = 0;
793         struct nes_device *nesdev;
794
795         list_for_each_entry(nesdev, &nes_dev_list, list) {
796                 if (i == ee_flsh_adapter) {
797                         devfn = nesdev->pcidev->devfn;
798                         bus_number = nesdev->pcidev->bus->number;
799                         break;
800                 }
801                 i++;
802         }
803
804         return snprintf(buf, PAGE_SIZE, "%x:%x\n", bus_number, devfn);
805 }
806
807 static ssize_t nes_store_adapter(struct device_driver *ddp,
808         const char *buf, size_t count)
809 {
810         char *p = (char *)buf;
811
812         ee_flsh_adapter = simple_strtoul(p, &p, 10);
813         return strnlen(buf, count);
814 }
815
816 static ssize_t nes_show_ee_cmd(struct device_driver *ddp, char *buf)
817 {
818         u32 eeprom_cmd = 0xdead;
819         u32 i = 0;
820         struct nes_device *nesdev;
821
822         list_for_each_entry(nesdev, &nes_dev_list, list) {
823                 if (i == ee_flsh_adapter) {
824                         eeprom_cmd = nes_read32(nesdev->regs + NES_EEPROM_COMMAND);
825                         break;
826                 }
827                 i++;
828         }
829         return snprintf(buf, PAGE_SIZE, "0x%x\n", eeprom_cmd);
830 }
831
832 static ssize_t nes_store_ee_cmd(struct device_driver *ddp,
833         const char *buf, size_t count)
834 {
835         char *p = (char *)buf;
836         u32 val;
837         u32 i = 0;
838         struct nes_device *nesdev;
839
840         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
841                 val = simple_strtoul(p, &p, 16);
842                 list_for_each_entry(nesdev, &nes_dev_list, list) {
843                         if (i == ee_flsh_adapter) {
844                                 nes_write32(nesdev->regs + NES_EEPROM_COMMAND, val);
845                                 break;
846                         }
847                         i++;
848                 }
849         }
850         return strnlen(buf, count);
851 }
852
853 static ssize_t nes_show_ee_data(struct device_driver *ddp, char *buf)
854 {
855         u32 eeprom_data = 0xdead;
856         u32 i = 0;
857         struct nes_device *nesdev;
858
859         list_for_each_entry(nesdev, &nes_dev_list, list) {
860                 if (i == ee_flsh_adapter) {
861                         eeprom_data = nes_read32(nesdev->regs + NES_EEPROM_DATA);
862                         break;
863                 }
864                 i++;
865         }
866
867         return  snprintf(buf, PAGE_SIZE, "0x%x\n", eeprom_data);
868 }
869
870 static ssize_t nes_store_ee_data(struct device_driver *ddp,
871         const char *buf, size_t count)
872 {
873         char *p = (char *)buf;
874         u32 val;
875         u32 i = 0;
876         struct nes_device *nesdev;
877
878         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
879                 val = simple_strtoul(p, &p, 16);
880                 list_for_each_entry(nesdev, &nes_dev_list, list) {
881                         if (i == ee_flsh_adapter) {
882                                 nes_write32(nesdev->regs + NES_EEPROM_DATA, val);
883                                 break;
884                         }
885                         i++;
886                 }
887         }
888         return strnlen(buf, count);
889 }
890
891 static ssize_t nes_show_flash_cmd(struct device_driver *ddp, char *buf)
892 {
893         u32 flash_cmd = 0xdead;
894         u32 i = 0;
895         struct nes_device *nesdev;
896
897         list_for_each_entry(nesdev, &nes_dev_list, list) {
898                 if (i == ee_flsh_adapter) {
899                         flash_cmd = nes_read32(nesdev->regs + NES_FLASH_COMMAND);
900                         break;
901                 }
902                 i++;
903         }
904
905         return  snprintf(buf, PAGE_SIZE, "0x%x\n", flash_cmd);
906 }
907
908 static ssize_t nes_store_flash_cmd(struct device_driver *ddp,
909         const char *buf, size_t count)
910 {
911         char *p = (char *)buf;
912         u32 val;
913         u32 i = 0;
914         struct nes_device *nesdev;
915
916         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
917                 val = simple_strtoul(p, &p, 16);
918                 list_for_each_entry(nesdev, &nes_dev_list, list) {
919                         if (i == ee_flsh_adapter) {
920                                 nes_write32(nesdev->regs + NES_FLASH_COMMAND, val);
921                                 break;
922                         }
923                         i++;
924                 }
925         }
926         return strnlen(buf, count);
927 }
928
929 static ssize_t nes_show_flash_data(struct device_driver *ddp, char *buf)
930 {
931         u32 flash_data = 0xdead;
932         u32 i = 0;
933         struct nes_device *nesdev;
934
935         list_for_each_entry(nesdev, &nes_dev_list, list) {
936                 if (i == ee_flsh_adapter) {
937                         flash_data = nes_read32(nesdev->regs + NES_FLASH_DATA);
938                         break;
939                 }
940                 i++;
941         }
942
943         return  snprintf(buf, PAGE_SIZE, "0x%x\n", flash_data);
944 }
945
946 static ssize_t nes_store_flash_data(struct device_driver *ddp,
947         const char *buf, size_t count)
948 {
949         char *p = (char *)buf;
950         u32 val;
951         u32 i = 0;
952         struct nes_device *nesdev;
953
954         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
955                 val = simple_strtoul(p, &p, 16);
956                 list_for_each_entry(nesdev, &nes_dev_list, list) {
957                         if (i == ee_flsh_adapter) {
958                                 nes_write32(nesdev->regs + NES_FLASH_DATA, val);
959                                 break;
960                         }
961                         i++;
962                 }
963         }
964         return strnlen(buf, count);
965 }
966
967 static ssize_t nes_show_nonidx_addr(struct device_driver *ddp, char *buf)
968 {
969         return  snprintf(buf, PAGE_SIZE, "0x%x\n", sysfs_nonidx_addr);
970 }
971
972 static ssize_t nes_store_nonidx_addr(struct device_driver *ddp,
973         const char *buf, size_t count)
974 {
975         char *p = (char *)buf;
976
977         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X')
978                 sysfs_nonidx_addr = simple_strtoul(p, &p, 16);
979
980         return strnlen(buf, count);
981 }
982
983 static ssize_t nes_show_nonidx_data(struct device_driver *ddp, char *buf)
984 {
985         u32 nonidx_data = 0xdead;
986         u32 i = 0;
987         struct nes_device *nesdev;
988
989         list_for_each_entry(nesdev, &nes_dev_list, list) {
990                 if (i == ee_flsh_adapter) {
991                         nonidx_data = nes_read32(nesdev->regs + sysfs_nonidx_addr);
992                         break;
993                 }
994                 i++;
995         }
996
997         return  snprintf(buf, PAGE_SIZE, "0x%x\n", nonidx_data);
998 }
999
1000 static ssize_t nes_store_nonidx_data(struct device_driver *ddp,
1001         const char *buf, size_t count)
1002 {
1003         char *p = (char *)buf;
1004         u32 val;
1005         u32 i = 0;
1006         struct nes_device *nesdev;
1007
1008         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
1009                 val = simple_strtoul(p, &p, 16);
1010                 list_for_each_entry(nesdev, &nes_dev_list, list) {
1011                         if (i == ee_flsh_adapter) {
1012                                 nes_write32(nesdev->regs + sysfs_nonidx_addr, val);
1013                                 break;
1014                         }
1015                         i++;
1016                 }
1017         }
1018         return strnlen(buf, count);
1019 }
1020
1021 static ssize_t nes_show_idx_addr(struct device_driver *ddp, char *buf)
1022 {
1023         return  snprintf(buf, PAGE_SIZE, "0x%x\n", sysfs_idx_addr);
1024 }
1025
1026 static ssize_t nes_store_idx_addr(struct device_driver *ddp,
1027         const char *buf, size_t count)
1028 {
1029         char *p = (char *)buf;
1030
1031         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X')
1032                 sysfs_idx_addr = simple_strtoul(p, &p, 16);
1033
1034         return strnlen(buf, count);
1035 }
1036
1037 static ssize_t nes_show_idx_data(struct device_driver *ddp, char *buf)
1038 {
1039         u32 idx_data = 0xdead;
1040         u32 i = 0;
1041         struct nes_device *nesdev;
1042
1043         list_for_each_entry(nesdev, &nes_dev_list, list) {
1044                 if (i == ee_flsh_adapter) {
1045                         idx_data = nes_read_indexed(nesdev, sysfs_idx_addr);
1046                         break;
1047                 }
1048                 i++;
1049         }
1050
1051         return  snprintf(buf, PAGE_SIZE, "0x%x\n", idx_data);
1052 }
1053
1054 static ssize_t nes_store_idx_data(struct device_driver *ddp,
1055         const char *buf, size_t count)
1056 {
1057         char *p = (char *)buf;
1058         u32 val;
1059         u32 i = 0;
1060         struct nes_device *nesdev;
1061
1062         if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
1063                 val = simple_strtoul(p, &p, 16);
1064                 list_for_each_entry(nesdev, &nes_dev_list, list) {
1065                         if (i == ee_flsh_adapter) {
1066                                 nes_write_indexed(nesdev, sysfs_idx_addr, val);
1067                                 break;
1068                         }
1069                         i++;
1070                 }
1071         }
1072         return strnlen(buf, count);
1073 }
1074
1075
1076 /**
1077  * nes_show_wqm_quanta
1078  */
1079 static ssize_t nes_show_wqm_quanta(struct device_driver *ddp, char *buf)
1080 {
1081         u32 wqm_quanta_value = 0xdead;
1082         u32 i = 0;
1083         struct nes_device *nesdev;
1084
1085         list_for_each_entry(nesdev, &nes_dev_list, list) {
1086                 if (i == ee_flsh_adapter) {
1087                         wqm_quanta_value = nesdev->nesadapter->wqm_quanta;
1088                         break;
1089                 }
1090                 i++;
1091         }
1092
1093         return  snprintf(buf, PAGE_SIZE, "0x%X\n", wqm_quanta);
1094 }
1095
1096
1097 /**
1098  * nes_store_wqm_quanta
1099  */
1100 static ssize_t nes_store_wqm_quanta(struct device_driver *ddp,
1101                                         const char *buf, size_t count)
1102 {
1103         unsigned long wqm_quanta_value;
1104         u32 wqm_config1;
1105         u32 i = 0;
1106         struct nes_device *nesdev;
1107
1108         strict_strtoul(buf, 0, &wqm_quanta_value);
1109         list_for_each_entry(nesdev, &nes_dev_list, list) {
1110                 if (i == ee_flsh_adapter) {
1111                         nesdev->nesadapter->wqm_quanta = wqm_quanta_value;
1112                         wqm_config1 = nes_read_indexed(nesdev,
1113                                                 NES_IDX_WQM_CONFIG1);
1114                         nes_write_indexed(nesdev, NES_IDX_WQM_CONFIG1,
1115                                         ((wqm_quanta_value << 1) |
1116                                         (wqm_config1 & 0x00000001)));
1117                         break;
1118                 }
1119                 i++;
1120         }
1121         return strnlen(buf, count);
1122 }
1123
1124 static DRIVER_ATTR(adapter, S_IRUSR | S_IWUSR,
1125                    nes_show_adapter, nes_store_adapter);
1126 static DRIVER_ATTR(eeprom_cmd, S_IRUSR | S_IWUSR,
1127                    nes_show_ee_cmd, nes_store_ee_cmd);
1128 static DRIVER_ATTR(eeprom_data, S_IRUSR | S_IWUSR,
1129                    nes_show_ee_data, nes_store_ee_data);
1130 static DRIVER_ATTR(flash_cmd, S_IRUSR | S_IWUSR,
1131                    nes_show_flash_cmd, nes_store_flash_cmd);
1132 static DRIVER_ATTR(flash_data, S_IRUSR | S_IWUSR,
1133                    nes_show_flash_data, nes_store_flash_data);
1134 static DRIVER_ATTR(nonidx_addr, S_IRUSR | S_IWUSR,
1135                    nes_show_nonidx_addr, nes_store_nonidx_addr);
1136 static DRIVER_ATTR(nonidx_data, S_IRUSR | S_IWUSR,
1137                    nes_show_nonidx_data, nes_store_nonidx_data);
1138 static DRIVER_ATTR(idx_addr, S_IRUSR | S_IWUSR,
1139                    nes_show_idx_addr, nes_store_idx_addr);
1140 static DRIVER_ATTR(idx_data, S_IRUSR | S_IWUSR,
1141                    nes_show_idx_data, nes_store_idx_data);
1142 static DRIVER_ATTR(wqm_quanta, S_IRUSR | S_IWUSR,
1143                    nes_show_wqm_quanta, nes_store_wqm_quanta);
1144
1145 static int nes_create_driver_sysfs(struct pci_driver *drv)
1146 {
1147         int error;
1148         error  = driver_create_file(&drv->driver, &driver_attr_adapter);
1149         error |= driver_create_file(&drv->driver, &driver_attr_eeprom_cmd);
1150         error |= driver_create_file(&drv->driver, &driver_attr_eeprom_data);
1151         error |= driver_create_file(&drv->driver, &driver_attr_flash_cmd);
1152         error |= driver_create_file(&drv->driver, &driver_attr_flash_data);
1153         error |= driver_create_file(&drv->driver, &driver_attr_nonidx_addr);
1154         error |= driver_create_file(&drv->driver, &driver_attr_nonidx_data);
1155         error |= driver_create_file(&drv->driver, &driver_attr_idx_addr);
1156         error |= driver_create_file(&drv->driver, &driver_attr_idx_data);
1157         error |= driver_create_file(&drv->driver, &driver_attr_wqm_quanta);
1158         return error;
1159 }
1160
1161 static void nes_remove_driver_sysfs(struct pci_driver *drv)
1162 {
1163         driver_remove_file(&drv->driver, &driver_attr_adapter);
1164         driver_remove_file(&drv->driver, &driver_attr_eeprom_cmd);
1165         driver_remove_file(&drv->driver, &driver_attr_eeprom_data);
1166         driver_remove_file(&drv->driver, &driver_attr_flash_cmd);
1167         driver_remove_file(&drv->driver, &driver_attr_flash_data);
1168         driver_remove_file(&drv->driver, &driver_attr_nonidx_addr);
1169         driver_remove_file(&drv->driver, &driver_attr_nonidx_data);
1170         driver_remove_file(&drv->driver, &driver_attr_idx_addr);
1171         driver_remove_file(&drv->driver, &driver_attr_idx_data);
1172         driver_remove_file(&drv->driver, &driver_attr_wqm_quanta);
1173 }
1174
1175 /**
1176  * nes_init_module - module initialization entry point
1177  */
1178 static int __init nes_init_module(void)
1179 {
1180         int retval;
1181         int retval1;
1182
1183         retval = nes_cm_start();
1184         if (retval) {
1185                 printk(KERN_ERR PFX "Unable to start NetEffect iWARP CM.\n");
1186                 return retval;
1187         }
1188         retval = pci_register_driver(&nes_pci_driver);
1189         if (retval >= 0) {
1190                 retval1 = nes_create_driver_sysfs(&nes_pci_driver);
1191                 if (retval1 < 0)
1192                         printk(KERN_ERR PFX "Unable to create NetEffect sys files.\n");
1193         }
1194         return retval;
1195 }
1196
1197
1198 /**
1199  * nes_exit_module - module unload entry point
1200  */
1201 static void __exit nes_exit_module(void)
1202 {
1203         nes_cm_stop();
1204         nes_remove_driver_sysfs(&nes_pci_driver);
1205
1206         pci_unregister_driver(&nes_pci_driver);
1207 }
1208
1209
1210 module_init(nes_init_module);
1211 module_exit(nes_exit_module);