net/liquidio: initialize

Default device configuration and initialization code.

Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Derek Chickles <derek.chickles@caviumnetworks.com>
Signed-off-by: Venkat Koppula <venkat.koppula@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com>
Signed-off-by: Mallesham Jatharakonda <mjatharakonda@oneconvergence.com>
This commit is contained in:
Shijith Thotton 2017-03-25 11:54:17 +05:30 committed by Ferruh Yigit
parent e7f2f7127e
commit 9055da263f
6 changed files with 316 additions and 1 deletions

View File

@ -51,6 +51,7 @@ VPATH += $(RTE_SDK)/drivers/net/liquidio/base
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_ethdev.c
SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_23xx_vf.c
# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lib/librte_eal lib/librte_ether

View File

@ -0,0 +1,67 @@
/*
* 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.
*/
#include <rte_ethdev.h>
#include <rte_cycles.h>
#include <rte_malloc.h>
#include "lio_logs.h"
#include "lio_23xx_vf.h"
#include "lio_23xx_reg.h"
int
cn23xx_vf_setup_device(struct lio_device *lio_dev)
{
uint64_t reg_val;
PMD_INIT_FUNC_TRACE();
/* INPUT_CONTROL[RPVF] gives the VF IOq count */
reg_val = lio_read_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(0));
lio_dev->pf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_PF_NUM_POS) &
CN23XX_PKT_INPUT_CTL_PF_NUM_MASK;
lio_dev->vf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_VF_NUM_POS) &
CN23XX_PKT_INPUT_CTL_VF_NUM_MASK;
reg_val = reg_val >> CN23XX_PKT_INPUT_CTL_RPVF_POS;
lio_dev->sriov_info.rings_per_vf =
reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK;
lio_dev->default_config = lio_get_conf(lio_dev);
if (lio_dev->default_config == NULL)
return -1;
return 0;
}

View File

@ -0,0 +1,84 @@
/*
* 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.
*/
#ifndef _LIO_23XX_VF_H_
#define _LIO_23XX_VF_H_
#include <stdio.h>
#include "lio_struct.h"
static const struct lio_config default_cn23xx_conf = {
.card_type = LIO_23XX,
.card_name = LIO_23XX_NAME,
/** IQ attributes */
.iq = {
.max_iqs = CN23XX_CFG_IO_QUEUES,
.pending_list_size =
(CN23XX_MAX_IQ_DESCRIPTORS * CN23XX_CFG_IO_QUEUES),
.instr_type = OCTEON_64BYTE_INSTR,
},
/** OQ attributes */
.oq = {
.max_oqs = CN23XX_CFG_IO_QUEUES,
.info_ptr = OCTEON_OQ_INFOPTR_MODE,
.refill_threshold = CN23XX_OQ_REFIL_THRESHOLD,
},
.num_nic_ports = CN23XX_DEFAULT_NUM_PORTS,
.num_def_rx_descs = CN23XX_MAX_OQ_DESCRIPTORS,
.num_def_tx_descs = CN23XX_MAX_IQ_DESCRIPTORS,
.def_rx_buf_size = CN23XX_OQ_BUF_SIZE,
};
static inline const struct lio_config *
lio_get_conf(struct lio_device *lio_dev)
{
const struct lio_config *default_lio_conf = NULL;
/* check the LIO Device model & return the corresponding lio
* configuration
*/
default_lio_conf = &default_cn23xx_conf;
if (default_lio_conf == NULL) {
lio_dev_err(lio_dev, "Configuration verification failed\n");
return NULL;
}
return default_lio_conf;
}
int cn23xx_vf_setup_device(struct lio_device *lio_dev);
#endif /* _LIO_23XX_VF_H_ */

View File

@ -42,6 +42,40 @@
#define LIO_CN23XX_VF_VID 0x9712
/* --------------------------CONFIG VALUES------------------------ */
/* CN23xx IQ configuration macros */
#define CN23XX_MAX_RINGS_PER_PF 64
#define CN23XX_MAX_RINGS_PER_VF 8
#define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF
#define CN23XX_MAX_IQ_DESCRIPTORS 512
#define CN23XX_MIN_IQ_DESCRIPTORS 128
#define CN23XX_MAX_OUTPUT_QUEUES CN23XX_MAX_RINGS_PER_PF
#define CN23XX_MAX_OQ_DESCRIPTORS 512
#define CN23XX_MIN_OQ_DESCRIPTORS 128
#define CN23XX_OQ_BUF_SIZE 1536
#define CN23XX_OQ_REFIL_THRESHOLD 16
#define CN23XX_DEFAULT_NUM_PORTS 1
#define CN23XX_CFG_IO_QUEUES CN23XX_MAX_RINGS_PER_PF
/* common OCTEON configuration macros */
#define OCTEON_64BYTE_INSTR 64
#define OCTEON_OQ_INFOPTR_MODE 1
/* Max IOQs per LIO Link */
#define LIO_MAX_IOQS_PER_IF 64
enum lio_card_type {
LIO_23XX /* 23xx */
};
#define LIO_23XX_NAME "23xx"
#define LIO_DEVICE_NAME_LEN 32
/* Routines for reading and writing CSRs */

View File

@ -37,9 +37,63 @@
#include <rte_alarm.h>
#include "lio_logs.h"
#include "lio_struct.h"
#include "lio_23xx_vf.h"
#include "lio_ethdev.h"
/**
* \brief Identify the LIO device and to map the BAR address space
* @param lio_dev lio device
*/
static int
lio_chip_specific_setup(struct lio_device *lio_dev)
{
struct rte_pci_device *pdev = lio_dev->pci_dev;
uint32_t dev_id = pdev->id.device_id;
const char *s;
int ret = 1;
switch (dev_id) {
case LIO_CN23XX_VF_VID:
lio_dev->chip_id = LIO_CN23XX_VF_VID;
ret = cn23xx_vf_setup_device(lio_dev);
s = "CN23XX VF";
break;
default:
s = "?";
lio_dev_err(lio_dev, "Unsupported Chip\n");
}
if (!ret)
lio_dev_info(lio_dev, "DEVICE : %s\n", s);
return ret;
}
static int
lio_first_time_init(struct lio_device *lio_dev,
struct rte_pci_device *pdev)
{
int dpdk_queues;
PMD_INIT_FUNC_TRACE();
/* set dpdk specific pci device pointer */
lio_dev->pci_dev = pdev;
/* Identify the LIO type and set device ops */
if (lio_chip_specific_setup(lio_dev)) {
lio_dev_err(lio_dev, "Chip specific setup failed\n");
return -1;
}
dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
lio_dev->max_tx_queues = dpdk_queues;
lio_dev->max_rx_queues = dpdk_queues;
return 0;
}
static int
lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
{
@ -84,6 +138,11 @@ lio_eth_dev_init(struct rte_eth_dev *eth_dev)
lio_dev->port_id = eth_dev->data->port_id;
if (lio_first_time_init(lio_dev, pdev)) {
lio_dev_err(lio_dev, "Device init failed\n");
return -EINVAL;
}
eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0);
if (eth_dev->data->mac_addrs == NULL) {
lio_dev_err(lio_dev,

View File

@ -43,16 +43,86 @@
#include "lio_hw_defs.h"
struct lio_sriov_info {
/** Number of rings assigned to VF */
uint32_t rings_per_vf;
/** Number of VF devices enabled */
uint32_t num_vfs;
};
/* Structure to define the configuration attributes for each Input queue. */
struct lio_iq_config {
/* Max number of IQs available */
uint8_t max_iqs;
/** Pending list size (usually set to the sum of the size of all Input
* queues)
*/
uint32_t pending_list_size;
/** Command size - 32 or 64 bytes */
uint32_t instr_type;
};
/* Structure to define the configuration attributes for each Output queue. */
struct lio_oq_config {
/* Max number of OQs available */
uint8_t max_oqs;
/** If set, the Output queue uses info-pointer mode. (Default: 1 ) */
uint32_t info_ptr;
/** The number of buffers that were consumed during packet processing by
* the driver on this Output queue before the driver attempts to
* replenish the descriptor ring with new buffers.
*/
uint32_t refill_threshold;
};
/* Structure to define the configuration. */
struct lio_config {
uint16_t card_type;
const char *card_name;
/** Input Queue attributes. */
struct lio_iq_config iq;
/** Output Queue attributes. */
struct lio_oq_config oq;
int num_nic_ports;
int num_def_tx_descs;
/* Num of desc for rx rings */
int num_def_rx_descs;
int def_rx_buf_size;
};
/* ----------------------- THE LIO DEVICE --------------------------- */
/** The lio device.
* Each lio device has this structure to represent all its
* components.
*/
struct lio_device {
/** PCI device pointer */
struct rte_pci_device *pci_dev;
/** Octeon Chip type */
uint16_t chip_id;
uint16_t pf_num;
uint16_t vf_num;
uint8_t *hw_addr;
struct lio_sriov_info sriov_info;
char dev_string[LIO_DEVICE_NAME_LEN]; /* Device print string */
const struct lio_config *default_config;
struct rte_eth_dev *eth_dev;
uint8_t max_rx_queues;