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);
329 /* Allocate and initialize EQ chain*/
330 if (qed_chain_alloc(p_hwfn->cdev,
331 QED_CHAIN_USE_TO_PRODUCE,
333 QED_CHAIN_CNT_TYPE_U16,
335 sizeof(union event_ring_element),
337 goto eq_allocate_fail;
339 /* register EQ completion on the SP SB */
340 qed_int_register_cb(p_hwfn, qed_eq_completion,
341 p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons);
346 qed_eq_free(p_hwfn, p_eq);
350 void qed_eq_setup(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq)
352 qed_chain_reset(&p_eq->chain);
355 void qed_eq_free(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq)
359 qed_chain_free(p_hwfn->cdev, &p_eq->chain);
363 /***************************************************************************
364 * CQE API - manipulate EQ functionality
365 ***************************************************************************/
366 static int qed_cqe_completion(struct qed_hwfn *p_hwfn,
367 struct eth_slow_path_rx_cqe *cqe,
368 enum protocol_type protocol)
370 if (IS_VF(p_hwfn->cdev))
373 /* @@@tmp - it's possible we'll eventually want to handle some
374 * actual commands that can arrive here, but for now this is only
375 * used to complete the ramrod using the echo value on the cqe
377 return qed_spq_completion(p_hwfn, cqe->echo, 0, NULL);
380 int qed_eth_cqe_completion(struct qed_hwfn *p_hwfn,
381 struct eth_slow_path_rx_cqe *cqe)
385 rc = qed_cqe_completion(p_hwfn, cqe, PROTOCOLID_ETH);
388 "Failed to handle RXQ CQE [cmd 0x%02x]\n",
394 /***************************************************************************
395 * Slow hwfn Queue (spq)
396 ***************************************************************************/
397 void qed_spq_setup(struct qed_hwfn *p_hwfn)
399 struct qed_spq *p_spq = p_hwfn->p_spq;
400 struct qed_spq_entry *p_virt = NULL;
401 dma_addr_t p_phys = 0;
404 INIT_LIST_HEAD(&p_spq->pending);
405 INIT_LIST_HEAD(&p_spq->completion_pending);
406 INIT_LIST_HEAD(&p_spq->free_pool);
407 INIT_LIST_HEAD(&p_spq->unlimited_pending);
408 spin_lock_init(&p_spq->lock);
411 p_phys = p_spq->p_phys + offsetof(struct qed_spq_entry, ramrod);
412 p_virt = p_spq->p_virt;
414 capacity = qed_chain_get_capacity(&p_spq->chain);
415 for (i = 0; i < capacity; i++) {
416 DMA_REGPAIR_LE(p_virt->elem.data_ptr, p_phys);
418 list_add_tail(&p_virt->list, &p_spq->free_pool);
421 p_phys += sizeof(struct qed_spq_entry);
425 p_spq->normal_count = 0;
426 p_spq->comp_count = 0;
427 p_spq->comp_sent_count = 0;
428 p_spq->unlimited_pending_count = 0;
430 bitmap_zero(p_spq->p_comp_bitmap, SPQ_RING_SIZE);
431 p_spq->comp_bitmap_idx = 0;
433 /* SPQ cid, cannot fail */
434 qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_CORE, &p_spq->cid);
435 qed_spq_hw_initialize(p_hwfn, p_spq);
437 /* reset the chain itself */
438 qed_chain_reset(&p_spq->chain);
441 int qed_spq_alloc(struct qed_hwfn *p_hwfn)
443 struct qed_spq_entry *p_virt = NULL;
444 struct qed_spq *p_spq = NULL;
445 dma_addr_t p_phys = 0;
449 p_spq = kzalloc(sizeof(struct qed_spq), GFP_KERNEL);
454 if (qed_chain_alloc(p_hwfn->cdev,
455 QED_CHAIN_USE_TO_PRODUCE,
456 QED_CHAIN_MODE_SINGLE,
457 QED_CHAIN_CNT_TYPE_U16,
458 0, /* N/A when the mode is SINGLE */
459 sizeof(struct slow_path_element),
461 goto spq_allocate_fail;
463 /* allocate and fill the SPQ elements (incl. ramrod data list) */
464 capacity = qed_chain_get_capacity(&p_spq->chain);
465 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
466 capacity * sizeof(struct qed_spq_entry),
467 &p_phys, GFP_KERNEL);
469 goto spq_allocate_fail;
471 p_spq->p_virt = p_virt;
472 p_spq->p_phys = p_phys;
473 p_hwfn->p_spq = p_spq;
478 qed_chain_free(p_hwfn->cdev, &p_spq->chain);
483 void qed_spq_free(struct qed_hwfn *p_hwfn)
485 struct qed_spq *p_spq = p_hwfn->p_spq;
492 capacity = qed_chain_get_capacity(&p_spq->chain);
493 dma_free_coherent(&p_hwfn->cdev->pdev->dev,
495 sizeof(struct qed_spq_entry),
496 p_spq->p_virt, p_spq->p_phys);
499 qed_chain_free(p_hwfn->cdev, &p_spq->chain);
504 int qed_spq_get_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry **pp_ent)
506 struct qed_spq *p_spq = p_hwfn->p_spq;
507 struct qed_spq_entry *p_ent = NULL;
510 spin_lock_bh(&p_spq->lock);
512 if (list_empty(&p_spq->free_pool)) {
513 p_ent = kzalloc(sizeof(*p_ent), GFP_ATOMIC);
516 "Failed to allocate an SPQ entry for a pending ramrod\n");
520 p_ent->queue = &p_spq->unlimited_pending;
522 p_ent = list_first_entry(&p_spq->free_pool,
523 struct qed_spq_entry, list);
524 list_del(&p_ent->list);
525 p_ent->queue = &p_spq->pending;
531 spin_unlock_bh(&p_spq->lock);
535 /* Locked variant; Should be called while the SPQ lock is taken */
536 static void __qed_spq_return_entry(struct qed_hwfn *p_hwfn,
537 struct qed_spq_entry *p_ent)
539 list_add_tail(&p_ent->list, &p_hwfn->p_spq->free_pool);
542 void qed_spq_return_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry *p_ent)
544 spin_lock_bh(&p_hwfn->p_spq->lock);
545 __qed_spq_return_entry(p_hwfn, p_ent);
546 spin_unlock_bh(&p_hwfn->p_spq->lock);
550 * @brief qed_spq_add_entry - adds a new entry to the pending
551 * list. Should be used while lock is being held.
553 * Addes an entry to the pending list is there is room (en empty
554 * element is available in the free_pool), or else places the
555 * entry in the unlimited_pending pool.
563 static int qed_spq_add_entry(struct qed_hwfn *p_hwfn,
564 struct qed_spq_entry *p_ent,
565 enum spq_priority priority)
567 struct qed_spq *p_spq = p_hwfn->p_spq;
569 if (p_ent->queue == &p_spq->unlimited_pending) {
571 if (list_empty(&p_spq->free_pool)) {
572 list_add_tail(&p_ent->list, &p_spq->unlimited_pending);
573 p_spq->unlimited_pending_count++;
577 struct qed_spq_entry *p_en2;
579 p_en2 = list_first_entry(&p_spq->free_pool,
580 struct qed_spq_entry, list);
581 list_del(&p_en2->list);
583 /* Copy the ring element physical pointer to the new
584 * entry, since we are about to override the entire ring
585 * entry and don't want to lose the pointer.
587 p_ent->elem.data_ptr = p_en2->elem.data_ptr;
591 /* EBLOCK responsible to free the allocated p_ent */
592 if (p_ent->comp_mode != QED_SPQ_MODE_EBLOCK)
599 /* entry is to be placed in 'pending' queue */
601 case QED_SPQ_PRIORITY_NORMAL:
602 list_add_tail(&p_ent->list, &p_spq->pending);
603 p_spq->normal_count++;
605 case QED_SPQ_PRIORITY_HIGH:
606 list_add(&p_ent->list, &p_spq->pending);
616 /***************************************************************************
618 ***************************************************************************/
619 u32 qed_spq_get_cid(struct qed_hwfn *p_hwfn)
622 return 0xffffffff; /* illegal */
623 return p_hwfn->p_spq->cid;
626 /***************************************************************************
627 * Posting new Ramrods
628 ***************************************************************************/
629 static int qed_spq_post_list(struct qed_hwfn *p_hwfn,
630 struct list_head *head, u32 keep_reserve)
632 struct qed_spq *p_spq = p_hwfn->p_spq;
635 while (qed_chain_get_elem_left(&p_spq->chain) > keep_reserve &&
637 struct qed_spq_entry *p_ent =
638 list_first_entry(head, struct qed_spq_entry, list);
639 list_del(&p_ent->list);
640 list_add_tail(&p_ent->list, &p_spq->completion_pending);
641 p_spq->comp_sent_count++;
643 rc = qed_spq_hw_post(p_hwfn, p_spq, p_ent);
645 list_del(&p_ent->list);
646 __qed_spq_return_entry(p_hwfn, p_ent);
654 static int qed_spq_pend_post(struct qed_hwfn *p_hwfn)
656 struct qed_spq *p_spq = p_hwfn->p_spq;
657 struct qed_spq_entry *p_ent = NULL;
659 while (!list_empty(&p_spq->free_pool)) {
660 if (list_empty(&p_spq->unlimited_pending))
663 p_ent = list_first_entry(&p_spq->unlimited_pending,
664 struct qed_spq_entry, list);
668 list_del(&p_ent->list);
670 qed_spq_add_entry(p_hwfn, p_ent, p_ent->priority);
673 return qed_spq_post_list(p_hwfn, &p_spq->pending,
674 SPQ_HIGH_PRI_RESERVE_DEFAULT);
677 int qed_spq_post(struct qed_hwfn *p_hwfn,
678 struct qed_spq_entry *p_ent, u8 *fw_return_code)
681 struct qed_spq *p_spq = p_hwfn ? p_hwfn->p_spq : NULL;
682 bool b_ret_ent = true;
688 DP_NOTICE(p_hwfn, "Got a NULL pointer\n");
692 /* Complete the entry */
693 rc = qed_spq_fill_entry(p_hwfn, p_ent);
695 spin_lock_bh(&p_spq->lock);
697 /* Check return value after LOCK is taken for cleaner error flow */
701 /* Add the request to the pending queue */
702 rc = qed_spq_add_entry(p_hwfn, p_ent, p_ent->priority);
706 rc = qed_spq_pend_post(p_hwfn);
708 /* Since it's possible that pending failed for a different
709 * entry [although unlikely], the failed entry was already
710 * dealt with; No need to return it here.
716 spin_unlock_bh(&p_spq->lock);
718 if (p_ent->comp_mode == QED_SPQ_MODE_EBLOCK) {
719 /* For entries in QED BLOCK mode, the completion code cannot
720 * perform the necessary cleanup - if it did, we couldn't
721 * access p_ent here to see whether it's successful or not.
722 * Thus, after gaining the answer perform the cleanup here.
724 rc = qed_spq_block(p_hwfn, p_ent, fw_return_code);
726 if (p_ent->queue == &p_spq->unlimited_pending) {
727 /* This is an allocated p_ent which does not need to
738 qed_spq_return_entry(p_hwfn, p_ent);
743 spin_lock_bh(&p_spq->lock);
744 list_del(&p_ent->list);
745 qed_chain_return_produced(&p_spq->chain);
748 /* return to the free pool */
750 __qed_spq_return_entry(p_hwfn, p_ent);
751 spin_unlock_bh(&p_spq->lock);
756 int qed_spq_completion(struct qed_hwfn *p_hwfn,
759 union event_ring_data *p_data)
761 struct qed_spq *p_spq;
762 struct qed_spq_entry *p_ent = NULL;
763 struct qed_spq_entry *tmp;
764 struct qed_spq_entry *found = NULL;
770 p_spq = p_hwfn->p_spq;
774 spin_lock_bh(&p_spq->lock);
775 list_for_each_entry_safe(p_ent, tmp, &p_spq->completion_pending, list) {
776 if (p_ent->elem.hdr.echo == echo) {
777 u16 pos = le16_to_cpu(echo) % SPQ_RING_SIZE;
779 list_del(&p_ent->list);
781 /* Avoid overriding of SPQ entries when getting
782 * out-of-order completions, by marking the completions
783 * in a bitmap and increasing the chain consumer only
784 * for the first successive completed entries.
786 __set_bit(pos, p_spq->p_comp_bitmap);
788 while (test_bit(p_spq->comp_bitmap_idx,
789 p_spq->p_comp_bitmap)) {
790 __clear_bit(p_spq->comp_bitmap_idx,
791 p_spq->p_comp_bitmap);
792 p_spq->comp_bitmap_idx++;
793 qed_chain_return_produced(&p_spq->chain);
801 /* This is relatively uncommon - depends on scenarios
802 * which have mutliple per-PF sent ramrods.
804 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
805 "Got completion for echo %04x - doesn't match echo %04x in completion pending list\n",
807 le16_to_cpu(p_ent->elem.hdr.echo));
810 /* Release lock before callback, as callback may post
811 * an additional ramrod.
813 spin_unlock_bh(&p_spq->lock);
817 "Failed to find an entry this EQE [echo %04x] completes\n",
822 DP_VERBOSE(p_hwfn, QED_MSG_SPQ,
823 "Complete EQE [echo %04x]: func %p cookie %p)\n",
825 p_ent->comp_cb.function, p_ent->comp_cb.cookie);
826 if (found->comp_cb.function)
827 found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data,
832 "Got a completion without a callback function\n");
834 if ((found->comp_mode != QED_SPQ_MODE_EBLOCK) ||
835 (found->queue == &p_spq->unlimited_pending))
836 /* EBLOCK is responsible for returning its own entry into the
837 * free list, unless it originally added the entry into the
838 * unlimited pending list.
840 qed_spq_return_entry(p_hwfn, found);
842 /* Attempt to post pending requests */
843 spin_lock_bh(&p_spq->lock);
844 rc = qed_spq_pend_post(p_hwfn);
845 spin_unlock_bh(&p_spq->lock);
850 struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn)
852 struct qed_consq *p_consq;
854 /* Allocate ConsQ struct */
855 p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL);
859 /* Allocate and initialize EQ chain*/
860 if (qed_chain_alloc(p_hwfn->cdev,
861 QED_CHAIN_USE_TO_PRODUCE,
863 QED_CHAIN_CNT_TYPE_U16,
864 QED_CHAIN_PAGE_SIZE / 0x80,
865 0x80, &p_consq->chain))
866 goto consq_allocate_fail;
871 qed_consq_free(p_hwfn, p_consq);
875 void qed_consq_setup(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq)
877 qed_chain_reset(&p_consq->chain);
880 void qed_consq_free(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq)
884 qed_chain_free(p_hwfn->cdev, &p_consq->chain);