hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/ethernet/mellanox/mlx5/core/cq.c
....@@ -34,19 +34,19 @@
3434 #include <linux/module.h>
3535 #include <linux/hardirq.h>
3636 #include <linux/mlx5/driver.h>
37
-#include <linux/mlx5/cmd.h>
3837 #include <rdma/ib_verbs.h>
3938 #include <linux/mlx5/cq.h>
4039 #include "mlx5_core.h"
40
+#include "lib/eq.h"
4141
4242 #define TASKLET_MAX_TIME 2
4343 #define TASKLET_MAX_TIME_JIFFIES msecs_to_jiffies(TASKLET_MAX_TIME)
4444
45
-void mlx5_cq_tasklet_cb(unsigned long data)
45
+void mlx5_cq_tasklet_cb(struct tasklet_struct *t)
4646 {
4747 unsigned long flags;
4848 unsigned long end = jiffies + TASKLET_MAX_TIME_JIFFIES;
49
- struct mlx5_eq_tasklet *ctx = (struct mlx5_eq_tasklet *)data;
49
+ struct mlx5_eq_tasklet *ctx = from_tasklet(ctx, t, task);
5050 struct mlx5_core_cq *mcq;
5151 struct mlx5_core_cq *temp;
5252
....@@ -57,7 +57,7 @@
5757 list_for_each_entry_safe(mcq, temp, &ctx->process_list,
5858 tasklet_ctx.list) {
5959 list_del_init(&mcq->tasklet_ctx.list);
60
- mcq->tasklet_ctx.comp(mcq);
60
+ mcq->tasklet_ctx.comp(mcq, NULL);
6161 mlx5_cq_put(mcq);
6262 if (time_after(jiffies, end))
6363 break;
....@@ -67,7 +67,8 @@
6767 tasklet_schedule(&ctx->task);
6868 }
6969
70
-static void mlx5_add_cq_to_tasklet(struct mlx5_core_cq *cq)
70
+static void mlx5_add_cq_to_tasklet(struct mlx5_core_cq *cq,
71
+ struct mlx5_eqe *eqe)
7172 {
7273 unsigned long flags;
7374 struct mlx5_eq_tasklet *tasklet_ctx = cq->tasklet_ctx.priv;
....@@ -86,22 +87,20 @@
8687 }
8788
8889 int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
89
- u32 *in, int inlen)
90
+ u32 *in, int inlen, u32 *out, int outlen)
9091 {
9192 int eqn = MLX5_GET(cqc, MLX5_ADDR_OF(create_cq_in, in, cq_context), c_eqn);
92
- u32 dout[MLX5_ST_SZ_DW(destroy_cq_out)];
93
- u32 out[MLX5_ST_SZ_DW(create_cq_out)];
94
- u32 din[MLX5_ST_SZ_DW(destroy_cq_in)];
95
- struct mlx5_eq *eq;
93
+ u32 din[MLX5_ST_SZ_DW(destroy_cq_in)] = {};
94
+ struct mlx5_eq_comp *eq;
9695 int err;
9796
98
- eq = mlx5_eqn2eq(dev, eqn);
97
+ eq = mlx5_eqn2comp_eq(dev, eqn);
9998 if (IS_ERR(eq))
10099 return PTR_ERR(eq);
101100
102
- memset(out, 0, sizeof(out));
101
+ memset(out, 0, outlen);
103102 MLX5_SET(create_cq_in, in, opcode, MLX5_CMD_OP_CREATE_CQ);
104
- err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
103
+ err = mlx5_cmd_exec(dev, in, inlen, out, outlen);
105104 if (err)
106105 return err;
107106
....@@ -109,6 +108,7 @@
109108 cq->cons_index = 0;
110109 cq->arm_sn = 0;
111110 cq->eq = eq;
111
+ cq->uid = MLX5_GET(create_cq_in, in, uid);
112112 refcount_set(&cq->refcount, 1);
113113 init_completion(&cq->free);
114114 if (!cq->comp)
....@@ -118,12 +118,12 @@
118118 INIT_LIST_HEAD(&cq->tasklet_ctx.list);
119119
120120 /* Add to comp EQ CQ tree to recv comp events */
121
- err = mlx5_eq_add_cq(eq, cq);
121
+ err = mlx5_eq_add_cq(&eq->core, cq);
122122 if (err)
123123 goto err_cmd;
124124
125125 /* Add to async EQ CQ tree to recv async events */
126
- err = mlx5_eq_add_cq(&dev->priv.eq_table.async_eq, cq);
126
+ err = mlx5_eq_add_cq(mlx5_get_async_eq(dev), cq);
127127 if (err)
128128 goto err_cq_add;
129129
....@@ -134,44 +134,39 @@
134134 cq->cqn);
135135
136136 cq->uar = dev->priv.uar;
137
+ cq->irqn = eq->core.irqn;
137138
138139 return 0;
139140
140141 err_cq_add:
141
- mlx5_eq_del_cq(eq, cq);
142
+ mlx5_eq_del_cq(&eq->core, cq);
142143 err_cmd:
143
- memset(din, 0, sizeof(din));
144
- memset(dout, 0, sizeof(dout));
145144 MLX5_SET(destroy_cq_in, din, opcode, MLX5_CMD_OP_DESTROY_CQ);
146145 MLX5_SET(destroy_cq_in, din, cqn, cq->cqn);
147
- mlx5_cmd_exec(dev, din, sizeof(din), dout, sizeof(dout));
146
+ MLX5_SET(destroy_cq_in, din, uid, cq->uid);
147
+ mlx5_cmd_exec_in(dev, destroy_cq, din);
148148 return err;
149149 }
150150 EXPORT_SYMBOL(mlx5_core_create_cq);
151151
152152 int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq)
153153 {
154
- u32 out[MLX5_ST_SZ_DW(destroy_cq_out)] = {0};
155
- u32 in[MLX5_ST_SZ_DW(destroy_cq_in)] = {0};
154
+ u32 in[MLX5_ST_SZ_DW(destroy_cq_in)] = {};
156155 int err;
157156
158
- err = mlx5_eq_del_cq(&dev->priv.eq_table.async_eq, cq);
159
- if (err)
160
- return err;
157
+ mlx5_debug_cq_remove(dev, cq);
161158
162
- err = mlx5_eq_del_cq(cq->eq, cq);
163
- if (err)
164
- return err;
159
+ mlx5_eq_del_cq(mlx5_get_async_eq(dev), cq);
160
+ mlx5_eq_del_cq(&cq->eq->core, cq);
165161
166162 MLX5_SET(destroy_cq_in, in, opcode, MLX5_CMD_OP_DESTROY_CQ);
167163 MLX5_SET(destroy_cq_in, in, cqn, cq->cqn);
168
- err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
164
+ MLX5_SET(destroy_cq_in, in, uid, cq->uid);
165
+ err = mlx5_cmd_exec_in(dev, destroy_cq, in);
169166 if (err)
170167 return err;
171168
172169 synchronize_irq(cq->irqn);
173
-
174
- mlx5_debug_cq_remove(dev, cq);
175170 mlx5_cq_put(cq);
176171 wait_for_completion(&cq->free);
177172
....@@ -180,22 +175,23 @@
180175 EXPORT_SYMBOL(mlx5_core_destroy_cq);
181176
182177 int mlx5_core_query_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
183
- u32 *out, int outlen)
178
+ u32 *out)
184179 {
185
- u32 in[MLX5_ST_SZ_DW(query_cq_in)] = {0};
180
+ u32 in[MLX5_ST_SZ_DW(query_cq_in)] = {};
186181
187182 MLX5_SET(query_cq_in, in, opcode, MLX5_CMD_OP_QUERY_CQ);
188183 MLX5_SET(query_cq_in, in, cqn, cq->cqn);
189
- return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
184
+ return mlx5_cmd_exec_inout(dev, query_cq, in, out);
190185 }
191186 EXPORT_SYMBOL(mlx5_core_query_cq);
192187
193188 int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
194189 u32 *in, int inlen)
195190 {
196
- u32 out[MLX5_ST_SZ_DW(modify_cq_out)] = {0};
191
+ u32 out[MLX5_ST_SZ_DW(modify_cq_out)] = {};
197192
198193 MLX5_SET(modify_cq_in, in, opcode, MLX5_CMD_OP_MODIFY_CQ);
194
+ MLX5_SET(modify_cq_in, in, uid, cq->uid);
199195 return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
200196 }
201197 EXPORT_SYMBOL(mlx5_core_modify_cq);
....@@ -205,7 +201,7 @@
205201 u16 cq_period,
206202 u16 cq_max_count)
207203 {
208
- u32 in[MLX5_ST_SZ_DW(modify_cq_in)] = {0};
204
+ u32 in[MLX5_ST_SZ_DW(modify_cq_in)] = {};
209205 void *cqc;
210206
211207 MLX5_SET(modify_cq_in, in, cqn, cq->cqn);