• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/scsi/bfa/include/cs/
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 */
17
18/**
19 *  bfa_q.h Circular queue definitions.
20 */
21
22#ifndef __BFA_Q_H__
23#define __BFA_Q_H__
24
25#define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
26#define bfa_q_next(_qe)	(((struct list_head *) (_qe))->next)
27#define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
28
29/*
30 * bfa_q_qe_init - to initialize a queue element
31 */
32#define bfa_q_qe_init(_qe) {						\
33	bfa_q_next(_qe) = (struct list_head *) NULL;			\
34	bfa_q_prev(_qe) = (struct list_head *) NULL;			\
35}
36
37/*
38 * bfa_q_deq - dequeue an element from head of the queue
39 */
40#define bfa_q_deq(_q, _qe) {						\
41	if (!list_empty(_q)) {					\
42		(*((struct list_head **) (_qe))) = bfa_q_next(_q);	\
43		bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) =	\
44						(struct list_head *) (_q); \
45		bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
46		BFA_Q_DBG_INIT(*((struct list_head **) _qe));		\
47	} else {							\
48		*((struct list_head **) (_qe)) = (struct list_head *) NULL; \
49	}								\
50}
51
52/*
53 * bfa_q_deq_tail - dequeue an element from tail of the queue
54 */
55#define bfa_q_deq_tail(_q, _qe) {					    \
56	if (!list_empty(_q)) {					            \
57		*((struct list_head **) (_qe)) = bfa_q_prev(_q);	    \
58		bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) = 	    \
59						(struct list_head *) (_q);  \
60		bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);    \
61		BFA_Q_DBG_INIT(*((struct list_head **) _qe));		    \
62	} else {							    \
63		*((struct list_head **) (_qe)) = (struct list_head *) NULL; \
64	}								    \
65}
66
67/*
68 * #ifdef BFA_DEBUG (Using bfa_assert to check for debug_build is not
69 * consistent across modules)
70 */
71#ifndef BFA_PERF_BUILD
72#define BFA_Q_DBG_INIT(_qe)	bfa_q_qe_init(_qe)
73#else
74#define BFA_Q_DBG_INIT(_qe)
75#endif
76
77#define bfa_q_is_on_q(_q, _qe)		\
78	bfa_q_is_on_q_func(_q, (struct list_head *)(_qe))
79extern int bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe);
80
81#endif
82