Issue: Udev events not generated by Ethernet driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue: Udev events not generated by Ethernet driver

Jump to solution
5,131 Views
B_K_Ankur
Contributor IV

Hello Friends,

I am using i.mx28evk with kernel 3.10.32 mainline on the board. I am facing issue of udev not receiving the events from Ethernet driver. I tried to monitor the udev events using command :

root@imx28evk:~# udevadm monitor

custom logging function 0x17b9c registered

runtime dir '/var/run/udev'

calling: monitor

monitor will print the received events for:

UDEV - the event which udev sends out after rule processing

KERNEL - the kernel uevent

[ 5772.113167] libphy: 800f0000.etherne:00 - Link is Down

[ 5774.193557] libphy: 800f0000.etherne:00 - Link is Up - 100/Full

//NO UDEV Events noticed disconnecting/connecting Ethernet 0

When I do plug/unplug the USB mass storgage I got lots of messages with udev events including action = add/remove. But with ethernet plugging/unplugging, I am not getting any messages.

I have also tried to find in the driver source under linux/driver/net/ethernet/freescale but couldnt able to find any api used to send uevent via kobject. Any comments on how to enable the udev events for Ethernet driver?

Regards,

Ankur

Labels (2)
Tags (2)
1 Solution
2,657 Views
B_K_Ankur
Contributor IV

Hello All,

Added Patch into kernel to send the udev events to userspace.Please find the attached one.

Regards,

Ankur

---

net/core/Makefile | 1 +

net/core/uevent.c | 43 +++++++++++++++++++++++++++++++++++++++++++

2 files changed, 44 insertions(+)

create mode 100644 net/core/uevent.c

diff --git a/net/core/Makefile b/net/core/Makefile

index b33b996..a2139a7 100644

--- a/net/core/Makefile

+++ b/net/core/Makefile

@@ -22,3 +22,4 @@ obj-$(CONFIG_TRACEPOINTS) += net-traces.o

obj-$(CONFIG_NET_DROP_MONITOR) += drop_monitor.o

obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o

obj-$(CONFIG_NETPRIO_CGROUP) += netprio_cgroup.o

+obj-$(CONFIG_HOTPLUG) += uevent.o

diff --git a/net/core/uevent.c b/net/core/uevent.c

new file mode 100644

index 0000000..14b1e6e

--- /dev/null

+++ b/net/core/uevent.c

@@ -0,0 +1,43 @@

+/*

+ * Linux network device event notification

+ */

+

+#include <linux/kernel.h>

+#include <linux/netdevice.h>

+#include <linux/kobject.h>

+#include <linux/notifier.h>

+

+/*

+ * Generate uevent in response to network device state changes.

+ * Other events are already handled by device subsystem.

+ */

+static int netdev_event(struct notifier_block *this, unsigned long event,

+ void *ptr)

+{

+ struct net_device *netdev = ptr;

+

+ switch (event) {

+ case NETDEV_UP:

+ kobject_uevent(&netdev->dev.kobj, KOBJ_ADD);

+ break;

+ case NETDEV_DOWN:

+ kobject_uevent(&netdev->dev.kobj, KOBJ_REMOVE);

+ break;

+ case NETDEV_CHANGE:{

+ kobject_uevent(&netdev->dev.kobj, KOBJ_CHANGE);

+ break;

+ }

+ }

+ return NOTIFY_DONE;

+}

+

+static struct notifier_block netdev_uevent_notifier = {

+ .notifier_call = netdev_event,

+};

+

+static int __init netdev_uevent_init(void)

+{

+ return register_netdevice_notifier(&netdev_uevent_notifier);

+}

+

+device_initcall(netdev_uevent_init);

--

View solution in original post

0 Kudos
4 Replies
2,657 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Can you share the udev rule? Have you tried this with the image of the FSL web page? (LTIB)

Best Regards,

Alejandro

0 Kudos
2,657 Views
B_K_Ankur
Contributor IV

Hello Alejandro,

Sorry, I was away and couldn't able to work on this issue.

Udev Rules used:

root@imx28evk:~# cat /etc/udev/rules.d/autonet.rules

# Handle network interface setup

SUBSYSTEM=="net", ACTION=="add" RUN+="/etc/udev/scripts/network.sh"

SUBSYSTEM=="net", ACTION=="remove" RUN+="/etc/udev/scripts/network.sh"

I am using opensource program in c to listen to all netlink activites from Kernel.

Checking Netlink Activities from Kernel: netlink.c (http://pastebin.com/CA8NThAS)

I have tested with the latest kernel 2.6.35 and didnt found Ethernet plug/unplug event working. Find the below logs:

root@imx28evk:~# uname -r

2.6.35.3-1.1.0+yocto+g914558e

root@imx28evk:~# ./netlink

PHY: 0:00 - Link is Down

PHY: 0:00 - Link is Up - 100/Full

Same Program Works for USB Plug/Unplug events:

root@imx28evk:~# ./netlink

usb 2-1: new high speed USB device using fsl-ehci and address 2

add@/devices/platform/fsl-ehci.0/usb2/2-1

ACTION=add

DEVPATH=/devices/platform/fsl-ehcscsi0 : usb-storage 2-1:1.0

i.0/usb2/2-1

SUBSYSTEM=usb

MAJOR=189

MINOR=129

DEVNAME=bus/usb/002/002

DEVTYPE=usb_device

PRODUCT=5dc/a817/1100

TYPE=0/0/0

BUSNUM=002

DEVNUM=002

SEQNUM=1830

add@/devices/platform/fsl-ehci.0/usb2/2-1/2-1:1.0

ACTION=add

DEVPATH=/devices/platform/fsl-ehci.0/usb2/2-1/2-1:1.0

....

Could anyone throw some light on why Ethernet driver fails to send the plug/unplug event to udev via netlink sockets?

Please feel free to share if you need more information.

Regards,

Ankur

0 Kudos
2,658 Views
B_K_Ankur
Contributor IV

Hello All,

Added Patch into kernel to send the udev events to userspace.Please find the attached one.

Regards,

Ankur

---

net/core/Makefile | 1 +

net/core/uevent.c | 43 +++++++++++++++++++++++++++++++++++++++++++

2 files changed, 44 insertions(+)

create mode 100644 net/core/uevent.c

diff --git a/net/core/Makefile b/net/core/Makefile

index b33b996..a2139a7 100644

--- a/net/core/Makefile

+++ b/net/core/Makefile

@@ -22,3 +22,4 @@ obj-$(CONFIG_TRACEPOINTS) += net-traces.o

obj-$(CONFIG_NET_DROP_MONITOR) += drop_monitor.o

obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o

obj-$(CONFIG_NETPRIO_CGROUP) += netprio_cgroup.o

+obj-$(CONFIG_HOTPLUG) += uevent.o

diff --git a/net/core/uevent.c b/net/core/uevent.c

new file mode 100644

index 0000000..14b1e6e

--- /dev/null

+++ b/net/core/uevent.c

@@ -0,0 +1,43 @@

+/*

+ * Linux network device event notification

+ */

+

+#include <linux/kernel.h>

+#include <linux/netdevice.h>

+#include <linux/kobject.h>

+#include <linux/notifier.h>

+

+/*

+ * Generate uevent in response to network device state changes.

+ * Other events are already handled by device subsystem.

+ */

+static int netdev_event(struct notifier_block *this, unsigned long event,

+ void *ptr)

+{

+ struct net_device *netdev = ptr;

+

+ switch (event) {

+ case NETDEV_UP:

+ kobject_uevent(&netdev->dev.kobj, KOBJ_ADD);

+ break;

+ case NETDEV_DOWN:

+ kobject_uevent(&netdev->dev.kobj, KOBJ_REMOVE);

+ break;

+ case NETDEV_CHANGE:{

+ kobject_uevent(&netdev->dev.kobj, KOBJ_CHANGE);

+ break;

+ }

+ }

+ return NOTIFY_DONE;

+}

+

+static struct notifier_block netdev_uevent_notifier = {

+ .notifier_call = netdev_event,

+};

+

+static int __init netdev_uevent_init(void)

+{

+ return register_netdevice_notifier(&netdev_uevent_notifier);

+}

+

+device_initcall(netdev_uevent_init);

--

0 Kudos
2,657 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Sorry for the delay, it seems that you already solved the problem. Thanks a lot for sharing the solution!!

Best Regards,

Alejandro

0 Kudos