Lines Matching full:oct
39 static void __check_db_timeout(struct octeon_device *oct, u64 iq_no);
47 int octeon_init_instr_queue(struct octeon_device *oct, in octeon_init_instr_queue() argument
56 int numa_node = dev_to_node(&oct->pci_dev->dev); in octeon_init_instr_queue()
58 if (OCTEON_CN6XXX(oct)) in octeon_init_instr_queue()
59 conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn6xxx))); in octeon_init_instr_queue()
60 else if (OCTEON_CN23XX_PF(oct)) in octeon_init_instr_queue()
61 conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn23xx_pf))); in octeon_init_instr_queue()
62 else if (OCTEON_CN23XX_VF(oct)) in octeon_init_instr_queue()
63 conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn23xx_vf))); in octeon_init_instr_queue()
66 dev_err(&oct->pci_dev->dev, "Unsupported Chip %x\n", in octeon_init_instr_queue()
67 oct->chip_id); in octeon_init_instr_queue()
73 iq = oct->instr_queue[iq_no]; in octeon_init_instr_queue()
75 iq->oct_dev = oct; in octeon_init_instr_queue()
77 iq->base_addr = lio_dma_alloc(oct, q_size, &iq->base_addr_dma); in octeon_init_instr_queue()
79 dev_err(&oct->pci_dev->dev, "Cannot allocate memory for instr queue %d\n", in octeon_init_instr_queue()
94 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); in octeon_init_instr_queue()
95 dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", in octeon_init_instr_queue()
100 dev_dbg(&oct->pci_dev->dev, "IQ[%d]: base: %p basedma: %pad count: %d\n", in octeon_init_instr_queue()
126 oct->io_qmask.iq |= BIT_ULL(iq_no); in octeon_init_instr_queue()
129 oct->io_qmask.iq64B |= ((conf->instr_type == 64) << iq_no); in octeon_init_instr_queue()
132 oct->fn_list.setup_iq_regs(oct, iq_no); in octeon_init_instr_queue()
134 oct->check_db_wq[iq_no].wq = alloc_workqueue("check_iq_db", in octeon_init_instr_queue()
137 if (!oct->check_db_wq[iq_no].wq) { in octeon_init_instr_queue()
140 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); in octeon_init_instr_queue()
141 dev_err(&oct->pci_dev->dev, "check db wq create failed for iq %d\n", in octeon_init_instr_queue()
146 db_wq = &oct->check_db_wq[iq_no]; in octeon_init_instr_queue()
149 db_wq->wk.ctxptr = oct; in octeon_init_instr_queue()
156 int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no) in octeon_delete_instr_queue() argument
159 struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; in octeon_delete_instr_queue()
161 cancel_delayed_work_sync(&oct->check_db_wq[iq_no].wk.work); in octeon_delete_instr_queue()
162 destroy_workqueue(oct->check_db_wq[iq_no].wq); in octeon_delete_instr_queue()
164 if (OCTEON_CN6XXX(oct)) in octeon_delete_instr_queue()
166 CFG_GET_IQ_INSTR_TYPE(CHIP_CONF(oct, cn6xxx)); in octeon_delete_instr_queue()
167 else if (OCTEON_CN23XX_PF(oct)) in octeon_delete_instr_queue()
169 CFG_GET_IQ_INSTR_TYPE(CHIP_CONF(oct, cn23xx_pf)); in octeon_delete_instr_queue()
170 else if (OCTEON_CN23XX_VF(oct)) in octeon_delete_instr_queue()
172 CFG_GET_IQ_INSTR_TYPE(CHIP_CONF(oct, cn23xx_vf)); in octeon_delete_instr_queue()
178 lio_dma_free(oct, (u32)q_size, iq->base_addr, in octeon_delete_instr_queue()
180 oct->io_qmask.iq &= ~(1ULL << iq_no); in octeon_delete_instr_queue()
181 vfree(oct->instr_queue[iq_no]); in octeon_delete_instr_queue()
182 oct->instr_queue[iq_no] = NULL; in octeon_delete_instr_queue()
183 oct->num_iqs--; in octeon_delete_instr_queue()
191 int octeon_setup_iq(struct octeon_device *oct, in octeon_setup_iq() argument
199 int numa_node = dev_to_node(&oct->pci_dev->dev); in octeon_setup_iq()
201 if (oct->instr_queue[iq_no]) { in octeon_setup_iq()
202 dev_dbg(&oct->pci_dev->dev, "IQ is in use. Cannot create the IQ: %d again\n", in octeon_setup_iq()
204 oct->instr_queue[iq_no]->txpciq.u64 = txpciq.u64; in octeon_setup_iq()
205 oct->instr_queue[iq_no]->app_ctx = app_ctx; in octeon_setup_iq()
208 oct->instr_queue[iq_no] = in octeon_setup_iq()
210 if (!oct->instr_queue[iq_no]) in octeon_setup_iq()
211 oct->instr_queue[iq_no] = in octeon_setup_iq()
213 if (!oct->instr_queue[iq_no]) in octeon_setup_iq()
217 oct->instr_queue[iq_no]->q_index = q_index; in octeon_setup_iq()
218 oct->instr_queue[iq_no]->app_ctx = app_ctx; in octeon_setup_iq()
219 oct->instr_queue[iq_no]->ifidx = ifidx; in octeon_setup_iq()
221 if (octeon_init_instr_queue(oct, txpciq, num_descs)) { in octeon_setup_iq()
222 vfree(oct->instr_queue[iq_no]); in octeon_setup_iq()
223 oct->instr_queue[iq_no] = NULL; in octeon_setup_iq()
227 oct->num_iqs++; in octeon_setup_iq()
228 if (oct->fn_list.enable_io_queues(oct)) { in octeon_setup_iq()
229 octeon_delete_instr_queue(oct, iq_no); in octeon_setup_iq()
236 int lio_wait_for_instr_fetch(struct octeon_device *oct) in lio_wait_for_instr_fetch() argument
243 for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { in lio_wait_for_instr_fetch()
244 if (!(oct->io_qmask.iq & BIT_ULL(i))) in lio_wait_for_instr_fetch()
247 atomic_read(&oct->instr_queue[i]->instr_pending); in lio_wait_for_instr_fetch()
249 __check_db_timeout(oct, i); in lio_wait_for_instr_fetch()
265 ring_doorbell(struct octeon_device *oct, struct octeon_instr_queue *iq) in ring_doorbell() argument
267 if (atomic_read(&oct->status) == OCT_DEV_RUNNING) { in ring_doorbell()
277 octeon_ring_doorbell_locked(struct octeon_device *oct, u32 iq_no) in octeon_ring_doorbell_locked() argument
281 iq = oct->instr_queue[iq_no]; in octeon_ring_doorbell_locked()
284 ring_doorbell(oct, iq); in octeon_ring_doorbell_locked()
338 octeon_register_reqtype_free_fn(struct octeon_device *oct, int reqtype, in octeon_register_reqtype_free_fn() argument
342 dev_err(&oct->pci_dev->dev, "%s: Invalid reqtype: %d\n", in octeon_register_reqtype_free_fn()
347 reqtype_free_fn[oct->octeon_id][reqtype] = fn; in octeon_register_reqtype_free_fn()
363 lio_process_iq_request_list(struct octeon_device *oct, in lio_process_iq_request_list() argument
366 struct cavium_wq *cwq = &oct->dma_comp_wq; in lio_process_iq_request_list()
389 reqtype_free_fn[oct->octeon_id][reqtype](buf); in lio_process_iq_request_list()
400 spin_lock_irqsave(&oct->response_list in lio_process_iq_request_list()
402 atomic_inc(&oct->response_list in lio_process_iq_request_list()
404 list_add_tail(&sc->node, &oct->response_list in lio_process_iq_request_list()
406 spin_unlock_irqrestore(&oct->response_list in lio_process_iq_request_list()
411 dev_err(&oct->pci_dev->dev, in lio_process_iq_request_list()
431 if (atomic_read(&oct->response_list in lio_process_iq_request_list()
441 octeon_flush_iq(struct octeon_device *oct, struct octeon_instr_queue *iq, in octeon_flush_iq() argument
453 iq->octeon_read_index = oct->fn_list.update_iq_read_idx(iq); in octeon_flush_iq()
462 lio_process_iq_request_list(oct, iq, in octeon_flush_iq()
467 lio_process_iq_request_list(oct, iq, 0); in octeon_flush_iq()
493 static void __check_db_timeout(struct octeon_device *oct, u64 iq_no) in __check_db_timeout() argument
498 if (!oct) in __check_db_timeout()
501 iq = oct->instr_queue[iq_no]; in __check_db_timeout()
515 octeon_flush_iq(oct, iq, 0); in __check_db_timeout()
526 struct octeon_device *oct = (struct octeon_device *)wk->ctxptr; in check_db_timeout() local
528 struct cavium_wq *db_wq = &oct->check_db_wq[iq_no]; in check_db_timeout()
531 __check_db_timeout(oct, iq_no); in check_db_timeout()
536 octeon_send_command(struct octeon_device *oct, u32 iq_no, in octeon_send_command() argument
542 struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; in octeon_send_command()
555 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, bytes_sent, datasize); in octeon_send_command()
556 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, instr_posted, 1); in octeon_send_command()
560 ring_doorbell(oct, iq); in octeon_send_command()
562 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, instr_dropped, 1); in octeon_send_command()
577 octeon_prepare_soft_command(struct octeon_device *oct, in octeon_prepare_soft_command() argument
595 oct_cfg = octeon_get_conf(oct); in octeon_prepare_soft_command()
597 if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct)) { in octeon_prepare_soft_command()
600 ih3->pkind = oct->instr_queue[sc->iq_no]->txpciq.s.pkind; in octeon_prepare_soft_command()
608 oct->instr_queue[sc->iq_no]->txpciq.s.use_qpg; in octeon_prepare_soft_command()
613 oct->instr_queue[sc->iq_no]->txpciq.s.ctrl_qpg; in octeon_prepare_soft_command()
632 rdp->pcie_port = oct->pcie_port; in octeon_prepare_soft_command()
669 rdp->pcie_port = oct->pcie_port; in octeon_prepare_soft_command()
684 int octeon_send_soft_command(struct octeon_device *oct, in octeon_send_soft_command() argument
693 iq = oct->instr_queue[sc->iq_no]; in octeon_send_soft_command()
695 dev_err(&oct->pci_dev->dev, "Soft commands are not allowed on Queue %d\n", in octeon_send_soft_command()
697 INCR_INSTRQUEUE_PKT_COUNT(oct, sc->iq_no, instr_dropped, 1); in octeon_send_soft_command()
701 if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct)) { in octeon_send_soft_command()
733 return (octeon_send_command(oct, sc->iq_no, 1, &sc->cmd, sc, in octeon_send_soft_command()
738 int octeon_setup_sc_buffer_pool(struct octeon_device *oct) in octeon_setup_sc_buffer_pool() argument
744 INIT_LIST_HEAD(&oct->sc_buf_pool.head); in octeon_setup_sc_buffer_pool()
745 spin_lock_init(&oct->sc_buf_pool.lock); in octeon_setup_sc_buffer_pool()
746 atomic_set(&oct->sc_buf_pool.alloc_buf_count, 0); in octeon_setup_sc_buffer_pool()
750 lio_dma_alloc(oct, in octeon_setup_sc_buffer_pool()
754 octeon_free_sc_buffer_pool(oct); in octeon_setup_sc_buffer_pool()
761 list_add_tail(&sc->node, &oct->sc_buf_pool.head); in octeon_setup_sc_buffer_pool()
768 int octeon_free_sc_done_list(struct octeon_device *oct) in octeon_free_sc_done_list() argument
775 done_sc_list = &oct->response_list[OCTEON_DONE_SC_LIST]; in octeon_free_sc_done_list()
776 zombie_sc_list = &oct->response_list[OCTEON_ZOMBIE_SC_LIST]; in octeon_free_sc_done_list()
781 sc_lists_lock = &oct->response_list[OCTEON_ORDERED_SC_LIST].lock; in octeon_free_sc_done_list()
797 octeon_free_soft_command(oct, sc); in octeon_free_sc_done_list()
808 int octeon_free_sc_zombie_list(struct octeon_device *oct) in octeon_free_sc_zombie_list() argument
815 zombie_sc_list = &oct->response_list[OCTEON_ZOMBIE_SC_LIST]; in octeon_free_sc_zombie_list()
816 sc_lists_lock = &oct->response_list[OCTEON_ORDERED_SC_LIST].lock; in octeon_free_sc_zombie_list()
824 octeon_free_soft_command(oct, sc); in octeon_free_sc_zombie_list()
833 int octeon_free_sc_buffer_pool(struct octeon_device *oct) in octeon_free_sc_buffer_pool() argument
838 octeon_free_sc_zombie_list(oct); in octeon_free_sc_buffer_pool()
840 spin_lock_bh(&oct->sc_buf_pool.lock); in octeon_free_sc_buffer_pool()
842 list_for_each_safe(tmp, tmp2, &oct->sc_buf_pool.head) { in octeon_free_sc_buffer_pool()
847 lio_dma_free(oct, sc->size, sc, sc->dma_addr); in octeon_free_sc_buffer_pool()
850 INIT_LIST_HEAD(&oct->sc_buf_pool.head); in octeon_free_sc_buffer_pool()
852 spin_unlock_bh(&oct->sc_buf_pool.lock); in octeon_free_sc_buffer_pool()
858 struct octeon_soft_command *octeon_alloc_soft_command(struct octeon_device *oct, in octeon_alloc_soft_command() argument
875 spin_lock_bh(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
877 if (list_empty(&oct->sc_buf_pool.head)) { in octeon_alloc_soft_command()
878 spin_unlock_bh(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
882 list_for_each(tmp, &oct->sc_buf_pool.head) in octeon_alloc_soft_command()
887 atomic_inc(&oct->sc_buf_pool.alloc_buf_count); in octeon_alloc_soft_command()
889 spin_unlock_bh(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
930 void octeon_free_soft_command(struct octeon_device *oct, in octeon_free_soft_command() argument
933 spin_lock_bh(&oct->sc_buf_pool.lock); in octeon_free_soft_command()
935 list_add_tail(&sc->node, &oct->sc_buf_pool.head); in octeon_free_soft_command()
937 atomic_dec(&oct->sc_buf_pool.alloc_buf_count); in octeon_free_soft_command()
939 spin_unlock_bh(&oct->sc_buf_pool.lock); in octeon_free_soft_command()