From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 25F1F43016;
	Wed,  9 Aug 2023 09:34:48 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id F106E43296;
	Wed,  9 Aug 2023 09:33:33 +0200 (CEST)
Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126])
 by mails.dpdk.org (Postfix) with ESMTP id 62EB74328C
 for <dev@dpdk.org>; Wed,  9 Aug 2023 09:33:31 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1691566411; x=1723102411;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=Xh50AYQi24PONCMlzK8wTtdnsJV9fSLYoiKZuuw/bbk=;
 b=lEQYnDW7fb6uTqTGnAG/ICv1tc/FuiI4M7EeNlfNm3m/U3fG+pC8tV/Z
 iEG12OoWsC9lb/BC9QwaYtzChwpw0OEdHoc5KiRUR3QICfX/Fx9xUa3d1
 gwD07SWXG7kIgkQAlRgVdQubvolf0VCuM3udoo9mboqtE2SLltn3jzJvC
 DcHA4VddGACpsenfnwUWG3JbjWMdfXs2au7eKH4wGO1N6o5cIfdjqNjbG
 KRso8592VIH4LS/7fmorh3XEoGF3BZQ7gluYWeykQB5jx2N5owdJ3VWvf
 7yCuyA9CG06q70wR1N7h5ScolkT43c8OdgD953B7io/T2Dk1qTqqoLp73 w==;
X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="356014513"
X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="356014513"
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 09 Aug 2023 00:33:30 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="1062337448"
X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="1062337448"
Received: from dpdk-beileix-icelake.sh.intel.com ([10.67.116.252])
 by fmsmga005.fm.intel.com with ESMTP; 09 Aug 2023 00:33:29 -0700
From: beilei.xing@intel.com
To: jingjing.wu@intel.com,
	mingxia.liu@intel.com
Cc: dev@dpdk.org,
	Beilei Xing <beilei.xing@intel.com>
Subject: [PATCH 13/19] net/cpfl: support link update for representor
Date: Wed,  9 Aug 2023 15:51:28 +0000
Message-Id: <20230809155134.539287-14-beilei.xing@intel.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230809155134.539287-1-beilei.xing@intel.com>
References: <20230809155134.539287-1-beilei.xing@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Beilei Xing <beilei.xing@intel.com>

Add link update ops for representor.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/cpfl/cpfl_ethdev.h      |  1 +
 drivers/net/cpfl/cpfl_representor.c | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 8a8721bbe9..7813b9173e 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -168,6 +168,7 @@ struct cpfl_repr {
 	struct cpfl_repr_id repr_id;
 	struct rte_ether_addr mac_addr;
 	struct cpfl_vport_info *vport_info;
+	bool func_up; /* If the represented function is up */
 };
 
 struct cpfl_repr_rx_queue {
diff --git a/drivers/net/cpfl/cpfl_representor.c b/drivers/net/cpfl/cpfl_representor.c
index 19c7fb4cb9..862464602f 100644
--- a/drivers/net/cpfl/cpfl_representor.c
+++ b/drivers/net/cpfl/cpfl_representor.c
@@ -408,6 +408,23 @@ cpfl_repr_tx_queue_setup(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+cpfl_repr_link_update(struct rte_eth_dev *ethdev,
+		      __rte_unused int wait_to_complete)
+{
+	struct cpfl_repr *repr = CPFL_DEV_TO_REPR(ethdev);
+	struct rte_eth_link *dev_link = &ethdev->data->dev_link;
+
+	if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+		PMD_INIT_LOG(ERR, "This ethdev is not representor.");
+		return -EINVAL;
+	}
+	dev_link->link_status = repr->func_up ?
+			RTE_ETH_LINK_UP : RTE_ETH_LINK_DOWN;
+
+	return 0;
+}
+
 static const struct eth_dev_ops cpfl_repr_dev_ops = {
 	.dev_start		= cpfl_repr_dev_start,
 	.dev_stop		= cpfl_repr_dev_stop,
@@ -417,6 +434,7 @@ static const struct eth_dev_ops cpfl_repr_dev_ops = {
 
 	.rx_queue_setup		= cpfl_repr_rx_queue_setup,
 	.tx_queue_setup		= cpfl_repr_tx_queue_setup,
+	.link_update		= cpfl_repr_link_update,
 };
 
 static int
@@ -431,6 +449,8 @@ cpfl_repr_init(struct rte_eth_dev *eth_dev, void *init_param)
 	repr->itf.type = CPFL_ITF_TYPE_REPRESENTOR;
 	repr->itf.adapter = adapter;
 	repr->itf.data = eth_dev->data;
+	if (repr->vport_info->vport_info.vport_status == CPCHNL2_VPORT_STATUS_ENABLED)
+		repr->func_up = true;
 
 	eth_dev->dev_ops = &cpfl_repr_dev_ops;
 
-- 
2.34.1