aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wimax_cmc/buffer.h
blob: f37d902ff89822da9c67166b252c7eabede5224c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * buffer.h
 *
 * Used q_send for the control and data packet sending, uses the BUFFER_DESCRIPTOR
 * q_received used for the control packet receive, data packet sent directly
 */
#ifndef _WIMAX_BUFFER_H
#define _WIMAX_BUFFER_H

/* structures */
struct buffer_descriptor {
	struct list_head	node;		/* list node */
	void			*buffer;	/* allocated buffer: It is used for copying and transfer */
	u_long			length;		/* current data length */
	u_short			type;		/* buffer type (used for control buffers) */
};

struct queue_info {
	struct list_head	head;		/* list head */
	spinlock_t		lock;		/* protection */
};

/******************************************************************************
 * queue_init_list -- Macro which will initialize a queue to NULL.
 ******************************************************************************/
#define queue_init_list(_L) ((_L).next = (_L).prev = NULL)

/******************************************************************************
 * queue_empty -- Macro which checks to see if a queue is empty.
 ******************************************************************************/
#define queue_empty(_L) (queue_get_head((_L)) == NULL)

/******************************************************************************
 * queue_get_head -- Macro which returns the head of the queue, but does not
 * remove the head from the queue.
 ******************************************************************************/
#define queue_get_head(_L) ((struct list_head *)((_L).next))

/******************************************************************************
 * queue_remove_head -- Macro which removes the head of the head of queue.
 ******************************************************************************/
#define queue_remove_head(_L)	\
{	\
	struct list_head *h;	\
	if ((h = (struct list_head *)(_L).next)) {	/* then fix up our our list to point to next elem */	\
		if (!((_L).next = h->next)) /* rechain list pointer to next link */	\
			/* if the list pointer is null, null out the reverse link */	\
			(_L).prev = NULL;	\
	}	\
}

/******************************************************************************
 * queue_put_tail -- Macro which puts an element at the tail (end) of the queue.
 ******************************************************************************/
#define queue_put_tail(_L,_E) \
{	\
	if ((_L).prev) {	\
		((struct list_head *)(_L).prev)->next = (struct list_head *)(&(_E));	\
		(_L).prev = (struct list_head *)(&(_E));	\
	} else	\
		(_L).next = (_L).prev = (struct list_head *)(&(_E));	\
	(_E).next = NULL;	\
}

/******************************************************************************
 * queue_pop_head -- Macro which  will pop the head off of a queue (list), and
 *                 return it (this differs only from queueremovehead only in the 1st line)
 ******************************************************************************/
#define queue_pop_head(_L) \
{	\
	(struct list_head *) (_L).next;	\
	queue_remove_head(_L);	\
}

#endif	/* _WIMAX_BUFFER_H */