From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 9CCE9199CE for ; Thu, 7 Sep 2017 10:36:53 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2017 01:36:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,357,1500966000"; d="scan'208";a="1011909894" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by orsmga003.jf.intel.com with ESMTP; 07 Sep 2017 01:36:50 -0700 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: Mohammad Abdul Awal , Remy Horton , Declan Doherty Date: Thu, 7 Sep 2017 09:35:39 +0100 Message-Id: <1504773339-21022-6-git-send-email-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504773339-21022-1-git-send-email-mohammad.abdul.awal@intel.com> References: <1504773339-21022-1-git-send-email-mohammad.abdul.awal@intel.com> Subject: [dpdk-dev] [RFC 5/5] Enable port representor PMD and broker for ixgbe PMD 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: Thu, 07 Sep 2017 08:36:54 -0000 Signed-off-by: Mohammad Abdul Awal Signed-off-by: Remy Horton Signed-off-by: Declan Doherty --- drivers/net/ixgbe/Makefile | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 33 +++-- drivers/net/ixgbe/ixgbe_ethdev.h | 11 ++ drivers/net/ixgbe/ixgbe_prep_ops.c | 279 +++++++++++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_prep_ops.h | 41 ++++++ 5 files changed, 353 insertions(+), 13 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_prep_ops.c create mode 100644 drivers/net/ixgbe/ixgbe_prep_ops.h diff --git a/drivers/net/ixgbe/Makefile b/drivers/net/ixgbe/Makefile index 5e57cb3..f216b97 100644 --- a/drivers/net/ixgbe/Makefile +++ b/drivers/net/ixgbe/Makefile @@ -1,7 +1,6 @@ # BSD LICENSE # # Copyright(c) 2010-2016 Intel Corporation. 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 @@ -125,6 +124,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_82599_bypass.c endif SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += rte_pmd_ixgbe.c SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_tm.c +SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_prep_ops.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_IXGBE_PMD)-include := rte_pmd_ixgbe.h diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 22171d8..80d5d34 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2,7 +2,6 @@ * BSD LICENSE * * Copyright(c) 2010-2017 Intel Corporation. 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 @@ -72,6 +71,7 @@ #include "base/ixgbe_type.h" #include "base/ixgbe_phy.h" #include "ixgbe_regs.h" +#include "ixgbe_prep_ops.h" /* * High threshold controlling when to start sending XOFF frames. Must be at @@ -173,8 +173,6 @@ static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev); static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev); static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev); static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev); -static int ixgbe_dev_link_update(struct rte_eth_dev *dev, - int wait_to_complete); static void ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev, @@ -205,8 +203,6 @@ static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, static void ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev); -static void ixgbevf_dev_info_get(struct rte_eth_dev *dev, - struct rte_eth_dev_info *dev_info); static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev, @@ -267,9 +263,6 @@ static void ixgbevf_dev_stop(struct rte_eth_dev *dev); static void ixgbevf_dev_close(struct rte_eth_dev *dev); static void ixgbevf_intr_disable(struct ixgbe_hw *hw); static void ixgbevf_intr_enable(struct ixgbe_hw *hw); -static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev, - struct rte_eth_stats *stats); -static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev); static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, @@ -1131,6 +1124,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev) uint32_t ctrl_ext; uint16_t csum; int diag, i; + struct rte_port_representor_broker *rep_broker; PMD_INIT_FUNC_TRACE(); @@ -1248,6 +1242,17 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev) return -EIO; } + /* Init port representor broker */ + if (rte_representor_enabled()) { + rep_broker = rte_representor_broker_init(eth_dev, + pci_dev->max_vfs, rte_ixgbe_prep_ops); + if (rep_broker == NULL) { + PMD_INIT_LOG(ERR, "Cannot allocate memory for " + "representor broker data\n"); + return errno; + } + } + /* Reset the hw statistics */ ixgbe_dev_stats_reset(eth_dev); @@ -1362,6 +1367,10 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev) hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + /* Deinit port representor broker */ + if (rte_representor_enabled()) + rte_representor_broker_free(eth_dev->data->port_id); + if (hw->adapter_stopped == 0) ixgbe_dev_close(eth_dev); @@ -3541,7 +3550,7 @@ ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, return IXGBEVF_NB_XSTATS; } -static void +void ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *) @@ -3558,7 +3567,7 @@ ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->obytes = hw_stats->vfgotc; } -static void +void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev) { struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *) @@ -3746,7 +3755,7 @@ ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev) return NULL; } -static void +void ixgbevf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -4004,7 +4013,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, return 0; } -static int +int ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) { return ixgbe_dev_link_update_share(dev, wait_to_complete, 0); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index caa50c8..1534ab7 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -589,6 +589,17 @@ struct ixgbe_adapter { /* * RX/TX function prototypes */ + +int ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); + +void ixgbevf_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats); + +void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev); + +void ixgbevf_dev_info_get(struct rte_eth_dev *dev, + struct rte_eth_dev_info *dev_info); + void ixgbe_dev_clear_queues(struct rte_eth_dev *dev); void ixgbe_dev_free_queues(struct rte_eth_dev *dev); diff --git a/drivers/net/ixgbe/ixgbe_prep_ops.c b/drivers/net/ixgbe/ixgbe_prep_ops.c new file mode 100644 index 0000000..b2d099a --- /dev/null +++ b/drivers/net/ixgbe/ixgbe_prep_ops.c @@ -0,0 +1,279 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 Intel Corporation. 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 Intel Corporation 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 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 +#include + +#include "base/ixgbe_type.h" +#include "ixgbe_ethdev.h" +#include "ixgbe_rxtx.h" +#include "rte_pmd_ixgbe.h" + +#include "ixgbe_prep_ops.h" + +static int ixgbe_prep_link_update( + __rte_unused struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, int wait_to_complete) +{ + return ixgbe_dev_link_update(prep->pdev, wait_to_complete); +} + +static void ixgbe_prep_promiscuous_enable( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep) +{ +} + +static void ixgbe_prep_promiscuous_disable( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep) +{ +} + +static void ixgbe_prep_allmulticast_enable( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep) +{ +} + +static void ixgbe_prep_allmulticast_disable( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep) +{ +} + +static void ixgbe_prep_mac_addr_remove( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep, + __rte_unused uint32_t index) +{ +} + +static int ixgbe_prep_mac_addr_add( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep, + __rte_unused struct ether_addr *mac_addr, __rte_unused uint32_t index, + __rte_unused uint32_t vmdq) +{ + return -ENOTSUP; +} + +static void ixgbe_prep_mac_addr_set(struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, struct ether_addr *mac_addr) +{ + uint32_t pfid; + uint32_t vf_index; + + pfid = rb->pfid; + vf_index = prep->vf_index; + + rte_pmd_ixgbe_set_vf_mac_addr(pfid, vf_index, mac_addr); +} + +static int ixgbe_prep_stats_get( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep, + __rte_unused struct rte_eth_stats *stats) +{ + return -ENOTSUP; +} + +static void ixgbe_prep_stats_reset( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep) +{ +} + +/* From ixgbe_ethdev.c */ +#define IXGBE_DEFAULT_RX_FREE_THRESH 32 +#define IXGBE_DEFAULT_RX_PTHRESH 8 +#define IXGBE_DEFAULT_RX_HTHRESH 8 +#define IXGBE_DEFAULT_RX_WTHRESH 0 +#define IXGBE_DEFAULT_TX_FREE_THRESH 32 +#define IXGBE_DEFAULT_TX_PTHRESH 32 +#define IXGBE_DEFAULT_TX_HTHRESH 0 +#define IXGBE_DEFAULT_TX_WTHRESH 0 +#define IXGBE_DEFAULT_TX_RSBIT_THRESH 32 +#define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */ + +static void ixgbe_prep_dev_infos_get( + __rte_unused struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, struct rte_eth_dev_info *dev_info) +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(prep->vdev); + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW( + prep->pdev->data->dev_private); + + /* Info pulled from HW MAC */ + dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues; + dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues; + if (hw->mac.type == ixgbe_mac_82598EB) + dev_info->max_vmdq_pools = ETH_16_POOLS; + else + dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->max_mac_addrs = hw->mac.num_rar_entries; + + dev_info->pci_dev = pci_dev; + + /* Hard-coded info */ + dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */ + dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */ + dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC; + dev_info->max_vfs = pci_dev->max_vfs; + + 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_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_TCP_TSO; + + dev_info->default_rxconf = (struct rte_eth_rxconf) { + .rx_thresh = { + .pthresh = IXGBE_DEFAULT_RX_PTHRESH, + .hthresh = IXGBE_DEFAULT_RX_HTHRESH, + .wthresh = IXGBE_DEFAULT_RX_WTHRESH, + }, + .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH, + .rx_drop_en = 0, + }; + + dev_info->default_txconf = (struct rte_eth_txconf) { + .tx_thresh = { + .pthresh = IXGBE_DEFAULT_TX_PTHRESH, + .hthresh = IXGBE_DEFAULT_TX_HTHRESH, + .wthresh = IXGBE_DEFAULT_TX_WTHRESH, + }, + .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH, + .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH, + .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | + ETH_TXQ_FLAGS_NOOFFLOADS, + }; + + dev_info->rx_desc_lim = (struct rte_eth_desc_lim) { + .nb_max = IXGBE_MAX_RING_DESC, + .nb_min = IXGBE_MIN_RING_DESC, + .nb_align = IXGBE_RXD_ALIGN, + }; + + dev_info->tx_desc_lim = (struct rte_eth_desc_lim) { + .nb_max = IXGBE_MAX_RING_DESC, + .nb_min = IXGBE_MIN_RING_DESC, + .nb_align = IXGBE_TXD_ALIGN, + .nb_seg_max = IXGBE_TX_MAX_SEG, + .nb_mtu_seg_max = IXGBE_TX_MAX_SEG, + }; +} + +static int ixgbe_prep_vlan_filter_set(struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, uint16_t vlan_id, int on) +{ + uint32_t pfid; + uint32_t vf_index; + uint64_t vf_mask; + + pfid = rb->pfid; + vf_index = prep->vf_index; + vf_mask = 1ULL << vf_index; + + return rte_pmd_ixgbe_set_vf_vlan_filter(pfid, vlan_id, vf_mask, on); +} + + +static int ixgbe_prep_vlan_tpid_set(struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, + enum rte_vlan_type type, uint16_t tpid) +{ + RTE_SET_USED(rb); + RTE_SET_USED(prep); + RTE_SET_USED(type); + RTE_SET_USED(tpid); + return -ENOTSUP; +} + +static void ixgbe_prep_vlan_offload_set( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep, __rte_unused int mask) +{ +} + +static void ixgbe_prep_vlan_strip_queue_set( + struct rte_port_representor_broker *rb, + struct rte_port_representor *prep, int on) +{ + uint32_t pfid; + uint32_t vf_index; + + pfid = rb->pfid; + vf_index = prep->vf_index; + + rte_pmd_ixgbe_set_vf_vlan_stripq(pfid, vf_index, on); +} + +static int ixgbe_prep_vlan_pvid_set( + __rte_unused struct rte_port_representor_broker *rb, + __rte_unused struct rte_port_representor *prep, + __rte_unused uint16_t vlan_id) +{ + return -ENOTSUP; +} + +struct representor_ops ixgbe_prep_ops = { + .link_update = ixgbe_prep_link_update, + + .promiscuous_enable = ixgbe_prep_promiscuous_enable, + .promiscuous_disable = ixgbe_prep_promiscuous_disable, + .allmulticast_enable = ixgbe_prep_allmulticast_enable, + .allmulticast_disable = ixgbe_prep_allmulticast_disable, + + .mac_addr_remove = ixgbe_prep_mac_addr_remove, + .mac_addr_add = ixgbe_prep_mac_addr_add, + .mac_addr_set = ixgbe_prep_mac_addr_set, + + .stats_get = ixgbe_prep_stats_get, + .stats_reset = ixgbe_prep_stats_reset, + + .dev_infos_get = ixgbe_prep_dev_infos_get, + + .vlan_filter_set = ixgbe_prep_vlan_filter_set, + .vlan_tpid_set = ixgbe_prep_vlan_tpid_set, + .vlan_offload_set = ixgbe_prep_vlan_offload_set, + .vlan_strip_queue_set = ixgbe_prep_vlan_strip_queue_set, + .vlan_pvid_set = ixgbe_prep_vlan_pvid_set, +}; + +struct representor_ops *rte_ixgbe_prep_ops = &ixgbe_prep_ops; + diff --git a/drivers/net/ixgbe/ixgbe_prep_ops.h b/drivers/net/ixgbe/ixgbe_prep_ops.h new file mode 100644 index 0000000..eb01bdd --- /dev/null +++ b/drivers/net/ixgbe/ixgbe_prep_ops.h @@ -0,0 +1,41 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 Intel Corporation. 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 Intel Corporation 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 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 _IXGBE_PREP_OPS_H_ +#define _IXGBE_PREP_OPS_H_ + +#include + +extern struct representor_ops *rte_ixgbe_prep_ops; + +#endif /* _IXGBE_PREP_OPS_H_ */ -- 2.7.4