2 * Misc useful os-independent macros and functions.
4 * Copyright 2006, Broadcom Corporation
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 * $Id: bcmutils.h,v 1.1.1.16 2006/04/08 06:13:39 honor Exp $
18 /* osl multi-precedence packet queue */
20 #define PKTQ_LEN_DEFAULT 128 /* Max 128 packets */
21 #define PKTQ_MAX_PREC 16 /* Maximum precedence levels */
25 void *head
; /* first packet to dequeue */
26 void *tail
; /* last packet to dequeue */
27 uint16 len
; /* number of queued packets */
28 uint16 max
; /* maximum number of queued packets */
30 uint16 num_prec
; /* number of precedences in use */
31 uint16 hi_prec
; /* rapid dequeue hint (>= highest non-empty prec) */
32 uint16 max
; /* total max packets */
33 uint16 len
; /* total number of packets */
36 #define PKTQ_PREC_ITER(pq, prec) for (prec = (pq)->num_prec - 1; prec >= 0; prec--)
38 /* forward definition of ether_addr structure used by some function prototypes */
42 /* operations on a specific precedence in packet queue */
44 #define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max))
45 #define pktq_plen(pq, prec) ((pq)->q[prec].len)
46 #define pktq_pavail(pq, prec) ((pq)->q[prec].max - (pq)->q[prec].len)
47 #define pktq_pfull(pq, prec) ((pq)->q[prec].len >= (pq)->q[prec].max)
48 #define pktq_pempty(pq, prec) ((pq)->q[prec].len == 0)
50 #define pktq_ppeek(pq, prec) ((pq)->q[prec].head)
51 #define pktq_ppeek_tail(pq, prec) ((pq)->q[prec].tail)
53 extern void *pktq_penq(struct pktq
*pq
, int prec
, void *p
);
54 extern void *pktq_penq_head(struct pktq
*pq
, int prec
, void *p
);
55 extern void *pktq_pdeq(struct pktq
*pq
, int prec
);
56 extern void *pktq_pdeq_tail(struct pktq
*pq
, int prec
);
57 /* Empty the queue at particular precedence level */
58 extern void pktq_pflush(osl_t
*osh
, struct pktq
*pq
, int prec
, bool dir
);
59 /* Remove a specified packet from its queue */
60 extern bool pktq_pdel(struct pktq
*pq
, void *p
, int prec
);
62 /* operations on a set of precedences in packet queue */
64 extern int pktq_mlen(struct pktq
*pq
, uint prec_bmp
);
65 extern void *pktq_mdeq(struct pktq
*pq
, uint prec_bmp
, int *prec_out
);
67 /* operations on packet queue as a whole */
69 #define pktq_len(pq) ((int)(pq)->len)
70 #define pktq_max(pq) ((int)(pq)->max)
71 #define pktq_avail(pq) ((int)((pq)->max - (pq)->len))
72 #define pktq_full(pq) ((pq)->len >= (pq)->max)
73 #define pktq_empty(pq) ((pq)->len == 0)
75 /* operations for single precedence queues */
76 #define pktenq(pq, p) pktq_penq((pq), 0, (p))
77 #define pktenq_head(pq, p) pktq_penq_head((pq), 0, (p))
78 #define pktdeq(pq) pktq_pdeq((pq), 0)
79 #define pktdeq_tail(pq) pktq_pdeq_tail((pq), 0)
81 extern void pktq_init(struct pktq
*pq
, int num_prec
, int max_len
);
82 /* prec_out may be NULL if caller is not interested in return value */
83 extern void *pktq_deq(struct pktq
*pq
, int *prec_out
);
84 extern void *pktq_deq_tail(struct pktq
*pq
, int *prec_out
);
85 extern void *pktq_peek(struct pktq
*pq
, int *prec_out
);
86 extern void *pktq_peek_tail(struct pktq
*pq
, int *prec_out
);
87 extern void pktq_flush(osl_t
*osh
, struct pktq
*pq
, bool dir
); /* Empty the entire queue */
91 extern uint
pktcopy(osl_t
*osh
, void *p
, uint offset
, int len
, uchar
*buf
);
92 extern uint
pkttotlen(osl_t
*osh
, void *p
);
93 extern void *pktlast(osl_t
*osh
, void *p
);
95 extern void pktsetprio(void *pkt
, bool update_vtag
);
This page took 0.055476 seconds and 5 git commands to generate.