~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to drivers/infiniband/hw/cxgb4/device.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
MODULE_LICENSE("Dual BSD/GPL");
45
45
MODULE_VERSION(DRV_VERSION);
46
46
 
47
 
static LIST_HEAD(dev_list);
 
47
static LIST_HEAD(uld_ctx_list);
48
48
static DEFINE_MUTEX(dev_mutex);
49
49
 
50
50
static struct dentry *c4iw_debugfs_root;
370
370
        c4iw_destroy_resource(&rdev->resource);
371
371
}
372
372
 
373
 
static void c4iw_remove(struct c4iw_dev *dev)
 
373
struct uld_ctx {
 
374
        struct list_head entry;
 
375
        struct cxgb4_lld_info lldi;
 
376
        struct c4iw_dev *dev;
 
377
};
 
378
 
 
379
static void c4iw_remove(struct uld_ctx *ctx)
374
380
{
375
 
        PDBG("%s c4iw_dev %p\n", __func__,  dev);
376
 
        list_del(&dev->entry);
377
 
        if (dev->registered)
378
 
                c4iw_unregister_device(dev);
379
 
        c4iw_rdev_close(&dev->rdev);
380
 
        idr_destroy(&dev->cqidr);
381
 
        idr_destroy(&dev->qpidr);
382
 
        idr_destroy(&dev->mmidr);
383
 
        iounmap(dev->rdev.oc_mw_kva);
384
 
        ib_dealloc_device(&dev->ibdev);
 
381
        PDBG("%s c4iw_dev %p\n", __func__,  ctx->dev);
 
382
        c4iw_unregister_device(ctx->dev);
 
383
        c4iw_rdev_close(&ctx->dev->rdev);
 
384
        idr_destroy(&ctx->dev->cqidr);
 
385
        idr_destroy(&ctx->dev->qpidr);
 
386
        idr_destroy(&ctx->dev->mmidr);
 
387
        iounmap(ctx->dev->rdev.oc_mw_kva);
 
388
        ib_dealloc_device(&ctx->dev->ibdev);
 
389
        ctx->dev = NULL;
385
390
}
386
391
 
387
392
static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
392
397
        devp = (struct c4iw_dev *)ib_alloc_device(sizeof(*devp));
393
398
        if (!devp) {
394
399
                printk(KERN_ERR MOD "Cannot allocate ib device\n");
395
 
                return NULL;
 
400
                return ERR_PTR(-ENOMEM);
396
401
        }
397
402
        devp->rdev.lldi = *infop;
398
403
 
402
407
        devp->rdev.oc_mw_kva = ioremap_wc(devp->rdev.oc_mw_pa,
403
408
                                               devp->rdev.lldi.vr->ocq.size);
404
409
 
405
 
        printk(KERN_INFO MOD "ocq memory: "
 
410
        PDBG(KERN_INFO MOD "ocq memory: "
406
411
               "hw_start 0x%x size %u mw_pa 0x%lx mw_kva %p\n",
407
412
               devp->rdev.lldi.vr->ocq.start, devp->rdev.lldi.vr->ocq.size,
408
413
               devp->rdev.oc_mw_pa, devp->rdev.oc_mw_kva);
409
414
 
410
 
        mutex_lock(&dev_mutex);
411
 
 
412
415
        ret = c4iw_rdev_open(&devp->rdev);
413
416
        if (ret) {
414
417
                mutex_unlock(&dev_mutex);
415
418
                printk(KERN_ERR MOD "Unable to open CXIO rdev err %d\n", ret);
416
419
                ib_dealloc_device(&devp->ibdev);
417
 
                return NULL;
 
420
                return ERR_PTR(ret);
418
421
        }
419
422
 
420
423
        idr_init(&devp->cqidr);
421
424
        idr_init(&devp->qpidr);
422
425
        idr_init(&devp->mmidr);
423
426
        spin_lock_init(&devp->lock);
424
 
        list_add_tail(&devp->entry, &dev_list);
425
 
        mutex_unlock(&dev_mutex);
426
427
 
427
428
        if (c4iw_debugfs_root) {
428
429
                devp->debugfs_root = debugfs_create_dir(
435
436
 
436
437
static void *c4iw_uld_add(const struct cxgb4_lld_info *infop)
437
438
{
438
 
        struct c4iw_dev *dev;
 
439
        struct uld_ctx *ctx;
439
440
        static int vers_printed;
440
441
        int i;
441
442
 
443
444
                printk(KERN_INFO MOD "Chelsio T4 RDMA Driver - version %s\n",
444
445
                       DRV_VERSION);
445
446
 
446
 
        dev = c4iw_alloc(infop);
447
 
        if (!dev)
 
447
        ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
 
448
        if (!ctx) {
 
449
                ctx = ERR_PTR(-ENOMEM);
448
450
                goto out;
 
451
        }
 
452
        ctx->lldi = *infop;
449
453
 
450
454
        PDBG("%s found device %s nchan %u nrxq %u ntxq %u nports %u\n",
451
 
             __func__, pci_name(dev->rdev.lldi.pdev),
452
 
             dev->rdev.lldi.nchan, dev->rdev.lldi.nrxq,
453
 
             dev->rdev.lldi.ntxq, dev->rdev.lldi.nports);
454
 
 
455
 
        for (i = 0; i < dev->rdev.lldi.nrxq; i++)
456
 
                PDBG("rxqid[%u] %u\n", i, dev->rdev.lldi.rxq_ids[i]);
 
455
             __func__, pci_name(ctx->lldi.pdev),
 
456
             ctx->lldi.nchan, ctx->lldi.nrxq,
 
457
             ctx->lldi.ntxq, ctx->lldi.nports);
 
458
 
 
459
        mutex_lock(&dev_mutex);
 
460
        list_add_tail(&ctx->entry, &uld_ctx_list);
 
461
        mutex_unlock(&dev_mutex);
 
462
 
 
463
        for (i = 0; i < ctx->lldi.nrxq; i++)
 
464
                PDBG("rxqid[%u] %u\n", i, ctx->lldi.rxq_ids[i]);
457
465
out:
458
 
        return dev;
 
466
        return ctx;
459
467
}
460
468
 
461
469
static int c4iw_uld_rx_handler(void *handle, const __be64 *rsp,
462
470
                        const struct pkt_gl *gl)
463
471
{
464
 
        struct c4iw_dev *dev = handle;
 
472
        struct uld_ctx *ctx = handle;
 
473
        struct c4iw_dev *dev = ctx->dev;
465
474
        struct sk_buff *skb;
466
475
        const struct cpl_act_establish *rpl;
467
476
        unsigned int opcode;
503
512
 
504
513
static int c4iw_uld_state_change(void *handle, enum cxgb4_state new_state)
505
514
{
506
 
        struct c4iw_dev *dev = handle;
 
515
        struct uld_ctx *ctx = handle;
507
516
 
508
517
        PDBG("%s new_state %u\n", __func__, new_state);
509
518
        switch (new_state) {
510
519
        case CXGB4_STATE_UP:
511
 
                printk(KERN_INFO MOD "%s: Up\n", pci_name(dev->rdev.lldi.pdev));
512
 
                if (!dev->registered) {
513
 
                        int ret;
514
 
                        ret = c4iw_register_device(dev);
515
 
                        if (ret)
 
520
                printk(KERN_INFO MOD "%s: Up\n", pci_name(ctx->lldi.pdev));
 
521
                if (!ctx->dev) {
 
522
                        int ret = 0;
 
523
 
 
524
                        ctx->dev = c4iw_alloc(&ctx->lldi);
 
525
                        if (!IS_ERR(ctx->dev))
 
526
                                ret = c4iw_register_device(ctx->dev);
 
527
                        if (IS_ERR(ctx->dev) || ret)
516
528
                                printk(KERN_ERR MOD
517
529
                                       "%s: RDMA registration failed: %d\n",
518
 
                                       pci_name(dev->rdev.lldi.pdev), ret);
 
530
                                       pci_name(ctx->lldi.pdev), ret);
519
531
                }
520
532
                break;
521
533
        case CXGB4_STATE_DOWN:
522
534
                printk(KERN_INFO MOD "%s: Down\n",
523
 
                       pci_name(dev->rdev.lldi.pdev));
524
 
                if (dev->registered)
525
 
                        c4iw_unregister_device(dev);
 
535
                       pci_name(ctx->lldi.pdev));
 
536
                if (ctx->dev)
 
537
                        c4iw_remove(ctx);
526
538
                break;
527
539
        case CXGB4_STATE_START_RECOVERY:
528
540
                printk(KERN_INFO MOD "%s: Fatal Error\n",
529
 
                       pci_name(dev->rdev.lldi.pdev));
530
 
                dev->rdev.flags |= T4_FATAL_ERROR;
531
 
                if (dev->registered) {
 
541
                       pci_name(ctx->lldi.pdev));
 
542
                if (ctx->dev) {
532
543
                        struct ib_event event;
533
544
 
 
545
                        ctx->dev->rdev.flags |= T4_FATAL_ERROR;
534
546
                        memset(&event, 0, sizeof event);
535
547
                        event.event  = IB_EVENT_DEVICE_FATAL;
536
 
                        event.device = &dev->ibdev;
 
548
                        event.device = &ctx->dev->ibdev;
537
549
                        ib_dispatch_event(&event);
538
 
                        c4iw_unregister_device(dev);
 
550
                        c4iw_remove(ctx);
539
551
                }
540
552
                break;
541
553
        case CXGB4_STATE_DETACH:
542
554
                printk(KERN_INFO MOD "%s: Detach\n",
543
 
                       pci_name(dev->rdev.lldi.pdev));
544
 
                mutex_lock(&dev_mutex);
545
 
                c4iw_remove(dev);
546
 
                mutex_unlock(&dev_mutex);
 
555
                       pci_name(ctx->lldi.pdev));
 
556
                if (ctx->dev)
 
557
                        c4iw_remove(ctx);
547
558
                break;
548
559
        }
549
560
        return 0;
576
587
 
577
588
static void __exit c4iw_exit_module(void)
578
589
{
579
 
        struct c4iw_dev *dev, *tmp;
 
590
        struct uld_ctx *ctx, *tmp;
580
591
 
581
592
        mutex_lock(&dev_mutex);
582
 
        list_for_each_entry_safe(dev, tmp, &dev_list, entry) {
583
 
                c4iw_remove(dev);
 
593
        list_for_each_entry_safe(ctx, tmp, &uld_ctx_list, entry) {
 
594
                if (ctx->dev)
 
595
                        c4iw_remove(ctx);
 
596
                kfree(ctx);
584
597
        }
585
598
        mutex_unlock(&dev_mutex);
586
599
        cxgb4_unregister_uld(CXGB4_ULD_RDMA);