37 #include <linux/version.h> 38 #include <linux/netdevice.h> 39 #include <linux/etherdevice.h> 53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) 84 memset(&dbg->
stats, 0,
sizeof(
struct net_device_stats));
86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) 87 dbg->
dev = alloc_netdev(
sizeof(
ec_debug_t *), name, NET_NAME_UNKNOWN, ether_setup);
89 dbg->
dev = alloc_netdev(
sizeof(
ec_debug_t *), name, ether_setup);
94 " for debug object!\n");
99 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31) 125 free_netdev(dbg->
dev);
134 const struct net_device *net_dev
142 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) 143 eth_hw_addr_set(dbg->
dev, net_dev->dev_addr);
145 memcpy(dbg->
dev->dev_addr, net_dev->dev_addr, ETH_ALEN);
149 if ((result = register_netdev(dbg->
dev))) {
151 " error %i\n", result);
168 unregister_netdev(dbg->
dev);
188 if (!(skb = dev_alloc_skb(size))) {
189 dbg->
stats.rx_dropped++;
194 memcpy(skb_put(skb, size), data, size);
197 dbg->
stats.rx_packets++;
198 dbg->
stats.rx_bytes += size;
202 skb->protocol = eth_type_trans(skb, dbg->
dev);
203 skb->ip_summed = CHECKSUM_UNNECESSARY;
216 struct net_device *dev
233 struct net_device *dev
251 struct net_device *dev
257 dbg->
stats.tx_dropped++;
268 struct net_device *dev
void ec_debug_clear(ec_debug_t *dbg)
Debug interface destructor.
Network interface for debugging purposes.
uint8_t registered
net_device is opened
int ec_dbgdev_tx(struct sk_buff *, struct net_device *)
Transmits data via the virtual network device.
Debugging network interface.
Global definitions and macros.
EtherCAT master structure.
void ec_debug_unregister(ec_debug_t *dbg)
Unregister debug interface.
struct net_device * dev
net_device for virtual ethernet device
#define EC_MASTER_WARN(master, fmt, args...)
Convenience macro for printing master-specific warnings to syslog.
ec_master_t * master
EtherCAT master.
#define EC_MASTER_ERR(master, fmt, args...)
Convenience macro for printing master-specific errors to syslog.
void ec_debug_send(ec_debug_t *dbg, const uint8_t *data, size_t size)
Sends frame data to the interface.
void ec_debug_register(ec_debug_t *dbg, const struct net_device *net_dev)
Register debug interface.
int ec_debug_init(ec_debug_t *dbg, ec_device_t *device, const char *name)
Debug interface constructor.
int ec_dbgdev_stop(struct net_device *)
Stops the virtual network device.
struct net_device_stats * ec_dbgdev_stats(struct net_device *)
Gets statistics about the virtual network device.
int ec_dbgdev_open(struct net_device *)
Opens the virtual network device.
static const struct net_device_ops ec_dbg_netdev_ops
Device operations for debug interfaces.
ec_device_t * device
Parent device.
uint8_t opened
net_device is opened
#define EC_MASTER_INFO(master, fmt, args...)
Convenience macro for printing master-specific information to syslog.
struct net_device_stats stats
device statistics