Lines Matching refs:oct
54 static void __check_db_timeout(struct octeon_device *oct, unsigned long iq_no);
58 static inline int IQ_INSTR_MODE_64B(struct octeon_device *oct, int iq_no) in IQ_INSTR_MODE_64B() argument
61 (struct octeon_instr_queue *)oct->instr_queue[iq_no]; in IQ_INSTR_MODE_64B()
65 #define IQ_INSTR_MODE_32B(oct, iq_no) (!IQ_INSTR_MODE_64B(oct, iq_no)) argument
71 int octeon_init_instr_queue(struct octeon_device *oct, in octeon_init_instr_queue() argument
79 if (OCTEON_CN6XXX(oct)) in octeon_init_instr_queue()
80 conf = &(CFG_GET_IQ_CFG(CHIP_FIELD(oct, cn6xxx, conf))); in octeon_init_instr_queue()
83 dev_err(&oct->pci_dev->dev, "Unsupported Chip %x\n", in octeon_init_instr_queue()
84 oct->chip_id); in octeon_init_instr_queue()
89 dev_err(&oct->pci_dev->dev, in octeon_init_instr_queue()
97 iq = oct->instr_queue[iq_no]; in octeon_init_instr_queue()
99 iq->base_addr = lio_dma_alloc(oct, q_size, in octeon_init_instr_queue()
102 dev_err(&oct->pci_dev->dev, "Cannot allocate memory for instr queue %d\n", in octeon_init_instr_queue()
114 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); in octeon_init_instr_queue()
115 dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", in octeon_init_instr_queue()
122 dev_dbg(&oct->pci_dev->dev, "IQ[%d]: base: %p basedma: %llx count: %d\n", in octeon_init_instr_queue()
139 oct->io_qmask.iq |= (1 << iq_no); in octeon_init_instr_queue()
142 oct->io_qmask.iq64B |= ((conf->instr_type == 64) << iq_no); in octeon_init_instr_queue()
145 oct->fn_list.setup_iq_regs(oct, iq_no); in octeon_init_instr_queue()
147 oct->check_db_wq[iq_no].wq = create_workqueue("check_iq_db"); in octeon_init_instr_queue()
148 if (!oct->check_db_wq[iq_no].wq) { in octeon_init_instr_queue()
149 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); in octeon_init_instr_queue()
150 dev_err(&oct->pci_dev->dev, "check db wq create failed for iq %d\n", in octeon_init_instr_queue()
155 db_wq = &oct->check_db_wq[iq_no]; in octeon_init_instr_queue()
158 db_wq->wk.ctxptr = oct; in octeon_init_instr_queue()
165 int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no) in octeon_delete_instr_queue() argument
168 struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; in octeon_delete_instr_queue()
170 cancel_delayed_work_sync(&oct->check_db_wq[iq_no].wk.work); in octeon_delete_instr_queue()
171 flush_workqueue(oct->check_db_wq[iq_no].wq); in octeon_delete_instr_queue()
172 destroy_workqueue(oct->check_db_wq[iq_no].wq); in octeon_delete_instr_queue()
174 if (OCTEON_CN6XXX(oct)) in octeon_delete_instr_queue()
176 CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn6xxx, conf)); in octeon_delete_instr_queue()
182 lio_dma_free(oct, (u32)q_size, iq->base_addr, in octeon_delete_instr_queue()
190 int octeon_setup_iq(struct octeon_device *oct, in octeon_setup_iq() argument
195 if (oct->instr_queue[iq_no]) { in octeon_setup_iq()
196 dev_dbg(&oct->pci_dev->dev, "IQ is in use. Cannot create the IQ: %d again\n", in octeon_setup_iq()
198 oct->instr_queue[iq_no]->app_ctx = app_ctx; in octeon_setup_iq()
201 oct->instr_queue[iq_no] = in octeon_setup_iq()
203 if (!oct->instr_queue[iq_no]) in octeon_setup_iq()
206 memset(oct->instr_queue[iq_no], 0, in octeon_setup_iq()
209 oct->instr_queue[iq_no]->app_ctx = app_ctx; in octeon_setup_iq()
210 if (octeon_init_instr_queue(oct, iq_no, num_descs)) { in octeon_setup_iq()
211 vfree(oct->instr_queue[iq_no]); in octeon_setup_iq()
212 oct->instr_queue[iq_no] = NULL; in octeon_setup_iq()
216 oct->num_iqs++; in octeon_setup_iq()
217 oct->fn_list.enable_io_queues(oct); in octeon_setup_iq()
221 int lio_wait_for_instr_fetch(struct octeon_device *oct) in lio_wait_for_instr_fetch() argument
230 if (!(oct->io_qmask.iq & (1UL << i))) in lio_wait_for_instr_fetch()
233 atomic_read(&oct-> in lio_wait_for_instr_fetch()
236 __check_db_timeout(oct, i); in lio_wait_for_instr_fetch()
251 ring_doorbell(struct octeon_device *oct, struct octeon_instr_queue *iq) in ring_doorbell() argument
253 if (atomic_read(&oct->status) == OCT_DEV_RUNNING) { in ring_doorbell()
343 octeon_register_reqtype_free_fn(struct octeon_device *oct, int reqtype, in octeon_register_reqtype_free_fn() argument
347 dev_err(&oct->pci_dev->dev, "%s: Invalid reqtype: %d\n", in octeon_register_reqtype_free_fn()
352 reqtype_free_fn[oct->octeon_id][reqtype] = fn; in octeon_register_reqtype_free_fn()
366 lio_process_iq_request_list(struct octeon_device *oct, in lio_process_iq_request_list() argument
391 reqtype_free_fn[oct->octeon_id][reqtype](buf); in lio_process_iq_request_list()
405 spin_lock_bh(&oct->response_list in lio_process_iq_request_list()
407 atomic_inc(&oct->response_list in lio_process_iq_request_list()
410 list_add_tail(&sc->node, &oct->response_list in lio_process_iq_request_list()
412 spin_unlock_bh(&oct->response_list in lio_process_iq_request_list()
416 sc->callback(oct, OCTEON_REQUEST_DONE, in lio_process_iq_request_list()
422 dev_err(&oct->pci_dev->dev, in lio_process_iq_request_list()
443 update_iq_indices(struct octeon_device *oct, struct octeon_instr_queue *iq) in update_iq_indices() argument
450 iq->octeon_read_index = oct->fn_list.update_iq_read_idx(oct, iq); in update_iq_indices()
454 inst_processed = lio_process_iq_request_list(oct, iq); in update_iq_indices()
463 octeon_flush_iq(struct octeon_device *oct, struct octeon_instr_queue *iq, in octeon_flush_iq() argument
468 update_iq_indices(oct, iq); in octeon_flush_iq()
473 static void __check_db_timeout(struct octeon_device *oct, unsigned long iq_no) in __check_db_timeout() argument
478 if (!oct) in __check_db_timeout()
480 iq = oct->instr_queue[iq_no]; in __check_db_timeout()
495 ring_doorbell(oct, iq); in __check_db_timeout()
501 octeon_flush_iq(oct, iq, 1); in __check_db_timeout()
510 struct octeon_device *oct = (struct octeon_device *)wk->ctxptr; in check_db_timeout() local
512 struct cavium_wq *db_wq = &oct->check_db_wq[iq_no]; in check_db_timeout()
514 __check_db_timeout(oct, iq_no); in check_db_timeout()
519 octeon_send_command(struct octeon_device *oct, u32 iq_no, in octeon_send_command() argument
524 struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; in octeon_send_command()
528 st = __post_command2(oct, iq, force_db, cmd); in octeon_send_command()
533 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, bytes_sent, datasize); in octeon_send_command()
534 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, instr_posted, 1); in octeon_send_command()
537 ring_doorbell(oct, iq); in octeon_send_command()
539 INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, instr_dropped, 1); in octeon_send_command()
545 octeon_flush_iq(oct, iq, 2); in octeon_send_command()
551 octeon_prepare_soft_command(struct octeon_device *oct, in octeon_prepare_soft_command() argument
567 oct_cfg = octeon_get_conf(oct); in octeon_prepare_soft_command()
591 rdp->pcie_port = oct->pcie_port; in octeon_prepare_soft_command()
603 while (!(oct->io_qmask.iq & (1 << sc->iq_no))) in octeon_prepare_soft_command()
607 int octeon_send_soft_command(struct octeon_device *oct, in octeon_send_soft_command() argument
634 return octeon_send_command(oct, sc->iq_no, 1, &sc->cmd, sc, in octeon_send_soft_command()
638 int octeon_setup_sc_buffer_pool(struct octeon_device *oct) in octeon_setup_sc_buffer_pool() argument
644 INIT_LIST_HEAD(&oct->sc_buf_pool.head); in octeon_setup_sc_buffer_pool()
645 spin_lock_init(&oct->sc_buf_pool.lock); in octeon_setup_sc_buffer_pool()
646 atomic_set(&oct->sc_buf_pool.alloc_buf_count, 0); in octeon_setup_sc_buffer_pool()
650 lio_dma_alloc(oct, in octeon_setup_sc_buffer_pool()
659 list_add_tail(&sc->node, &oct->sc_buf_pool.head); in octeon_setup_sc_buffer_pool()
665 int octeon_free_sc_buffer_pool(struct octeon_device *oct) in octeon_free_sc_buffer_pool() argument
670 spin_lock(&oct->sc_buf_pool.lock); in octeon_free_sc_buffer_pool()
672 list_for_each_safe(tmp, tmp2, &oct->sc_buf_pool.head) { in octeon_free_sc_buffer_pool()
677 lio_dma_free(oct, sc->size, sc, sc->dma_addr); in octeon_free_sc_buffer_pool()
680 INIT_LIST_HEAD(&oct->sc_buf_pool.head); in octeon_free_sc_buffer_pool()
682 spin_unlock(&oct->sc_buf_pool.lock); in octeon_free_sc_buffer_pool()
687 struct octeon_soft_command *octeon_alloc_soft_command(struct octeon_device *oct, in octeon_alloc_soft_command() argument
701 spin_lock(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
703 if (list_empty(&oct->sc_buf_pool.head)) { in octeon_alloc_soft_command()
704 spin_unlock(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
708 list_for_each(tmp, &oct->sc_buf_pool.head) in octeon_alloc_soft_command()
713 atomic_inc(&oct->sc_buf_pool.alloc_buf_count); in octeon_alloc_soft_command()
715 spin_unlock(&oct->sc_buf_pool.lock); in octeon_alloc_soft_command()
755 void octeon_free_soft_command(struct octeon_device *oct, in octeon_free_soft_command() argument
758 spin_lock(&oct->sc_buf_pool.lock); in octeon_free_soft_command()
760 list_add_tail(&sc->node, &oct->sc_buf_pool.head); in octeon_free_soft_command()
762 atomic_dec(&oct->sc_buf_pool.alloc_buf_count); in octeon_free_soft_command()
764 spin_unlock(&oct->sc_buf_pool.lock); in octeon_free_soft_command()