Commit 17f14d7c authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcmutil: add dequeue function with filtering

Adding a packet dequeue function that will return packets that
pass the provided match function.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarPiotr Haber <phaber@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6fc9ca13
......@@ -116,6 +116,31 @@ struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec)
}
EXPORT_SYMBOL(brcmu_pktq_pdeq);
/*
* precedence based dequeue with match function. Passing a NULL pointer
* for the match function parameter is considered to be a wildcard so
* any packet on the queue is returned. In that case it is no different
* from brcmu_pktq_pdeq() above.
*/
struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
bool (*match_fn)(struct sk_buff *skb,
void *arg), void *arg)
{
struct sk_buff_head *q;
struct sk_buff *p, *next;
q = &pq->q[prec].skblist;
skb_queue_walk_safe(q, p, next) {
if (match_fn == NULL || match_fn(p, arg)) {
skb_unlink(p, q);
pq->len--;
return p;
}
}
return NULL;
}
EXPORT_SYMBOL(brcmu_pktq_pdeq_match);
struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec)
{
struct sk_buff_head *q;
......
......@@ -120,6 +120,10 @@ extern struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec,
struct sk_buff *p);
extern struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec);
extern struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec);
extern struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
bool (*match_fn)(struct sk_buff *p,
void *arg),
void *arg);
/* packet primitives */
extern struct sk_buff *brcmu_pkt_buf_get_skb(uint len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment