DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ziyang Xuan <xuanziyang2@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <xuanziyang2@huawei.com>,
	<waterman.cao@huawei.com>, <shahar.belkar@huawei.com>,
	<luoxianjun@huawei.com>, <tanya.brokhman@huawei.com>,
	<wulike1@huawei.com>, <zhouguoyang@huawei.com>,
	Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>
Subject: [dpdk-dev] [PATCH v1 03/15] net/hinic: add VF PMD operation interfaces
Date: Fri, 6 Sep 2019 20:50:52 +0800	[thread overview]
Message-ID: <8a01e9c2612db35a3cf9f648d62c16a1b0d0ea82.1567773211.git.xuanziyang2@huawei.com> (raw)
In-Reply-To: <cover.1567773211.git.xuanziyang2@huawei.com>

From: Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>

This patch adds VF PMD operation interfaces to support SRIOV.

Signed-off-by: Ziyang Xuan <xuanziyang2@huawei.com>
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 236 +++++++++++++++++++++++------------
 1 file changed, 159 insertions(+), 77 deletions(-)

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 044af90..90ebc16 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -20,6 +20,7 @@
 #include "base/hinic_pmd_cmdq.h"
 #include "base/hinic_pmd_niccfg.h"
 #include "base/hinic_pmd_nicio.h"
+#include "base/hinic_pmd_mbox.h"
 #include "hinic_pmd_ethdev.h"
 #include "hinic_pmd_tx.h"
 #include "hinic_pmd_rx.h"
@@ -32,6 +33,8 @@
 #define HINIC_DEV_ID_MEZZ_25GE		0x0210
 #define HINIC_DEV_ID_MEZZ_40GE		0x020D
 #define HINIC_DEV_ID_MEZZ_100GE		0x0205
+#define HINIC_DEV_ID_VF			0x375E
+#define HINIC_DEV_ID_VF_HV		0x379E
 
 #define HINIC_SERVICE_MODE_NIC		2
 
@@ -197,10 +200,16 @@ struct hinic_xstats_name_off {
 
 static int hinic_xstats_calc_num(struct hinic_nic_dev *nic_dev)
 {
-	return (HINIC_VPORT_XSTATS_NUM +
-		HINIC_PHYPORT_XSTATS_NUM +
-		HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq +
-		HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq);
+	if (HINIC_IS_VF(nic_dev->hwdev)) {
+		return (HINIC_VPORT_XSTATS_NUM +
+			HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq +
+			HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq);
+	} else {
+		return (HINIC_VPORT_XSTATS_NUM +
+			HINIC_PHYPORT_XSTATS_NUM +
+			HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq +
+			HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq);
+	}
 }
 
 static const struct rte_eth_desc_lim hinic_rx_desc_lim = {
@@ -913,6 +922,8 @@ static int hinic_dev_start(struct rte_eth_dev *dev)
 	(void)hinic_set_vport_enable(nic_dev->hwdev, false);
 
 en_vport_fail:
+	hinic_set_pf_status(nic_dev->hwdev->hwif, HINIC_PF_STATUS_INIT);
+
 	/* Flush tx && rx chip resources in case of set vport fake fail */
 	(void)hinic_flush_qp_res(nic_dev->hwdev);
 	rte_delay_ms(100);
@@ -1670,6 +1681,9 @@ static int hinic_dev_xstats_get(struct rte_eth_dev *dev,
 		count++;
 	}
 
+	if (HINIC_IS_VF(nic_dev->hwdev))
+		return count;
+
 	/* Get stats from hinic_phy_port_stats */
 	err = hinic_get_phy_port_stats(nic_dev->hwdev, &port_stats);
 	if (err)
@@ -1738,6 +1752,9 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev,
 		count++;
 	}
 
+	if (HINIC_IS_VF(nic_dev->hwdev))
+		return count;
+
 	/* get phy port stats */
 	for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) {
 		snprintf(xstats_names[count].name,
@@ -1778,18 +1795,39 @@ static int hinic_set_default_dcb_feature(struct hinic_nic_dev *nic_dev)
 					up_pgid, up_bw, up_strict);
 }
 
-static void hinic_init_default_cos(struct hinic_nic_dev *nic_dev)
+static int hinic_init_default_cos(struct hinic_nic_dev *nic_dev)
 {
-	nic_dev->default_cos =
-			(hinic_global_func_id(nic_dev->hwdev) +
-			 DEFAULT_BASE_COS) % NR_MAX_COS;
+	u8 cos_id = 0;
+	int err;
+
+	if (!HINIC_IS_VF(nic_dev->hwdev)) {
+		nic_dev->default_cos =
+				(hinic_global_func_id(nic_dev->hwdev) +
+						DEFAULT_BASE_COS) % NR_MAX_COS;
+	} else {
+		err = hinic_vf_get_default_cos(nic_dev->hwdev, &cos_id);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Get VF default cos failed, err: %d",
+					err);
+			return HINIC_ERROR;
+		}
+
+		nic_dev->default_cos = cos_id;
+	}
+
+	return 0;
 }
 
 static int hinic_set_default_hw_feature(struct hinic_nic_dev *nic_dev)
 {
 	int err;
 
-	hinic_init_default_cos(nic_dev);
+	err = hinic_init_default_cos(nic_dev);
+	if (err)
+		return err;
+
+	if (hinic_func_type(nic_dev->hwdev) == TYPE_VF)
+		return 0;
 
 	/* Restore DCB configure to default status */
 	err = hinic_set_default_dcb_feature(nic_dev);
@@ -1825,6 +1863,9 @@ static int32_t hinic_card_workmode_check(struct hinic_nic_dev *nic_dev)
 	struct hinic_board_info info = { 0 };
 	int rc;
 
+	if (hinic_func_type(nic_dev->hwdev) == TYPE_VF)
+		return 0;
+
 	rc = hinic_get_board_info(nic_dev->hwdev, &info);
 	if (rc)
 		return rc;
@@ -1840,7 +1881,7 @@ static int hinic_copy_mempool_init(struct hinic_nic_dev *nic_dev)
 		nic_dev->cpy_mpool =
 		rte_pktmbuf_pool_create(nic_dev->proc_dev_name,
 					HINIC_COPY_MEMPOOL_DEPTH,
-					RTE_CACHE_LINE_SIZE, 0,
+					0, 0,
 					HINIC_COPY_MBUF_SIZE,
 					rte_socket_id());
 		if (!nic_dev->cpy_mpool) {
@@ -1951,6 +1992,14 @@ static int hinic_nic_dev_create(struct rte_eth_dev *eth_dev)
 		goto init_pf_to_mgmt_fail;
 	}
 
+	/* init mailbox */
+	rc = hinic_comm_func_to_func_init(nic_dev->hwdev);
+	if (rc) {
+		PMD_DRV_LOG(ERR, "Initialize func_to_func failed, dev_name: %s",
+			    eth_dev->data->name);
+		goto init_func_to_func_fail;
+	}
+
 	rc = hinic_card_workmode_check(nic_dev);
 	if (rc) {
 		PMD_DRV_LOG(ERR, "Check card workmode failed, dev_name: %s",
@@ -2050,6 +2099,9 @@ static int hinic_nic_dev_create(struct rte_eth_dev *eth_dev)
 init_cmdq_fail:
 l2nic_reset_fail:
 workmode_check_fail:
+	hinic_comm_func_to_func_free(nic_dev->hwdev);
+
+init_func_to_func_fail:
 	hinic_comm_pf_to_mgmt_free(nic_dev->hwdev);
 
 init_pf_to_mgmt_fail:
@@ -2083,6 +2135,7 @@ static void hinic_nic_dev_destroy(struct rte_eth_dev *eth_dev)
 	hinic_deinit_nicio(nic_dev->hwdev);
 	hinic_deactivate_hwdev_state(nic_dev->hwdev);
 	hinic_comm_cmdqs_free(nic_dev->hwdev);
+	hinic_comm_func_to_func_free(nic_dev->hwdev);
 	hinic_comm_pf_to_mgmt_free(nic_dev->hwdev);
 	hinic_comm_aeqs_free(nic_dev->hwdev);
 	free_cfg_mgmt(nic_dev->hwdev);
@@ -2092,6 +2145,93 @@ static void hinic_nic_dev_destroy(struct rte_eth_dev *eth_dev)
 	nic_dev->hwdev = NULL;
 }
 
+/**
+ * DPDK callback to close the device.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ */
+static void hinic_dev_close(struct rte_eth_dev *dev)
+{
+	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+
+	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
+		PMD_DRV_LOG(WARNING, "Device %s already closed",
+			    dev->data->name);
+		return;
+	}
+
+	/* stop device first */
+	hinic_dev_stop(dev);
+
+	/* rx_cqe, rx_info */
+	hinic_free_all_rx_resources(dev);
+
+	/* tx_info */
+	hinic_free_all_tx_resources(dev);
+
+	/* free wq, pi_dma_addr */
+	hinic_free_all_rq(nic_dev);
+
+	/* free wq, db_addr */
+	hinic_free_all_sq(nic_dev);
+
+	/* deinit mac vlan tbl */
+	hinic_deinit_mac_addr(dev);
+
+	/* disable hardware and uio interrupt */
+	hinic_disable_interrupt(dev);
+
+	/* deinit nic hardware device */
+	hinic_nic_dev_destroy(dev);
+}
+
+static const struct eth_dev_ops hinic_pmd_ops = {
+	.dev_configure                 = hinic_dev_configure,
+	.dev_infos_get                 = hinic_dev_infos_get,
+	.rx_queue_setup                = hinic_rx_queue_setup,
+	.tx_queue_setup                = hinic_tx_queue_setup,
+	.dev_start                     = hinic_dev_start,
+	.link_update                   = hinic_link_update,
+	.rx_queue_release              = hinic_rx_queue_release,
+	.tx_queue_release              = hinic_tx_queue_release,
+	.dev_stop                      = hinic_dev_stop,
+	.dev_close                     = hinic_dev_close,
+	.promiscuous_enable            = hinic_dev_promiscuous_enable,
+	.promiscuous_disable           = hinic_dev_promiscuous_disable,
+	.rss_hash_update               = hinic_rss_hash_update,
+	.rss_hash_conf_get             = hinic_rss_conf_get,
+	.reta_update                   = hinic_rss_indirtbl_update,
+	.reta_query                    = hinic_rss_indirtbl_query,
+	.stats_get                     = hinic_dev_stats_get,
+	.stats_reset                   = hinic_dev_stats_reset,
+	.xstats_get                    = hinic_dev_xstats_get,
+	.xstats_reset                  = hinic_dev_xstats_reset,
+	.xstats_get_names              = hinic_dev_xstats_get_names,
+};
+
+static const struct eth_dev_ops hinic_pmd_vf_ops = {
+	.dev_configure                 = hinic_dev_configure,
+	.dev_infos_get                 = hinic_dev_infos_get,
+	.rx_queue_setup                = hinic_rx_queue_setup,
+	.tx_queue_setup                = hinic_tx_queue_setup,
+	.dev_start                     = hinic_dev_start,
+	.link_update                   = hinic_link_update,
+	.rx_queue_release              = hinic_rx_queue_release,
+	.tx_queue_release              = hinic_tx_queue_release,
+	.dev_stop                      = hinic_dev_stop,
+	.dev_close                     = hinic_dev_close,
+	.rss_hash_update               = hinic_rss_hash_update,
+	.rss_hash_conf_get             = hinic_rss_conf_get,
+	.reta_update                   = hinic_rss_indirtbl_update,
+	.reta_query                    = hinic_rss_indirtbl_query,
+	.stats_get                     = hinic_dev_stats_get,
+	.stats_reset                   = hinic_dev_stats_reset,
+	.xstats_get                    = hinic_dev_xstats_get,
+	.xstats_reset                  = hinic_dev_xstats_reset,
+	.xstats_get_names              = hinic_dev_xstats_get_names,
+};
+
 static int hinic_func_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
@@ -2146,6 +2286,11 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 		goto create_nic_dev_fail;
 	}
 
+	if (HINIC_IS_VF(nic_dev->hwdev))
+		eth_dev->dev_ops = &hinic_pmd_vf_ops;
+	else
+		eth_dev->dev_ops = &hinic_pmd_ops;
+
 	rc = hinic_init_mac_addr(eth_dev);
 	if (rc) {
 		PMD_DRV_LOG(ERR, "Initialize mac table failed, dev_name: %s",
@@ -2187,6 +2332,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	hinic_deinit_mac_addr(eth_dev);
 
 init_mac_fail:
+	eth_dev->dev_ops = NULL;
 	hinic_nic_dev_destroy(eth_dev);
 
 create_nic_dev_fail:
@@ -2199,71 +2345,6 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 	return rc;
 }
 
-/**
- * DPDK callback to close the device.
- *
- * @param dev
- *   Pointer to Ethernet device structure.
- */
-static void hinic_dev_close(struct rte_eth_dev *dev)
-{
-	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-
-	if (hinic_test_and_set_bit(HINIC_DEV_CLOSE, &nic_dev->dev_status)) {
-		PMD_DRV_LOG(WARNING, "Device %s already closed",
-			    dev->data->name);
-		return;
-	}
-
-	/* stop device first */
-	hinic_dev_stop(dev);
-
-	/* rx_cqe, rx_info */
-	hinic_free_all_rx_resources(dev);
-
-	/* tx_info */
-	hinic_free_all_tx_resources(dev);
-
-	/* free wq, pi_dma_addr */
-	hinic_free_all_rq(nic_dev);
-
-	/* free wq, db_addr */
-	hinic_free_all_sq(nic_dev);
-
-	/* deinit mac vlan tbl */
-	hinic_deinit_mac_addr(dev);
-
-	/* disable hardware and uio interrupt */
-	hinic_disable_interrupt(dev);
-
-	/* deinit nic hardware device */
-	hinic_nic_dev_destroy(dev);
-}
-
-static const struct eth_dev_ops hinic_pmd_ops = {
-	.dev_configure                 = hinic_dev_configure,
-	.dev_infos_get                 = hinic_dev_infos_get,
-	.rx_queue_setup                = hinic_rx_queue_setup,
-	.tx_queue_setup                = hinic_tx_queue_setup,
-	.dev_start                     = hinic_dev_start,
-	.link_update                   = hinic_link_update,
-	.rx_queue_release              = hinic_rx_queue_release,
-	.tx_queue_release              = hinic_tx_queue_release,
-	.dev_stop                      = hinic_dev_stop,
-	.dev_close                     = hinic_dev_close,
-	.promiscuous_enable            = hinic_dev_promiscuous_enable,
-	.promiscuous_disable           = hinic_dev_promiscuous_disable,
-	.rss_hash_update               = hinic_rss_hash_update,
-	.rss_hash_conf_get             = hinic_rss_conf_get,
-	.reta_update                   = hinic_rss_indirtbl_update,
-	.reta_query                    = hinic_rss_indirtbl_query,
-	.stats_get                     = hinic_dev_stats_get,
-	.stats_reset                   = hinic_dev_stats_reset,
-	.xstats_get                    = hinic_dev_xstats_get,
-	.xstats_reset                  = hinic_dev_xstats_reset,
-	.xstats_get_names              = hinic_dev_xstats_get_names,
-};
-
 static int hinic_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
@@ -2276,8 +2357,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev)
 		    (rte_eal_process_type() == RTE_PROC_PRIMARY) ?
 		    "primary" : "secondary");
 
-	/* rte_eth_dev ops, rx_burst and tx_burst */
-	eth_dev->dev_ops = &hinic_pmd_ops;
+	/* rte_eth_dev rx_burst and tx_burst */
 	eth_dev->rx_pkt_burst = hinic_recv_pkts;
 	eth_dev->tx_pkt_burst = hinic_xmit_pkts;
 
@@ -2311,6 +2391,8 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 	{ RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_25GE) },
 	{ RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_40GE) },
 	{ RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_100GE) },
+	{ RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_VF) },
+	{ RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_VF_HV) },
 	{.vendor_id = 0},
 };
 
-- 
1.8.3.1


  parent reply	other threads:[~2019-09-06 12:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 12:49 [dpdk-dev] [PATCH v1 00/15] Add advanced features for Huawei hinic pmd Ziyang Xuan
2019-09-06 12:49 ` [dpdk-dev] [PATCH v1 01/15] net/hinic/base: add mbox command channel for SRIOV Ziyang Xuan
2019-09-06 12:50 ` [dpdk-dev] [PATCH v1 02/15] net/hinic/base: add HW interfaces of SRIOV Ziyang Xuan
2019-09-06 12:50 ` Ziyang Xuan [this message]
2019-09-06 12:51 ` [dpdk-dev] [PATCH v1 04/15] net/hinic: add VLAN filter and offload Ziyang Xuan
2019-09-06 12:51 ` [dpdk-dev] [PATCH v1 05/15] net/hinic: add allmulticast mode and MTU set Ziyang Xuan
2019-09-06 12:52 ` [dpdk-dev] [PATCH v1 06/15] net/hinic: add unicast and multicast MAC set Ziyang Xuan
2019-09-06 12:52 ` [dpdk-dev] [PATCH v1 07/15] net/hinic: add fdir config interface Ziyang Xuan
2019-09-06 12:52 ` [dpdk-dev] [PATCH v1 08/15] net/hinic: add fdir validate flow operations Ziyang Xuan
2019-09-06 12:53 ` [dpdk-dev] [PATCH v1 09/15] net/hinic: create and destroy ntuple filter Ziyang Xuan
2019-09-06 12:53 ` [dpdk-dev] [PATCH v1 10/15] net/hinic: create and destroy fdir filter Ziyang Xuan
2019-09-06 12:54 ` [dpdk-dev] [PATCH v1 11/15] net/hinic: flush " Ziyang Xuan
2019-09-06 12:54 ` [dpdk-dev] [PATCH v1 12/15] net/hinic: set link down and up Ziyang Xuan
2019-09-06 12:55 ` [dpdk-dev] [PATCH v1 13/15] net/hinic: support inner L3 checksum offload Ziyang Xuan
2019-09-06 12:55 ` [dpdk-dev] [PATCH v1 14/15] net/hinic: support LRO offload Ziyang Xuan
2019-09-06 12:56 ` [dpdk-dev] [PATCH v1 15/15] net/hinic: add hinic PMD doc files Ziyang Xuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a01e9c2612db35a3cf9f648d62c16a1b0d0ea82.1567773211.git.xuanziyang2@huawei.com \
    --to=xuanziyang2@huawei.com \
    --cc=cloud.wangxiaoyun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=luoxianjun@huawei.com \
    --cc=shahar.belkar@huawei.com \
    --cc=tanya.brokhman@huawei.com \
    --cc=waterman.cao@huawei.com \
    --cc=wulike1@huawei.com \
    --cc=zhouguoyang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).