From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id C6F027CD5 for ; Sat, 10 Mar 2018 23:49:26 +0100 (CET) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id w2AMnLUj014042; Sat, 10 Mar 2018 14:49:22 -0800 From: Rahul Lakkireddy To: dev@dpdk.org Cc: kumaras@chelsio.com, nirranjan@chelsio.com, indranil@chelsio.com Date: Sun, 11 Mar 2018 04:18:19 +0530 Message-Id: X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 01/13] cxgbe: add skeleton VF driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2018 22:49:27 -0000 From: Kumar Sanghvi Add minimal VF driver. Declare functions common to both PF and VF functionality in separate header file and import the header file. Signed-off-by: Kumar Sanghvi Signed-off-by: Rahul Lakkireddy --- doc/guides/nics/features/cxgbevf.ini | 28 +++++++++++ doc/guides/rel_notes/release_18_05.rst | 5 ++ drivers/net/cxgbe/Makefile | 1 + drivers/net/cxgbe/cxgbe_ethdev.c | 70 +++++++++++--------------- drivers/net/cxgbe/cxgbe_pfvf.h | 38 ++++++++++++++ drivers/net/cxgbe/cxgbevf_ethdev.c | 91 ++++++++++++++++++++++++++++++++++ 6 files changed, 193 insertions(+), 40 deletions(-) create mode 100644 doc/guides/nics/features/cxgbevf.ini create mode 100644 drivers/net/cxgbe/cxgbe_pfvf.h create mode 100644 drivers/net/cxgbe/cxgbevf_ethdev.c diff --git a/doc/guides/nics/features/cxgbevf.ini b/doc/guides/nics/features/cxgbevf.ini new file mode 100644 index 000000000..7706106d1 --- /dev/null +++ b/doc/guides/nics/features/cxgbevf.ini @@ -0,0 +1,28 @@ +; +; Supported features of the 'cxgbevf' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Speed capabilities = Y +Link status = Y +Queue start/stop = Y +MTU update = Y +Jumbo frame = Y +Scattered Rx = Y +TSO = Y +Promiscuous mode = Y +Allmulticast mode = Y +RSS hash = Y +CRC offload = Y +VLAN offload = Y +L3 checksum offload = Y +L4 checksum offload = Y +Packet type parsing = Y +Basic stats = Y +Stats per queue = Y +Multiprocess aware = Y +Linux UIO = Y +Linux VFIO = Y +x86-32 = Y +x86-64 = Y diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index f2525bbd9..93ee69249 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -45,6 +45,11 @@ New Features Support to update RSS hash and key has been added to CXGBE PMD. +* **Added CXGBE VF PMD.** + + CXGBE VF Poll Mode Driver has been added to run DPDK over Chelsio + T5/T6 NIC VF instances. + * **Updated Solarflare network PMD.** Updated the sfc_efx driver including the following changes: diff --git a/drivers/net/cxgbe/Makefile b/drivers/net/cxgbe/Makefile index 65df14253..397977e02 100644 --- a/drivers/net/cxgbe/Makefile +++ b/drivers/net/cxgbe/Makefile @@ -80,6 +80,7 @@ VPATH += $(SRCDIR)/base # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbevf_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += cxgbe_main.c SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += sge.c SRCS-$(CONFIG_RTE_LIBRTE_CXGBE_PMD) += t4_hw.c diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 781d75cc2..7f523265d 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -63,6 +63,7 @@ #include #include "cxgbe.h" +#include "cxgbe_pfvf.h" /* * Macros needed to support the PCI Device ID Table ... @@ -135,8 +136,8 @@ static uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, return work_done; } -static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, - struct rte_eth_dev_info *device_info) +void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_info *device_info) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -178,7 +179,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, cxgbe_get_speed_caps(pi, &device_info->speed_capa); } -static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) +void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -187,7 +188,7 @@ static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) 1, -1, 1, -1, false); } -static void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) +void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -196,7 +197,7 @@ static void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) 0, -1, 1, -1, false); } -static void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) +void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -207,7 +208,7 @@ static void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) -1, 1, 1, -1, false); } -static void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev) +void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -218,8 +219,8 @@ static void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev) -1, 0, 1, -1, false); } -static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev, - __rte_unused int wait_to_complete) +int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev, + __rte_unused int wait_to_complete) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -239,7 +240,7 @@ static int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev, return 0; } -static int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) +int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -267,17 +268,10 @@ static int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu) return err; } -static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev, - uint16_t tx_queue_id); -static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev, - uint16_t tx_queue_id); -static void cxgbe_dev_tx_queue_release(void *q); -static void cxgbe_dev_rx_queue_release(void *q); - /* * Stop device. */ -static void cxgbe_dev_close(struct rte_eth_dev *eth_dev) +void cxgbe_dev_close(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -316,7 +310,7 @@ static void cxgbe_dev_close(struct rte_eth_dev *eth_dev) /* Start the device. * It returns 0 on success. */ -static int cxgbe_dev_start(struct rte_eth_dev *eth_dev) +int cxgbe_dev_start(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -368,7 +362,7 @@ static int cxgbe_dev_start(struct rte_eth_dev *eth_dev) /* * Stop device: disable rx and tx functions to allow for reconfiguring. */ -static void cxgbe_dev_stop(struct rte_eth_dev *eth_dev) +void cxgbe_dev_stop(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -387,7 +381,7 @@ static void cxgbe_dev_stop(struct rte_eth_dev *eth_dev) t4_sge_eth_clear_queues(pi); } -static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev) +int cxgbe_dev_configure(struct rte_eth_dev *eth_dev) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -409,8 +403,7 @@ static int cxgbe_dev_configure(struct rte_eth_dev *eth_dev) return 0; } -static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev, - uint16_t tx_queue_id) +int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) { int ret; struct sge_eth_txq *txq = (struct sge_eth_txq *) @@ -425,8 +418,7 @@ static int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev, return ret; } -static int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, - uint16_t tx_queue_id) +int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) { int ret; struct sge_eth_txq *txq = (struct sge_eth_txq *) @@ -441,10 +433,10 @@ static int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, return ret; } -static int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, - uint16_t queue_idx, uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_txconf *tx_conf) +int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, + uint16_t queue_idx, uint16_t nb_desc, + unsigned int socket_id, + const struct rte_eth_txconf *tx_conf) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -495,7 +487,7 @@ static int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, return err; } -static void cxgbe_dev_tx_queue_release(void *q) +void cxgbe_dev_tx_queue_release(void *q) { struct sge_eth_txq *txq = (struct sge_eth_txq *)q; @@ -511,8 +503,7 @@ static void cxgbe_dev_tx_queue_release(void *q) } } -static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev, - uint16_t rx_queue_id) +int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) { int ret; struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); @@ -531,8 +522,7 @@ static int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev, return ret; } -static int cxgbe_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, - uint16_t rx_queue_id) +int cxgbe_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) { int ret; struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); @@ -550,11 +540,11 @@ static int cxgbe_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, return ret; } -static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, - uint16_t queue_idx, uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mp) +int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, + uint16_t queue_idx, uint16_t nb_desc, + unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp) { struct port_info *pi = (struct port_info *)(eth_dev->data->dev_private); struct adapter *adapter = pi->adapter; @@ -628,7 +618,7 @@ static int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, return err; } -static void cxgbe_dev_rx_queue_release(void *q) +void cxgbe_dev_rx_queue_release(void *q) { struct sge_eth_rxq *rxq = (struct sge_eth_rxq *)q; struct sge_rspq *rq = &rxq->rspq; @@ -774,7 +764,7 @@ static int cxgbe_flow_ctrl_set(struct rte_eth_dev *eth_dev, &pi->link_cfg); } -static const uint32_t * +const uint32_t * cxgbe_dev_supported_ptypes_get(struct rte_eth_dev *eth_dev) { static const uint32_t ptypes[] = { diff --git a/drivers/net/cxgbe/cxgbe_pfvf.h b/drivers/net/cxgbe/cxgbe_pfvf.h new file mode 100644 index 000000000..e3d8533ca --- /dev/null +++ b/drivers/net/cxgbe/cxgbe_pfvf.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Chelsio Communications. + * All rights reserved. + */ + +#ifndef _CXGBE_PFVF_H_ +#define _CXGBE_PFVF_H_ + +void cxgbe_dev_rx_queue_release(void *q); +void cxgbe_dev_tx_queue_release(void *q); +void cxgbe_dev_stop(struct rte_eth_dev *eth_dev); +void cxgbe_dev_close(struct rte_eth_dev *eth_dev); +void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_info *device_info); +void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev); +void cxgbe_dev_promiscuous_disable(struct rte_eth_dev *eth_dev); +void cxgbe_dev_allmulticast_enable(struct rte_eth_dev *eth_dev); +void cxgbe_dev_allmulticast_disable(struct rte_eth_dev *eth_dev); +int cxgbe_dev_configure(struct rte_eth_dev *eth_dev); +int cxgbe_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t queue_idx, + uint16_t nb_desc, unsigned int socket_id, + const struct rte_eth_txconf *tx_conf); +int cxgbe_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t queue_idx, + uint16_t nb_desc, unsigned int socket_id, + const struct rte_eth_rxconf *rx_conf, + struct rte_mempool *mp); +int cxgbe_dev_tx_queue_start(struct rte_eth_dev *eth_dev, + uint16_t tx_queue_id); +int cxgbe_dev_rx_queue_start(struct rte_eth_dev *eth_dev, + uint16_t tx_queue_id); +int cxgbe_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id); +int cxgbe_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id); +int cxgbe_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu); +int cxgbe_dev_start(struct rte_eth_dev *eth_dev); +int cxgbe_dev_link_update(struct rte_eth_dev *eth_dev, + int wait_to_complete); +const uint32_t *cxgbe_dev_supported_ptypes_get(struct rte_eth_dev *eth_dev); +#endif /* _CXGBE_PFVF_H_ */ diff --git a/drivers/net/cxgbe/cxgbevf_ethdev.c b/drivers/net/cxgbe/cxgbevf_ethdev.c new file mode 100644 index 000000000..7d5b8c07f --- /dev/null +++ b/drivers/net/cxgbe/cxgbevf_ethdev.c @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Chelsio Communications. + * All rights reserved. + */ + +#include +#include + +#include "cxgbe.h" +#include "cxgbe_pfvf.h" + +/* + * Macros needed to support the PCI Device ID Table ... + */ +#define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \ + static const struct rte_pci_id cxgb4vf_pci_tbl[] = { +#define CH_PCI_DEVICE_ID_FUNCTION 0x8 + +#define PCI_VENDOR_ID_CHELSIO 0x1425 + +#define CH_PCI_ID_TABLE_ENTRY(devid) \ + { RTE_PCI_DEVICE(PCI_VENDOR_ID_CHELSIO, (devid)) } + +#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \ + { .vendor_id = 0, } \ + } + +/* + *... and the PCI ID Table itself ... + */ +#include "t4_pci_id_tbl.h" + +static const struct eth_dev_ops cxgbevf_eth_dev_ops = { + .dev_start = cxgbe_dev_start, + .dev_stop = cxgbe_dev_stop, + .dev_close = cxgbe_dev_close, + .promiscuous_enable = cxgbe_dev_promiscuous_enable, + .promiscuous_disable = cxgbe_dev_promiscuous_disable, + .allmulticast_enable = cxgbe_dev_allmulticast_enable, + .allmulticast_disable = cxgbe_dev_allmulticast_disable, + .dev_configure = cxgbe_dev_configure, + .dev_infos_get = cxgbe_dev_info_get, + .dev_supported_ptypes_get = cxgbe_dev_supported_ptypes_get, + .link_update = cxgbe_dev_link_update, + .mtu_set = cxgbe_dev_mtu_set, + .tx_queue_setup = cxgbe_dev_tx_queue_setup, + .tx_queue_start = cxgbe_dev_tx_queue_start, + .tx_queue_stop = cxgbe_dev_tx_queue_stop, + .tx_queue_release = cxgbe_dev_tx_queue_release, + .rx_queue_setup = cxgbe_dev_rx_queue_setup, + .rx_queue_start = cxgbe_dev_rx_queue_start, + .rx_queue_stop = cxgbe_dev_rx_queue_stop, + .rx_queue_release = cxgbe_dev_rx_queue_release, +}; + +/* + * Initialize driver + * It returns 0 on success. + */ +static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev) +{ + CXGBE_FUNC_TRACE(); + + eth_dev->dev_ops = &cxgbevf_eth_dev_ops; + + /* XXX: Do probe */ + return -EIO; +} + +static int eth_cxgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pci_dev) +{ + return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct port_info), + eth_cxgbevf_dev_init); +} + +static int eth_cxgbevf_pci_remove(struct rte_pci_device *pci_dev) +{ + return rte_eth_dev_pci_generic_remove(pci_dev, NULL); +} + +static struct rte_pci_driver rte_cxgbevf_pmd = { + .id_table = cxgb4vf_pci_tbl, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = eth_cxgbevf_pci_probe, + .remove = eth_cxgbevf_pci_remove, +}; + +RTE_PMD_REGISTER_PCI(net_cxgbevf, rte_cxgbevf_pmd); +RTE_PMD_REGISTER_PCI_TABLE(net_cxgbevf, cxgb4vf_pci_tbl); +RTE_PMD_REGISTER_KMOD_DEP(net_cxgbevf, "* igb_uio | vfio-pci"); -- 2.14.1