From patchwork Wed Sep 2 06:38:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiming Yang X-Patchwork-Id: 76291 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E73F1A04B5; Wed, 2 Sep 2020 08:59:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F1411C069; Wed, 2 Sep 2020 08:59:30 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BE0F0CF3 for ; Wed, 2 Sep 2020 08:59:28 +0200 (CEST) IronPort-SDR: kjAS0o5qdC/juQUKu+d1jQYVPiWEiTa33eE0ioZqC1c8j4pygX73LA0Vy2N5veTJuRXU1SzEvo e+0RfHxJuiOg== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="156593269" X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="156593269" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2020 23:59:26 -0700 IronPort-SDR: tNZaHPw0Mfc4CL8ojvvmpy2cnuCgtK3uMTBME5cDZ4vbpoySopshDat88t/y7dIWlOsgah9gR2 qG2bhtRf2Jsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,381,1592895600"; d="scan'208";a="325664230" Received: from dpdk-qiming1.sh.intel.com ([10.67.119.9]) by fmsmga004.fm.intel.com with ESMTP; 01 Sep 2020 23:59:25 -0700 From: Qiming Yang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, Qiming Yang Date: Wed, 2 Sep 2020 14:38:01 +0800 Message-Id: <20200902063802.102428-2-qiming.yang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200902063802.102428-1-qiming.yang@intel.com> References: <20200902063802.102428-1-qiming.yang@intel.com> Subject: [dpdk-dev] [PATCH 1/2] net/ice: add dcf port representor infrastructure 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Defines data structures and code to init/uninit VF representors during pci_probe and pci_remove respectively. Most of the dev_ops for the VF representor are just stubs for now and will be will be filled out in next patch Signed-off-by: Qiming Yang --- drivers/net/ice/Makefile | 1 + drivers/net/ice/ice_dcf_ethdev.c | 66 +++++- drivers/net/ice/ice_dcf_ethdev.h | 11 + drivers/net/ice/ice_dcf_vf_representor.c | 245 +++++++++++++++++++++++ 4 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ice/ice_dcf_vf_representor.c diff --git a/drivers/net/ice/Makefile b/drivers/net/ice/Makefile index 34cd4024b..f9eb34a87 100644 --- a/drivers/net/ice/Makefile +++ b/drivers/net/ice/Makefile @@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_vf_representor.c SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c # install this header file diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 2faed3cc7..73af87785 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -973,17 +973,79 @@ ice_dcf_cap_selected(struct rte_devargs *devargs) static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) { + struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 }; + char name[RTE_ETH_NAME_MAX_LEN]; + int i, retval; + if (!ice_dcf_cap_selected(pci_dev->device.devargs)) return 1; - return rte_eth_dev_pci_generic_probe(pci_dev, + if (pci_dev->device.devargs) { + retval = rte_eth_devargs_parse(pci_dev->device.devargs->args, + ð_da); + if (retval) + return retval; + } + + retval = rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct ice_dcf_adapter), ice_dcf_dev_init); + if (retval) + return retval; + + /* probe VF representor ports */ + struct rte_eth_dev *dcf_ethdev = + rte_eth_dev_allocated(pci_dev->device.name); + + if (dcf_ethdev == NULL) { + PMD_DRV_LOG(ERR, "failed to allocate ethdev.\n"); + return -ENODEV; + } + + for (i = 0; i < eth_da.nb_representor_ports; i++) { + if (eth_da.representor_ports[i] == 0) { + PMD_DRV_LOG(ERR, "vf 0 can't be a vf representor.\n"); + continue; + } + + struct ice_dcf_vf_representor representor = { + .vf_id = eth_da.representor_ports[i], + .switch_domain_id = 0, + .adapter = (struct ice_dcf_adapter *) + dcf_ethdev->data->dev_private + }; + + snprintf(name, sizeof(name), "net_%s_representor_%d", + pci_dev->device.name, eth_da.representor_ports[i]); + + retval = rte_eth_dev_create(&pci_dev->device, name, + sizeof(struct ice_dcf_vf_representor), + NULL, NULL, ice_dcf_vf_representor_init, + &representor); + + if (retval) + PMD_DRV_LOG(ERR, + "failed to create dcf vf representor %s.\n", + name); + } + + return 0; } static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev) { - return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit); + struct rte_eth_dev *ethdev; + + ethdev = rte_eth_dev_allocated(pci_dev->device.name); + if (!ethdev) + return 0; + + if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + return rte_eth_dev_pci_generic_remove(pci_dev, + ice_dcf_dev_uninit); + else + return rte_eth_dev_pci_generic_remove(pci_dev, + ice_dcf_vf_representor_uninit); } static const struct rte_pci_id pci_id_ice_dcf_map[] = { diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index b54528bea..bf6e6982f 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -22,9 +22,20 @@ struct ice_dcf_adapter { struct ice_dcf_hw real_hw; }; +/** + * Struct to store private data for each VF representor instance + */ +struct ice_dcf_vf_representor { + struct ice_dcf_adapter *adapter; + uint16_t switch_domain_id; + uint16_t vf_id; +}; + void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, uint8_t *msg, uint16_t msglen); int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev); void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev); +int ice_dcf_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params); +int ice_dcf_vf_representor_uninit(struct rte_eth_dev *ethdev); #endif /* _ICE_DCF_ETHDEV_H_ */ diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c new file mode 100644 index 000000000..ceb54ab15 --- /dev/null +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -0,0 +1,245 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Intel Corporation + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ice_generic_flow.h" +#include "ice_dcf_ethdev.h" +#include "ice_rxtx.h" + +static uint16_t +ice_dcf_representor_rx_burst(__rte_unused void *rxq, + __rte_unused struct rte_mbuf **rx_pkts, + __rte_unused uint16_t nb_pkts) +{ + return 0; +} + +static uint16_t +ice_dcf_representor_tx_burst(__rte_unused void *txq, + __rte_unused struct rte_mbuf **tx_pkts, + __rte_unused uint16_t nb_pkts) +{ + return 0; +} + +static int +ice_dcf_representor_dev_configure(__rte_unused struct rte_eth_dev *dev) +{ + return 0; +} + +static int +ice_dcf_representor_dev_start(struct rte_eth_dev *dev) +{ + dev->data->dev_link.link_status = ETH_LINK_UP; + + return 0; +} + +static void +ice_dcf_representor_dev_stop(struct rte_eth_dev *dev) +{ + dev->data->dev_link.link_status = ETH_LINK_DOWN; +} + +static int +ice_dcf_representor_rx_queue_setup(__rte_unused struct rte_eth_dev *dev, + __rte_unused uint16_t rx_queue_id, + __rte_unused uint16_t nb_rx_desc, + __rte_unused unsigned int socket_id, + __rte_unused const struct rte_eth_rxconf *rx_conf, + __rte_unused struct rte_mempool *mb_pool) +{ + return 0; +} + +static int +ice_dcf_representor_tx_queue_setup(__rte_unused struct rte_eth_dev *dev, + __rte_unused uint16_t rx_queue_id, + __rte_unused uint16_t nb_rx_desc, + __rte_unused unsigned int socket_id, + __rte_unused const struct rte_eth_txconf *tx_conf) +{ + return 0; +} + +static int +ice_dcf_representor_promiscuous_enable(__rte_unused struct rte_eth_dev *ethdev) +{ + return 0; +} + +static int +ice_dcf_representor_promiscuous_disable(__rte_unused struct rte_eth_dev *ethdev) +{ + return 0; +} + +static int +ice_dcf_representor_link_update(__rte_unused struct rte_eth_dev *ethdev, + __rte_unused int wait_to_complete) +{ + return 0; +} + +static int +ice_dcf_representor_dev_info_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info) +{ + struct ice_dcf_vf_representor *representor = dev->data->dev_private; + struct ice_dcf_hw *hw = &representor->adapter->real_hw; + + dev_info->device = dev->device; + dev_info->max_mac_addrs = 1; + dev_info->max_rx_queues = hw->vsi_res->num_queue_pairs; + dev_info->max_tx_queues = hw->vsi_res->num_queue_pairs; + dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN; + dev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX; + dev_info->hash_key_size = hw->vf_res->rss_key_size; + dev_info->reta_size = hw->vf_res->rss_lut_size; + dev_info->flow_type_rss_offloads = ICE_RSS_OFFLOAD_ALL; + + dev_info->rx_offload_capa = + DEV_RX_OFFLOAD_VLAN_STRIP | + DEV_RX_OFFLOAD_IPV4_CKSUM | + DEV_RX_OFFLOAD_UDP_CKSUM | + DEV_RX_OFFLOAD_TCP_CKSUM | + DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_RX_OFFLOAD_SCATTER | + DEV_RX_OFFLOAD_JUMBO_FRAME | + DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_RSS_HASH; + dev_info->tx_offload_capa = + DEV_TX_OFFLOAD_VLAN_INSERT | + DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | + DEV_TX_OFFLOAD_TCP_TSO | + DEV_TX_OFFLOAD_VXLAN_TNL_TSO | + DEV_TX_OFFLOAD_GRE_TNL_TSO | + DEV_TX_OFFLOAD_IPIP_TNL_TSO | + DEV_TX_OFFLOAD_GENEVE_TNL_TSO | + DEV_TX_OFFLOAD_MULTI_SEGS; + + dev_info->default_rxconf = (struct rte_eth_rxconf) { + .rx_thresh = { + .pthresh = ICE_DEFAULT_RX_PTHRESH, + .hthresh = ICE_DEFAULT_RX_HTHRESH, + .wthresh = ICE_DEFAULT_RX_WTHRESH, + }, + .rx_free_thresh = ICE_DEFAULT_RX_FREE_THRESH, + .rx_drop_en = 0, + .offloads = 0, + }; + + dev_info->default_txconf = (struct rte_eth_txconf) { + .tx_thresh = { + .pthresh = ICE_DEFAULT_TX_PTHRESH, + .hthresh = ICE_DEFAULT_TX_HTHRESH, + .wthresh = ICE_DEFAULT_TX_WTHRESH, + }, + .tx_free_thresh = ICE_DEFAULT_TX_FREE_THRESH, + .tx_rs_thresh = ICE_DEFAULT_TX_RSBIT_THRESH, + .offloads = 0, + }; + + dev_info->rx_desc_lim = (struct rte_eth_desc_lim) { + .nb_max = ICE_MAX_RING_DESC, + .nb_min = ICE_MIN_RING_DESC, + .nb_align = ICE_ALIGN_RING_DESC, + }; + + dev_info->tx_desc_lim = (struct rte_eth_desc_lim) { + .nb_max = ICE_MAX_RING_DESC, + .nb_min = ICE_MIN_RING_DESC, + .nb_align = ICE_ALIGN_RING_DESC, + }; + + dev_info->switch_info.name = + representor->adapter->real_hw.eth_dev->device->name; + dev_info->switch_info.domain_id = representor->switch_domain_id; + dev_info->switch_info.port_id = representor->vf_id; + + return 0; +} + +static const struct eth_dev_ops ice_dcf_representor_dev_ops = { + .dev_configure = ice_dcf_representor_dev_configure, + .dev_start = ice_dcf_representor_dev_start, + .dev_stop = ice_dcf_representor_dev_stop, + .dev_infos_get = ice_dcf_representor_dev_info_get, + .rx_queue_setup = ice_dcf_representor_rx_queue_setup, + .tx_queue_setup = ice_dcf_representor_tx_queue_setup, + .promiscuous_enable = ice_dcf_representor_promiscuous_enable, + .promiscuous_disable = ice_dcf_representor_promiscuous_disable, + .link_update = ice_dcf_representor_link_update, +}; + +int +ice_dcf_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) +{ + struct ice_dcf_vf_representor *representor = ethdev->data->dev_private; + struct ice_dcf_hw *real_hw; + + representor->adapter = + ((struct ice_dcf_vf_representor *)init_params)->adapter; + representor->switch_domain_id = + ((struct ice_dcf_vf_representor *) + init_params)->switch_domain_id; + representor->vf_id = + ((struct ice_dcf_vf_representor *)init_params)->vf_id; + + real_hw = &representor->adapter->real_hw; + + if (representor->vf_id >= real_hw->num_vfs) + return -ENODEV; + + ethdev->dev_ops = &ice_dcf_representor_dev_ops; + + /* No data-path, but need stub Rx/Tx functions to avoid crash + * when testing with the likes of testpmd. + */ + ethdev->rx_pkt_burst = ice_dcf_representor_rx_burst; + ethdev->tx_pkt_burst = ice_dcf_representor_tx_burst; + + ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR; + ethdev->data->representor_id = representor->vf_id; + + struct rte_ether_addr mac_addr; + + memset(&mac_addr, 0, sizeof(mac_addr)); + ethdev->data->mac_addrs = &mac_addr; + + return 0; +} + +int +ice_dcf_vf_representor_uninit(struct rte_eth_dev *ethdev) +{ + ethdev->data->mac_addrs = NULL; + + return 0; +} +