From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0042.outbound.protection.outlook.com [104.47.42.42]) by dpdk.org (Postfix) with ESMTP id A71A4FAE8 for ; Thu, 2 Mar 2017 12:40:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lzA+tZo1f8zzbBsO/FENe6b/5ot3Q6OPXb4lT2BBduU=; b=Q/cqVxs8+qQvyP3EDjWF8L/94wj/kf8MLrHVl93yxQIIrgnOxQGbxpJhwDHOPnWOTt/tUZcux1lkNv/fTFMgqX3dE22VqufWsHPNkCo39QYhCCTXcqCa+V9cZjFw340MROu8USKeZYpobYT0a+v9x+3vgXCnsnd2XA0/oZuSXtQ= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:40:12 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:49 +0530 Message-Id: <1488454371-3342-45-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: 3f51b1cd-b85a-4df2-e522-08d46160e504 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:539e2qo9oK1wRdKv7JbFWmwzsjPVEjOZw91NExjBVdTIRJETsRbhxo7iuDTVNx/7IbqdQWLCv0WbujCYzvbUKPQRONb/ehuLp0Nww7gxfdL3GZBKjCbcYSOR8uAk1XSzcgnFcU3PJljgp1cQJfnxi3PnNCd/1DlcCRk3qSSNbxNzTHRrBPmxkvZ01z9q2JMjNP8aVvxTq/TCBhFFxcaE8kTT9ZOxd+q1ugGs2IQf03RxZEfwnrSWLE3DPuX2poB4MiYcwtOPhCsvCWV3muKhxg==; 25:/pu5ngV2CgJur3FKbRCnsMM1g2m9mRRpmr4XSeEUITHtQdnBN6lYhjDrPPpZJ9P+QRhH+iAsuOqs79H6I6FqlHXjvJOoPs82EG45TRUcuWBygjLnqFvTolUK5ldZsbyWxeDXBGTnc1zmp5tcY1EignCGVk4wm0qXkUPvcll+N3MzXICFkaSP/7RHO5clz2fQBiFc9faAvmTh21C3v1xIfv0ZlcbhxP9MYtaTVPjK13PXu6J1XLG+3MfpRZAf77ktCAF4uRBPOBt1Rx0WK6amW44CQ+b/jaK0aGUyKek/ysxttWJnizq3rbDg8aofOySCKDI5NrJ8loqvgZjdehvptNeNjxAbgaLO7vDSyoW7vkm21NK2QDchPOKQPHbDMPYN9lHhx2WLIdrrk8lxdvrNttXq25Vs7ctvg4aBx0ya3HG6CUZ6/ejA9bM1xvsGCIePDGFeZbR4ry5ffr982+GCoQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:NbLuFpbvvzS5rIORD9i/bBzGGgmrl+3VRmtefyiygWsSGcA42rvtu7GnCapcTyu5y1+SYv4nCIRfiwNK303/IQ1W/obeQA/3J7SVg32nU0TQvFWBeeSkTzrIHaXDKBPUJPWc/uL69MvyEen2kaCj9mzf0IxkTtStFa9m9uWHxsDTBCBjcJ/xXaWyw0XMCgf4xn8SS/z7q3v7yr2ma+eOwIjdTrqvKHCQ5xPRChgU7NoCxacAqh24pi+5do+0/U2Y; 20:GzmBJT9+TLLccsJAVTEIVyOXHtZ4rhO19gSZqDmfykHBO1jY4+sOL90PMCnFsvs+G/yUtqvUsrr0XN90rldeFen6Uf3dp2oX/dhMQa8MGVY8UgCwDVvux3To7xj1oFQgmrXHs4lSfROtDKsrU7RqNfP+eXUj/TyVHK1Txo+RiUcrvuMpt66LXGihxnW7O7kVR78Pd737ayr/CLqA13ASdgdyldQJW+JcVCBoBaDplESLXB5tekMkVCSkrR6nOW7O9YOeF8UxDf2rfydDoA63sfvmBh1CbVxSHv/thydSGD6FjaRpzCq49TtR4Gx7FPwzeg6jblK0tDzF5cxeSMAKeELMkeuRKGxTGQu4Qbyv+w1XYrcAUpevo2ovHCySss+oCLcgyVdrGXGgcEBn6ycp3HGQ495u334vQKPmSdy+rkO8dLEjPFQNDecZFsv1D2ubmr85cpHqXMPy6i6ZDkfJOMWb0ydXlKn2rooyxOK+YU6hCVzTlvax+Lo0VimX7iU2aGcHsOMoCNGbGjNktWHTlJ3QAwjrkYDEeS7YO2pzHolNcvC8xOF2K13qlmFZ5pvwg6oF1LsbJfIesogYx0PsvOWnDq3Es8+KQxRJj2d8zck= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:oQxftiRzoE9QLiUFTDP1VxZ9ZmAeikXj2ncvYdnyDt+WD5fqcCsM3wOf0KMPdx6OLljO7KFu+yeRrmAhdbrtjorRS4QrwyDFU630vxVmVFVWLR7jMRIXvFfaeywqkrpv6ciYSQU1jFYY/25EATzbjujyyYd0h0HTnSCQmanJdP2+9Ff42DKj03gQ2wjJPAPHWlF9R463CySTYjKY3TMU7hukxEqMG+lLMca71uTRziARr0aEjJAa+YEr8Z/ahChUdbOPRj2UKJLtkQsqcPtXUZNwwBDdBWh/5nkeq7//63BjVrbCy5xNHzkFiPKX6U3gQR24po1tN9ioUZvhyWFg76sFOIElC+2yKdmMQ3ahU2p51oZjzAXAOqoVNhnHpiWKPbWHwSoS+g/VxxephEDCo5Ud6Gf3hwaKEgk5ql7jvFw7bmsTHtlhn32+/Jah+TMgSOkqWdU2eSeILtzkEAcW3xkhODSxIzO5+kKmzG1BLm4bQIFbBXvV7a1Pcc2xEUtDN3KZG6fnmGWn6NblSi3jj2bMXqvL9PRRp3SPy2a+1k1v987ThFaxq3I/Mn/t2GfBRjYkrUpOALCCGdv9ZcaT587Bb4MnM++Tld9ZCCI/m2I= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(2950100002)(6916009)(42882006)(575784001)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(6666003)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277; 23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microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:1+5GydAcwrmwOpS5WvzhFoF8Dnfy3tWjXAyy2a+M+Hkflc5GrQ/XHNwNLNWl9iFJgkmNBAjwmjxVX/Is0u+P1zCOP94RzY8TveyPnbeE/pGMR4PKatJ9GPD66UnOnn0ln5YtrwlGltHTgpVb13VfpKRAOBpjUd5EwKLw86If7jhpDXs0pb0fqZowQyK0N39RM3S3HVSq2Dqvb5eJJL5ogD2ROHDhqpPKEevZ9eWhKo8JG6a7NIpiGnQV2RXz0+x6LulpX7bW+LeLAeqOs/DpSroxV6G8RU4GTAa0xHnvx6FOcvsPrQ41AjRPq2BQaU45Kj1lkw7zmvFnhObAsQhGGw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:40:12.9233 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 44/46] net/liquidio: add API to close device 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, 02 Mar 2017 11:40:17 -0000 Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/lio_ethdev.c | 68 +++++++++++++++++++++++++++++++++++++-- drivers/net/liquidio/lio_ethdev.h | 5 +++ drivers/net/liquidio/lio_rxtx.c | 57 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_rxtx.h | 2 ++ 4 files changed, 130 insertions(+), 2 deletions(-) diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index b0db8ea..9a936bf 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -1109,7 +1109,7 @@ struct rte_lio_xstats_name_off { * @return * - nothing */ -static void +void lio_dev_rx_queue_release(void *rxq) { struct lio_droq *droq = rxq; @@ -1204,7 +1204,7 @@ struct rte_lio_xstats_name_off { * @return * - nothing */ -static void +void lio_dev_tx_queue_release(void *txq) { struct lio_instr_queue *tq = txq; @@ -1433,6 +1433,68 @@ struct rte_lio_xstats_name_off { } /** + * Reset and stop the device. This occurs on the first + * call to this routine. Subsequent calls will simply + * return. NB: This will require the NIC to be rebooted. + * + * @param eth_dev + * Pointer to the structure rte_eth_dev + * + * @return + * - nothing + */ +static void +lio_dev_close(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + uint32_t i; + + lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id); + + if (lio_dev->intf_open) + lio_dev_stop(eth_dev); + + lio_wait_for_instr_fetch(lio_dev); + + lio_dev->fn_list.disable_io_queues(lio_dev); + + cn23xx_vf_set_io_queues_off(lio_dev); + + /* Reset iq regs (IQ_DBELL). + * Clear sli_pktx_cnts (OQ_PKTS_SENT). + */ + for (i = 0; i < lio_dev->nb_rx_queues; i++) { + struct lio_droq *droq = lio_dev->droq[i]; + + if (droq == NULL) + break; + + uint32_t pkt_count = rte_read32(droq->pkts_sent_reg); + + lio_dev_dbg(lio_dev, + "pending oq count %u\n", pkt_count); + rte_write32(pkt_count, droq->pkts_sent_reg); + } + + /* Do FLR for the VF */ + cn23xx_vf_ask_pf_to_do_flr(lio_dev); + + /* lio_free_mbox */ + lio_dev->fn_list.free_mbox(lio_dev); + + /* Free glist resources */ + rte_free(lio_dev->glist_head); + rte_free(lio_dev->glist_lock); + lio_dev->glist_head = NULL; + lio_dev->glist_lock = NULL; + + lio_dev->port_configured = 0; + + /* Delete all queues */ + lio_dev_clear_queues(eth_dev); +} + +/** * Enable tunnel rx checksum verification from firmware. */ static void @@ -1678,6 +1740,7 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) .dev_stop = lio_dev_stop, .dev_set_link_up = lio_dev_set_link_up, .dev_set_link_down = lio_dev_set_link_down, + .dev_close = lio_dev_close, .allmulticast_enable = lio_dev_allmulticast_enable, .allmulticast_disable = lio_dev_allmulticast_disable, .link_update = lio_dev_link_update, @@ -1840,6 +1903,7 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) rte_free(eth_dev->data->mac_addrs); eth_dev->data->mac_addrs = NULL; + eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index 150e9c9..ee30615 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -196,4 +196,9 @@ struct lio_rss_set { uint8_t itable[LIO_RSS_MAX_TABLE_SZ]; uint8_t key[LIO_RSS_MAX_KEY_SZ]; }; + +void lio_dev_rx_queue_release(void *rxq); + +void lio_dev_tx_queue_release(void *txq); + #endif /* _LIO_ETHDEV_H_ */ diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index 470131c..9533015 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -918,6 +918,40 @@ return -1; } +int +lio_wait_for_instr_fetch(struct lio_device *lio_dev) +{ + int pending, instr_cnt; + int i, retry = 1000; + + do { + instr_cnt = 0; + + for (i = 0; i < LIO_MAX_INSTR_QUEUES(lio_dev); i++) { + if (!(lio_dev->io_qmask.iq & (1ULL << i))) + continue; + + if (lio_dev->instr_queue[i] == NULL) + break; + + pending = rte_atomic64_read( + &lio_dev->instr_queue[i]->instr_pending); + if (pending) + lio_flush_iq(lio_dev, lio_dev->instr_queue[i]); + + instr_cnt += pending; + } + + if (instr_cnt == 0) + break; + + rte_delay_ms(1); + + } while (retry-- && instr_cnt); + + return instr_cnt; +} + static inline void lio_ring_doorbell(struct lio_device *lio_dev, struct lio_instr_queue *iq) @@ -1826,3 +1860,26 @@ struct lio_soft_command * return processed; } +void +lio_dev_clear_queues(struct rte_eth_dev *eth_dev) +{ + struct lio_instr_queue *txq; + struct lio_droq *rxq; + uint16_t i; + + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { + txq = eth_dev->data->tx_queues[i]; + if (txq != NULL) { + lio_dev_tx_queue_release(txq); + eth_dev->data->tx_queues[i] = NULL; + } + } + + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { + rxq = eth_dev->data->rx_queues[i]; + if (rxq != NULL) { + lio_dev_rx_queue_release(rxq); + eth_dev->data->rx_queues[i] = NULL; + } + } +} diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h index d5aed6a..85685dc 100644 --- a/drivers/net/liquidio/lio_rxtx.h +++ b/drivers/net/liquidio/lio_rxtx.h @@ -752,6 +752,7 @@ int lio_setup_sglists(struct lio_device *lio_dev, int iq_no, int fw_mapped_iq, int num_descs, unsigned int socket_id); uint16_t lio_dev_xmit_pkts(void *tx_queue, struct rte_mbuf **pkts, uint16_t nb_pkts); +int lio_wait_for_instr_fetch(struct lio_device *lio_dev); int lio_setup_iq(struct lio_device *lio_dev, int q_index, union octeon_txpciq iq_no, uint32_t num_descs, void *app_ctx, unsigned int socket_id); @@ -764,4 +765,5 @@ int lio_setup_iq(struct lio_device *lio_dev, int q_index, */ int lio_setup_instr_queue0(struct lio_device *lio_dev); void lio_free_instr_queue0(struct lio_device *lio_dev); +void lio_dev_clear_queues(struct rte_eth_dev *eth_dev); #endif /* _LIO_RXTX_H_ */ -- 1.8.3.1