devices/ccat/netdev-3.4-ethercat.c
branchstable-1.5
changeset 2552 6e419c23b1b3
parent 2551 000da5069f1a
equal deleted inserted replaced
2551:000da5069f1a 2552:6e419c23b1b3
    25 #include <linux/kthread.h>
    25 #include <linux/kthread.h>
    26 #include <linux/module.h>
    26 #include <linux/module.h>
    27 #include <linux/netdevice.h>
    27 #include <linux/netdevice.h>
    28 #include <linux/spinlock.h>
    28 #include <linux/spinlock.h>
    29 
    29 
       
    30 #include "compat.h"
    30 #include "module.h"
    31 #include "module.h"
    31 #include "netdev.h"
    32 #include "netdev.h"
    32 #include "print.h"
    33 #include "print.h"
    33 
    34 
    34 /**
    35 /**
    55 static void ec_poll(struct net_device *dev);
    56 static void ec_poll(struct net_device *dev);
    56 static int run_poll_thread(void *data);
    57 static int run_poll_thread(void *data);
    57 static int run_rx_thread(void *data);
    58 static int run_rx_thread(void *data);
    58 static int run_tx_thread(void *data);
    59 static int run_tx_thread(void *data);
    59 
    60 
       
    61 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
    60 static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64
    62 static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64
    61 						      *storage);
    63 						      *storage);
       
    64 #endif
    62 static int ccat_eth_open(struct net_device *dev);
    65 static int ccat_eth_open(struct net_device *dev);
    63 static netdev_tx_t ccat_eth_start_xmit(struct sk_buff *skb,
    66 static netdev_tx_t ccat_eth_start_xmit(struct sk_buff *skb,
    64 				       struct net_device *dev);
    67 				       struct net_device *dev);
    65 static int ccat_eth_stop(struct net_device *dev);
    68 static int ccat_eth_stop(struct net_device *dev);
    66 static void ccat_eth_xmit_raw(struct net_device *dev, const char *data,
    69 static void ccat_eth_xmit_raw(struct net_device *dev, const char *data,
    67 			      size_t len);
    70 			      size_t len);
    68 
    71 
    69 static const struct net_device_ops ccat_eth_netdev_ops = {
    72 static const struct net_device_ops ccat_eth_netdev_ops = {
       
    73 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
    70 	.ndo_get_stats64 = ccat_eth_get_stats64,
    74 	.ndo_get_stats64 = ccat_eth_get_stats64,
       
    75 #endif
    71 	.ndo_open = ccat_eth_open,
    76 	.ndo_open = ccat_eth_open,
    72 	.ndo_start_xmit = ccat_eth_start_xmit,
    77 	.ndo_start_xmit = ccat_eth_start_xmit,
    73 	.ndo_stop = ccat_eth_stop,
    78 	.ndo_stop = ccat_eth_stop,
    74 };
    79 };
    75 
    80 
   238 						   *const priv)
   243 						   *const priv)
   239 {
   244 {
   240 	return (1 << 24) == (ioread32(priv->reg.mii + 0x8 + 4) & (1 << 24));
   245 	return (1 << 24) == (ioread32(priv->reg.mii + 0x8 + 4) & (1 << 24));
   241 }
   246 }
   242 
   247 
       
   248 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
   243 static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64
   249 static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64
   244 						      *storage)
   250 						      *storage)
   245 {
   251 {
   246 	struct ccat_eth_priv *const priv = netdev_priv(dev);
   252 	struct ccat_eth_priv *const priv = netdev_priv(dev);
   247 	CCatMacRegs mac;
   253 	CCatMacRegs mac;
   275 	/* for cslip etc */
   281 	/* for cslip etc */
   276 	//TODO __u64    rx_compressed;
   282 	//TODO __u64    rx_compressed;
   277 	//TODO __u64    tx_compressed;
   283 	//TODO __u64    tx_compressed;
   278 	return storage;
   284 	return storage;
   279 }
   285 }
       
   286 #endif
   280 
   287 
   281 struct ccat_eth_priv *ccat_eth_init(const struct ccat_device *const ccatdev,
   288 struct ccat_eth_priv *ccat_eth_init(const struct ccat_device *const ccatdev,
   282 				    const void __iomem * const addr)
   289 				    const void __iomem * const addr)
   283 {
   290 {
   284 	struct ccat_eth_priv *priv;
   291 	struct ccat_eth_priv *priv;