From patchwork Wed Jun 23 04:46:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 94735 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EDE8AA0C41; Wed, 23 Jun 2021 06:51:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 568A841155; Wed, 23 Jun 2021 06:49:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 58BF24113E for ; Wed, 23 Jun 2021 06:49:28 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15N4kOS9026099 for ; Tue, 22 Jun 2021 21:49:27 -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-type; s=pfpt0220; bh=DALxVDOGyKMsPuPJI/QKqYg21osKHdZUoVbvhSzV20Y=; b=S1GDnga2r2IcXq+92D9966FW5kaxcXeM2uE9s1c49CZkY/TfaerN1OLsjFlA0yk3UtAo 7C3bu4m6Jok+bfD5OiARas4zatMVI1a43DkFGCFOj1CKfhQaiT2UgpIFNajJLuV8Up5w LjGendhqnUUYsJDqGvroApBCUARHtcc/2xxzaglpFLfWZAHqWY1QLXKw6Ppzm2NsYbPO XuPcy4bkopDDQ4HOC9YeeD3k4FhnezOLRf3CH9A70JJ6WVZY1Y2fR9NWFo0VTMioLG7O 0nTJGaTns25VrMrUCrd70ouEQ5rXEGRerem7cvKjszew8RJG4yyfppTjn3qBiGOAGv3w Ug== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 39bptj1gs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 21:49:27 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 22 Jun 2021 21:49:25 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 22 Jun 2021 21:49:25 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id D100C5B6937; Tue, 22 Jun 2021 21:49:22 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , , Date: Wed, 23 Jun 2021 10:16:39 +0530 Message-ID: <20210623044702.4240-40-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210623044702.4240-1-ndabilpuram@marvell.com> References: <20210306153404.10781-1-ndabilpuram@marvell.com> <20210623044702.4240-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ol8TIC_sCV0vdvMYeA3vNlKXvKNIiZz- X-Proofpoint-GUID: ol8TIC_sCV0vdvMYeA3vNlKXvKNIiZz- X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-23_01:2021-06-22, 2021-06-23 signatures=0 Subject: [dpdk-dev] [PATCH v4 39/62] net/cnxk: add link up/down operations 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 Sender: "dev" From: Sunil Kumar Kori Patch implements link up/down ethdev operations for cn9k and cn10k platform. Signed-off-by: Sunil Kumar Kori --- drivers/net/cnxk/cnxk_ethdev.c | 4 +++- drivers/net/cnxk/cnxk_ethdev.h | 4 ++++ drivers/net/cnxk/cnxk_ethdev_ops.c | 47 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index abca49b..a18d1d5 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -975,7 +975,7 @@ cnxk_nix_configure(struct rte_eth_dev *eth_dev) return rc; } -static int +int cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid) { struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); @@ -1189,6 +1189,8 @@ struct eth_dev_ops cnxk_eth_dev_ops = { .tx_burst_mode_get = cnxk_nix_tx_burst_mode_get, .flow_ctrl_get = cnxk_nix_flow_ctrl_get, .flow_ctrl_set = cnxk_nix_flow_ctrl_set, + .dev_set_link_up = cnxk_nix_set_link_up, + .dev_set_link_down = cnxk_nix_set_link_down, }; static int diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index e788a42..5e982f9 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -251,6 +251,9 @@ int cnxk_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev, struct rte_eth_fc_conf *fc_conf); int cnxk_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev, struct rte_eth_fc_conf *fc_conf); +int cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev); +int cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev); + int cnxk_nix_configure(struct rte_eth_dev *eth_dev); int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid, uint16_t nb_desc, uint16_t fp_tx_q_sz, @@ -259,6 +262,7 @@ int cnxk_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid, uint16_t nb_desc, uint16_t fp_rx_q_sz, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp); +int cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid); int cnxk_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qid); int cnxk_nix_dev_start(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c index 97c5428..c8da129 100644 --- a/drivers/net/cnxk/cnxk_ethdev_ops.c +++ b/drivers/net/cnxk/cnxk_ethdev_ops.c @@ -512,3 +512,50 @@ cnxk_nix_allmulticast_disable(struct rte_eth_dev *eth_dev) return roc_nix_npc_mcast_config(&dev->nix, false, eth_dev->data->promiscuous); } + +int +cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + int rc, i; + + if (roc_nix_is_vf_or_sdp(nix)) + return -ENOTSUP; + + rc = roc_nix_mac_link_state_set(nix, true); + if (rc) + goto exit; + + /* Start tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { + rc = cnxk_nix_tx_queue_start(eth_dev, i); + if (rc) + goto exit; + } + +exit: + return rc; +} + +int +cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev) +{ + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct roc_nix *nix = &dev->nix; + int rc, i; + + if (roc_nix_is_vf_or_sdp(nix)) + return -ENOTSUP; + + /* Stop tx queues */ + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { + rc = cnxk_nix_tx_queue_stop(eth_dev, i); + if (rc) + goto exit; + } + + rc = roc_nix_mac_link_state_set(nix, false); +exit: + return rc; +}