DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gur Stavi <gur.stavi@huawei.com>
To: Gur Stavi <gur.stavi@huawei.com>
Cc: <dev@dpdk.org>, "John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH v01] net/af_packet: support link status update
Date: Sun, 13 Oct 2024 17:29:23 +0300	[thread overview]
Message-ID: <330d6b3cea8a28688e9b58ea4a02ca68ac3aab96.1728829107.git.gur.stavi@huawei.com> (raw)

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 <gur.stavi@huawei.com>
---
 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


             reply	other threads:[~2024-10-14 17:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-13 14:29 Gur Stavi [this message]
2024-10-14 17:41 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=330d6b3cea8a28688e9b58ea4a02ca68ac3aab96.1728829107.git.gur.stavi@huawei.com \
    --to=gur.stavi@huawei.com \
    --cc=dev@dpdk.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).