master/debug.c
changeset 1579 326d47aa986c
parent 1363 11c0b2caa253
child 1907 dd276ae226b4
equal deleted inserted replaced
1511:53bf35f7b6ea 1579:326d47aa986c
    32    Ethernet interface for debugging purposes.
    32    Ethernet interface for debugging purposes.
    33 */
    33 */
    34 
    34 
    35 /*****************************************************************************/
    35 /*****************************************************************************/
    36 
    36 
       
    37 #include <linux/version.h>
    37 #include <linux/netdevice.h>
    38 #include <linux/netdevice.h>
    38 #include <linux/etherdevice.h>
    39 #include <linux/etherdevice.h>
    39 
    40 
    40 #include "globals.h"
    41 #include "globals.h"
    41 #include "debug.h"
    42 #include "debug.h"
    46 int ec_dbgdev_open(struct net_device *);
    47 int ec_dbgdev_open(struct net_device *);
    47 int ec_dbgdev_stop(struct net_device *);
    48 int ec_dbgdev_stop(struct net_device *);
    48 int ec_dbgdev_tx(struct sk_buff *, struct net_device *);
    49 int ec_dbgdev_tx(struct sk_buff *, struct net_device *);
    49 struct net_device_stats *ec_dbgdev_stats(struct net_device *);
    50 struct net_device_stats *ec_dbgdev_stats(struct net_device *);
    50 
    51 
       
    52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
       
    53 static const struct net_device_ops ec_dbg_netdev_ops =
       
    54 {
       
    55     .ndo_open = ec_dbgdev_open,
       
    56     .ndo_stop = ec_dbgdev_stop,
       
    57     .ndo_start_xmit = ec_dbgdev_tx,
       
    58     .ndo_get_stats = ec_dbgdev_stats,
       
    59 };
       
    60 #endif
       
    61 
    51 /*****************************************************************************/
    62 /*****************************************************************************/
    52 
    63 
    53 /** Debug interface constructor.
    64 /** Debug interface constructor.
    54  *
    65  *
    55  * Initializes the debug object, creates a net_device and registeres it.
    66  * Initializes the debug object, creates a net_device and registeres it.
    72         EC_ERR("Unable to allocate net_device for debug object!\n");
    83         EC_ERR("Unable to allocate net_device for debug object!\n");
    73         return -ENODEV;
    84         return -ENODEV;
    74     }
    85     }
    75 
    86 
    76     // initialize net_device
    87     // initialize net_device
       
    88 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
       
    89     dbg->dev->netdev_ops = &ec_dbg_netdev_ops;
       
    90 #else
    77     dbg->dev->open = ec_dbgdev_open;
    91     dbg->dev->open = ec_dbgdev_open;
    78     dbg->dev->stop = ec_dbgdev_stop;
    92     dbg->dev->stop = ec_dbgdev_stop;
    79     dbg->dev->hard_start_xmit = ec_dbgdev_tx;
    93     dbg->dev->hard_start_xmit = ec_dbgdev_tx;
    80     dbg->dev->get_stats = ec_dbgdev_stats;
    94     dbg->dev->get_stats = ec_dbgdev_stats;
       
    95 #endif
    81 
    96 
    82     // initialize private data
    97     // initialize private data
    83     *((ec_debug_t **) netdev_priv(dbg->dev)) = dbg;
    98     *((ec_debug_t **) netdev_priv(dbg->dev)) = dbg;
    84 
    99 
    85     return 0;
   100     return 0;