#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <net/arp.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/errqueue.h>
#include <linux/leds.h>
#include <linux/workqueue.h>
#include "arcdevice.h"
#include "com9026.h"
static void null_rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length);
static int null_build_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, uint8_t daddr);
static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
int length, int bufnum);
static void arcnet_rx(struct net_device *dev, int bufnum);
struct ArcProto *arc_proto_map[256];
EXPORT_SYMBOL(…);
struct ArcProto *arc_proto_default;
EXPORT_SYMBOL(…);
struct ArcProto *arc_bcast_proto;
EXPORT_SYMBOL(…);
struct ArcProto *arc_raw_proto;
EXPORT_SYMBOL(…);
static struct ArcProto arc_proto_null = …;
int arcnet_debug = …;
EXPORT_SYMBOL(…);
static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *daddr,
const void *saddr, unsigned len);
static int go_tx(struct net_device *dev);
static int debug = …;
module_param(debug, int, 0);
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
static int __init arcnet_init(void)
{ … }
static void __exit arcnet_exit(void)
{ … }
module_init(…) …;
module_exit(arcnet_exit);
#if ARCNET_DEBUG_MAX & D_SKB
void arcnet_dump_skb(struct net_device *dev,
struct sk_buff *skb, char *desc)
{
char hdr[32];
snprintf(hdr, sizeof(hdr), "%6s:%s skb->data:", dev->name, desc);
print_hex_dump(KERN_DEBUG, hdr, DUMP_PREFIX_OFFSET,
16, 1, skb->data, skb->len, true);
}
EXPORT_SYMBOL(arcnet_dump_skb);
#endif
#if (ARCNET_DEBUG_MAX & (D_RX | D_TX))
static void arcnet_dump_packet(struct net_device *dev, int bufnum,
char *desc, int take_arcnet_lock)
{
struct arcnet_local *lp = netdev_priv(dev);
int i, length;
unsigned long flags = 0;
static uint8_t buf[512];
char hdr[32];
if (take_arcnet_lock)
spin_lock_irqsave(&lp->lock, flags);
lp->hw.copy_from_card(dev, bufnum, 0, buf, 512);
if (take_arcnet_lock)
spin_unlock_irqrestore(&lp->lock, flags);
length = (buf[2] ? 256 : 512);
snprintf(hdr, sizeof(hdr), "%6s:%s packet dump:", dev->name, desc);
print_hex_dump(KERN_DEBUG, hdr, DUMP_PREFIX_OFFSET,
16, 1, buf, length, true);
}
#else
#define arcnet_dump_packet(dev, bufnum, desc, take_arcnet_lock) …
#endif
void arcnet_led_event(struct net_device *dev, enum arcnet_led_event event)
{ … }
EXPORT_SYMBOL_GPL(…);
static void arcnet_led_release(struct device *gendev, void *res)
{ … }
void devm_arcnet_led_init(struct net_device *netdev, int index, int subid)
{ … }
EXPORT_SYMBOL_GPL(…);
void arcnet_unregister_proto(struct ArcProto *proto)
{ … }
EXPORT_SYMBOL(…);
static void release_arcbuf(struct net_device *dev, int bufnum)
{ … }
static int get_arcbuf(struct net_device *dev)
{ … }
static int choose_mtu(void)
{ … }
static const struct header_ops arcnet_header_ops = …;
static const struct net_device_ops arcnet_netdev_ops = …;
static void arcdev_setup(struct net_device *dev)
{ … }
static void arcnet_timer(struct timer_list *t)
{ … }
static void reset_device_work(struct work_struct *work)
{ … }
static void arcnet_reply_work(struct work_struct *t)
{
struct arcnet_local *lp = from_work(lp, t, reply_work);
struct sk_buff *ackskb, *skb;
struct sock_exterr_skb *serr;
struct sock *sk;
int ret;
local_irq_disable();
skb = lp->outgoing.skb;
if (!skb || !skb->sk) {
local_irq_enable();
return;
}
sock_hold(skb->sk);
sk = skb->sk;
ackskb = skb_clone_sk(skb);
sock_put(skb->sk);
if (!ackskb) {
local_irq_enable();
return;
}
serr = SKB_EXT_ERR(ackskb);
memset(serr, 0, sizeof(*serr));
serr->ee.ee_errno = ENOMSG;
serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS;
serr->ee.ee_data = skb_shinfo(skb)->tskey;
serr->ee.ee_info = lp->reply_status;
dev_kfree_skb(lp->outgoing.skb);
lp->outgoing.skb = NULL;
ackskb->dev = lp->dev;
ret = sock_queue_err_skb(sk, ackskb);
if (ret)
dev_kfree_skb_irq(ackskb);
local_irq_enable();
};
struct net_device *alloc_arcdev(const char *name)
{ … }
EXPORT_SYMBOL(…);
void free_arcdev(struct net_device *dev)
{ … }
EXPORT_SYMBOL(…);
int arcnet_open(struct net_device *dev)
{ … }
EXPORT_SYMBOL(…);
int arcnet_close(struct net_device *dev)
{ … }
EXPORT_SYMBOL(…);
static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *daddr,
const void *saddr, unsigned len)
{ … }
netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
struct net_device *dev)
{ … }
EXPORT_SYMBOL(…);
static int go_tx(struct net_device *dev)
{ … }
void arcnet_timeout(struct net_device *dev, unsigned int txqueue)
{ … }
EXPORT_SYMBOL(…);
irqreturn_t arcnet_interrupt(int irq, void *dev_id)
{ … }
EXPORT_SYMBOL(…);
static void arcnet_rx(struct net_device *dev, int bufnum)
{ … }
static void null_rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{ … }
static int null_build_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, uint8_t daddr)
{ … }
static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
int length, int bufnum)
{ … }