Hi all,
after looking at driver source, I've figured out that rt_e1000e driver do not support link detection.
I've added basic ethtool support for GLINK on e1000e, see attached patch.

Regards,
Elker



Il 25/06/2014 11.53, Elker Cavina ha scritto:
Hi
I'm using RTNet-0.9.13 with RTAI-3.9.2; my embedded pc has two e1000e ethernet ports (so rt_e1000e is employed).

The first port is configured as standard linux (eth1), second port gets configured to rtnet (firstly unbinded by linux driver, then configured as rteth0). So far I'm working correctly in rtnet side; I'm also using rtcap and configured rteth0 on linux side and tcpdump works great to sniff realtime packets.

Now I want to detect if carrier is lost on rtnet port; on linux managed ethernet port looking at /sys/class/net/eth1/carrier I can detect link loss, however in /sys/class/net/rteth0/carrier I always get link active even on cable disconnected.

Digging into code I can see carrier detected and managed in rtdev->link_state, but I can't find the link to the sys filesystem or an ioctl call to detect link status.

Is possible to detect link status on rt_e1000e driver?
If not, can someone point to some code to implement this?

Thanks,
Elker

>From cac65b786995b3c1e300beec4ae144cda8a5be67 Mon Sep 17 00:00:00 2001
From: Elker Cavina <elkercav...@gmail.com>
Date: Tue, 1 Jul 2014 11:16:38 +0200
Subject: [PATCH] e1000e: link detection via ethtool GLINK command

---
 drivers/e1000e/netdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/e1000e/netdev.c b/drivers/e1000e/netdev.c
index 5634a9b..ce2d6aa 100644
--- a/drivers/e1000e/netdev.c
+++ b/drivers/e1000e/netdev.c
@@ -147,6 +147,8 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
        {}
 };
 
+static int e1000_ioctl(struct rtnet_device *, unsigned int req, void* arg);
+
 /*
  * e1000_regdump - register printout routine
  */
@@ -3503,6 +3505,28 @@ struct rtnl_link_stats64 *e1000e_get_stats64(struct 
net_device *netdev,
 }
 #endif
 
+static int e1000_ioctl(struct rtnet_device *dev, unsigned int req, void* arg)
+{
+       struct ifreq *ifr = arg;
+       switch (req) {
+               case SIOCETHTOOL: {
+                       struct ethtool_value *value;
+                       value = (struct ethtool_value *)ifr->ifr_data;
+                       if (value->cmd == ETHTOOL_GLINK) {
+                               if (rtnetif_carrier_ok(dev)) 
+                                       value->data=1;
+                               else 
+                                       value->data=0;
+                               return 0;
+                       }
+                       break;
+               }
+       }
+       
+       return -EOPNOTSUPP;
+}
+
+
 static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
 {
        struct e1000_hw *hw = &adapter->hw;
@@ -4058,6 +4082,7 @@ static int e1000_probe(struct pci_dev *pdev,
        netdev->stop = e1000_close;
        netdev->hard_start_xmit = e1000_xmit_frame;
         //netdev->get_stats = e1000_get_stats;
+       netdev->do_ioctl = e1000_ioctl;
        netdev->map_rtskb = e1000_map_rtskb;
        netdev->unmap_rtskb = e1000_unmap_rtskb;
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
-- 
1.8.5.2.msysgit.0

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to