1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
9 #include <linux/types.h>
10 #include <asm/byteorder.h>
12 #include <linux/delay.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
16 #include <linux/list.h>
17 #include <linux/pci.h>
18 #include <linux/slab.h>
19 #include <linux/spinlock.h>
20 #include <linux/string.h>
23 #include "qed_dev_api.h"
28 #include "qed_reg_addr.h"
30 #include "qed_sriov.h"
32 /***************************************************************************
33 * Structures & Definitions
34 ***************************************************************************/
36 #define SPQ_HIGH_PRI_RESERVE_DEFAULT (1)
37 #define SPQ_BLOCK_SLEEP_LENGTH (1000)
39 /***************************************************************************
40 * Blocking Imp. (BLOCK/EBLOCK mode)
41 ***************************************************************************/
42 static void qed_spq_blocking_cb(struct qed_hwfn *p_hwfn,
44 union event_ring_data *data, u8 fw_return_code)
46 struct qed_spq_comp_done *comp_done;
48 comp_done = (struct qed_spq_comp_done *)cookie;
50 comp_done->done = 0x1;
51 comp_done->fw_return_code = fw_return_code;
53 /* make update visible to waiting thread */
57 static int qed_spq_block(struct qed_hwfn *p_hwfn,
58 struct qed_spq_entry *p_ent,
61 int sleep_count = SPQ_BLOCK_SLEEP_LENGTH;
62 struct qed_spq_comp_done *comp_done;
65 comp_done = (struct qed_spq_comp_done *)p_ent->comp_cb.cookie;
67 /* validate we receive completion update */
69 if (comp_done->done == 1) {
71 *p_fw_ret = comp_done->fw_return_code;
74 usleep_range(5000, 10000);
78 DP_INFO(p_hwfn, "Ramrod is stuck, requesting MCP drain\n");
79 rc = qed_mcp_drain(p_hwfn, p_hwfn->p_main_ptt);
81 DP_NOTICE(p_hwfn, "MCP drain failed\n");
83 /* Retry after drain */
84 sleep_count = SPQ_BLOCK_SLEEP_LENGTH;
86 /* validate we receive completion update */
88 if (comp_done->done == 1) {
90 *p_fw_ret = comp_done->fw_return_code;
93 usleep_range(5000, 10000);
97 if (comp_done->done == 1) {
99 *p_fw_ret = comp_done->fw_return_code;
103 DP_NOTICE(p_hwfn, "Ramrod is stuck, MCP drain failed\n");
108 /***************************************************************************
109 * SPQ entries inner API
110 ***************************************************************************/
111 static int qed_spq_fill_entry(struct qed_hwfn *p_hwfn,
112 struct qed_spq_entry *p_ent)
116 switch (p_ent->comp_mode) {
117 case QED_SPQ_MODE_EBLOCK:
118 case QED_SPQ_MODE_BLOCK:
119 p_ent->comp_cb.function = qed_spq_blocking_cb;
121 case QED_SPQ_MODE_CB:
124 DP_NOTICE(p_hwfn, "Unknown SPQE completion mode %d\n",
129 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
130 "Ramrod header: [CID 0x%08x CMD 0x%02x protocol 0x%02x] Data pointer: [%08x:%08x] Completion Mode: %s\n",
132 p_ent->elem.hdr.cmd_id,
133 p_ent->elem.hdr.protocol_id,
134 p_ent->elem.data_ptr.hi,
135 p_ent->elem.data_ptr.lo,
136 D_TRINE(p_ent->comp_mode, QED_SPQ_MODE_EBLOCK,
137 QED_SPQ_MODE_BLOCK, "MODE_EBLOCK", "MODE_BLOCK",
143 /***************************************************************************
145 ***************************************************************************/
146 static void qed_spq_hw_initialize(struct qed_hwfn *p_hwfn,
147 struct qed_spq *p_spq)
150 struct qed_cxt_info cxt_info;
151 struct core_conn_context *p_cxt;
152 union qed_qm_pq_params pq_params;
155 cxt_info.iid = p_spq->cid;
157 rc = qed_cxt_get_cid_info(p_hwfn, &cxt_info);
160 DP_NOTICE(p_hwfn, "Cannot find context info for cid=%d\n",
165 p_cxt = cxt_info.p_cxt;
167 SET_FIELD(p_cxt->xstorm_ag_context.flags10,
168 XSTORM_CORE_CONN_AG_CTX_DQ_CF_EN, 1);
169 SET_FIELD(p_cxt->xstorm_ag_context.flags1,
170 XSTORM_CORE_CONN_AG_CTX_DQ_CF_ACTIVE, 1);
171 SET_FIELD(p_cxt->xstorm_ag_context.flags9,
172 XSTORM_CORE_CONN_AG_CTX_CONSOLID_PROD_CF_EN, 1);
174 /* QM physical queue */
175 memset(&pq_params, 0, sizeof(pq_params));
176 pq_params.core.tc = LB_TC;
177 pq = qed_get_qm_pq(p_hwfn, PROTOCOLID_CORE, &pq_params);
178 p_cxt->xstorm_ag_context.physical_q0 = cpu_to_le16(pq);
180 p_cxt->xstorm_st_context.spq_base_lo =
181 DMA_LO_LE(p_spq->chain.p_phys_addr);
182 p_cxt->xstorm_st_context.spq_base_hi =
183 DMA_HI_LE(p_spq->chain.p_phys_addr);
185 DMA_REGPAIR_LE(p_cxt->xstorm_st_context.consolid_base_addr,
186 p_hwfn->p_consq->chain.p_phys_addr);
189 static int qed_spq_hw_post(struct qed_hwfn *p_hwfn,
190 struct qed_spq *p_spq, struct qed_spq_entry *p_ent)
192 struct qed_chain *p_chain = &p_hwfn->p_spq->chain;
193 u16 echo = qed_chain_get_prod_idx(p_chain);
194 struct slow_path_element *elem;
195 struct core_db_data db;
197 p_ent->elem.hdr.echo = cpu_to_le16(echo);
198 elem = qed_chain_produce(p_chain);
200 DP_NOTICE(p_hwfn, "Failed to produce from SPQ chain\n");
204 *elem = p_ent->elem; /* struct assignment */
206 /* send a doorbell on the slow hwfn session */
207 memset(&db, 0, sizeof(db));
208 SET_FIELD(db.params, CORE_DB_DATA_DEST, DB_DEST_XCM);
209 SET_FIELD(db.params, CORE_DB_DATA_AGG_CMD, DB_AGG_CMD_SET);
210 SET_FIELD(db.params, CORE_DB_DATA_AGG_VAL_SEL,
211 DQ_XCM_CORE_SPQ_PROD_CMD);
212 db.agg_flags = DQ_XCM_CORE_DQ_CF_CMD;
213 db.spq_prod = cpu_to_le16(qed_chain_get_prod_idx(p_chain));
215 /* make sure the SPQE is updated before the doorbell */
218 DOORBELL(p_hwfn, qed_db_addr(p_spq->cid, DQ_DEMS_LEGACY), *(u32 *)&db);
220 /* make sure doorbell is rang */
223 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
224 "Doorbelled [0x%08x, CID 0x%08x] with Flags: %02x agg_params: %02x, prod: %04x\n",
225 qed_db_addr(p_spq->cid, DQ_DEMS_LEGACY),
226 p_spq->cid, db.params, db.agg_flags,
227 qed_chain_get_prod_idx(p_chain));
232 /***************************************************************************
233 * Asynchronous events
234 ***************************************************************************/
236 qed_async_event_completion(struct qed_hwfn *p_hwfn,
237 struct event_ring_entry *p_eqe)
239 switch (p_eqe->protocol_id) {
240 case PROTOCOLID_COMMON:
241 return qed_sriov_eqe_event(p_hwfn,
243 p_eqe->echo, &p_eqe->data);
246 "Unknown Async completion for protocol: %d\n",
252 /***************************************************************************
254 ***************************************************************************/
255 void qed_eq_prod_update(struct qed_hwfn *p_hwfn, u16 prod)
257 u32 addr = GTT_BAR0_MAP_REG_USDM_RAM +
258 USTORM_EQE_CONS_OFFSET(p_hwfn->rel_pf_id);
260 REG_WR16(p_hwfn, addr, prod);
262 /* keep prod updates ordered */
266 int qed_eq_completion(struct qed_hwfn *p_hwfn, void *cookie)
268 struct qed_eq *p_eq = cookie;
269 struct qed_chain *p_chain = &p_eq->chain;
272 /* take a snapshot of the FW consumer */
273 u16 fw_cons_idx = le16_to_cpu(*p_eq->p_fw_cons);
275 DP_VERBOSE(p_hwfn, QED_MSG_SPQ, "fw_cons_idx %x\n", fw_cons_idx);
277 /* Need to guarantee the fw_cons index we use points to a usuable
278 * element (to comply with our chain), so our macros would comply
280 if ((fw_cons_idx & qed_chain_get_usable_per_page(p_chain)) ==
281 qed_chain_get_usable_per_page(p_chain))
282 fw_cons_idx += qed_chain_get_unusable_per_page(p_chain);
284 /* Complete current segment of eq entries */
285 while (fw_cons_idx != qed_chain_get_cons_idx(p_chain)) {
286 struct event_ring_entry *p_eqe = qed_chain_consume(p_chain);
293 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
294 "op %x prot %x res0 %x echo %x fwret %x flags %x\n",
298 le16_to_cpu(p_eqe->echo),
299 p_eqe->fw_return_code,
302 if (GET_FIELD(p_eqe->flags, EVENT_RING_ENTRY_ASYNC)) {
303 if (qed_async_event_completion(p_hwfn, p_eqe))
305 } else if (qed_spq_completion(p_hwfn,
307 p_eqe->fw_return_code,
312 qed_chain_recycle_consumed(p_chain);
315 qed_eq_prod_update(p_hwfn, qed_chain_get_prod_idx(p_chain));
320 struct qed_eq *qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
324 /* Allocate EQ struct */
325 p_eq = kzalloc(sizeof(*p_eq), GFP_KERNEL);
327 DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_eq'\n");
331 /* Allocate and initialize EQ chain*/
332 if (qed_chain_alloc(p_hwfn->cdev,
333 QED_CHAIN_USE_TO_PRODUCE,
335 QED_CHAIN_CNT_TYPE_U16,
337 sizeof(union event_ring_element),
339 DP_NOTICE(p_hwfn, "Failed to allocate eq chain\n");
340 goto eq_allocate_fail;
343 /* register EQ completion on the SP SB */
344 qed_int_register_cb(p_hwfn, qed_eq_completion,
345 p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons);
350 qed_eq_free(p_hwfn, p_eq);
354 void qed_eq_setup(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq)
356 qed_chain_reset(&p_eq->chain);
359 void qed_eq_free(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq)
363 qed_chain_free(p_hwfn->cdev, &p_eq->chain);
367 /***************************************************************************
368 * CQE API - manipulate EQ functionality
369 ***************************************************************************/
370 static int qed_cqe_completion(struct qed_hwfn *p_hwfn,
371 struct eth_slow_path_rx_cqe *cqe,
372 enum protocol_type protocol)
374 if (IS_VF(p_hwfn->cdev))
377 /* @@@tmp - it's possible we'll eventually want to handle some
378 * actual commands that can arrive here, but for now this is only
379 * used to complete the ramrod using the echo value on the cqe
381 return qed_spq_completion(p_hwfn, cqe->echo, 0, NULL);
384 int qed_eth_cqe_completion(struct qed_hwfn *p_hwfn,
385 struct eth_slow_path_rx_cqe *cqe)
389 rc = qed_cqe_completion(p_hwfn, cqe, PROTOCOLID_ETH);
392 "Failed to handle RXQ CQE [cmd 0x%02x]\n",
398 /***************************************************************************
399 * Slow hwfn Queue (spq)
400 ***************************************************************************/
401 void qed_spq_setup(struct qed_hwfn *p_hwfn)
403 struct qed_spq *p_spq = p_hwfn->p_spq;
404 struct qed_spq_entry *p_virt = NULL;
405 dma_addr_t p_phys = 0;
408 INIT_LIST_HEAD(&p_spq->pending);
409 INIT_LIST_HEAD(&p_spq->completion_pending);
410 INIT_LIST_HEAD(&p_spq->free_pool);
411 INIT_LIST_HEAD(&p_spq->unlimited_pending);
412 spin_lock_init(&p_spq->lock);
415 p_phys = p_spq->p_phys + offsetof(struct qed_spq_entry, ramrod);
416 p_virt = p_spq->p_virt;
418 capacity = qed_chain_get_capacity(&p_spq->chain);
419 for (i = 0; i < capacity; i++) {
420 DMA_REGPAIR_LE(p_virt->elem.data_ptr, p_phys);
422 list_add_tail(&p_virt->list, &p_spq->free_pool);
425 p_phys += sizeof(struct qed_spq_entry);
429 p_spq->normal_count = 0;
430 p_spq->comp_count = 0;
431 p_spq->comp_sent_count = 0;
432 p_spq->unlimited_pending_count = 0;
434 bitmap_zero(p_spq->p_comp_bitmap, SPQ_RING_SIZE);
435 p_spq->comp_bitmap_idx = 0;
437 /* SPQ cid, cannot fail */
438 qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_CORE, &p_spq->cid);
439 qed_spq_hw_initialize(p_hwfn, p_spq);
441 /* reset the chain itself */
442 qed_chain_reset(&p_spq->chain);
445 int qed_spq_alloc(struct qed_hwfn *p_hwfn)
447 struct qed_spq_entry *p_virt = NULL;
448 struct qed_spq *p_spq = NULL;
449 dma_addr_t p_phys = 0;
453 p_spq = kzalloc(sizeof(struct qed_spq), GFP_KERNEL);
455 DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_spq'\n");
460 if (qed_chain_alloc(p_hwfn->cdev,
461 QED_CHAIN_USE_TO_PRODUCE,
462 QED_CHAIN_MODE_SINGLE,
463 QED_CHAIN_CNT_TYPE_U16,
464 0, /* N/A when the mode is SINGLE */
465 sizeof(struct slow_path_element),
467 DP_NOTICE(p_hwfn, "Failed to allocate spq chain\n");
468 goto spq_allocate_fail;
471 /* allocate and fill the SPQ elements (incl. ramrod data list) */
472 capacity = qed_chain_get_capacity(&p_spq->chain);
473 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
475 sizeof(struct qed_spq_entry),
476 &p_phys, GFP_KERNEL);
479 goto spq_allocate_fail;
481 p_spq->p_virt = p_virt;
482 p_spq->p_phys = p_phys;
483 p_hwfn->p_spq = p_spq;
488 qed_chain_free(p_hwfn->cdev, &p_spq->chain);
493 void qed_spq_free(struct qed_hwfn *p_hwfn)
495 struct qed_spq *p_spq = p_hwfn->p_spq;
502 capacity = qed_chain_get_capacity(&p_spq->chain);
503 dma_free_coherent(&p_hwfn->cdev->pdev->dev,
505 sizeof(struct qed_spq_entry),
506 p_spq->p_virt, p_spq->p_phys);
509 qed_chain_free(p_hwfn->cdev, &p_spq->chain);
514 int qed_spq_get_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry **pp_ent)
516 struct qed_spq *p_spq = p_hwfn->p_spq;
517 struct qed_spq_entry *p_ent = NULL;
520 spin_lock_bh(&p_spq->lock);
522 if (list_empty(&p_spq->free_pool)) {
523 p_ent = kzalloc(sizeof(*p_ent), GFP_ATOMIC);
526 "Failed to allocate an SPQ entry for a pending ramrod\n");
530 p_ent->queue = &p_spq->unlimited_pending;
532 p_ent = list_first_entry(&p_spq->free_pool,
533 struct qed_spq_entry, list);
534 list_del(&p_ent->list);
535 p_ent->queue = &p_spq->pending;
541 spin_unlock_bh(&p_spq->lock);
545 /* Locked variant; Should be called while the SPQ lock is taken */
546 static void __qed_spq_return_entry(struct qed_hwfn *p_hwfn,
547 struct qed_spq_entry *p_ent)
549 list_add_tail(&p_ent->list, &p_hwfn->p_spq->free_pool);
552 void qed_spq_return_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry *p_ent)
554 spin_lock_bh(&p_hwfn->p_spq->lock);
555 __qed_spq_return_entry(p_hwfn, p_ent);
556 spin_unlock_bh(&p_hwfn->p_spq->lock);
560 * @brief qed_spq_add_entry - adds a new entry to the pending
561 * list. Should be used while lock is being held.
563 * Addes an entry to the pending list is there is room (en empty
564 * element is available in the free_pool), or else places the
565 * entry in the unlimited_pending pool.
573 static int qed_spq_add_entry(struct qed_hwfn *p_hwfn,
574 struct qed_spq_entry *p_ent,
575 enum spq_priority priority)
577 struct qed_spq *p_spq = p_hwfn->p_spq;
579 if (p_ent->queue == &p_spq->unlimited_pending) {
581 if (list_empty(&p_spq->free_pool)) {
582 list_add_tail(&p_ent->list, &p_spq->unlimited_pending);
583 p_spq->unlimited_pending_count++;
587 struct qed_spq_entry *p_en2;
589 p_en2 = list_first_entry(&p_spq->free_pool,
590 struct qed_spq_entry, list);
591 list_del(&p_en2->list);
593 /* Copy the ring element physical pointer to the new
594 * entry, since we are about to override the entire ring
595 * entry and don't want to lose the pointer.
597 p_ent->elem.data_ptr = p_en2->elem.data_ptr;
601 /* EBLOCK responsible to free the allocated p_ent */
602 if (p_ent->comp_mode != QED_SPQ_MODE_EBLOCK)
609 /* entry is to be placed in 'pending' queue */
611 case QED_SPQ_PRIORITY_NORMAL:
612 list_add_tail(&p_ent->list, &p_spq->pending);
613 p_spq->normal_count++;
615 case QED_SPQ_PRIORITY_HIGH:
616 list_add(&p_ent->list, &p_spq->pending);
626 /***************************************************************************
628 ***************************************************************************/
629 u32 qed_spq_get_cid(struct qed_hwfn *p_hwfn)
632 return 0xffffffff; /* illegal */
633 return p_hwfn->p_spq->cid;
636 /***************************************************************************
637 * Posting new Ramrods
638 ***************************************************************************/
639 static int qed_spq_post_list(struct qed_hwfn *p_hwfn,
640 struct list_head *head, u32 keep_reserve)
642 struct qed_spq *p_spq = p_hwfn->p_spq;
645 while (qed_chain_get_elem_left(&p_spq->chain) > keep_reserve &&
647 struct qed_spq_entry *p_ent =
648 list_first_entry(head, struct qed_spq_entry, list);
649 list_del(&p_ent->list);
650 list_add_tail(&p_ent->list, &p_spq->completion_pending);
651 p_spq->comp_sent_count++;
653 rc = qed_spq_hw_post(p_hwfn, p_spq, p_ent);
655 list_del(&p_ent->list);
656 __qed_spq_return_entry(p_hwfn, p_ent);
664 static int qed_spq_pend_post(struct qed_hwfn *p_hwfn)
666 struct qed_spq *p_spq = p_hwfn->p_spq;
667 struct qed_spq_entry *p_ent = NULL;
669 while (!list_empty(&p_spq->free_pool)) {
670 if (list_empty(&p_spq->unlimited_pending))
673 p_ent = list_first_entry(&p_spq->unlimited_pending,
674 struct qed_spq_entry, list);
678 list_del(&p_ent->list);
680 qed_spq_add_entry(p_hwfn, p_ent, p_ent->priority);
683 return qed_spq_post_list(p_hwfn, &p_spq->pending,
684 SPQ_HIGH_PRI_RESERVE_DEFAULT);
687 int qed_spq_post(struct qed_hwfn *p_hwfn,
688 struct qed_spq_entry *p_ent, u8 *fw_return_code)
691 struct qed_spq *p_spq = p_hwfn ? p_hwfn->p_spq : NULL;
692 bool b_ret_ent = true;
698 DP_NOTICE(p_hwfn, "Got a NULL pointer\n");
702 /* Complete the entry */
703 rc = qed_spq_fill_entry(p_hwfn, p_ent);
705 spin_lock_bh(&p_spq->lock);
707 /* Check return value after LOCK is taken for cleaner error flow */
711 /* Add the request to the pending queue */
712 rc = qed_spq_add_entry(p_hwfn, p_ent, p_ent->priority);
716 rc = qed_spq_pend_post(p_hwfn);
718 /* Since it's possible that pending failed for a different
719 * entry [although unlikely], the failed entry was already
720 * dealt with; No need to return it here.
726 spin_unlock_bh(&p_spq->lock);
728 if (p_ent->comp_mode == QED_SPQ_MODE_EBLOCK) {
729 /* For entries in QED BLOCK mode, the completion code cannot
730 * perform the necessary cleanup - if it did, we couldn't
731 * access p_ent here to see whether it's successful or not.
732 * Thus, after gaining the answer perform the cleanup here.
734 rc = qed_spq_block(p_hwfn, p_ent, fw_return_code);
736 if (p_ent->queue == &p_spq->unlimited_pending) {
737 /* This is an allocated p_ent which does not need to
748 qed_spq_return_entry(p_hwfn, p_ent);
753 spin_lock_bh(&p_spq->lock);
754 list_del(&p_ent->list);
755 qed_chain_return_produced(&p_spq->chain);
758 /* return to the free pool */
760 __qed_spq_return_entry(p_hwfn, p_ent);
761 spin_unlock_bh(&p_spq->lock);
766 int qed_spq_completion(struct qed_hwfn *p_hwfn,
769 union event_ring_data *p_data)
771 struct qed_spq *p_spq;
772 struct qed_spq_entry *p_ent = NULL;
773 struct qed_spq_entry *tmp;
774 struct qed_spq_entry *found = NULL;
780 p_spq = p_hwfn->p_spq;
784 spin_lock_bh(&p_spq->lock);
785 list_for_each_entry_safe(p_ent, tmp, &p_spq->completion_pending, list) {
786 if (p_ent->elem.hdr.echo == echo) {
787 u16 pos = le16_to_cpu(echo) % SPQ_RING_SIZE;
789 list_del(&p_ent->list);
791 /* Avoid overriding of SPQ entries when getting
792 * out-of-order completions, by marking the completions
793 * in a bitmap and increasing the chain consumer only
794 * for the first successive completed entries.
796 __set_bit(pos, p_spq->p_comp_bitmap);
798 while (test_bit(p_spq->comp_bitmap_idx,
799 p_spq->p_comp_bitmap)) {
800 __clear_bit(p_spq->comp_bitmap_idx,
801 p_spq->p_comp_bitmap);
802 p_spq->comp_bitmap_idx++;
803 qed_chain_return_produced(&p_spq->chain);
811 /* This is relatively uncommon - depends on scenarios
812 * which have mutliple per-PF sent ramrods.
814 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
815 "Got completion for echo %04x - doesn't match echo %04x in completion pending list\n",
817 le16_to_cpu(p_ent->elem.hdr.echo));
820 /* Release lock before callback, as callback may post
821 * an additional ramrod.
823 spin_unlock_bh(&p_spq->lock);
827 "Failed to find an entry this EQE completes\n");
831 DP_VERBOSE(p_hwfn, QED_MSG_SPQ, "Complete: func %p cookie %p)\n",
832 p_ent->comp_cb.function, p_ent->comp_cb.cookie);
833 if (found->comp_cb.function)
834 found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data,
837 if ((found->comp_mode != QED_SPQ_MODE_EBLOCK) ||
838 (found->queue == &p_spq->unlimited_pending))
839 /* EBLOCK is responsible for returning its own entry into the
840 * free list, unless it originally added the entry into the
841 * unlimited pending list.
843 qed_spq_return_entry(p_hwfn, found);
845 /* Attempt to post pending requests */
846 spin_lock_bh(&p_spq->lock);
847 rc = qed_spq_pend_post(p_hwfn);
848 spin_unlock_bh(&p_spq->lock);
853 struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn)
855 struct qed_consq *p_consq;
857 /* Allocate ConsQ struct */
858 p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL);
860 DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_consq'\n");
864 /* Allocate and initialize EQ chain*/
865 if (qed_chain_alloc(p_hwfn->cdev,
866 QED_CHAIN_USE_TO_PRODUCE,
868 QED_CHAIN_CNT_TYPE_U16,
869 QED_CHAIN_PAGE_SIZE / 0x80,
870 0x80, &p_consq->chain)) {
871 DP_NOTICE(p_hwfn, "Failed to allocate consq chain");
872 goto consq_allocate_fail;
878 qed_consq_free(p_hwfn, p_consq);
882 void qed_consq_setup(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq)
884 qed_chain_reset(&p_consq->chain);
887 void qed_consq_free(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq)
891 qed_chain_free(p_hwfn->cdev, &p_consq->chain);