From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A85EAA0547; Thu, 24 Jun 2021 15:32:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3734B40040; Thu, 24 Jun 2021 15:32:40 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 65D774003C for ; Thu, 24 Jun 2021 15:32:39 +0200 (CEST) IronPort-SDR: +DumLCeHhjc7/kZR+YoRG7BzQX34aCdvzTf/V3HM8KowkXaexWBJ1iiUVR8lbxCrTOXlRhVhcA 54m8GX++Bhkg== X-IronPort-AV: E=McAfee;i="6200,9189,10024"; a="204460294" X-IronPort-AV: E=Sophos;i="5.83,296,1616482800"; d="scan'208";a="204460294" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2021 06:32:21 -0700 IronPort-SDR: bsdBSo2zD1EWYOec4oSMKaUPJ6cGV5EFWQ34IcGtOrgPUqYyOWZH9MQrAeP59RpcIFYOTeEMkB 8MbC0XKS24aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,296,1616482800"; d="scan'208";a="445306075" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.27]) by orsmga007.jf.intel.com with ESMTP; 24 Jun 2021 06:32:20 -0700 From: Ferruh Yigit To: Ferruh Yigit , Ray Kinsella , Neil Horman Cc: dev@dpdk.org, Dan Gora Date: Thu, 24 Jun 2021 14:32:16 +0100 Message-Id: <20210624133216.3088933-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] kni: update link only on change 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" 'rte_kni_update_link()' updates virtual KNI interface link using kernel sysfs interface. If the requested link status is same as interface link status, do not update the link status but return with success. Signed-off-by: Ferruh Yigit --- Cc: Dan Gora --- lib/kni/rte_kni.c | 5 ++++- lib/kni/version.map | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 9dae6a8d7c0c..8ac4484272b0 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -810,6 +810,9 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) } old_linkup = (old_carrier[0] == '1'); + if (old_linkup == (int)linkup) + goto out; + new_carrier = linkup ? "1" : "0"; ret = write(fd, new_carrier, 1); if (ret < 1) { @@ -817,7 +820,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) close(fd); return -1; } - +out: close(fd); return old_linkup; } diff --git a/lib/kni/version.map b/lib/kni/version.map index a93da95f3671..bb810a7f2f38 100644 --- a/lib/kni/version.map +++ b/lib/kni/version.map @@ -19,5 +19,6 @@ DPDK_21 { EXPERIMENTAL { global: + # updated in v21.08 rte_kni_update_link; }; -- 2.31.1