From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0049.outbound.protection.outlook.com [104.47.36.49]) by dpdk.org (Postfix) with ESMTP id 53EC6F97C for ; Tue, 21 Feb 2017 10:29:55 +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=HOrghO9BKq/DS2YH3z6Sc+w2IOHpM2N6VMgUSKxIwkU=; b=MymfzQpYVB0fP6nKvuE1iOxFv+V9Fub21kVFW5KYXWhHfeKSWhk42Ql+kbb3P1InSoorVbIYNEWLkWnXxyVBGRZ4E1DSR6GHeS6pG8BsfJZM7XcY7VRWVH7oLt3nHrCJIS01DRXZWmuN/+fwHwikbxJ6ZFf1W+j/pYQSSWomW/Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shijith.Thotton@cavium.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Tue, 21 Feb 2017 09:29:51 +0000 From: Shijith Thotton To: dev@dpdk.org Cc: Jerin Jacob , Derek Chickles , Venkat Koppula , Mallesham Jatharakonda Date: Tue, 21 Feb 2017 14:56:49 +0530 Message-Id: <1487669225-30091-35-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-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: MA1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.56.29) To SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) X-MS-Office365-Filtering-Correlation-Id: f1ab792d-dce3-4e5d-08a8-08d45a3c3120 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 3:hGkqc6lGF1ULd9LHg8xnkpsJ8QEYI1JXemFm59ShggZIBoc6K0S7dyfDAx5b62IS0PSjeaiPHXa+Nq5PDB8LOI+OV9ZU0PWwDG08lOZJ1cMvZQNN1nvf6MJmTQAbPO9bz0d3w86zkOPquFrh4JttarHIrjNaM2BzKbwJiA5Ewqyvs1QyL1LeobsNnSd57pEsY6vCOu1SSwMua5WRJQcIHLpOB9Ivedt+mqmOYWiOx/puyWS4dVDbNFv4N3znBsUUemDBN1TxbVfbYIHfFVIRsQ==; 25:HVwRiuXUrKeJIQZWQK3KM9ID6rCepiHTYnKwsId9WUTFETZDLwWh3lEOOKP1VCbUbT75IohdoYCZzwVHMJvZ3tu+1lHp2WmFfSqR+NI+6cdHUSz5d0LnHZVM2VIV4u2SglTAwAL8obFp4uUVit75Yed160xyYgA7TDC5c06WW3JKUDvcWvdHGFAwGd2D0Q7uvYDndDAplx4ENILY/SaZzgRofw+72FOHI9RLiHtL35By8sTha9G7ZbRZkf9CDzz08NxYLDEtUYw00gpzDp6i83Dj6YoT+GJb7MSpaeKIII5qZiRUuCaex86XgxyVUQv7Y80jPsJedhC8IyHiRTbrZ8Z36nLmF4iOmMlq3K/Nx0Rqru6pw5FFnvHPVYwnAm8Z+3feKFVuu4FoMIuzsgopVkS0/SkAOFlEA0PcmOcDe/U2XXThhzG8nhXOq+mXiB/Rfk+63MD/aTq91KLxho4Cnw== X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 31:MzWagXZRLftxTXJrXVZsABpgrOmoaqxWxH6BNSjObfLqWS+0hJAPgpT+ExgzgxDxxbzWonMmf3ekBKO/z3A/HyUj59nS5+YePJHkWW9Yd2yLwgzuzI+Ab1KED2OWGLPiRkLvafr3f+AzcIVKGlTaXkD5JGehrOa0uuuqH9EylfwEXrj98lwo1kclAnv6S8ORIhnxVm82tECZ2K2tesPAlAWwOabpeetEvyldI9eKBvY=; 20:IcDeP/OaXtZHg+YTgljcYZ1DHjiiTLm0NIGr+dA5CGsOgsbtUuK5CXVLM191XKqLIhjKLDGtq7ZELcb8+6QLVtTYFOrefOvGEB5pAl63xLPdEiUXlq+kKXbDeyl/9ewgV691+B5/Dc6B52s7NY9i8bX6dEtY8kU7e5XJweU5RfR7qd0av2srD5xjHqQ2qMgPYWaPwuLKiATBHPokSaTcSZ5tRzG8NaFDYXFYh7GmPEWSxB/aUmglq43lwR3R3XXKsumVAiO2oYcU2WuF8/vjsyPLWwzF257jGqCNu1up/atprnEMGqtd+0yVzbWBHlG95pK0xvcVb+4RtyZPIa8XSQIMckV3+dX5f6ir7Onv5Z9Br46MTVJutzTl7sgh2hJ2d9pUPMCPasByo8PCT2YwT8ZhCQ5Q2Bg2oZkPAXbQAs1hJwHaZlYkYu0lguMY3YicGRlPn1Hc30rwZnkfCE41/afP6rdGEE4MOFunP4a8sbMoekC8O+G4UQ+tq/bknMPcL7JLFUtUuZOs0xlkkJUzBi3D9c4wmFb/HM4PhAEFoUkaCmOEMWMRjUBJRBypWuURbdyefe/33vrM36Vi7OqX94l1hcW+e241fP6Qy+9FWtA= 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)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:SN1PR07MB2285; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 4:ZCV4dUAkYIZRU3z8mPlYuDo5cpRLWwKVmdFtoP1gItg1lC6/lqRkxGHxclyHMeFiW2ipw3VnUaij+AxAuQn6uNVh5Dfsg9C7adFH3ZQ4SymAapDH7Y+n4SSgQwrv/mYfhUpPpJIiTTcFPm3xol2JxPvBdu9X1M49WVqvHjXkeFRndnXY414VtBoTzuHdQkSnjYTqZ9xvi0xJ2hGDz1801iAS94tCEEFgaCM8AYm9L33WSfETqQNKaffHF4dawCLM+Scbjv7rrCpqWr3nfLTBVQaMxIGoHwiZ5T7ogII4HrshJqBMyScU+K5eNsYxFKG/RrL/dCT8B9lwcOII4w2Y0CHV97W7UMeeOoZOOwdnGTXiEmKWigKwW5FKfxBXCq3D55IxgvgYRTNkKFBZyabQFHNbNhtS8xplhVP0prHWNsTLhRdYn3wiCss3XIDfnmmc6tb+TDnblp8Sv70F/Vq790S5mpUuppMrCSDOTCzMGGDqMao4FoueyA/2SvpsA/AzIGhLPXPiPrpC0rNZCwJiyZEsZd6kyGiGG2uyoeXofdsgf4aeDrj0Wj8Rr/aGwqavs46Cub8Rhcyxub0Tf8AjdodQsQ72VxPDoFMKBdJ9O7Q= X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(50226002)(81166006)(42186005)(2361001)(101416001)(81156014)(305945005)(3846002)(6116002)(5009440100003)(8676002)(105586002)(7736002)(53936002)(36756003)(110136004)(106356001)(6506006)(25786008)(38730400002)(2351001)(92566002)(48376002)(6486002)(97736004)(50466002)(5003940100001)(189998001)(68736007)(2906002)(4326007)(33646002)(76176999)(54906002)(5660300001)(6916009)(50986999)(2950100002)(6512007)(4720700003)(42882006)(66066001)(47776003)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2285; H:lio357.in.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07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S24/HsbHC5dtFCYqtBNj/CN8gOGUSINZlB8kPQA9qgcPIeoemH79myFjVnpXs9v84rGKfLXA==; 24:dZt3tq9gt52cxllphHYkoyDd2sEPaNVSCmRdfGGzL8c6zSPSHljalZoRFLBQFeSpuAT0oEdXxbSf78GOPrGT40wT5bjk34V1cEacz2QtlQ4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 7:bTQsqWGDDTdt2rjkhzAk4yR20tdeUZjZQ1h/cjdHeJgaip5sAdlgAjnc0eqscv3famwtemnO4kUQvLHRxDhwvT9lHSibbYAKSRf6dBni+clVWV76AG/4fUDuscSJO/fyLDUYNLN3lJ043AXV1x4iLmTMqD2fNZKJFyczypzBnoL9IIJ4Op5vcauLIWTxucwmxmG/T0HE4G/I+4y11akE2FcexgpTSFIHNivlDfB2ulbn71wfRlwGWIMekBDWpMPQms4LWIcVzxAlcFICBzgDxX3PSrUiKYu/ZOzJSnhty9bGRjO51g5im9uts+cwKwoO+wPLfuH1UrRIxQe5NzVJ6A== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 09:29:51.5427 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2285 Subject: [dpdk-dev] [PATCH 34/50] net/liquidio: add API to start device and check link 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: Tue, 21 Feb 2017 09:29:55 -0000 Add API to start device and periodic check of link state. Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/base/lio_hw_defs.h | 1 + drivers/net/liquidio/lio_ethdev.c | 108 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 8 +++ drivers/net/liquidio/lio_rxtx.c | 2 +- drivers/net/liquidio/lio_struct.h | 2 + 5 files changed, 120 insertions(+), 1 deletion(-) diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index ed6d90c..302a512 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -122,6 +122,7 @@ enum octeon_tag_type { /** LIO_OPCODE subcodes */ /* This subcode is sent by core PCI driver to indicate cores are ready. */ #define LIO_OPCODE_NW_DATA 0x02 /* network packet data */ +#define LIO_OPCODE_INFO 0x04 #define LIO_OPCODE_IF_CFG 0x09 #define LIO_MAX_RX_PKTLEN (64 * 1024) diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index e997e40..256e6b8 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -246,6 +246,113 @@ } } +/** + * Api to check link state. + */ +static void +lio_dev_get_link_status(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + uint16_t timeout = LIO_MAX_CMD_TIMEOUT; + struct lio_link_status_resp *resp; + union octeon_link_status *ls; + struct lio_soft_command *sc; + uint32_t resp_size; + + if (!lio_dev->intf_open) + return; + + resp_size = sizeof(struct lio_link_status_resp); + sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0); + if (sc == NULL) + return; + + resp = (struct lio_link_status_resp *)sc->virtrptr; + lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE, + LIO_OPCODE_INFO, 0, 0, 0); + + /* Setting wait time in seconds */ + sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000; + + if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED) + goto get_status_fail; + + while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) { + lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]); + rte_delay_ms(1); + } + + if (resp->status) + goto get_status_fail; + + ls = &resp->link_info.link; + + lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3); + + if (lio_dev->linfo.link.link_status64 != ls->link_status64) + lio_dev->linfo.link.link_status64 = ls->link_status64; + + lio_free_soft_command(sc); + + return; + +get_status_fail: + lio_free_soft_command(sc); +} + +/* This function will be invoked every LSC_TIMEOUT ns (100ms) + * and will update link state if it changes. + */ +static void +lio_sync_link_state_check(void *eth_dev) +{ + struct lio_device *lio_dev = + (((struct rte_eth_dev *)eth_dev)->data->dev_private); + + if (lio_dev->port_configured) + lio_dev_get_link_status(eth_dev); + + /* Schedule periodic link status check. + * Stop check if interface is close and start again while opening. + */ + if (lio_dev->intf_open) + rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check, + eth_dev); +} + +static int +lio_dev_start(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + int ret = 0; + + lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id); + + if (lio_dev->fn_list.enable_io_queues(lio_dev)) + return -1; + + /* Ready for link status updates */ + lio_dev->intf_open = 1; + rte_mb(); + + /* start polling for lsc */ + ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT, + lio_sync_link_state_check, + eth_dev); + if (ret) { + lio_dev_err(lio_dev, + "link state check handler creation failed\n"); + goto dev_lsc_handle_error; + } + + return 0; + +dev_lsc_handle_error: + lio_dev->intf_open = 0; + + return ret; +} + static int lio_dev_configure(struct rte_eth_dev *eth_dev) { struct lio_device *lio_dev = LIO_DEV(eth_dev); @@ -414,6 +521,7 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) /* Define our ethernet definitions */ static const struct eth_dev_ops liovf_eth_dev_ops = { .dev_configure = lio_dev_configure, + .dev_start = lio_dev_start, .rx_queue_setup = lio_dev_rx_queue_setup, .rx_queue_release = lio_dev_rx_queue_release, .tx_queue_setup = lio_dev_tx_queue_setup, diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index 22e3d83..c7d3336 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -38,6 +38,8 @@ #include "lio_struct.h" +/* timeout to check link state updates from firmware in us */ +#define LIO_LSC_TIMEOUT 100000 /* 100000us (100ms) */ #define LIO_MAX_CMD_TIMEOUT 10000 /* 10000ms (10s) */ #define LIO_DEV(_eth_dev) ((_eth_dev)->data->dev_private) @@ -73,4 +75,10 @@ struct lio_if_cfg_resp { struct octeon_if_cfg_info cfg_info; uint64_t status; }; + +struct lio_link_status_resp { + uint64_t rh; + struct octeon_link_info link_info; + uint64_t status; +}; #endif /* _LIO_ETHDEV_H_ */ diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index edb1577..fe9a7f1 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -1587,7 +1587,7 @@ struct lio_soft_command * lio_dev = txq->lio_dev; iq_no = txq->txpciq.s.q_no; - if (!lio_dev->linfo.link.s.link_up) { + if (!lio_dev->intf_open || !lio_dev->linfo.link.s.link_up) { PMD_TX_LOG(lio_dev, ERR, "Transmit failed link_status : %d\n", lio_dev->linfo.link.s.link_up); goto xmit_failed; diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index de4c1f3..91a8fd2 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -569,6 +569,8 @@ struct lio_device { /** The state of this device */ rte_atomic64_t status; + uint8_t intf_open; + struct octeon_link_info linfo; uint8_t *hw_addr; -- 1.8.3.1