The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/cxgb/sys/mbufq.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /**************************************************************************
    2 
    3 Copyright (c) 2007-2008, Chelsio Inc.
    4 All rights reserved.
    5 
    6 Redistribution and use in source and binary forms, with or without
    7 modification, are permitted provided that the following conditions are met:
    8 
    9  1. Redistributions of source code must retain the above copyright notice,
   10     this list of conditions and the following disclaimer.
   11 
   12  2. Neither the name of the Chelsio Corporation nor the names of its
   13     contributors may be used to endorse or promote products derived from
   14     this software without specific prior written permission.
   15 
   16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   26 POSSIBILITY OF SUCH DAMAGE.
   27 
   28 $FreeBSD: releng/8.0/sys/dev/cxgb/sys/mbufq.h 183062 2008-09-16 02:03:28Z kmacy $
   29 
   30 ***************************************************************************/
   31 
   32 #ifndef CXGB_MBUFQ_H_
   33 #define CXGB_MBUFQ_H_
   34 
   35 struct mbuf_head {
   36         struct mbuf *head;
   37         struct mbuf *tail;
   38         uint32_t     qlen;
   39         uint32_t     qsize;
   40         struct mtx   lock;
   41 };
   42 
   43 static __inline void
   44 mbufq_init(struct mbuf_head *l)
   45 {
   46         l->head = l->tail = NULL;
   47         l->qlen = l->qsize = 0;
   48 }
   49 
   50 static __inline int
   51 mbufq_empty(struct mbuf_head *l)
   52 {
   53         return (l->head == NULL);
   54 }
   55 
   56 static __inline int
   57 mbufq_len(struct mbuf_head *l)
   58 {
   59         return (l->qlen);
   60 }
   61 
   62 static __inline int
   63 mbufq_size(struct mbuf_head *l)
   64 {
   65         return (l->qsize);
   66 }
   67 
   68 static __inline int
   69 mbufq_head_size(struct mbuf_head *l)
   70 {
   71         return (l->head ? l->head->m_pkthdr.len : 0);
   72 }
   73 
   74 static __inline void
   75 mbufq_tail(struct mbuf_head *l, struct mbuf *m)
   76 {
   77         l->qlen++;
   78         if (l->head == NULL)
   79                 l->head = m;
   80         else
   81                 l->tail->m_nextpkt = m;
   82         l->tail = m;
   83         l->qsize += m->m_pkthdr.len;
   84 }
   85 
   86 static __inline struct mbuf *
   87 mbufq_dequeue(struct mbuf_head *l)
   88 {
   89         struct mbuf *m;
   90 
   91         m = l->head;
   92         if (m) {
   93                 if (m == l->tail) 
   94                         l->head = l->tail = NULL;
   95                 else
   96                         l->head = m->m_nextpkt;
   97                 m->m_nextpkt = NULL;
   98                 l->qlen--;
   99                 l->qsize -= m->m_pkthdr.len;
  100         }
  101 
  102         return (m);
  103 }
  104 
  105 static __inline struct mbuf *
  106 mbufq_peek(const struct mbuf_head *l)
  107 {
  108         return (l->head);
  109 }
  110 
  111 static __inline void
  112 mbufq_append(struct mbuf_head *a, struct mbuf_head *b)
  113 {
  114         if (a->tail) 
  115                 a->tail->m_nextpkt = b->head;
  116         if (b->tail)
  117                 a->tail = b->tail;
  118         a->qlen += b->qlen;
  119         a->qsize += b->qsize;
  120         
  121         
  122 }
  123 #endif  /* CXGB_MBUFQ_H_ */

Cache object: 5454d5e4ad1ac6aa88767e980d0d28bd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.