diff options
author | Saeed Mahameed <saeedm@mellanox.com> | 2015-04-02 10:07:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-02 16:33:42 -0400 |
commit | 233d05d28ad942929b6b4fbc48aa8dd083c16484 (patch) | |
tree | 342d60a038d65bed539d3d5c000be459cf040e01 /drivers/infiniband/hw/mlx5/main.c | |
parent | 4ae6c18c59f1419202ab5e2a918e551099d88f9f (diff) |
net/mlx5_core: Move completion eqs from mlx5_ib to mlx5_core
Preparation for ethernet driver.
These functions will be used in drivers other than mlx5_ib.
Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 104 |
1 files changed, 4 insertions, 100 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 45816b10af5e..e59e2a1f8726 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -62,95 +62,6 @@ static char mlx5_version[] = | |||
62 | DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v" | 62 | DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v" |
63 | DRIVER_VERSION " (" DRIVER_RELDATE ")\n"; | 63 | DRIVER_VERSION " (" DRIVER_RELDATE ")\n"; |
64 | 64 | ||
65 | int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn) | ||
66 | { | ||
67 | struct mlx5_eq_table *table = &dev->mdev->priv.eq_table; | ||
68 | struct mlx5_eq *eq, *n; | ||
69 | int err = -ENOENT; | ||
70 | |||
71 | spin_lock(&table->lock); | ||
72 | list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { | ||
73 | if (eq->index == vector) { | ||
74 | *eqn = eq->eqn; | ||
75 | *irqn = eq->irqn; | ||
76 | err = 0; | ||
77 | break; | ||
78 | } | ||
79 | } | ||
80 | spin_unlock(&table->lock); | ||
81 | |||
82 | return err; | ||
83 | } | ||
84 | |||
85 | static int alloc_comp_eqs(struct mlx5_ib_dev *dev) | ||
86 | { | ||
87 | struct mlx5_eq_table *table = &dev->mdev->priv.eq_table; | ||
88 | char name[MLX5_MAX_EQ_NAME]; | ||
89 | struct mlx5_eq *eq, *n; | ||
90 | int ncomp_vec; | ||
91 | int nent; | ||
92 | int err; | ||
93 | int i; | ||
94 | |||
95 | INIT_LIST_HEAD(&dev->eqs_list); | ||
96 | ncomp_vec = table->num_comp_vectors; | ||
97 | nent = MLX5_COMP_EQ_SIZE; | ||
98 | for (i = 0; i < ncomp_vec; i++) { | ||
99 | eq = kzalloc(sizeof(*eq), GFP_KERNEL); | ||
100 | if (!eq) { | ||
101 | err = -ENOMEM; | ||
102 | goto clean; | ||
103 | } | ||
104 | |||
105 | snprintf(name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); | ||
106 | err = mlx5_create_map_eq(dev->mdev, eq, | ||
107 | i + MLX5_EQ_VEC_COMP_BASE, nent, 0, | ||
108 | name, &dev->mdev->priv.uuari.uars[0]); | ||
109 | if (err) { | ||
110 | kfree(eq); | ||
111 | goto clean; | ||
112 | } | ||
113 | mlx5_ib_dbg(dev, "allocated completion EQN %d\n", eq->eqn); | ||
114 | eq->index = i; | ||
115 | spin_lock(&table->lock); | ||
116 | list_add_tail(&eq->list, &dev->eqs_list); | ||
117 | spin_unlock(&table->lock); | ||
118 | } | ||
119 | |||
120 | dev->num_comp_vectors = ncomp_vec; | ||
121 | return 0; | ||
122 | |||
123 | clean: | ||
124 | spin_lock(&table->lock); | ||
125 | list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { | ||
126 | list_del(&eq->list); | ||
127 | spin_unlock(&table->lock); | ||
128 | if (mlx5_destroy_unmap_eq(dev->mdev, eq)) | ||
129 | mlx5_ib_warn(dev, "failed to destroy EQ 0x%x\n", eq->eqn); | ||
130 | kfree(eq); | ||
131 | spin_lock(&table->lock); | ||
132 | } | ||
133 | spin_unlock(&table->lock); | ||
134 | return err; | ||
135 | } | ||
136 | |||
137 | static void free_comp_eqs(struct mlx5_ib_dev *dev) | ||
138 | { | ||
139 | struct mlx5_eq_table *table = &dev->mdev->priv.eq_table; | ||
140 | struct mlx5_eq *eq, *n; | ||
141 | |||
142 | spin_lock(&table->lock); | ||
143 | list_for_each_entry_safe(eq, n, &dev->eqs_list, list) { | ||
144 | list_del(&eq->list); | ||
145 | spin_unlock(&table->lock); | ||
146 | if (mlx5_destroy_unmap_eq(dev->mdev, eq)) | ||
147 | mlx5_ib_warn(dev, "failed to destroy EQ 0x%x\n", eq->eqn); | ||
148 | kfree(eq); | ||
149 | spin_lock(&table->lock); | ||
150 | } | ||
151 | spin_unlock(&table->lock); | ||
152 | } | ||
153 | |||
154 | static int mlx5_ib_query_device(struct ib_device *ibdev, | 65 | static int mlx5_ib_query_device(struct ib_device *ibdev, |
155 | struct ib_device_attr *props) | 66 | struct ib_device_attr *props) |
156 | { | 67 | { |
@@ -1291,10 +1202,6 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1291 | 1202 | ||
1292 | get_ext_port_caps(dev); | 1203 | get_ext_port_caps(dev); |
1293 | 1204 | ||
1294 | err = alloc_comp_eqs(dev); | ||
1295 | if (err) | ||
1296 | goto err_dealloc; | ||
1297 | |||
1298 | MLX5_INIT_DOORBELL_LOCK(&dev->uar_lock); | 1205 | MLX5_INIT_DOORBELL_LOCK(&dev->uar_lock); |
1299 | 1206 | ||
1300 | strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX); | 1207 | strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX); |
@@ -1303,7 +1210,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1303 | dev->ib_dev.local_dma_lkey = mdev->caps.gen.reserved_lkey; | 1210 | dev->ib_dev.local_dma_lkey = mdev->caps.gen.reserved_lkey; |
1304 | dev->num_ports = mdev->caps.gen.num_ports; | 1211 | dev->num_ports = mdev->caps.gen.num_ports; |
1305 | dev->ib_dev.phys_port_cnt = dev->num_ports; | 1212 | dev->ib_dev.phys_port_cnt = dev->num_ports; |
1306 | dev->ib_dev.num_comp_vectors = dev->num_comp_vectors; | 1213 | dev->ib_dev.num_comp_vectors = |
1214 | dev->mdev->priv.eq_table.num_comp_vectors; | ||
1307 | dev->ib_dev.dma_device = &mdev->pdev->dev; | 1215 | dev->ib_dev.dma_device = &mdev->pdev->dev; |
1308 | 1216 | ||
1309 | dev->ib_dev.uverbs_abi_ver = MLX5_IB_UVERBS_ABI_VERSION; | 1217 | dev->ib_dev.uverbs_abi_ver = MLX5_IB_UVERBS_ABI_VERSION; |
@@ -1390,13 +1298,13 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1390 | 1298 | ||
1391 | err = init_node_data(dev); | 1299 | err = init_node_data(dev); |
1392 | if (err) | 1300 | if (err) |
1393 | goto err_eqs; | 1301 | goto err_dealloc; |
1394 | 1302 | ||
1395 | mutex_init(&dev->cap_mask_mutex); | 1303 | mutex_init(&dev->cap_mask_mutex); |
1396 | 1304 | ||
1397 | err = create_dev_resources(&dev->devr); | 1305 | err = create_dev_resources(&dev->devr); |
1398 | if (err) | 1306 | if (err) |
1399 | goto err_eqs; | 1307 | goto err_dealloc; |
1400 | 1308 | ||
1401 | err = mlx5_ib_odp_init_one(dev); | 1309 | err = mlx5_ib_odp_init_one(dev); |
1402 | if (err) | 1310 | if (err) |
@@ -1433,9 +1341,6 @@ err_odp: | |||
1433 | err_rsrc: | 1341 | err_rsrc: |
1434 | destroy_dev_resources(&dev->devr); | 1342 | destroy_dev_resources(&dev->devr); |
1435 | 1343 | ||
1436 | err_eqs: | ||
1437 | free_comp_eqs(dev); | ||
1438 | |||
1439 | err_dealloc: | 1344 | err_dealloc: |
1440 | ib_dealloc_device((struct ib_device *)dev); | 1345 | ib_dealloc_device((struct ib_device *)dev); |
1441 | 1346 | ||
@@ -1450,7 +1355,6 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) | |||
1450 | destroy_umrc_res(dev); | 1355 | destroy_umrc_res(dev); |
1451 | mlx5_ib_odp_remove_one(dev); | 1356 | mlx5_ib_odp_remove_one(dev); |
1452 | destroy_dev_resources(&dev->devr); | 1357 | destroy_dev_resources(&dev->devr); |
1453 | free_comp_eqs(dev); | ||
1454 | ib_dealloc_device(&dev->ib_dev); | 1358 | ib_dealloc_device(&dev->ib_dev); |
1455 | } | 1359 | } |
1456 | 1360 | ||