Lines Matching refs:oct
30 u32 cn23xx_vf_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us) in cn23xx_vf_get_oq_ticks() argument
33 u32 oqticks_per_us = (u32)oct->pfvf_hsword.coproc_tics_per_us; in cn23xx_vf_get_oq_ticks()
50 static int cn23xx_vf_reset_io_queues(struct octeon_device *oct, u32 num_queues) in cn23xx_vf_reset_io_queues() argument
59 d64 = octeon_read_csr64(oct, in cn23xx_vf_reset_io_queues()
62 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no), in cn23xx_vf_reset_io_queues()
68 u64 reg_val = octeon_read_csr64(oct, in cn23xx_vf_reset_io_queues()
74 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no))); in cn23xx_vf_reset_io_queues()
78 dev_err(&oct->pci_dev->dev, in cn23xx_vf_reset_io_queues()
85 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no), in cn23xx_vf_reset_io_queues()
89 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no))); in cn23xx_vf_reset_io_queues()
91 dev_err(&oct->pci_dev->dev, in cn23xx_vf_reset_io_queues()
101 static int cn23xx_vf_setup_global_input_regs(struct octeon_device *oct) in cn23xx_vf_setup_global_input_regs() argument
103 struct octeon_cn23xx_vf *cn23xx = (struct octeon_cn23xx_vf *)oct->chip; in cn23xx_vf_setup_global_input_regs()
108 if (cn23xx_vf_reset_io_queues(oct, oct->sriov_info.rings_per_vf)) in cn23xx_vf_setup_global_input_regs()
111 for (q_no = 0; q_no < (oct->sriov_info.rings_per_vf); q_no++) { in cn23xx_vf_setup_global_input_regs()
114 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_DOORBELL(q_no), in cn23xx_vf_setup_global_input_regs()
116 iq = oct->instr_queue[q_no]; in cn23xx_vf_setup_global_input_regs()
121 inst_cnt_reg = (u8 *)oct->mmio[0].hw_addr + in cn23xx_vf_setup_global_input_regs()
124 d64 = octeon_read_csr64(oct, in cn23xx_vf_setup_global_input_regs()
129 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_INSTR_COUNT64(q_no), in cn23xx_vf_setup_global_input_regs()
135 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no), in cn23xx_vf_setup_global_input_regs()
151 static void cn23xx_vf_setup_global_output_regs(struct octeon_device *oct) in cn23xx_vf_setup_global_output_regs() argument
156 for (q_no = 0; q_no < (oct->sriov_info.rings_per_vf); q_no++) { in cn23xx_vf_setup_global_output_regs()
157 octeon_write_csr(oct, CN23XX_VF_SLI_OQ_PKTS_CREDIT(q_no), in cn23xx_vf_setup_global_output_regs()
161 octeon_read_csr(oct, CN23XX_VF_SLI_OQ_PKTS_SENT(q_no)); in cn23xx_vf_setup_global_output_regs()
166 octeon_read_csr(oct, CN23XX_VF_SLI_OQ_PKT_CONTROL(q_no)); in cn23xx_vf_setup_global_output_regs()
197 octeon_write_csr(oct, CN23XX_VF_SLI_OQ_PKT_CONTROL(q_no), in cn23xx_vf_setup_global_output_regs()
202 static int cn23xx_setup_vf_device_regs(struct octeon_device *oct) in cn23xx_setup_vf_device_regs() argument
204 if (cn23xx_vf_setup_global_input_regs(oct)) in cn23xx_setup_vf_device_regs()
207 cn23xx_vf_setup_global_output_regs(oct); in cn23xx_setup_vf_device_regs()
212 static void cn23xx_setup_vf_iq_regs(struct octeon_device *oct, u32 iq_no) in cn23xx_setup_vf_iq_regs() argument
214 struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; in cn23xx_setup_vf_iq_regs()
218 octeon_write_csr64(oct, CN23XX_VF_SLI_IQ_BASE_ADDR64(iq_no), in cn23xx_setup_vf_iq_regs()
220 octeon_write_csr(oct, CN23XX_VF_SLI_IQ_SIZE(iq_no), iq->max_count); in cn23xx_setup_vf_iq_regs()
226 (u8 *)oct->mmio[0].hw_addr + CN23XX_VF_SLI_IQ_DOORBELL(iq_no); in cn23xx_setup_vf_iq_regs()
228 (u8 *)oct->mmio[0].hw_addr + CN23XX_VF_SLI_IQ_INSTR_COUNT64(iq_no); in cn23xx_setup_vf_iq_regs()
229 dev_dbg(&oct->pci_dev->dev, "InstQ[%d]:dbell reg @ 0x%p instcnt_reg @ 0x%p\n", in cn23xx_setup_vf_iq_regs()
237 if (oct->msix_on) { in cn23xx_setup_vf_iq_regs()
245 static void cn23xx_setup_vf_oq_regs(struct octeon_device *oct, u32 oq_no) in cn23xx_setup_vf_oq_regs() argument
247 struct octeon_droq *droq = oct->droq[oq_no]; in cn23xx_setup_vf_oq_regs()
249 octeon_write_csr64(oct, CN23XX_VF_SLI_OQ_BASE_ADDR64(oq_no), in cn23xx_setup_vf_oq_regs()
251 octeon_write_csr(oct, CN23XX_VF_SLI_OQ_SIZE(oq_no), droq->max_count); in cn23xx_setup_vf_oq_regs()
253 octeon_write_csr(oct, CN23XX_VF_SLI_OQ_BUFF_INFO_SIZE(oq_no), in cn23xx_setup_vf_oq_regs()
258 (u8 *)oct->mmio[0].hw_addr + CN23XX_VF_SLI_OQ_PKTS_SENT(oq_no); in cn23xx_setup_vf_oq_regs()
260 (u8 *)oct->mmio[0].hw_addr + CN23XX_VF_SLI_OQ_PKTS_CREDIT(oq_no); in cn23xx_setup_vf_oq_regs()
271 static int cn23xx_free_vf_mbox(struct octeon_device *oct) in cn23xx_free_vf_mbox() argument
273 cancel_delayed_work_sync(&oct->mbox[0]->mbox_poll_wk.work); in cn23xx_free_vf_mbox()
274 vfree(oct->mbox[0]); in cn23xx_free_vf_mbox()
278 static int cn23xx_setup_vf_mbox(struct octeon_device *oct) in cn23xx_setup_vf_mbox() argument
290 mbox->oct_dev = oct; in cn23xx_setup_vf_mbox()
298 (u8 *)oct->mmio[0].hw_addr + CN23XX_VF_SLI_PKT_MBOX_INT(0); in cn23xx_setup_vf_mbox()
301 (u8 *)oct->mmio[0].hw_addr + CN23XX_SLI_PKT_PF_VF_MBOX_SIG(0, 0); in cn23xx_setup_vf_mbox()
304 (u8 *)oct->mmio[0].hw_addr + CN23XX_SLI_PKT_PF_VF_MBOX_SIG(0, 1); in cn23xx_setup_vf_mbox()
311 oct->mbox[0] = mbox; in cn23xx_setup_vf_mbox()
318 static int cn23xx_enable_vf_io_queues(struct octeon_device *oct) in cn23xx_enable_vf_io_queues() argument
322 for (q_no = 0; q_no < oct->num_iqs; q_no++) { in cn23xx_enable_vf_io_queues()
326 if (oct->io_qmask.iq64B & BIT_ULL(q_no)) { in cn23xx_enable_vf_io_queues()
328 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no)); in cn23xx_enable_vf_io_queues()
331 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no), reg_val); in cn23xx_enable_vf_io_queues()
335 if (oct->io_qmask.iq & BIT_ULL(q_no)) { in cn23xx_enable_vf_io_queues()
337 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no)); in cn23xx_enable_vf_io_queues()
340 oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(q_no), reg_val); in cn23xx_enable_vf_io_queues()
343 for (q_no = 0; q_no < oct->num_oqs; q_no++) { in cn23xx_enable_vf_io_queues()
347 if (oct->io_qmask.oq & BIT_ULL(q_no)) { in cn23xx_enable_vf_io_queues()
349 oct, CN23XX_VF_SLI_OQ_PKT_CONTROL(q_no)); in cn23xx_enable_vf_io_queues()
352 oct, CN23XX_VF_SLI_OQ_PKT_CONTROL(q_no), reg_val); in cn23xx_enable_vf_io_queues()
359 static void cn23xx_disable_vf_io_queues(struct octeon_device *oct) in cn23xx_disable_vf_io_queues() argument
361 u32 num_queues = oct->num_iqs; in cn23xx_disable_vf_io_queues()
366 if (num_queues < oct->num_oqs) in cn23xx_disable_vf_io_queues()
367 num_queues = oct->num_oqs; in cn23xx_disable_vf_io_queues()
369 cn23xx_vf_reset_io_queues(oct, num_queues); in cn23xx_disable_vf_io_queues()
372 void cn23xx_vf_ask_pf_to_do_flr(struct octeon_device *oct) in cn23xx_vf_ask_pf_to_do_flr() argument
387 octeon_mbox_write(oct, &mbox_cmd); in cn23xx_vf_ask_pf_to_do_flr()
390 static void octeon_pfvf_hs_callback(struct octeon_device *oct, in octeon_pfvf_hs_callback() argument
396 memcpy((uint8_t *)&oct->pfvf_hsword, cmd->msg.s.params, in octeon_pfvf_hs_callback()
406 int cn23xx_octeon_pfvf_handshake(struct octeon_device *oct) in cn23xx_octeon_pfvf_handshake() argument
416 dev_dbg(&oct->pci_dev->dev, "requesting info from pf\n"); in cn23xx_octeon_pfvf_handshake()
436 octeon_mbox_write(oct, &mbox_cmd); in cn23xx_octeon_pfvf_handshake()
446 dev_err(&oct->pci_dev->dev, "octeon_pfvf_handshake timeout\n"); in cn23xx_octeon_pfvf_handshake()
450 for (q_no = 0 ; q_no < oct->num_iqs ; q_no++) in cn23xx_octeon_pfvf_handshake()
451 oct->instr_queue[q_no]->txpciq.s.pkind = oct->pfvf_hsword.pkind; in cn23xx_octeon_pfvf_handshake()
456 dev_err(&oct->pci_dev->dev, in cn23xx_octeon_pfvf_handshake()
462 dev_dbg(&oct->pci_dev->dev, in cn23xx_octeon_pfvf_handshake()
466 dev_dbg(&oct->pci_dev->dev, "got data from pf pkind is %d\n", in cn23xx_octeon_pfvf_handshake()
467 oct->pfvf_hsword.pkind); in cn23xx_octeon_pfvf_handshake()
474 struct octeon_device *oct = ioq_vector->oct_dev; in cn23xx_handle_vf_mbox_intr() local
479 mbox_int_val = readq(oct->mbox[0]->mbox_int_reg); in cn23xx_handle_vf_mbox_intr()
480 writeq(mbox_int_val, oct->mbox[0]->mbox_int_reg); in cn23xx_handle_vf_mbox_intr()
481 if (octeon_mbox_read(oct->mbox[0])) in cn23xx_handle_vf_mbox_intr()
482 schedule_delayed_work(&oct->mbox[0]->mbox_poll_wk.work, in cn23xx_handle_vf_mbox_intr()
490 struct octeon_device *oct = ioq_vector->oct_dev; in cn23xx_vf_msix_interrupt_handler() local
491 struct octeon_droq *droq = oct->droq[ioq_vector->droq_index]; in cn23xx_vf_msix_interrupt_handler()
495 dev_dbg(&oct->pci_dev->dev, "In %s octeon_dev @ %p\n", __func__, oct); in cn23xx_vf_msix_interrupt_handler()
544 static void cn23xx_enable_vf_interrupt(struct octeon_device *oct, u8 intr_flag) in cn23xx_enable_vf_interrupt() argument
546 struct octeon_cn23xx_vf *cn23xx = (struct octeon_cn23xx_vf *)oct->chip; in cn23xx_enable_vf_interrupt()
550 for (q_no = 0; q_no < oct->num_oqs; q_no++) { in cn23xx_enable_vf_interrupt()
555 oct, (u32)CFG_GET_OQ_INTR_TIME(cn23xx->conf)); in cn23xx_enable_vf_interrupt()
558 oct, CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(q_no), in cn23xx_enable_vf_interrupt()
565 for (q_no = 0; q_no < oct->num_oqs; q_no++) { in cn23xx_enable_vf_interrupt()
568 oct, CN23XX_VF_SLI_IQ_INSTR_COUNT64(q_no), in cn23xx_enable_vf_interrupt()
570 oct, CN23XX_VF_SLI_IQ_INSTR_COUNT64(q_no)) & in cn23xx_enable_vf_interrupt()
579 oct, CN23XX_VF_SLI_PKT_MBOX_INT(0), in cn23xx_enable_vf_interrupt()
580 (octeon_read_csr64(oct, CN23XX_VF_SLI_PKT_MBOX_INT(0)) | in cn23xx_enable_vf_interrupt()
585 static void cn23xx_disable_vf_interrupt(struct octeon_device *oct, u8 intr_flag) in cn23xx_disable_vf_interrupt() argument
590 for (q_no = 0; q_no < oct->num_oqs; q_no++) { in cn23xx_disable_vf_interrupt()
593 oct, CN23XX_VF_SLI_OQ_PKT_INT_LEVELS(q_no), in cn23xx_disable_vf_interrupt()
598 for (q_no = 0; q_no < oct->num_oqs; q_no++) { in cn23xx_disable_vf_interrupt()
600 oct, CN23XX_VF_SLI_IQ_INSTR_COUNT64(q_no), in cn23xx_disable_vf_interrupt()
602 oct, CN23XX_VF_SLI_IQ_INSTR_COUNT64(q_no)) & in cn23xx_disable_vf_interrupt()
610 oct, CN23XX_VF_SLI_PKT_MBOX_INT(0), in cn23xx_disable_vf_interrupt()
611 (octeon_read_csr64(oct, CN23XX_VF_SLI_PKT_MBOX_INT(0)) & in cn23xx_disable_vf_interrupt()
616 int cn23xx_setup_octeon_vf_device(struct octeon_device *oct) in cn23xx_setup_octeon_vf_device() argument
618 struct octeon_cn23xx_vf *cn23xx = (struct octeon_cn23xx_vf *)oct->chip; in cn23xx_setup_octeon_vf_device()
622 if (octeon_map_pci_barx(oct, 0, 0)) in cn23xx_setup_octeon_vf_device()
626 reg_val = octeon_read_csr64(oct, CN23XX_VF_SLI_IQ_PKT_CONTROL64(0)); in cn23xx_setup_octeon_vf_device()
628 oct->pf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_PF_NUM_POS) & in cn23xx_setup_octeon_vf_device()
630 oct->vf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_VF_NUM_POS) & in cn23xx_setup_octeon_vf_device()
637 cn23xx->conf = oct_get_config_info(oct, LIO_23XX); in cn23xx_setup_octeon_vf_device()
639 dev_err(&oct->pci_dev->dev, "%s No Config found for CN23XX\n", in cn23xx_setup_octeon_vf_device()
641 octeon_unmap_pci_barx(oct, 0); in cn23xx_setup_octeon_vf_device()
645 if (oct->sriov_info.rings_per_vf > rings_per_vf) { in cn23xx_setup_octeon_vf_device()
646 dev_warn(&oct->pci_dev->dev, in cn23xx_setup_octeon_vf_device()
648 oct->sriov_info.rings_per_vf, rings_per_vf, in cn23xx_setup_octeon_vf_device()
650 oct->sriov_info.rings_per_vf = rings_per_vf; in cn23xx_setup_octeon_vf_device()
653 dev_warn(&oct->pci_dev->dev, in cn23xx_setup_octeon_vf_device()
658 oct->sriov_info.rings_per_vf = in cn23xx_setup_octeon_vf_device()
661 oct->sriov_info.rings_per_vf = rings_per_vf; in cn23xx_setup_octeon_vf_device()
665 oct->fn_list.setup_iq_regs = cn23xx_setup_vf_iq_regs; in cn23xx_setup_octeon_vf_device()
666 oct->fn_list.setup_oq_regs = cn23xx_setup_vf_oq_regs; in cn23xx_setup_octeon_vf_device()
667 oct->fn_list.setup_mbox = cn23xx_setup_vf_mbox; in cn23xx_setup_octeon_vf_device()
668 oct->fn_list.free_mbox = cn23xx_free_vf_mbox; in cn23xx_setup_octeon_vf_device()
670 oct->fn_list.msix_interrupt_handler = cn23xx_vf_msix_interrupt_handler; in cn23xx_setup_octeon_vf_device()
672 oct->fn_list.setup_device_regs = cn23xx_setup_vf_device_regs; in cn23xx_setup_octeon_vf_device()
673 oct->fn_list.update_iq_read_idx = cn23xx_update_read_index; in cn23xx_setup_octeon_vf_device()
675 oct->fn_list.enable_interrupt = cn23xx_enable_vf_interrupt; in cn23xx_setup_octeon_vf_device()
676 oct->fn_list.disable_interrupt = cn23xx_disable_vf_interrupt; in cn23xx_setup_octeon_vf_device()
678 oct->fn_list.enable_io_queues = cn23xx_enable_vf_io_queues; in cn23xx_setup_octeon_vf_device()
679 oct->fn_list.disable_io_queues = cn23xx_disable_vf_io_queues; in cn23xx_setup_octeon_vf_device()