OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [net/] [netrom/] [nr_loopback.c] - Blame information for rev 1772

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1629 jcastillo
/*
2
 *      NET/ROM release 006
3
 *
4
 *      This code REQUIRES 1.2.1 or higher/ NET3.029
5
 *
6
 *      This module:
7
 *              This module is free software; you can redistribute it and/or
8
 *              modify it under the terms of the GNU General Public License
9
 *              as published by the Free Software Foundation; either version
10
 *              2 of the License, or (at your option) any later version.
11
 *
12
 *      History
13
 *      NET/ROM 006     Tomi(OH2BNS)    Created this file.
14
 *                                      Changed the way the loopback
15
 *                                      queue is consumed.
16
 *
17
 */
18
 
19
#include <linux/config.h>
20
#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
21
#include <linux/types.h>
22
#include <linux/timer.h>
23
#include <net/ax25.h>
24
#include <linux/skbuff.h>
25
#include <net/netrom.h>
26
 
27
static struct sk_buff_head loopback_queue;
28
static struct timer_list loopback_timer;
29
 
30
static void nr_set_loopback_timer(void);
31
 
32
void nr_loopback_init(void)
33
{
34
        skb_queue_head_init(&loopback_queue);
35
 
36
        init_timer(&loopback_timer);
37
}
38
 
39
void nr_loopback_clear(void)
40
{
41
        struct sk_buff *skb;
42
 
43
        del_timer(&loopback_timer);
44
 
45
        while ((skb = skb_dequeue(&loopback_queue)) != NULL)
46
                kfree_skb(skb, FREE_READ);
47
}
48
 
49
static int nr_loopback_running(void)
50
{
51
        return (loopback_timer.prev != NULL || loopback_timer.next != NULL);
52
}
53
 
54
int nr_loopback_queue(struct sk_buff *skb)
55
{
56
        struct sk_buff *skbn;
57
 
58
        skbn = skb_clone(skb, GFP_ATOMIC);
59
 
60
        kfree_skb(skb, FREE_WRITE);
61
 
62
        if (skbn != NULL) {
63
                skb_queue_tail(&loopback_queue, skbn);
64
 
65
                if (!nr_loopback_running())
66
                        nr_set_loopback_timer();
67
        }
68
 
69
        return 1;
70
}
71
 
72
static void nr_loopback_timer(unsigned long);
73
 
74
static void nr_set_loopback_timer(void)
75
{
76
        del_timer(&loopback_timer);
77
 
78
        loopback_timer.data     = 0;
79
        loopback_timer.function = &nr_loopback_timer;
80
        loopback_timer.expires  = jiffies + 10;
81
 
82
        add_timer(&loopback_timer);
83
}
84
 
85
static void nr_loopback_timer(unsigned long param)
86
{
87
        struct sk_buff *skb;
88
        ax25_address *nr_dest;
89
        struct device *dev;
90
 
91
        if ((skb = skb_dequeue(&loopback_queue)) != NULL) {
92
                nr_dest = (ax25_address *)(skb->data + 7);
93
 
94
                dev = nr_dev_get(nr_dest);
95
 
96
                if (dev == NULL || nr_rx_frame(skb, dev) == 0)
97
                        kfree_skb(skb, FREE_READ);
98
 
99
                if (!skb_queue_empty(&loopback_queue) && !nr_loopback_running())
100
                        nr_set_loopback_timer();
101
        }
102
}
103
 
104
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.