X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fliquidio%2Fbase%2Flio_23xx_vf.c;h=ddbc8c0e0cf55371e3a1a5bf8bcd0c3d9e3ad570;hb=7365a3cee51fb0a0535336f5a5da1c3d41ee256a;hp=181f830298ad35c823e59c18d76bd8919fde301e;hpb=04443cf25844b4c122adef80ec1098c9713f5d32;p=dpdk.git diff --git a/drivers/net/liquidio/base/lio_23xx_vf.c b/drivers/net/liquidio/base/lio_23xx_vf.c index 181f830298..ddbc8c0e0c 100644 --- a/drivers/net/liquidio/base/lio_23xx_vf.c +++ b/drivers/net/liquidio/base/lio_23xx_vf.c @@ -1,37 +1,10 @@ -/* - * BSD LICENSE - * - * Copyright(c) 2017 Cavium, Inc.. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Cavium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc */ -#include +#include + +#include #include #include @@ -148,6 +121,8 @@ cn23xx_vf_setup_global_output_regs(struct lio_device *lio_dev) reg_val &= 0xEFFFFFFFFFFFFFFFL; + lio_write_csr(lio_dev, CN23XX_SLI_OQ_PKTS_SENT(q_no), reg_val); + reg_val = lio_read_csr(lio_dev, CN23XX_SLI_OQ_PKT_CONTROL(q_no)); @@ -209,7 +184,7 @@ cn23xx_vf_setup_iq_regs(struct lio_device *lio_dev, uint32_t iq_no) /* Write the start of the input queue's ring and its size */ lio_write_csr64(lio_dev, CN23XX_SLI_IQ_BASE_ADDR64(iq_no), iq->base_addr_dma); - lio_write_csr(lio_dev, CN23XX_SLI_IQ_SIZE(iq_no), iq->max_count); + lio_write_csr(lio_dev, CN23XX_SLI_IQ_SIZE(iq_no), iq->nb_desc); /* Remember the doorbell & instruction count register addr * for this queue @@ -232,6 +207,27 @@ cn23xx_vf_setup_iq_regs(struct lio_device *lio_dev, uint32_t iq_no) rte_write64(pkt_in_done, iq->inst_cnt_reg); } +static void +cn23xx_vf_setup_oq_regs(struct lio_device *lio_dev, uint32_t oq_no) +{ + struct lio_droq *droq = lio_dev->droq[oq_no]; + + PMD_INIT_FUNC_TRACE(); + + lio_write_csr64(lio_dev, CN23XX_SLI_OQ_BASE_ADDR64(oq_no), + droq->desc_ring_dma); + lio_write_csr(lio_dev, CN23XX_SLI_OQ_SIZE(oq_no), droq->nb_desc); + + lio_write_csr(lio_dev, CN23XX_SLI_OQ_BUFF_INFO_SIZE(oq_no), + (droq->buffer_size | (OCTEON_RH_SIZE << 16))); + + /* Get the mapped address of the pkt_sent and pkts_credit regs */ + droq->pkts_sent_reg = (uint8_t *)lio_dev->hw_addr + + CN23XX_SLI_OQ_PKTS_SENT(oq_no); + droq->pkts_credit_reg = (uint8_t *)lio_dev->hw_addr + + CN23XX_SLI_OQ_PKTS_CREDIT(oq_no); +} + static void cn23xx_vf_free_mbox(struct lio_device *lio_dev) { @@ -289,12 +285,79 @@ cn23xx_vf_setup_mbox(struct lio_device *lio_dev) return 0; } +static int +cn23xx_vf_enable_io_queues(struct lio_device *lio_dev) +{ + uint32_t q_no; + + PMD_INIT_FUNC_TRACE(); + + for (q_no = 0; q_no < lio_dev->num_iqs; q_no++) { + uint64_t reg_val; + + /* set the corresponding IQ IS_64B bit */ + if (lio_dev->io_qmask.iq64B & (1ULL << q_no)) { + reg_val = lio_read_csr64( + lio_dev, + CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); + reg_val = reg_val | CN23XX_PKT_INPUT_CTL_IS_64B; + lio_write_csr64(lio_dev, + CN23XX_SLI_IQ_PKT_CONTROL64(q_no), + reg_val); + } + + /* set the corresponding IQ ENB bit */ + if (lio_dev->io_qmask.iq & (1ULL << q_no)) { + reg_val = lio_read_csr64( + lio_dev, + CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); + reg_val = reg_val | CN23XX_PKT_INPUT_CTL_RING_ENB; + lio_write_csr64(lio_dev, + CN23XX_SLI_IQ_PKT_CONTROL64(q_no), + reg_val); + } + } + for (q_no = 0; q_no < lio_dev->num_oqs; q_no++) { + uint32_t reg_val; + + /* set the corresponding OQ ENB bit */ + if (lio_dev->io_qmask.oq & (1ULL << q_no)) { + reg_val = lio_read_csr( + lio_dev, + CN23XX_SLI_OQ_PKT_CONTROL(q_no)); + reg_val = reg_val | CN23XX_PKT_OUTPUT_CTL_RING_ENB; + lio_write_csr(lio_dev, + CN23XX_SLI_OQ_PKT_CONTROL(q_no), + reg_val); + } + } + + return 0; +} + +static void +cn23xx_vf_disable_io_queues(struct lio_device *lio_dev) +{ + uint32_t num_queues; + + PMD_INIT_FUNC_TRACE(); + + /* per HRM, rings can only be disabled via reset operation, + * NOT via SLI_PKT()_INPUT/OUTPUT_CONTROL[ENB] + */ + num_queues = lio_dev->num_iqs; + if (num_queues < lio_dev->num_oqs) + num_queues = lio_dev->num_oqs; + + cn23xx_vf_reset_io_queues(lio_dev, num_queues); +} + void cn23xx_vf_ask_pf_to_do_flr(struct lio_device *lio_dev) { struct lio_mbox_cmd mbox_cmd; - mbox_cmd.msg.mbox_msg64 = 0; + memset(&mbox_cmd, 0, sizeof(struct lio_mbox_cmd)); mbox_cmd.msg.s.type = LIO_MBOX_REQUEST; mbox_cmd.msg.s.resp_needed = 0; mbox_cmd.msg.s.cmd = LIO_VF_FLR_REQUEST; @@ -436,59 +499,15 @@ cn23xx_vf_setup_device(struct lio_device *lio_dev) return -1; lio_dev->fn_list.setup_iq_regs = cn23xx_vf_setup_iq_regs; + lio_dev->fn_list.setup_oq_regs = cn23xx_vf_setup_oq_regs; lio_dev->fn_list.setup_mbox = cn23xx_vf_setup_mbox; lio_dev->fn_list.free_mbox = cn23xx_vf_free_mbox; lio_dev->fn_list.setup_device_regs = cn23xx_vf_setup_device_regs; - return 0; -} - -int -cn23xx_vf_set_io_queues_off(struct lio_device *lio_dev) -{ - uint32_t loop = CN23XX_VF_BUSY_READING_REG_LOOP_COUNT; - uint64_t q_no; - - /* Disable the i/p and o/p queues for this Octeon. - * IOQs will already be in reset. - * If RST bit is set, wait for Quiet bit to be set - * Once Quiet bit is set, clear the RST bit - */ - PMD_INIT_FUNC_TRACE(); - - for (q_no = 0; q_no < lio_dev->sriov_info.rings_per_vf; q_no++) { - volatile uint64_t reg_val; - - reg_val = lio_read_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - while ((reg_val & CN23XX_PKT_INPUT_CTL_RST) && !(reg_val & - CN23XX_PKT_INPUT_CTL_QUIET) && loop) { - reg_val = lio_read_csr64( - lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - loop = loop - 1; - } - - if (loop == 0) { - lio_dev_err(lio_dev, - "clearing the reset reg failed or setting the quiet reg failed for qno %lu\n", - (unsigned long)q_no); - return -1; - } - - reg_val = reg_val & ~CN23XX_PKT_INPUT_CTL_RST; - lio_write_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(q_no), - reg_val); - - reg_val = lio_read_csr64(lio_dev, - CN23XX_SLI_IQ_PKT_CONTROL64(q_no)); - if (reg_val & CN23XX_PKT_INPUT_CTL_RST) { - lio_dev_err(lio_dev, "unable to reset qno %lu\n", - (unsigned long)q_no); - return -1; - } - } + lio_dev->fn_list.enable_io_queues = cn23xx_vf_enable_io_queues; + lio_dev->fn_list.disable_io_queues = cn23xx_vf_disable_io_queues; return 0; } +