How can i get fec PHY link status from user space for plug/unplug the network cable in i.mx25 board

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

How can i get fec PHY link status from user space for plug/unplug the network cable in i.mx25 board

7,627 Views
gurumoorthirasi
Contributor IV

Dear All,

we are using i.mx25 processor with linux 2.6.31 for our product.


we need to get the fec PHY link status from user space for whenever change in the network cable like connection/removing.

we need to show it on my UI about network connection.

Please kindly give us the workaround to do that.

And sysfs interface also not updating the carrier value for connection and remove.  it remains the same value only. value wont get changed.

we have used some utility like ethtool and mii-tool from userspace . it wont give the information about PHY link status.

mii-tool

SIOCGMIIPHY on 'eth0' failed: Operation not supported

no MII interfaces found

ethtool eth0

Settings for eth0:

No data available

what i need to do to done this?

This is high priority !!!

Regards,

Guru

Tags (5)
9 Replies

4,125 Views
akatskuki
Contributor I

Any updates here at all? We are working on Linux kernel 2.6.35 with an i.mx53 (old, I know) and similarly are unable to detect a changing carrier state on plug/unplug. The value is constantly “1” for the /sys/class/net/eth0/carrier file

Does this require a kernel patch to support?

Using the “ifplugd” package also fails to detect changes in plugged state of Ethernet. So I think im needing to change something in the kernel but not sure where to start. Maybe the device tree somewhere? Ethernet works, as eth0 is brought UP during boot (regardless of cable being plugged in or not) but I want to be able to run dhcp after we’ve completed boot and randomly plug in a Ethernet cable

Any ideas would be great

0 Kudos
Reply

5,281 Views
harikrishnamanu
Contributor I

Hi all,

I had a similar problem in imx28 board.

I want to get PHY Link status from user space when ever there is change in link status.

I am able to get the status by doing cat /sys/class/net/eth0/carrier.

But when i try opening this sysfs entry from my code ,i am not able to do so.It is giving error always.I even tried changing permissions of the sysfs entry.Not able to uderstand what the problem is .so  please help me in reading the PHY status from userspace continously,so that i can handle my requirement with the status i get.

0 Kudos
Reply

5,281 Views
gurumoorthirasi
Contributor IV

Hi Hari,

I will give you one workaround for your application.

As u tried, Get the status using cat command and write one script to writing the cat value to one local file for all the time and tried to read that file.

you can get the phy link status value.

hope it works fine.

Regards,

Guru

5,281 Views
harikrishnamanu
Contributor I

Hi guru guru,

Thanks for replying.I actually tried with the script after i posted this.I am able to read it.I am working on some flashing procedure .

My actual requirement was restarting the whole flashing procedure when ever Link goes down in between flashing .i.e,due to some packet loss and so on. link stops and will be UP automatically  but my flashing stops abruptly .so i want to restart when this happens.

Now the problem is i am able to restart above mentioned process when it fails once data is sent from my part and if link is down by reading the status.But when reception fails it is getting blocked in recv from() function and status cant be read though it fails.

so i am looking for some mechanism which can send me a signal from fec driver so that i can wakeup a process in userspace and kill the present running process and start new one.

0 Kudos
Reply

5,281 Views
gusarambula
NXP TechSupport
NXP TechSupport

Have you used ifup eth0 prior to using mii-tool? I do not know in detail how mii-tool communicates with the Ethernet PHY but it seems that eth0 is down and that’s why is sending that error.

0 Kudos
Reply

5,281 Views
gurumoorthirasi
Contributor IV

Hi,

eth0 interface is up only. Give me some idea to access the link status from userspce.

what could be the problem for this ?

Guru

0 Kudos
Reply

5,281 Views
fabio_estevam
NXP Employee
NXP Employee

On a 3.18-rc kernel:

cat /sys/class/net/eth0/carrier                         

1      

cat /sys/class/net/eth0/carrier_changes                 
1                 

If you unplug the cable then plug it again:

cat /sys/class/net/eth0/carrier_changes                 
3                                                

,as it incremented in the unplug then incremented again after plugging it.

5,281 Views
fabio_estevam
NXP Employee
NXP Employee

By the way, this works exactly the same on my host Linux PC:

With Ethernet cable connected:

cat /sys/class/net/eth0/carrier

1

With Ethernet cable disconnected:

cat /sys/class/net/eth0/carrier

0

0 Kudos
Reply

5,281 Views
gurumoorthirasi
Contributor IV

Dear Fabio,

I am using freescale BSP with Linux 2.6.31 kernel in i.mx25 board. it wont give the carrier status.

Regards,

Guru

0 Kudos
Reply