From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6F89A0538; Wed, 5 Feb 2020 10:27:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 421AD1C1A6; Wed, 5 Feb 2020 10:27:17 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 29F3A1C1A2 for ; Wed, 5 Feb 2020 10:27:15 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0159EtgY013811 for ; Wed, 5 Feb 2020 01:27:14 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=pfpt0818; bh=BuezWvcG1oIrTqpG2t0nZKlTxbZ2TsIbETXWPvR175Y=; b=NdC0aAZbRoD9x5Zy/LoCvB86nPZ/dnXyfrsn0c2FADyK83uP97LhdTutxJICC+DzCaUA w6ecFRzSe0McdlqaTUkJc9PSNYd0FD9+duw0O06yKAJWlsoopIM0yGFhMVE+/BKWs8yo aFq6StRGcmN416yGc3YmeGVOmEz8BOHeYtgpMNhQaU0TJDDEMGkOPQxYig+gCJQaCKzk T1f6gaUJXxeNUC+A7j/C7NbHox10JqkPSoj5E3XjIqnKejfEVdLrpO2I0+tBdnq8MtNM a7jNK+kpRDJaOXJSFLpNV/ej40cCQsf1izXu6SCV29zsj08VHlDWUhRQH2bP/nG4xbc3 7A== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2xyhn124gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 05 Feb 2020 01:27:14 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Feb 2020 01:27:12 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Wed, 5 Feb 2020 01:27:12 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UVirHAPGeRI4r3HZVzIfL7nrwGDnsUD7TYo0RPLHddqNzXX2TTWy0kAA14+GyUgwsqJSf/69D4Um0UNd3BQHHsLtUqN+OTniOqYOLOKeLMp8ga9A2Om49rIlF5MN9WJEZWLaODrThd6vSgSW3zyH8o8i2lLbAkO16wKWdbKHvrCzsiosNteFMXBCSztyxe0GObWOaMtdHeQTonSU6lVUSQmZqGM5raFfrwSAA20f5lTxOZgJsYbC2Oa4+ig3Pc0J4o3EVmEpVzer1iUt8InhixIdHXsN0Vl8Il8szV7jXiG7kDMTAGpXxNHlLWC7vwThxF5nWOAH4p6Wh+FKb0ZadQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BuezWvcG1oIrTqpG2t0nZKlTxbZ2TsIbETXWPvR175Y=; b=GH2oRpsdgDrzQawmFvceIXkc3G9zl1Zfkg8aiZ1WuHI0h6q1rrp5nVG03aHqeOLrYTjrz8xEizigQRsNikmGPLS5XqKfL4S9TZ4gz6+WeLFqn+J9gBECfji60tM0f1Hnf026PJ4qdfMRmcUVR4NdBS+k++GnXmtB/H3F2j/vu3WA1iIWNs1n6mgjYlKOmGjoC6z4hDDdwYZY8t7pqLkIHaNA+hr3cRdOGCGbyPJstsw6CUw+JbFEmDtPvMMvdyjM5pdhokK5NSPomQetNatrvw2NjMDFQcuABe3mlOLt3On6NJ9gBHMa1BOVEUHu/vCVWD+yhtCInIgHFjUeExSs7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BuezWvcG1oIrTqpG2t0nZKlTxbZ2TsIbETXWPvR175Y=; b=S8woYbCGqzsfDe9nE0MnArpUKMu+c4LPINJVQCv/sPeHPuJaS8vVaoFSD6Dlk2hNWMmmGF+k3py00GgFJOBvnOpCWVObgaofHB2SyI6H5GzlzvGnuCiBca58M24t899+ZjviTnHSQ/BUks15fMEAOp4JEbb5gzdAITKMl1O6ARY= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.20.19) by MN2PR18MB3165.namprd18.prod.outlook.com (10.255.237.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Wed, 5 Feb 2020 09:27:10 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::6de0:6ead:9fc:5beb]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::6de0:6ead:9fc:5beb%3]) with mapi id 15.20.2686.035; Wed, 5 Feb 2020 09:27:10 +0000 From: Harman Kalra To: Jerin Jacob , Maciej Czekaj CC: , Harman Kalra Date: Wed, 5 Feb 2020 14:56:33 +0530 Message-ID: <1580894793-6394-1-git-send-email-hkalra@marvell.com> X-Mailer: git-send-email 2.7.4 Content-Type: text/plain X-ClientProxiedBy: PN1PR0101CA0057.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::19) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:38::19) MIME-Version: 1.0 Received: from hkarlara-OptiPlex-3046.marvell.com (115.113.156.2) by PN1PR0101CA0057.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2686.32 via Frontend Transport; Wed, 5 Feb 2020 09:27:08 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [115.113.156.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2e690cf-b4c7-498d-6b59-08d7aa1d9353 X-MS-TrafficTypeDiagnostic: MN2PR18MB3165: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:262; X-Forefront-PRVS: 0304E36CA3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(136003)(376002)(346002)(366004)(199004)(189003)(7696005)(52116002)(26005)(8936002)(110136005)(316002)(66946007)(81166006)(36756003)(4326008)(8676002)(81156014)(55236004)(16526019)(186003)(6666004)(107886003)(478600001)(86362001)(956004)(2616005)(66476007)(66556008)(6636002)(5660300002)(6486002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3165; H:MN2PR18MB2848.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +ecidxm6BSijMlcQG34qjdx/y3Cygnm0UutOZ/ACRrrpI3KkSHiPi/xCj6tfTh/u+Arh2xH4ZYjmGNKJ044U2BSWjDRiT3v9jhDDFtt7AohLTr+/RDcZj3piG3t8KYZ1rKSNyABrk5d+TAGu232KLQRWdKQnmJhdsnVaN5A9b0+bi4cwi8oHpOSqRBFtqSamXcvU1UWtWkHsShQ94JJ8RErzbj9GqjtNRK9QLQAxNltul/nz/nXBLmU0PVuONBpsRDj8Ob4c4B5sjKijnTyLpXZSc2z6k+vR/3gJ4b5qzidDbUBwWYAWVtroM5TLcTjcn/h+jdfFVQCGCLZAGHwVeI/9neogvrzwUN+AiWwYBMHRJkZPekWyc5xBMtPrJfRvZ5gkcJCLJBwFKLEmIkLLBTKOgFEjN3wwJtqpdv5bNPE0fIhu7aMQcB625XvqFlhJ X-MS-Exchange-AntiSpam-MessageData: iFldfDN5k3fTUByW2aJzA1zvzPed1TdxyfV+hGBZDz0RAxNkGM4Qk6mm1DUP9G30lsE7ktlEwzt4NgXU+bAOZQH1li3ZF7KnrbLBxSzp/4Orb6AiQ1pS4TT74EZJwZC4RIH5EaFpcQe99ANQnhKTZQ== X-MS-Exchange-CrossTenant-Network-Message-Id: b2e690cf-b4c7-498d-6b59-08d7aa1d9353 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2020 09:27:10.1274 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uwYJORqpnLVfBRrN8hRqRPJERtXTbdOW1aXAuJ817XYfSa8m6ZlGuofhe1M03n2RNlpTU5QkmJMpNun6poNXjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3165 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_02:2020-02-04, 2020-02-05 signatures=0 Subject: [dpdk-dev] [PATCH] net/thunderx: add link up and down ops 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" Add support for .set_link_up/down() eth ops to bring link up and down. Signed-off-by: Harman Kalra --- drivers/net/thunderx/base/nicvf_mbox.c | 10 ++++++++ drivers/net/thunderx/base/nicvf_mbox.h | 10 ++++++++ drivers/net/thunderx/nicvf_ethdev.c | 33 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/drivers/net/thunderx/base/nicvf_mbox.c b/drivers/net/thunderx/base/nicvf_mbox.c index 8f83d41dd..5b3ab939d 100644 --- a/drivers/net/thunderx/base/nicvf_mbox.c +++ b/drivers/net/thunderx/base/nicvf_mbox.c @@ -413,6 +413,16 @@ nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask, return nicvf_mbox_send_msg_to_pf(nic, &mbx); } +int +nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable) +{ + struct nic_mbx mbx = { .msg = { 0 } }; + + mbx.lbk.msg = NIC_MBOX_MSG_SET_LINK; + mbx.lbk.vf_id = nic->vf_id; + mbx.lbk.enable = enable; + return nicvf_mbox_send_msg_to_pf(nic, &mbx); +} void nicvf_mbox_shutdown(struct nicvf *nic) { diff --git a/drivers/net/thunderx/base/nicvf_mbox.h b/drivers/net/thunderx/base/nicvf_mbox.h index 81f1f4083..d0b294362 100644 --- a/drivers/net/thunderx/base/nicvf_mbox.h +++ b/drivers/net/thunderx/base/nicvf_mbox.h @@ -40,6 +40,7 @@ #define NIC_MBOX_MSG_ALLOC_SQS 0x12 /* Allocate secondary Qset */ #define NIC_MBOX_MSG_LOOPBACK 0x16 /* Set interface in loopback */ #define NIC_MBOX_MSG_RESET_STAT_COUNTER 0x17 /* Reset statistics counters */ +#define NIC_MBOX_MSG_SET_LINK 0x21 /* Set link up/down */ #define NIC_MBOX_MSG_CFG_DONE 0xF0 /* VF configuration done */ #define NIC_MBOX_MSG_SHUTDOWN 0xF1 /* VF is being shutdown */ #define NIC_MBOX_MSG_MAX 0x100 /* Maximum number of messages */ @@ -169,6 +170,13 @@ struct reset_stat_cfg { uint16_t sq_stat_mask; }; +/* Set link up/down */ +struct set_link_state { + uint8_t msg; + uint8_t vf_id; + bool enable; +}; + struct nic_mbx { /* 128 bit shared memory between PF and each VF */ union { @@ -186,6 +194,7 @@ union { struct sqs_alloc sqs_alloc; struct set_loopback lbk; struct reset_stat_cfg reset_stat; + struct set_link_state set_link; }; }; @@ -210,6 +219,7 @@ int nicvf_mbox_rq_sync(struct nicvf *nic); int nicvf_mbox_loopback_config(struct nicvf *nic, bool enable); int nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask, uint8_t tx_stat_mask, uint16_t rq_stat_mask, uint16_t sq_stat_mask); +int nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable); void nicvf_mbox_shutdown(struct nicvf *nic); void nicvf_mbox_cfg_done(struct nicvf *nic); diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 2cf0ffe13..6f43541a5 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -1988,6 +1988,37 @@ nicvf_dev_configure(struct rte_eth_dev *dev) return 0; } +static int +nicvf_dev_set_link_up(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + int rc, i; + + rc = nicvf_mbox_set_link_up_down(nic, true); + if (rc) + goto done; + + /* Start tx queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) + nicvf_dev_tx_queue_start(dev, i); + +done: + return rc; +} + +static int +nicvf_dev_set_link_down(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + int i; + + /* Stop tx queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) + nicvf_dev_tx_queue_stop(dev, i); + + return nicvf_mbox_set_link_up_down(nic, false); +} + /* Initialize and register driver with DPDK Application */ static const struct eth_dev_ops nicvf_eth_dev_ops = { .dev_configure = nicvf_dev_configure, @@ -2015,6 +2046,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .rx_queue_count = nicvf_dev_rx_queue_count, .tx_queue_setup = nicvf_dev_tx_queue_setup, .tx_queue_release = nicvf_dev_tx_queue_release, + .dev_set_link_up = nicvf_dev_set_link_up, + .dev_set_link_down = nicvf_dev_set_link_down, .get_reg = nicvf_dev_get_regs, }; -- 2.18.0