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>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v02] net/af_packet: support link status update
Date: Tue, 15 Oct 2024 12:57:29 +0300	[thread overview]
Message-ID: <09f27e6b7844ee016487d4ea6c1e11ef940e3a87.1728983875.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>
---
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


             reply	other threads:[~2024-10-15  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15  9:57 Gur Stavi [this message]
2024-10-15 15:19 ` Stephen Hemminger
2024-10-16 23:29   ` Ferruh Yigit

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=09f27e6b7844ee016487d4ea6c1e11ef940e3a87.1728983875.git.gur.stavi@huawei.com \
    --to=gur.stavi@huawei.com \
    --cc=dev@dpdk.org \
    --cc=linville@tuxdriver.com \
    --cc=stephen@networkplumber.org \
    /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).