DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v02] net/af_packet: support link status update
@ 2024-10-15  9:57 Gur Stavi
  2024-10-15 15:19 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Gur Stavi @ 2024-10-15  9:57 UTC (permalink / raw)
  To: Gur Stavi; +Cc: dev, John W. Linville, Stephen Hemminger

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v02] net/af_packet: support link status update
  2024-10-15  9:57 [PATCH v02] net/af_packet: support link status update Gur Stavi
@ 2024-10-15 15:19 ` Stephen Hemminger
  2024-10-16 23:29   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2024-10-15 15:19 UTC (permalink / raw)
  To: Gur Stavi; +Cc: dev, John W. Linville

On Tue, 15 Oct 2024 12:57:29 +0300
Gur Stavi <gur.stavi@huawei.com> wrote:

> 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

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v02] net/af_packet: support link status update
  2024-10-15 15:19 ` Stephen Hemminger
@ 2024-10-16 23:29   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2024-10-16 23:29 UTC (permalink / raw)
  To: Stephen Hemminger, Gur Stavi; +Cc: dev, John W. Linville

On 10/15/2024 4:19 PM, Stephen Hemminger wrote:
> On Tue, 15 Oct 2024 12:57:29 +0300
> Gur Stavi <gur.stavi@huawei.com> wrote:
> 
>> 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
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-16 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15  9:57 [PATCH v02] net/af_packet: support link status update Gur Stavi
2024-10-15 15:19 ` Stephen Hemminger
2024-10-16 23:29   ` Ferruh Yigit

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).