diff options
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/main.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/main.c | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 60c9f4f103fc..5789ea2c934d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/io-mapping.h> | 42 | #include <linux/io-mapping.h> |
43 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
44 | #include <linux/netdevice.h> | 44 | #include <linux/netdevice.h> |
45 | #include <linux/kmod.h> | ||
45 | 46 | ||
46 | #include <linux/mlx4/device.h> | 47 | #include <linux/mlx4/device.h> |
47 | #include <linux/mlx4/doorbell.h> | 48 | #include <linux/mlx4/doorbell.h> |
@@ -561,13 +562,17 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) | |||
561 | } | 562 | } |
562 | 563 | ||
563 | dev->caps.num_ports = func_cap.num_ports; | 564 | dev->caps.num_ports = func_cap.num_ports; |
564 | dev->caps.num_qps = func_cap.qp_quota; | 565 | dev->quotas.qp = func_cap.qp_quota; |
565 | dev->caps.num_srqs = func_cap.srq_quota; | 566 | dev->quotas.srq = func_cap.srq_quota; |
566 | dev->caps.num_cqs = func_cap.cq_quota; | 567 | dev->quotas.cq = func_cap.cq_quota; |
567 | dev->caps.num_eqs = func_cap.max_eq; | 568 | dev->quotas.mpt = func_cap.mpt_quota; |
568 | dev->caps.reserved_eqs = func_cap.reserved_eq; | 569 | dev->quotas.mtt = func_cap.mtt_quota; |
569 | dev->caps.num_mpts = func_cap.mpt_quota; | 570 | dev->caps.num_qps = 1 << hca_param.log_num_qps; |
570 | dev->caps.num_mtts = func_cap.mtt_quota; | 571 | dev->caps.num_srqs = 1 << hca_param.log_num_srqs; |
572 | dev->caps.num_cqs = 1 << hca_param.log_num_cqs; | ||
573 | dev->caps.num_mpts = 1 << hca_param.log_mpt_sz; | ||
574 | dev->caps.num_eqs = func_cap.max_eq; | ||
575 | dev->caps.reserved_eqs = func_cap.reserved_eq; | ||
571 | dev->caps.num_pds = MLX4_NUM_PDS; | 576 | dev->caps.num_pds = MLX4_NUM_PDS; |
572 | dev->caps.num_mgms = 0; | 577 | dev->caps.num_mgms = 0; |
573 | dev->caps.num_amgms = 0; | 578 | dev->caps.num_amgms = 0; |
@@ -650,6 +655,27 @@ err_mem: | |||
650 | return err; | 655 | return err; |
651 | } | 656 | } |
652 | 657 | ||
658 | static void mlx4_request_modules(struct mlx4_dev *dev) | ||
659 | { | ||
660 | int port; | ||
661 | int has_ib_port = false; | ||
662 | int has_eth_port = false; | ||
663 | #define EN_DRV_NAME "mlx4_en" | ||
664 | #define IB_DRV_NAME "mlx4_ib" | ||
665 | |||
666 | for (port = 1; port <= dev->caps.num_ports; port++) { | ||
667 | if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB) | ||
668 | has_ib_port = true; | ||
669 | else if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH) | ||
670 | has_eth_port = true; | ||
671 | } | ||
672 | |||
673 | if (has_ib_port) | ||
674 | request_module_nowait(IB_DRV_NAME); | ||
675 | if (has_eth_port) | ||
676 | request_module_nowait(EN_DRV_NAME); | ||
677 | } | ||
678 | |||
653 | /* | 679 | /* |
654 | * Change the port configuration of the device. | 680 | * Change the port configuration of the device. |
655 | * Every user of this function must hold the port mutex. | 681 | * Every user of this function must hold the port mutex. |
@@ -681,6 +707,11 @@ int mlx4_change_port_types(struct mlx4_dev *dev, | |||
681 | } | 707 | } |
682 | mlx4_set_port_mask(dev); | 708 | mlx4_set_port_mask(dev); |
683 | err = mlx4_register_device(dev); | 709 | err = mlx4_register_device(dev); |
710 | if (err) { | ||
711 | mlx4_err(dev, "Failed to register device\n"); | ||
712 | goto out; | ||
713 | } | ||
714 | mlx4_request_modules(dev); | ||
684 | } | 715 | } |
685 | 716 | ||
686 | out: | 717 | out: |
@@ -2075,9 +2106,15 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) | |||
2075 | "aborting.\n"); | 2106 | "aborting.\n"); |
2076 | return err; | 2107 | return err; |
2077 | } | 2108 | } |
2078 | if (num_vfs > MLX4_MAX_NUM_VF) { | 2109 | |
2079 | printk(KERN_ERR "There are more VF's (%d) than allowed(%d)\n", | 2110 | /* Due to requirement that all VFs and the PF are *guaranteed* 2 MACS |
2080 | num_vfs, MLX4_MAX_NUM_VF); | 2111 | * per port, we must limit the number of VFs to 63 (since their are |
2112 | * 128 MACs) | ||
2113 | */ | ||
2114 | if (num_vfs >= MLX4_MAX_NUM_VF) { | ||
2115 | dev_err(&pdev->dev, | ||
2116 | "Requested more VF's (%d) than allowed (%d)\n", | ||
2117 | num_vfs, MLX4_MAX_NUM_VF - 1); | ||
2081 | return -EINVAL; | 2118 | return -EINVAL; |
2082 | } | 2119 | } |
2083 | 2120 | ||
@@ -2154,6 +2191,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data) | |||
2154 | mutex_init(&priv->bf_mutex); | 2191 | mutex_init(&priv->bf_mutex); |
2155 | 2192 | ||
2156 | dev->rev_id = pdev->revision; | 2193 | dev->rev_id = pdev->revision; |
2194 | dev->numa_node = dev_to_node(&pdev->dev); | ||
2157 | /* Detect if this device is a virtual function */ | 2195 | /* Detect if this device is a virtual function */ |
2158 | if (pci_dev_data & MLX4_PCI_DEV_IS_VF) { | 2196 | if (pci_dev_data & MLX4_PCI_DEV_IS_VF) { |
2159 | /* When acting as pf, we normally skip vfs unless explicitly | 2197 | /* When acting as pf, we normally skip vfs unless explicitly |
@@ -2295,6 +2333,8 @@ slave_start: | |||
2295 | if (err) | 2333 | if (err) |
2296 | goto err_steer; | 2334 | goto err_steer; |
2297 | 2335 | ||
2336 | mlx4_init_quotas(dev); | ||
2337 | |||
2298 | for (port = 1; port <= dev->caps.num_ports; port++) { | 2338 | for (port = 1; port <= dev->caps.num_ports; port++) { |
2299 | err = mlx4_init_port_info(dev, port); | 2339 | err = mlx4_init_port_info(dev, port); |
2300 | if (err) | 2340 | if (err) |
@@ -2305,6 +2345,8 @@ slave_start: | |||
2305 | if (err) | 2345 | if (err) |
2306 | goto err_port; | 2346 | goto err_port; |
2307 | 2347 | ||
2348 | mlx4_request_modules(dev); | ||
2349 | |||
2308 | mlx4_sense_init(dev); | 2350 | mlx4_sense_init(dev); |
2309 | mlx4_start_sense(dev); | 2351 | mlx4_start_sense(dev); |
2310 | 2352 | ||