From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0081.outbound.protection.outlook.com [104.47.36.81]) by dpdk.org (Postfix) with ESMTP id D45A1D4A4 for ; Sat, 25 Mar 2017 07:29:10 +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=xCoIDJtj4bUAgjlRb0nxqUI8yzI8mU52IjIc7WYyWX8=; b=fPPBVfG+hifQW1p5s3oLx6l5LFtuyQB98yh/6bFrU8/xBt2QOjjlq5jPYcoZPlTHJKx468jN7YM8pB0ogBZuYMKlIMT1w8vk8196gm55sk0GJQ0Taj9yoWHlovPmksPy4InjYmdmaBWQDATsRg67voY0uByNgUx8DrndamBkLIY= 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 CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:29:06 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:55 +0530 Message-Id: <1490423097-6797-45-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-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: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: e47d6c86-1a28-49e1-b78a-08d473483ebe X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:1mJGtTu8WeuJnaiaPtzX6HsngOA0PwEC8QOuWsGrP1t691/NTVrWwnftdfyFrv/8Qruj6yoduu+J2quATuWxbdLybHwPhDjFrSoO2M4BkTjkFoRV5eYDWEwDhaPKeiJ+pcf4xhdmUcxGymX/57nFCLbg3YoPACOnjSehMlZo2dRzBl4eXUxvAScibwZfO/Z6ckS6FEgzsbX2cKYrZCpR75+4MAIheI1on7LREmy+xfvuKZ5MVFCmxwJFnplCBHQppNfbPqrFHlT/N5kFqF3ZHA==; 25:Qo0ahiU6nSoQXmGW4hNRncLRwtEXAE8/PLWpy4UF28ErPVbhE9GfbBzWEqTMLE8q7yJNWRtxOL4YzR14p/cE2w7Jcm0ka0/g30QQMNVjeSH5+APjnMG524EGayePTkZDYhh+8MJdFcWijkoKB8zii9B1rUtCPoZbGZRmGRZ4/YQg6Q1RDCoeMH5zS8A79e7TDgIP7j0MKqlqIc1UQCvnHRgWs8chlyV2KZgYIJxC4YdFmBg0EteaqOaFW0yhib5uxpgnJmeSGW6FwXlgVhpqc36KLOzHsyoj9FeOyYEjW8RjJoOugvhximjtmmW1nsWNRU2Yt4OIccANeweKsU78tQYcObKVr4v/xKm2xZKV1UaKww4an6LbbGl3ywR8S6cgEDD8E4/N3YRq5O20NZpFQcq9lyKBuUeaFunABgYbRjThoBiAI/GHmSFMPyvN5zK8CcqraaaSC+TXggteR49YAg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:BWx/lZ543+BOVcHgQOdCEZI244oIQ11ldHMewavhlIxwU4DOOCsR1l2AVH9/2+Ny2r+Xf9UrbgACZkTchiJvJuSqSpJtR5pfs7dFgr4ZZMT94VxGNxHQNF9J5eHcN+yWROmFsvidH9Ledgyv9s+PFEKIeMlOBWvLWMLa0yHPAjGgahx31iz7eDLgeGpqYav5QK/2+jdeayso6wkEhd0PNXRO+D536rMgJQuC4PlUoq0=; 20:+xlJeNmFfOazR6bJ1ORu3U3Kz9aaZG7LrftdOYrQu7W8ychhWditJ16lLRBP0gMD2o28BikCs/pv5MhsD69Os5LjvbOCsDQMWptd30BNtnjYZ2BqhAuusI/I7jCFzNTd3qGvjJ1g/pypKVnVdPrT3QzA66+5jWepfZtvoPgeDapD3S/3TJ/pKhHc/2AMhs6Ty7Y+V6tdXZzd5cunpBtZVfTpNpcWTBhYgdv0GE8FAm0o2ca4fpmrCV4CGcFb9zWjbSbpKP3pLSfNu17aeZ3pbB6NUWan5XUf7xZPZaH3m8qW9Lx2Eu/3baZawCnym6wLmY0FXABK49jvbzReCGvTrka+nFA+B0aXbCncMWab/9ZALJ3Cb7KZiiwvJ5xWBhfLNVDQsbG2Bo38I8lK2tFeqH1j9tc2yyDAyRLoM9hecbMWe9yBBvs3qI2R1uNkWtZpHcpSptmJ+FOVAZY/ukH/K6kQb8XlGB2ojK9ImeM1idZOscuHFVJywcOKM9WG/8KEP1+B5W9aiR151Gm8pBOQhhZx2/1+uMMYuR70YiDEHCS/ByurwKpm093jHuSgnjDpyeJKzori/chvUgnXxdON0vZQ7z5+zseAwju/Fb9auf8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:VWje1+Ll3iglCVuqIJES9+nZqSW/2eNBF1IkQWZySGGobxKxK+nJzQSxTHnbTF05GmVCKJlKSfpnlSBkXHZ+QWe02SfaIuGIaQ46izjjg04YZfcXlWWzx8BBF2B5wQ0fyQkJjmI1n0650VExQXSQ9isoVQ+6Bpjo060LpXZFL+nAfcN29WXJUNzhgFkKYNy86ctE67sbDLbtv7oX9/XbcFzbrkz58bEIsHtcO/+WnJ8GiyE64EuxmMKzp0mwoWlovv5bs6RFlF2SqHMoRL+7f+49lMvvLq00doW4XJx9bR7llrcGvGDKIprc6a/eGEBl6NWARQONJamg6pPd3FmU1Urv7shbgxuhGR+xbjV3oVr0AgJoLn6pv8VR3LOXTkcJKivAjkrYZm6iUjH/TgczDElrS6L/5ZRDUgZmTRbS2VmlDgipgNTGBm8a3ADlqqZ39cYbljlyFKxXWmX3Qjk7G2DbsQWWn+CDVMPdvESgeYOWk3tVPFAtSLolcpwEpYMxBtn8NmyYB02qEKHH9/tOhA5T0usNrONJy2pVfKKEWS9YaheK1kSG+Aj43/4n8wLwwPz7Cv4nF0hM8sS+hqRRJianNaVxAu9+yiCWQaHsbAQ= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:Ppq1UX07PXG4J2egN0whSwghiIpvncyqZPuwgf969?= =?us-ascii?Q?zF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u?= =?us-ascii?Q?gqU90nSNXiLBhl0tH7XlO2J+5vCrt/G23sHJOkrWy31G8XbShn3VOQVuZkxJ?= =?us-ascii?Q?BSGdxRu+cJfbs7YeP9UN8JTZxdHQSONT6pgawdwPh4g5dO/14lZZvC53xptj?= =?us-ascii?Q?rjsY0lsY5YVviSr7em2dt8GraHU?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:r0boW6WfJwIItHtmbuOD5TilVWrQ4ZcL7ci/tVqRkuWV13FP8XaAOwkYMZrOg62WXGM0hx+4zKVWf+TlFMu07uk7Er7dAi0t5vwAapkYfBKyplGmM3hzRSI3xGytWXRByTxCAl6NTNgW4la79BDaat+hDY2EdAXVnFNsgjzWQ6Xxp6Cwd8duEyCIgg7OI98p3bWWnvD0glrFqJQbmbgKhycZljjbqqZcNLRKlDfEAiumrto3gZDDizFRof/nwdaBG68Dt5C/OwNAD0DoAS93gkAxL7rbDCAwlehyGDLaSx0KQnk2FEl71uqI5eJXfKVDG6W/WI6KBJPaVXfnGLPtszB9kI2Z/7CSkGY3RTHlVYmoveFPkV8oYCLv/M/ZoCwZmOuiKneZqp9emdATJrbH8A==; 5:HqIaucmDoFaDvqD6w3JcVOkpzO5t0sN3SrdYdLXokQttwZHdgZFy4lc3JS/5tWaPFbLRwc7d+4Bw3R0WZEpL6gbh89TFqp5ltE+fUSrgv9s1H1IaGfqYnZHe+V6aullv9EsqA1uLAevnx27KaBpPPg==; 24:OOtCLWDTrH4PiyKBjiPBB0+sPWFAnkSWk/nCSSSU1w1NHwXHd+dDtCPSoq4VU7eW5xGqwRDLk+a5RcAP6xsln/O8+sCgS5B8JHUONf/IbnY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:ELCiOf6gN7m/VDKSqHDD8Q9teHsxzV9q2rtFDCn5/1v819fwVwU3iJGw96Ilf9X0N6GSkQQ1tDE6whyERxBITPE7nZQboqyWWdEZJHCUK/hhge82pRp8lerwtkG8oUra0mNZMShY7wVrYAHj74NycaGK5oRmjmjsWXgENFbDGC89FxWrygMTWeLAjz3co8cZJlSen1MUK0yzMtysdWWiwXCJLV+flH6fA2Ebpzeypzth5JKJbU0ECVIiAKWolcTM6KxoRUffAObyQCrYlpAH+aRGLgOdchsuCnvuViXC4CS8Nrs5aUo8NagJyhgwPXPTCUPtFtBc9sYQZAPMe/cOXg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:29:06.9829 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 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: Sat, 25 Mar 2017 06:29:11 -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 76d775d..60dfa61 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, @@ -1839,6 +1902,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