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 A79F5A055F; Thu, 27 Feb 2020 12:34:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1DD692C4F; Thu, 27 Feb 2020 12:34:23 +0100 (CET) Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) by dpdk.org (Postfix) with ESMTP id 524522C02 for ; Thu, 27 Feb 2020 12:34:22 +0100 (CET) Received: by mail-il1-f193.google.com with SMTP id g126so2138258ilh.2 for ; Thu, 27 Feb 2020 03:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2dlxfClWG+CF/oqcOj9JmfNwNVqUHBLMgYsNdXm1qOQ=; b=p5Q9K7SdtRDgrvrdWQnxj7QyBCUE4un3yq62T+ePsfAEQXWZJCuzr/fM9lI777MaDC 2rCrWcJntiFbzu4ku4OOjezzUhGetT29Hyr6ZAjxBSvmDJuFXPDU1c3gHGqTJOUFmcZI AhcgFZMsBVeKztAqy03QuBn36z8aBe/0/4Pkyk8jxQkrWGF6i4KJhsAiVSJUJBLLRJzl QCtcPHzKIuHIBGo32iAqrCTMxpyz3GcDm17o9/Max488sSNa4/zQyoDPC/b38WdETvhu 7zzGeLmC+qJFK7wf0ekpkGI6tyIDDSzGA0kaq+FFySeojQvRRJRJFbXWCN3fB7DRq/GZ bIdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2dlxfClWG+CF/oqcOj9JmfNwNVqUHBLMgYsNdXm1qOQ=; b=cR4IYNdLA/jrAgA5SkDQZ80ag67lQvyWq5fbjVq2UXSlHiSs4RK253YkRs0lhLsNR9 WLFG8BDHAztIFIE3PX4tI5CsUyUiC0zO5Wmv4tOYYctXHMbIVyarIJvGRYRm9w7mW1Eo 5R8aqesWeYc/APwC5fCy5jGKqN2j6DhjtogA5hm8uHIoeKFRE3+mQbMCkUeioNyHgBz4 1Th+0D3GJG10FfJqwoXvyXKUqtUFpsmAVETKm5ojmVvpk66dNngkk0w2NJdevvjmsh8P 3T66zLdbRYCIXKnkftDPQAPKaW5kLznzGaO66yWAXsZxh93qc/eOwOjZj84mj4EnHEkh Jf/g== X-Gm-Message-State: APjAAAWxliteX2SVWRmNPgkeKVePpEdhcp9+yaR8WYEXEmcguO0fFdnz +L0KzeCxuVnhEVhNMylubdUpEUwZLUMZCCxbCv8= X-Google-Smtp-Source: APXvYqwFm0TmTvO/ZlDMH8iFTPwrBoS1+69Xjp1pvpN2yq67WnxNlKFn0QkFwKZo2mJ3Y6r808VZKPxQeitjFciWK9g= X-Received: by 2002:a92:481d:: with SMTP id v29mr5181258ila.271.1582803261329; Thu, 27 Feb 2020 03:34:21 -0800 (PST) MIME-Version: 1.0 References: <1580894793-6394-1-git-send-email-hkalra@marvell.com> In-Reply-To: <1580894793-6394-1-git-send-email-hkalra@marvell.com> From: Jerin Jacob Date: Thu, 27 Feb 2020 17:04:03 +0530 Message-ID: To: Harman Kalra , Ferruh Yigit Cc: Jerin Jacob , Maciej Czekaj , dpdk-dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [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" On Wed, Feb 5, 2020 at 2:57 PM Harman Kalra wrote: > > Add support for .set_link_up/down() eth ops to bring > link up and down. > > Signed-off-by: Harman Kalra Acked-by: Jerin Jacob Applied to dpdk-next-net-mrvl/master. Thanks > --- > 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 >