From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 712B6A04A4; Sat, 18 Dec 2021 03:54:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9328C41152; Sat, 18 Dec 2021 03:52:39 +0100 (CET) Received: from VLXDG1SPAM1.ramaxel.com (email.unionmem.com [221.4.138.186]) by mails.dpdk.org (Postfix) with ESMTP id E8DB3411E6 for ; Sat, 18 Dec 2021 03:52:36 +0100 (CET) Received: from V12DG1MBS01.ramaxel.local (v12dg1mbs01.ramaxel.local [172.26.18.31]) by VLXDG1SPAM1.ramaxel.com with ESMTPS id 1BI2q1C1010343 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 18 Dec 2021 10:52:01 +0800 (GMT-8) (envelope-from songyl@ramaxel.com) Received: from localhost.localdomain (10.64.9.47) by V12DG1MBS01.ramaxel.local (172.26.18.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Sat, 18 Dec 2021 10:52:00 +0800 From: Yanling Song To: CC: , , , Subject: [PATCH v1 14/25] net/spnic: add port/vport enable Date: Sat, 18 Dec 2021 10:51:41 +0800 Message-ID: <9770b350bfc497935e3df4b5b98982d572c02014.1639636621.git.songyl@ramaxel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.64.9.47] X-ClientProxiedBy: V12DG1MBS01.ramaxel.local (172.26.18.31) To V12DG1MBS01.ramaxel.local (172.26.18.31) X-DNSRBL: X-MAIL: VLXDG1SPAM1.ramaxel.com 1BI2q1C1010343 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch adds interface to enable port/vport so that the hardware would receive packets to host. Signed-off-by: Yanling Song --- drivers/net/spnic/spnic_ethdev.c | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c index db16d4038d..826a34f7fc 100644 --- a/drivers/net/spnic/spnic_ethdev.c +++ b/drivers/net/spnic/spnic_ethdev.c @@ -855,8 +855,10 @@ static void spnic_deinit_sw_rxtxqs(struct spnic_nic_dev *nic_dev) static int spnic_dev_start(struct rte_eth_dev *eth_dev) { struct spnic_nic_dev *nic_dev; + struct spnic_rxq *rxq = NULL; u64 nic_features; int err; + u16 i; nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev); @@ -916,6 +918,22 @@ static int spnic_dev_start(struct rte_eth_dev *eth_dev) spnic_start_all_sqs(eth_dev); + /* Open virtual port and ready to start packet receiving */ + err = spnic_set_vport_enable(nic_dev->hwdev, true); + if (err) { + PMD_DRV_LOG(ERR, "Enable vport failed, dev_name: %s", + eth_dev->data->name); + goto en_vport_fail; + } + + /* Open physical port and start packet receiving */ + err = spnic_set_port_enable(nic_dev->hwdev, true); + if (err) { + PMD_DRV_LOG(ERR, "Enable physical port failed, dev_name: %s", + eth_dev->data->name); + goto en_port_fail; + } + /* Update eth_dev link status */ if (eth_dev->data->dev_conf.intr_conf.lsc != 0) (void)spnic_link_update(eth_dev, 0); @@ -924,6 +942,20 @@ static int spnic_dev_start(struct rte_eth_dev *eth_dev) return 0; +en_port_fail: + (void)spnic_set_vport_enable(nic_dev->hwdev, false); + +en_vport_fail: + /* Flush tx && rx chip resources in case of setting vport fake fail */ + (void)spnic_flush_qps_res(nic_dev->hwdev); + rte_delay_ms(100); + for (i = 0; i < nic_dev->num_rqs; i++) { + rxq = nic_dev->rxqs[i]; + spnic_remove_rq_from_rx_queue_list(nic_dev, rxq->q_id); + spnic_free_rxq_mbufs(rxq); + eth_dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + eth_dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + } start_rqs_fail: spnic_remove_rxtx_configure(eth_dev); @@ -951,6 +983,7 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) { struct spnic_nic_dev *nic_dev; struct rte_eth_link link; + int err; nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev); if (!rte_bit_relaxed_test_and_clear32(SPNIC_DEV_START, &nic_dev->dev_status)) { @@ -959,6 +992,19 @@ static int spnic_dev_stop(struct rte_eth_dev *dev) return 0; } + /* Stop phy port and vport */ + err = spnic_set_port_enable(nic_dev->hwdev, false); + if (err) + PMD_DRV_LOG(WARNING, "Disable phy port failed, error: %d, " + "dev_name: %s, port_id: %d", err, dev->data->name, + dev->data->port_id); + + err = spnic_set_vport_enable(nic_dev->hwdev, false); + if (err) + PMD_DRV_LOG(WARNING, "Disable vport failed, error: %d, " + "dev_name: %s, port_id: %d", err, dev->data->name, + dev->data->port_id); + /* Clear recorded link status */ memset(&link, 0, sizeof(link)); (void)rte_eth_linkstatus_set(dev, &link); -- 2.27.0