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 52EEB45B3A; Mon, 14 Oct 2024 19:28:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 353C840654; Mon, 14 Oct 2024 19:28:13 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 2AEB540273 for ; Sun, 13 Oct 2024 14:18:56 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XRKC644byz6K5lQ; Sun, 13 Oct 2024 20:18:26 +0800 (CST) Received: from frapeml500005.china.huawei.com (unknown [7.182.85.13]) by mail.maildlp.com (Postfix) with ESMTPS id 67238140447; Sun, 13 Oct 2024 20:18:55 +0800 (CST) Received: from china (10.220.118.114) by frapeml500005.china.huawei.com (7.182.85.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sun, 13 Oct 2024 14:18:52 +0200 From: Gur Stavi To: Gur Stavi CC: , "John W. Linville" Subject: [PATCH v01] net/af_packet: support link status update Date: Sun, 13 Oct 2024 17:29:23 +0300 Message-ID: <330d6b3cea8a28688e9b58ea4a02ca68ac3aab96.1728829107.git.gur.stavi@huawei.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.220.118.114] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To frapeml500005.china.huawei.com (7.182.85.13) X-Mailman-Approved-At: Mon, 14 Oct 2024 19:28:10 +0200 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 For net_af_packet PMD, eth_link_update was an empty function. Application may be interested in link up/down status. This patch adds implementation that updates dev_link->link_status based on socket IFF_RUNNING flag. Signed-off-by: Gur Stavi --- drivers/net/af_packet/rte_eth_af_packet.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 68870dd3e2..0f416f34c4 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -472,9 +472,23 @@ eth_dev_close(struct rte_eth_dev *dev) } static int -eth_link_update(struct rte_eth_dev *dev __rte_unused, +eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) { + const struct pmd_internals *internals = dev->data->dev_private; + struct rte_eth_link *dev_link = &dev->data->dev_link; + int sockfd = internals->rx_queue[0].sockfd; + struct ifreq ifr = { }; + int ret; + + if (sockfd == -1) + return 0; + + strlcpy(ifr.ifr_name, internals->if_name, IFNAMSIZ); + ret = ioctl(sockfd, SIOCGIFFLAGS, &ifr); + if (!ret) + dev_link->link_status = (ifr.ifr_flags & IFF_RUNNING) ? + RTE_ETH_LINK_UP : RTE_ETH_LINK_DOWN; return 0; } base-commit: 98613d32e3dac58d685f4f236cf8cc9733abaaf3 -- 2.40.1