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 4A4A145B40; Tue, 15 Oct 2024 09:47:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA8734027C; Tue, 15 Oct 2024 09:47:04 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 501AF400EF for ; Tue, 15 Oct 2024 09:47:03 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XSR395wN4z6FGbt; Tue, 15 Oct 2024 15:45:25 +0800 (CST) Received: from frapeml500005.china.huawei.com (unknown [7.182.85.13]) by mail.maildlp.com (Postfix) with ESMTPS id BD963140451; Tue, 15 Oct 2024 15:47:02 +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; Tue, 15 Oct 2024 09:46:59 +0200 From: Gur Stavi To: Gur Stavi CC: , "John W. Linville" , Stephen Hemminger Subject: [PATCH v02] net/af_packet: support link status update Date: Tue, 15 Oct 2024 12:57:29 +0300 Message-ID: <09f27e6b7844ee016487d4ea6c1e11ef940e3a87.1728983875.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-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 --- v2: * return error on ioctl error v1: https://mails.dpdk.org/archives/dev/2024-October/304831.html --- drivers/net/af_packet/rte_eth_af_packet.c | 15 ++++++++++++++- 1 file changed, 14 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..fb4743f3e0 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -472,9 +472,22 @@ 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 = { }; + + if (sockfd == -1) + return 0; + + strlcpy(ifr.ifr_name, internals->if_name, IFNAMSIZ); + if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) + return -errno; + 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