* [PATCH v01] net/af_packet: support link status update
@ 2024-10-13 14:29 Gur Stavi
2024-10-14 17:41 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Gur Stavi @ 2024-10-13 14:29 UTC (permalink / raw)
To: Gur Stavi; +Cc: dev, John W. Linville
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v01] net/af_packet: support link status update
2024-10-13 14:29 [PATCH v01] net/af_packet: support link status update Gur Stavi
@ 2024-10-14 17:41 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2024-10-14 17:41 UTC (permalink / raw)
To: Gur Stavi; +Cc: dev, John W. Linville
On Sun, 13 Oct 2024 17:29:23 +0300
Gur Stavi <gur.stavi@huawei.com> wrote:
> 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;
If ioctl() fails, the function should return an error.
something like:
if (ioctl(sockfd, SIOCGIFFFLAGS, &ifr) != 0)
return -errno;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-14 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-13 14:29 [PATCH v01] net/af_packet: support link status update Gur Stavi
2024-10-14 17:41 ` Stephen Hemminger
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).