Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlx4: Connect the infiniband part to the auxiliary bus

Use the auxiliary bus to perform device management of the infiniband
part of the mlx4 driver.

Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Tested-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Pavlu and committed by
David S. Miller
7d22b1cb eb93ae49

+67 -23
+54 -23
drivers/infiniband/hw/mlx4/main.c
··· 2609 2609 .destroy_flow = mlx4_ib_destroy_flow, 2610 2610 }; 2611 2611 2612 - static void *mlx4_ib_add(struct mlx4_dev *dev) 2612 + static int mlx4_ib_probe(struct auxiliary_device *adev, 2613 + const struct auxiliary_device_id *id) 2613 2614 { 2615 + struct mlx4_adev *madev = container_of(adev, struct mlx4_adev, adev); 2616 + struct mlx4_dev *dev = madev->mdev; 2614 2617 struct mlx4_ib_dev *ibdev; 2615 2618 int num_ports = 0; 2616 2619 int i, j; ··· 2633 2630 2634 2631 /* No point in registering a device with no ports... */ 2635 2632 if (num_ports == 0) 2636 - return NULL; 2633 + return -ENODEV; 2637 2634 2638 2635 ibdev = ib_alloc_device(mlx4_ib_dev, ib_dev); 2639 2636 if (!ibdev) { 2640 2637 dev_err(&dev->persist->pdev->dev, 2641 2638 "Device struct alloc failed\n"); 2642 - return NULL; 2639 + return -ENOMEM; 2643 2640 } 2644 2641 2645 2642 iboe = &ibdev->iboe; 2646 2643 2647 - if (mlx4_pd_alloc(dev, &ibdev->priv_pdn)) 2644 + err = mlx4_pd_alloc(dev, &ibdev->priv_pdn); 2645 + if (err) 2648 2646 goto err_dealloc; 2649 2647 2650 - if (mlx4_uar_alloc(dev, &ibdev->priv_uar)) 2648 + err = mlx4_uar_alloc(dev, &ibdev->priv_uar); 2649 + if (err) 2651 2650 goto err_pd; 2652 2651 2653 2652 ibdev->uar_map = ioremap((phys_addr_t) ibdev->priv_uar.pfn << PAGE_SHIFT, 2654 2653 PAGE_SIZE); 2655 - if (!ibdev->uar_map) 2654 + if (!ibdev->uar_map) { 2655 + err = -ENOMEM; 2656 2656 goto err_uar; 2657 + } 2657 2658 MLX4_INIT_DOORBELL_LOCK(&ibdev->uar_lock); 2658 2659 2659 2660 ibdev->dev = dev; ··· 2701 2694 2702 2695 spin_lock_init(&iboe->lock); 2703 2696 2704 - if (init_node_data(ibdev)) 2697 + err = init_node_data(ibdev); 2698 + if (err) 2705 2699 goto err_map; 2706 2700 mlx4_init_sl2vl_tbl(ibdev); 2707 2701 ··· 2734 2726 new_counter_index = kmalloc(sizeof(*new_counter_index), 2735 2727 GFP_KERNEL); 2736 2728 if (!new_counter_index) { 2729 + err = -ENOMEM; 2737 2730 if (allocated) 2738 2731 mlx4_counter_free(ibdev->dev, counter_index); 2739 2732 goto err_counter; ··· 2752 2743 new_counter_index = 2753 2744 kmalloc(sizeof(struct counter_index), 2754 2745 GFP_KERNEL); 2755 - if (!new_counter_index) 2746 + if (!new_counter_index) { 2747 + err = -ENOMEM; 2756 2748 goto err_counter; 2749 + } 2757 2750 new_counter_index->index = counter_index; 2758 2751 new_counter_index->allocated = 0; 2759 2752 list_add_tail(&new_counter_index->list, ··· 2784 2773 2785 2774 ibdev->ib_uc_qpns_bitmap = bitmap_alloc(ibdev->steer_qpn_count, 2786 2775 GFP_KERNEL); 2787 - if (!ibdev->ib_uc_qpns_bitmap) 2776 + if (!ibdev->ib_uc_qpns_bitmap) { 2777 + err = -ENOMEM; 2788 2778 goto err_steer_qp_release; 2779 + } 2789 2780 2790 2781 if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DMFS_IPOIB) { 2791 2782 bitmap_zero(ibdev->ib_uc_qpns_bitmap, ··· 2807 2794 for (j = 1; j <= ibdev->dev->caps.num_ports; j++) 2808 2795 atomic64_set(&iboe->mac[j - 1], ibdev->dev->caps.def_mac[j]); 2809 2796 2810 - if (mlx4_ib_alloc_diag_counters(ibdev)) 2797 + err = mlx4_ib_alloc_diag_counters(ibdev); 2798 + if (err) 2811 2799 goto err_steer_free_bitmap; 2812 2800 2813 - if (ib_register_device(&ibdev->ib_dev, "mlx4_%d", 2814 - &dev->persist->pdev->dev)) 2801 + err = ib_register_device(&ibdev->ib_dev, "mlx4_%d", 2802 + &dev->persist->pdev->dev); 2803 + if (err) 2815 2804 goto err_diag_counters; 2816 2805 2817 - if (mlx4_ib_mad_init(ibdev)) 2806 + err = mlx4_ib_mad_init(ibdev); 2807 + if (err) 2818 2808 goto err_reg; 2819 2809 2820 - if (mlx4_ib_init_sriov(ibdev)) 2810 + err = mlx4_ib_init_sriov(ibdev); 2811 + if (err) 2821 2812 goto err_mad; 2822 2813 2823 2814 if (!iboe->nb.notifier_call) { ··· 2861 2844 err = mlx4_register_event_notifier(dev, &ibdev->mlx_nb); 2862 2845 WARN(err, "failed to register mlx4 event notifier (%d)", err); 2863 2846 2864 - return ibdev; 2847 + auxiliary_set_drvdata(adev, ibdev); 2848 + return 0; 2865 2849 2866 2850 err_notif: 2867 2851 if (ibdev->iboe.nb.notifier_call) { ··· 2906 2888 err_dealloc: 2907 2889 ib_dealloc_device(&ibdev->ib_dev); 2908 2890 2909 - return NULL; 2891 + return err; 2910 2892 } 2911 2893 2912 2894 int mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn) ··· 2973 2955 return err; 2974 2956 } 2975 2957 2976 - static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr) 2958 + static void mlx4_ib_remove(struct auxiliary_device *adev) 2977 2959 { 2978 - struct mlx4_ib_dev *ibdev = ibdev_ptr; 2960 + struct mlx4_adev *madev = container_of(adev, struct mlx4_adev, adev); 2961 + struct mlx4_dev *dev = madev->mdev; 2962 + struct mlx4_ib_dev *ibdev = auxiliary_get_drvdata(adev); 2979 2963 int p; 2980 2964 int i; 2981 2965 ··· 3323 3303 return NOTIFY_DONE; 3324 3304 } 3325 3305 3326 - static struct mlx4_interface mlx4_ib_interface = { 3327 - .add = mlx4_ib_add, 3328 - .remove = mlx4_ib_remove, 3306 + static const struct auxiliary_device_id mlx4_ib_id_table[] = { 3307 + { .name = MLX4_ADEV_NAME ".ib" }, 3308 + {}, 3309 + }; 3310 + 3311 + MODULE_DEVICE_TABLE(auxiliary, mlx4_ib_id_table); 3312 + 3313 + static struct mlx4_adrv mlx4_ib_adrv = { 3314 + .adrv = { 3315 + .name = "ib", 3316 + .probe = mlx4_ib_probe, 3317 + .remove = mlx4_ib_remove, 3318 + .id_table = mlx4_ib_id_table, 3319 + }, 3329 3320 .protocol = MLX4_PROT_IB_IPV6, 3330 3321 .flags = MLX4_INTFF_BONDING 3331 3322 }; ··· 3361 3330 if (err) 3362 3331 goto clean_cm; 3363 3332 3364 - err = mlx4_register_interface(&mlx4_ib_interface); 3333 + err = mlx4_register_auxiliary_driver(&mlx4_ib_adrv); 3365 3334 if (err) 3366 3335 goto clean_mcg; 3367 3336 ··· 3383 3352 3384 3353 static void __exit mlx4_ib_cleanup(void) 3385 3354 { 3386 - mlx4_unregister_interface(&mlx4_ib_interface); 3355 + mlx4_unregister_auxiliary_driver(&mlx4_ib_adrv); 3387 3356 mlx4_ib_mcg_destroy(); 3388 3357 mlx4_ib_cm_destroy(); 3389 3358 mlx4_ib_qp_event_cleanup();
+13
drivers/net/ethernet/mellanox/mlx4/intf.c
··· 59 59 return false; 60 60 } 61 61 62 + static bool is_ib_supported(struct mlx4_dev *dev) 63 + { 64 + for (int port = 1; port <= dev->caps.num_ports; port++) 65 + if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB) 66 + return true; 67 + 68 + if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) 69 + return true; 70 + 71 + return false; 72 + } 73 + 62 74 static const struct mlx4_adev_device { 63 75 const char *suffix; 64 76 bool (*is_supported)(struct mlx4_dev *dev); 65 77 } mlx4_adev_devices[] = { 66 78 { "eth", is_eth_supported }, 79 + { "ib", is_ib_supported }, 67 80 }; 68 81 69 82 int mlx4_adev_init(struct mlx4_dev *dev)