diff options
Diffstat (limited to 'drivers/net/mlx4/main.c')
-rw-r--r-- | drivers/net/mlx4/main.c | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index 0cb0431ee19c..c94b3426d355 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c | |||
@@ -143,6 +143,7 @@ static void mlx4_set_port_mask(struct mlx4_dev *dev) | |||
143 | if (dev->caps.port_type[i] == MLX4_PORT_TYPE_IB) | 143 | if (dev->caps.port_type[i] == MLX4_PORT_TYPE_IB) |
144 | dev->caps.port_mask |= 1 << (i - 1); | 144 | dev->caps.port_mask |= 1 << (i - 1); |
145 | } | 145 | } |
146 | |||
146 | static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | 147 | static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) |
147 | { | 148 | { |
148 | int err; | 149 | int err; |
@@ -226,11 +227,6 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
226 | dev->caps.bmme_flags = dev_cap->bmme_flags; | 227 | dev->caps.bmme_flags = dev_cap->bmme_flags; |
227 | dev->caps.reserved_lkey = dev_cap->reserved_lkey; | 228 | dev->caps.reserved_lkey = dev_cap->reserved_lkey; |
228 | dev->caps.stat_rate_support = dev_cap->stat_rate_support; | 229 | dev->caps.stat_rate_support = dev_cap->stat_rate_support; |
229 | dev->caps.udp_rss = dev_cap->udp_rss; | ||
230 | dev->caps.loopback_support = dev_cap->loopback_support; | ||
231 | dev->caps.vep_uc_steering = dev_cap->vep_uc_steering; | ||
232 | dev->caps.vep_mc_steering = dev_cap->vep_mc_steering; | ||
233 | dev->caps.wol = dev_cap->wol; | ||
234 | dev->caps.max_gso_sz = dev_cap->max_gso_sz; | 230 | dev->caps.max_gso_sz = dev_cap->max_gso_sz; |
235 | 231 | ||
236 | dev->caps.log_num_macs = log_num_mac; | 232 | dev->caps.log_num_macs = log_num_mac; |
@@ -262,6 +258,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
262 | 258 | ||
263 | mlx4_set_port_mask(dev); | 259 | mlx4_set_port_mask(dev); |
264 | 260 | ||
261 | dev->caps.max_counters = 1 << ilog2(dev_cap->max_counters); | ||
262 | |||
265 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps; | 263 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps; |
266 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] = | 264 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] = |
267 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] = | 265 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] = |
@@ -839,6 +837,45 @@ err_stop_fw: | |||
839 | return err; | 837 | return err; |
840 | } | 838 | } |
841 | 839 | ||
840 | static int mlx4_init_counters_table(struct mlx4_dev *dev) | ||
841 | { | ||
842 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
843 | int nent; | ||
844 | |||
845 | if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) | ||
846 | return -ENOENT; | ||
847 | |||
848 | nent = dev->caps.max_counters; | ||
849 | return mlx4_bitmap_init(&priv->counters_bitmap, nent, nent - 1, 0, 0); | ||
850 | } | ||
851 | |||
852 | static void mlx4_cleanup_counters_table(struct mlx4_dev *dev) | ||
853 | { | ||
854 | mlx4_bitmap_cleanup(&mlx4_priv(dev)->counters_bitmap); | ||
855 | } | ||
856 | |||
857 | int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx) | ||
858 | { | ||
859 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
860 | |||
861 | if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_COUNTERS)) | ||
862 | return -ENOENT; | ||
863 | |||
864 | *idx = mlx4_bitmap_alloc(&priv->counters_bitmap); | ||
865 | if (*idx == -1) | ||
866 | return -ENOMEM; | ||
867 | |||
868 | return 0; | ||
869 | } | ||
870 | EXPORT_SYMBOL_GPL(mlx4_counter_alloc); | ||
871 | |||
872 | void mlx4_counter_free(struct mlx4_dev *dev, u32 idx) | ||
873 | { | ||
874 | mlx4_bitmap_free(&mlx4_priv(dev)->counters_bitmap, idx); | ||
875 | return; | ||
876 | } | ||
877 | EXPORT_SYMBOL_GPL(mlx4_counter_free); | ||
878 | |||
842 | static int mlx4_setup_hca(struct mlx4_dev *dev) | 879 | static int mlx4_setup_hca(struct mlx4_dev *dev) |
843 | { | 880 | { |
844 | struct mlx4_priv *priv = mlx4_priv(dev); | 881 | struct mlx4_priv *priv = mlx4_priv(dev); |
@@ -943,6 +980,12 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) | |||
943 | goto err_qp_table_free; | 980 | goto err_qp_table_free; |
944 | } | 981 | } |
945 | 982 | ||
983 | err = mlx4_init_counters_table(dev); | ||
984 | if (err && err != -ENOENT) { | ||
985 | mlx4_err(dev, "Failed to initialize counters table, aborting.\n"); | ||
986 | goto err_counters_table_free; | ||
987 | } | ||
988 | |||
946 | for (port = 1; port <= dev->caps.num_ports; port++) { | 989 | for (port = 1; port <= dev->caps.num_ports; port++) { |
947 | enum mlx4_port_type port_type = 0; | 990 | enum mlx4_port_type port_type = 0; |
948 | mlx4_SENSE_PORT(dev, port, &port_type); | 991 | mlx4_SENSE_PORT(dev, port, &port_type); |
@@ -969,6 +1012,9 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) | |||
969 | err_mcg_table_free: | 1012 | err_mcg_table_free: |
970 | mlx4_cleanup_mcg_table(dev); | 1013 | mlx4_cleanup_mcg_table(dev); |
971 | 1014 | ||
1015 | err_counters_table_free: | ||
1016 | mlx4_cleanup_counters_table(dev); | ||
1017 | |||
972 | err_qp_table_free: | 1018 | err_qp_table_free: |
973 | mlx4_cleanup_qp_table(dev); | 1019 | mlx4_cleanup_qp_table(dev); |
974 | 1020 | ||
@@ -1299,6 +1345,7 @@ err_port: | |||
1299 | for (--port; port >= 1; --port) | 1345 | for (--port; port >= 1; --port) |
1300 | mlx4_cleanup_port_info(&priv->port[port]); | 1346 | mlx4_cleanup_port_info(&priv->port[port]); |
1301 | 1347 | ||
1348 | mlx4_cleanup_counters_table(dev); | ||
1302 | mlx4_cleanup_mcg_table(dev); | 1349 | mlx4_cleanup_mcg_table(dev); |
1303 | mlx4_cleanup_qp_table(dev); | 1350 | mlx4_cleanup_qp_table(dev); |
1304 | mlx4_cleanup_srq_table(dev); | 1351 | mlx4_cleanup_srq_table(dev); |
@@ -1359,6 +1406,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) | |||
1359 | mlx4_CLOSE_PORT(dev, p); | 1406 | mlx4_CLOSE_PORT(dev, p); |
1360 | } | 1407 | } |
1361 | 1408 | ||
1409 | mlx4_cleanup_counters_table(dev); | ||
1362 | mlx4_cleanup_mcg_table(dev); | 1410 | mlx4_cleanup_mcg_table(dev); |
1363 | mlx4_cleanup_qp_table(dev); | 1411 | mlx4_cleanup_qp_table(dev); |
1364 | mlx4_cleanup_srq_table(dev); | 1412 | mlx4_cleanup_srq_table(dev); |