Lines Matching +full:- +full:eq
1 // SPDX-License-Identifier: GPL-2.0
14 struct hw_eq *eq = NULL; in efct_hw_init_queues() local
24 hw->eq_count = 0; in efct_hw_init_queues()
25 hw->cq_count = 0; in efct_hw_init_queues()
26 hw->mq_count = 0; in efct_hw_init_queues()
27 hw->wq_count = 0; in efct_hw_init_queues()
28 hw->rq_count = 0; in efct_hw_init_queues()
29 hw->hw_rq_count = 0; in efct_hw_init_queues()
30 INIT_LIST_HEAD(&hw->eq_list); in efct_hw_init_queues()
32 for (i = 0; i < hw->config.n_eq; i++) { in efct_hw_init_queues()
33 /* Create EQ */ in efct_hw_init_queues()
34 eq = efct_hw_new_eq(hw, EFCT_HW_EQ_DEPTH); in efct_hw_init_queues()
35 if (!eq) { in efct_hw_init_queues()
37 return -ENOMEM; in efct_hw_init_queues()
40 eqs[i] = eq; in efct_hw_init_queues()
44 cq = efct_hw_new_cq(eq, in efct_hw_init_queues()
45 hw->num_qentries[SLI4_QTYPE_CQ]); in efct_hw_init_queues()
48 return -ENOMEM; in efct_hw_init_queues()
54 return -ENOMEM; in efct_hw_init_queues()
59 cq = efct_hw_new_cq(eq, hw->num_qentries[SLI4_QTYPE_CQ]); in efct_hw_init_queues()
62 return -ENOMEM; in efct_hw_init_queues()
65 wq = efct_hw_new_wq(cq, hw->num_qentries[SLI4_QTYPE_WQ]); in efct_hw_init_queues()
68 return -ENOMEM; in efct_hw_init_queues()
73 if (efct_hw_new_cq_set(eqs, cqs, i, hw->num_qentries[SLI4_QTYPE_CQ])) { in efct_hw_init_queues()
75 return -EIO; in efct_hw_init_queues()
81 return -EIO; in efct_hw_init_queues()
85 rqs[j]->filter_mask = 0; in efct_hw_init_queues()
86 rqs[j]->is_mrq = true; in efct_hw_init_queues()
87 rqs[j]->base_mrq_id = rqs[0]->hdr->id; in efct_hw_init_queues()
90 hw->hw_mrq_count = i; in efct_hw_init_queues()
98 struct efct *efct = hw->os; in efct_hw_map_wq_cpu()
102 hw->wq_cpu_array = kcalloc(num_possible_cpus(), sizeof(void *), in efct_hw_map_wq_cpu()
104 if (!hw->wq_cpu_array) in efct_hw_map_wq_cpu()
105 return -ENOMEM; in efct_hw_map_wq_cpu()
107 for (i = 0; i < hw->config.n_eq; i++) { in efct_hw_map_wq_cpu()
111 maskp = pci_irq_get_affinity(efct->pci, i); in efct_hw_map_wq_cpu()
120 hw->wq_cpu_array[cpu] = hw->hw_wq[i]; in efct_hw_map_wq_cpu()
130 struct hw_eq *eq = kzalloc(sizeof(*eq), GFP_KERNEL); in efct_hw_new_eq() local
132 if (!eq) in efct_hw_new_eq()
135 eq->type = SLI4_QTYPE_EQ; in efct_hw_new_eq()
136 eq->hw = hw; in efct_hw_new_eq()
137 eq->entry_count = entry_count; in efct_hw_new_eq()
138 eq->instance = hw->eq_count++; in efct_hw_new_eq()
139 eq->queue = &hw->eq[eq->instance]; in efct_hw_new_eq()
140 INIT_LIST_HEAD(&eq->cq_list); in efct_hw_new_eq()
142 if (sli_queue_alloc(&hw->sli, SLI4_QTYPE_EQ, eq->queue, entry_count, in efct_hw_new_eq()
144 efc_log_err(hw->os, "EQ[%d] alloc failure\n", eq->instance); in efct_hw_new_eq()
145 kfree(eq); in efct_hw_new_eq()
149 sli_eq_modify_delay(&hw->sli, eq->queue, 1, 0, 8); in efct_hw_new_eq()
150 hw->hw_eq[eq->instance] = eq; in efct_hw_new_eq()
151 INIT_LIST_HEAD(&eq->list_entry); in efct_hw_new_eq()
152 list_add_tail(&eq->list_entry, &hw->eq_list); in efct_hw_new_eq()
153 efc_log_debug(hw->os, "create eq[%2d] id %3d len %4d\n", eq->instance, in efct_hw_new_eq()
154 eq->queue->id, eq->entry_count); in efct_hw_new_eq()
155 return eq; in efct_hw_new_eq()
159 efct_hw_new_cq(struct hw_eq *eq, u32 entry_count) in efct_hw_new_cq() argument
161 struct efct_hw *hw = eq->hw; in efct_hw_new_cq()
167 cq->eq = eq; in efct_hw_new_cq()
168 cq->type = SLI4_QTYPE_CQ; in efct_hw_new_cq()
169 cq->instance = eq->hw->cq_count++; in efct_hw_new_cq()
170 cq->entry_count = entry_count; in efct_hw_new_cq()
171 cq->queue = &hw->cq[cq->instance]; in efct_hw_new_cq()
173 INIT_LIST_HEAD(&cq->q_list); in efct_hw_new_cq()
175 if (sli_queue_alloc(&hw->sli, SLI4_QTYPE_CQ, cq->queue, in efct_hw_new_cq()
176 cq->entry_count, eq->queue)) { in efct_hw_new_cq()
177 efc_log_err(hw->os, "CQ[%d] allocation failure len=%d\n", in efct_hw_new_cq()
178 eq->instance, eq->entry_count); in efct_hw_new_cq()
183 hw->hw_cq[cq->instance] = cq; in efct_hw_new_cq()
184 INIT_LIST_HEAD(&cq->list_entry); in efct_hw_new_cq()
185 list_add_tail(&cq->list_entry, &eq->cq_list); in efct_hw_new_cq()
186 efc_log_debug(hw->os, "create cq[%2d] id %3d len %4d\n", cq->instance, in efct_hw_new_cq()
187 cq->queue->id, cq->entry_count); in efct_hw_new_cq()
196 struct efct_hw *hw = eqs[0]->hw; in efct_hw_new_cq_set()
197 struct sli4 *sli4 = &hw->sli; in efct_hw_new_cq_set()
212 cq->eq = eqs[i]; in efct_hw_new_cq_set()
213 cq->type = SLI4_QTYPE_CQ; in efct_hw_new_cq_set()
214 cq->instance = hw->cq_count++; in efct_hw_new_cq_set()
215 cq->entry_count = entry_count; in efct_hw_new_cq_set()
216 cq->queue = &hw->cq[cq->instance]; in efct_hw_new_cq_set()
217 qs[i] = cq->queue; in efct_hw_new_cq_set()
218 assefct[i] = eqs[i]->queue; in efct_hw_new_cq_set()
219 INIT_LIST_HEAD(&cq->q_list); in efct_hw_new_cq_set()
223 efc_log_err(hw->os, "Failed to create CQ Set.\n"); in efct_hw_new_cq_set()
228 hw->hw_cq[cqs[i]->instance] = cqs[i]; in efct_hw_new_cq_set()
229 INIT_LIST_HEAD(&cqs[i]->list_entry); in efct_hw_new_cq_set()
230 list_add_tail(&cqs[i]->list_entry, &cqs[i]->eq->cq_list); in efct_hw_new_cq_set()
240 return -EIO; in efct_hw_new_cq_set()
246 struct efct_hw *hw = cq->eq->hw; in efct_hw_new_mq()
252 mq->cq = cq; in efct_hw_new_mq()
253 mq->type = SLI4_QTYPE_MQ; in efct_hw_new_mq()
254 mq->instance = cq->eq->hw->mq_count++; in efct_hw_new_mq()
255 mq->entry_count = entry_count; in efct_hw_new_mq()
256 mq->entry_size = EFCT_HW_MQ_DEPTH; in efct_hw_new_mq()
257 mq->queue = &hw->mq[mq->instance]; in efct_hw_new_mq()
259 if (sli_queue_alloc(&hw->sli, SLI4_QTYPE_MQ, mq->queue, mq->entry_size, in efct_hw_new_mq()
260 cq->queue)) { in efct_hw_new_mq()
261 efc_log_err(hw->os, "MQ allocation failure\n"); in efct_hw_new_mq()
266 hw->hw_mq[mq->instance] = mq; in efct_hw_new_mq()
267 INIT_LIST_HEAD(&mq->list_entry); in efct_hw_new_mq()
268 list_add_tail(&mq->list_entry, &cq->q_list); in efct_hw_new_mq()
269 efc_log_debug(hw->os, "create mq[%2d] id %3d len %4d\n", mq->instance, in efct_hw_new_mq()
270 mq->queue->id, mq->entry_count); in efct_hw_new_mq()
277 struct efct_hw *hw = cq->eq->hw; in efct_hw_new_wq()
283 wq->hw = cq->eq->hw; in efct_hw_new_wq()
284 wq->cq = cq; in efct_hw_new_wq()
285 wq->type = SLI4_QTYPE_WQ; in efct_hw_new_wq()
286 wq->instance = cq->eq->hw->wq_count++; in efct_hw_new_wq()
287 wq->entry_count = entry_count; in efct_hw_new_wq()
288 wq->queue = &hw->wq[wq->instance]; in efct_hw_new_wq()
289 wq->wqec_set_count = EFCT_HW_WQEC_SET_COUNT; in efct_hw_new_wq()
290 wq->wqec_count = wq->wqec_set_count; in efct_hw_new_wq()
291 wq->free_count = wq->entry_count - 1; in efct_hw_new_wq()
292 INIT_LIST_HEAD(&wq->pending_list); in efct_hw_new_wq()
294 if (sli_queue_alloc(&hw->sli, SLI4_QTYPE_WQ, wq->queue, in efct_hw_new_wq()
295 wq->entry_count, cq->queue)) { in efct_hw_new_wq()
296 efc_log_err(hw->os, "WQ allocation failure\n"); in efct_hw_new_wq()
301 hw->hw_wq[wq->instance] = wq; in efct_hw_new_wq()
302 INIT_LIST_HEAD(&wq->list_entry); in efct_hw_new_wq()
303 list_add_tail(&wq->list_entry, &cq->q_list); in efct_hw_new_wq()
304 efc_log_debug(hw->os, "create wq[%2d] id %3d len %4d cls %d\n", in efct_hw_new_wq()
305 wq->instance, wq->queue->id, wq->entry_count, wq->class); in efct_hw_new_wq()
313 struct efct_hw *hw = cqs[0]->eq->hw; in efct_hw_new_rq_set()
332 rq->instance = hw->hw_rq_count++; in efct_hw_new_rq_set()
333 rq->cq = cqs[i]; in efct_hw_new_rq_set()
334 rq->type = SLI4_QTYPE_RQ; in efct_hw_new_rq_set()
335 rq->entry_count = entry_count; in efct_hw_new_rq_set()
338 rq->hdr = &hw->rq[hw->rq_count]; in efct_hw_new_rq_set()
339 rq->hdr_entry_size = EFCT_HW_RQ_HEADER_SIZE; in efct_hw_new_rq_set()
340 hw->hw_rq_lookup[hw->rq_count] = rq->instance; in efct_hw_new_rq_set()
341 hw->rq_count++; in efct_hw_new_rq_set()
342 qs[q_count] = rq->hdr; in efct_hw_new_rq_set()
345 rq->data = &hw->rq[hw->rq_count]; in efct_hw_new_rq_set()
346 rq->data_entry_size = hw->config.rq_default_buffer_size; in efct_hw_new_rq_set()
347 hw->hw_rq_lookup[hw->rq_count] = rq->instance; in efct_hw_new_rq_set()
348 hw->rq_count++; in efct_hw_new_rq_set()
349 qs[q_count + 1] = rq->data; in efct_hw_new_rq_set()
351 rq->rq_tracker = NULL; in efct_hw_new_rq_set()
354 if (sli_fc_rq_set_alloc(&hw->sli, num_rq_pairs, qs, in efct_hw_new_rq_set()
355 cqs[0]->queue->id, in efct_hw_new_rq_set()
356 rqs[0]->entry_count, in efct_hw_new_rq_set()
357 rqs[0]->hdr_entry_size, in efct_hw_new_rq_set()
358 rqs[0]->data_entry_size)) { in efct_hw_new_rq_set()
359 efc_log_err(hw->os, "RQ Set alloc failure for base CQ=%d\n", in efct_hw_new_rq_set()
360 cqs[0]->queue->id); in efct_hw_new_rq_set()
365 hw->hw_rq[rqs[i]->instance] = rqs[i]; in efct_hw_new_rq_set()
366 INIT_LIST_HEAD(&rqs[i]->list_entry); in efct_hw_new_rq_set()
367 list_add_tail(&rqs[i]->list_entry, &cqs[i]->q_list); in efct_hw_new_rq_set()
368 size = sizeof(struct efc_hw_sequence *) * rqs[i]->entry_count; in efct_hw_new_rq_set()
369 rqs[i]->rq_tracker = kzalloc(size, GFP_KERNEL); in efct_hw_new_rq_set()
370 if (!rqs[i]->rq_tracker) in efct_hw_new_rq_set()
379 kfree(rqs[i]->rq_tracker); in efct_hw_new_rq_set()
384 return -EIO; in efct_hw_new_rq_set()
388 efct_hw_del_eq(struct hw_eq *eq) in efct_hw_del_eq() argument
393 if (!eq) in efct_hw_del_eq()
396 list_for_each_entry_safe(cq, cq_next, &eq->cq_list, list_entry) in efct_hw_del_eq()
398 list_del(&eq->list_entry); in efct_hw_del_eq()
399 eq->hw->hw_eq[eq->instance] = NULL; in efct_hw_del_eq()
400 kfree(eq); in efct_hw_del_eq()
412 list_for_each_entry_safe(q, q_next, &cq->q_list, list_entry) { in efct_hw_del_cq()
413 switch (q->type) { in efct_hw_del_cq()
427 list_del(&cq->list_entry); in efct_hw_del_cq()
428 cq->eq->hw->hw_cq[cq->instance] = NULL; in efct_hw_del_cq()
438 list_del(&mq->list_entry); in efct_hw_del_mq()
439 mq->cq->eq->hw->hw_mq[mq->instance] = NULL; in efct_hw_del_mq()
449 list_del(&wq->list_entry); in efct_hw_del_wq()
450 wq->cq->eq->hw->hw_wq[wq->instance] = NULL; in efct_hw_del_wq()
462 kfree(rq->rq_tracker); in efct_hw_del_rq()
463 rq->rq_tracker = NULL; in efct_hw_del_rq()
464 list_del(&rq->list_entry); in efct_hw_del_rq()
465 hw = rq->cq->eq->hw; in efct_hw_del_rq()
466 hw->hw_rq[rq->instance] = NULL; in efct_hw_del_rq()
473 struct hw_eq *eq; in efct_hw_queue_teardown() local
476 if (!hw->eq_list.next) in efct_hw_queue_teardown()
479 list_for_each_entry_safe(eq, eq_next, &hw->eq_list, list_entry) in efct_hw_queue_teardown()
480 efct_hw_del_eq(eq); in efct_hw_queue_teardown()
486 return efct_hw_queue_hash_find(hw->rq_hash, rq_id); in efct_hw_rqpair_find()
492 struct sli4_queue *rq_hdr = &hw->rq[rqindex]; in efct_hw_rqpair_get()
494 struct hw_rq *rq = hw->hw_rq[hw->hw_rq_lookup[rqindex]]; in efct_hw_rqpair_get()
497 if (bufindex >= rq_hdr->length) { in efct_hw_rqpair_get()
498 efc_log_err(hw->os, in efct_hw_rqpair_get()
500 rqindex, bufindex, rq_hdr->length, rq_hdr->id); in efct_hw_rqpair_get()
505 spin_lock_irqsave(&rq_hdr->lock, flags); in efct_hw_rqpair_get()
507 seq = rq->rq_tracker[bufindex]; in efct_hw_rqpair_get()
508 rq->rq_tracker[bufindex] = NULL; in efct_hw_rqpair_get()
511 efc_log_err(hw->os, in efct_hw_rqpair_get()
513 rqindex, bufindex, rq_hdr->index); in efct_hw_rqpair_get()
516 spin_unlock_irqrestore(&rq_hdr->lock, flags); in efct_hw_rqpair_get()
533 rq_status = sli_fc_rqe_rqid_and_index(&hw->sli, cqe, in efct_hw_rqpair_process_rq()
542 efc_log_debug(hw->os, in efct_hw_rqpair_process_rq()
553 efc_log_debug(hw->os, in efct_hw_rqpair_process_rq()
565 efc_log_debug(hw->os, "Warning: RCQE status=%#x,\n", in efct_hw_rqpair_process_rq()
571 return -EIO; in efct_hw_rqpair_process_rq()
576 efc_log_debug(hw->os, "Error: rq_id lookup failed for id=%#x\n", in efct_hw_rqpair_process_rq()
578 return -EIO; in efct_hw_rqpair_process_rq()
581 rq = hw->hw_rq[hw->hw_rq_lookup[rqindex]]; in efct_hw_rqpair_process_rq()
582 rq->use_count++; in efct_hw_rqpair_process_rq()
586 return -EIO; in efct_hw_rqpair_process_rq()
588 seq->hw = hw; in efct_hw_rqpair_process_rq()
590 sli_fc_rqe_length(&hw->sli, cqe, &h_len, &p_len); in efct_hw_rqpair_process_rq()
591 seq->header->dma.len = h_len; in efct_hw_rqpair_process_rq()
592 seq->payload->dma.len = p_len; in efct_hw_rqpair_process_rq()
593 seq->fcfi = sli_fc_rqe_fcfi(&hw->sli, cqe); in efct_hw_rqpair_process_rq()
594 seq->hw_priv = cq->eq; in efct_hw_rqpair_process_rq()
596 efct_unsolicited_cb(hw->os, seq); in efct_hw_rqpair_process_rq()
604 struct sli4_queue *rq_hdr = &hw->rq[seq->header->rqindex]; in efct_hw_rqpair_put()
605 struct sli4_queue *rq_payload = &hw->rq[seq->payload->rqindex]; in efct_hw_rqpair_put()
606 u32 hw_rq_index = hw->hw_rq_lookup[seq->header->rqindex]; in efct_hw_rqpair_put()
607 struct hw_rq *rq = hw->hw_rq[hw_rq_index]; in efct_hw_rqpair_put()
615 phys_hdr[0] = upper_32_bits(seq->header->dma.phys); in efct_hw_rqpair_put()
616 phys_hdr[1] = lower_32_bits(seq->header->dma.phys); in efct_hw_rqpair_put()
617 phys_payload[0] = upper_32_bits(seq->payload->dma.phys); in efct_hw_rqpair_put()
618 phys_payload[1] = lower_32_bits(seq->payload->dma.phys); in efct_hw_rqpair_put()
620 /* rq_hdr lock also covers payload / header->rqindex+1 queue */ in efct_hw_rqpair_put()
621 spin_lock_irqsave(&rq_hdr->lock, flags); in efct_hw_rqpair_put()
628 qindex_payload = sli_rq_write(&hw->sli, rq_payload, in efct_hw_rqpair_put()
630 qindex_hdr = sli_rq_write(&hw->sli, rq_hdr, (void *)phys_hdr); in efct_hw_rqpair_put()
633 efc_log_err(hw->os, "RQ_ID=%#x write failed\n", rq_hdr->id); in efct_hw_rqpair_put()
634 spin_unlock_irqrestore(&rq_hdr->lock, flags); in efct_hw_rqpair_put()
635 return -EIO; in efct_hw_rqpair_put()
642 if (!rq->rq_tracker[qindex_hdr]) { in efct_hw_rqpair_put()
643 rq->rq_tracker[qindex_hdr] = seq; in efct_hw_rqpair_put()
645 efc_log_debug(hw->os, in efct_hw_rqpair_put()
650 spin_unlock_irqrestore(&rq_hdr->lock, flags); in efct_hw_rqpair_put()
664 efc_log_err(hw->os, "error writing buffers\n"); in efct_hw_rqpair_sequence_free()
665 return -EIO; in efct_hw_rqpair_sequence_free()
674 struct efct *efct = efc->base; in efct_efc_hw_sequence_free()
676 return efct_hw_rqpair_sequence_free(&efct->hw, seq); in efct_efc_hw_sequence_free()