From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 10270A0096 for ; Sun, 2 Jun 2019 17:30:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 314941BA90; Sun, 2 Jun 2019 17:26:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id F30401BA56 for ; Sun, 2 Jun 2019 17:25:57 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x52FKKp3020361; Sun, 2 Jun 2019 08:25:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=WiiKubifMQcDY+t3Qzx7kzodLc95n1rC7FTfTjEa5xU=; b=l5JzTDbJs6YVtuGoOYBPqTHk8wRj7wpLbiWAa2A+nA6DRX5TOj1OmrIx7Q2+oYaj6Z6k ZwcgClVJ1XMHDq4WMa595P7FPc1ov0NUDIYcvTFWIzaCOuLuSkbi8rtXybKy18vVn++R dEVIrVCfgdC8FfwfzHGGrp6nem9xqy0JbdhlgS1Rljgw2DngFM+CeCrUBaIJedNnO24d r9t/m/lJ9QROUWdxNkCV5IckC3JXIzxeYTMOTvQACrYCIQrx+R4kvhNbu7xEOuYhCr1F 08ecJsuBvnBJeMtRNZ2/CoZdemdPSJOTcP2qYEMrzfrWJBrL3qj7qo+m1rUP0Iyhh0yE Yw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2survk495q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 02 Jun 2019 08:25:57 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 2 Jun 2019 08:25:55 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Sun, 2 Jun 2019 08:25:55 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 22FF23F703F; Sun, 2 Jun 2019 08:25:53 -0700 (PDT) From: To: , Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K CC: , Vamsi Attunuru Date: Sun, 2 Jun 2019 20:54:02 +0530 Message-ID: <20190602152434.23996-27-jerinj@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190602152434.23996-1-jerinj@marvell.com> References: <20190602152434.23996-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-02_09:, , signatures=0 Subject: [dpdk-dev] [PATCH v1 26/58] net/octeontx2: add link status set operations 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Vamsi Attunuru Add support for setting the link up and down. Signed-off-by: Vamsi Attunuru Signed-off-by: Nithin Dabilpuram --- drivers/net/octeontx2/otx2_ethdev.c | 2 ++ drivers/net/octeontx2/otx2_ethdev.h | 2 ++ drivers/net/octeontx2/otx2_link.c | 49 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 9fbade075..9ceeb6ffa 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -1268,6 +1268,8 @@ static const struct eth_dev_ops otx2_eth_dev_ops = { .tx_queue_stop = otx2_nix_tx_queue_stop, .rx_queue_start = otx2_nix_rx_queue_start, .rx_queue_stop = otx2_nix_rx_queue_stop, + .dev_set_link_up = otx2_nix_dev_set_link_up, + .dev_set_link_down = otx2_nix_dev_set_link_down, .dev_supported_ptypes_get = otx2_nix_supported_ptypes_get, .stats_get = otx2_nix_dev_stats_get, .stats_reset = otx2_nix_dev_stats_reset, diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index 83d6b2dc2..7bd3e83e4 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -269,6 +269,8 @@ void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set); int otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete); void otx2_eth_dev_link_status_update(struct otx2_dev *dev, struct cgx_link_user_info *link); +int otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev); +int otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev); /* IRQ */ int otx2_nix_register_irqs(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/octeontx2/otx2_link.c b/drivers/net/octeontx2/otx2_link.c index 228a0cd8e..8fcbdc9b7 100644 --- a/drivers/net/octeontx2/otx2_link.c +++ b/drivers/net/octeontx2/otx2_link.c @@ -106,3 +106,52 @@ otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) return rte_eth_linkstatus_set(eth_dev, &link); } + +static int +nix_dev_set_link_state(struct rte_eth_dev *eth_dev, uint8_t enable) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + struct otx2_mbox *mbox = dev->mbox; + struct cgx_set_link_state_msg *req; + + req = otx2_mbox_alloc_msg_cgx_set_link_state(mbox); + req->enable = enable; + return otx2_mbox_process(mbox); +} + +int +otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + int rc, i; + + if (otx2_dev_is_vf(dev)) + return -ENOTSUP; + + rc = nix_dev_set_link_state(eth_dev, 1); + if (rc) + goto done; + + /* Start tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + otx2_nix_tx_queue_start(eth_dev, i); + +done: + return rc; +} + +int +otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + int i; + + if (otx2_dev_is_vf(dev)) + return -ENOTSUP; + + /* Stop tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + otx2_nix_tx_queue_stop(eth_dev, i); + + return nix_dev_set_link_state(eth_dev, 0); +} -- 2.21.0