39 #include <linux/export.h>
47 #define MLX4_CQ_STATUS_OK ( 0 << 28)
48 #define MLX4_CQ_STATUS_OVERFLOW ( 9 << 28)
49 #define MLX4_CQ_STATUS_WRITE_FAIL (10 << 28)
50 #define MLX4_CQ_FLAG_CC ( 1 << 18)
51 #define MLX4_CQ_FLAG_OI ( 1 << 17)
52 #define MLX4_CQ_STATE_ARMED ( 9 << 8)
53 #define MLX4_CQ_STATE_ARMED_SOL ( 6 << 8)
54 #define MLX4_EQ_STATE_FIRED (10 << 8)
61 cqn & (dev->
caps.num_cqs - 1));
63 mlx4_dbg(dev,
"Completion event for bogus CQ %08x\n", cqn);
77 spin_lock(&cq_table->
lock);
83 spin_unlock(&cq_table->
lock);
86 mlx4_warn(dev,
"Async event for bogus CQ %08x\n", cqn);
90 cq->
event(cq, event_type);
105 int cq_num,
u32 opmod)
114 return mlx4_cmd_box(dev, 0, mailbox ? mailbox->
dma : 0,
128 return PTR_ERR(mailbox);
130 cq_context = mailbox->
buf;
131 memset(cq_context, 0,
sizeof *cq_context);
136 err = mlx4_MODIFY_CQ(dev, mailbox, cq->
cqn, 1);
153 return PTR_ERR(mailbox);
155 cq_context = mailbox->
buf;
156 memset(cq_context, 0,
sizeof *cq_context);
164 err = mlx4_MODIFY_CQ(dev, mailbox, cq->
cqn, 0);
203 if (mlx4_is_mfunc(dev)) {
204 err = mlx4_cmd_imm(dev, 0, &out_param,
RES_CQ,
210 *cqn = get_param_l(&out_param);
227 static void mlx4_cq_free_icm(
struct mlx4_dev *dev,
int cqn)
232 if (mlx4_is_mfunc(dev)) {
233 set_param_l(&in_param, cqn);
238 mlx4_warn(dev,
"Failed freeing cq:%d\n", cqn);
245 unsigned vector,
int collapsed)
254 if (vector > dev->
caps.num_comp_vectors + dev->
caps.comp_pool)
259 err = mlx4_cq_alloc_icm(dev, &cq->
cqn);
263 spin_lock_irq(&cq_table->
lock);
265 spin_unlock_irq(&cq_table->
lock);
270 if (IS_ERR(mailbox)) {
271 err = PTR_ERR(mailbox);
275 cq_context = mailbox->
buf;
276 memset(cq_context, 0,
sizeof *cq_context);
288 err = mlx4_SW2HW_CQ(dev, mailbox, cq->
cqn);
297 init_completion(&cq->
free);
302 spin_lock_irq(&cq_table->
lock);
304 spin_unlock_irq(&cq_table->
lock);
307 mlx4_cq_free_icm(dev, cq->
cqn);
319 err = mlx4_HW2SW_CQ(dev,
NULL, cq->
cqn);
321 mlx4_warn(dev,
"HW2SW_CQ failed (%d) for CQN %06x\n", err, cq->
cqn);
325 spin_lock_irq(&cq_table->
lock);
327 spin_unlock_irq(&cq_table->
lock);
333 mlx4_cq_free_icm(dev, cq->
cqn);
344 if (mlx4_is_slave(dev))
348 dev->
caps.num_cqs - 1, dev->
caps.reserved_cqs, 0);
357 if (mlx4_is_slave(dev))