OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / klips / net / ipsec_xscale / ipsec_glue_mbuf.c
1 /*
2  * IPSEC_GLUE_MBUF interface code.
3  * Copyright 2003 Intel Corporation All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14
15  RCSID $Id: ipsec_glue_mbuf.c,v 1.0 2003/04/22 05:40:47 rgb Exp $
16
17  */
18
19 #include "ipsec_glue_mbuf.h"
20
21 IX_MBUF_POOL *pIpsecMbufHdrPool; /* mbuf header pool pointer */
22 IX_MBUF       *pIpsecMbufHdr;
23 UINT32        mbufHdrAreaMemSize;
24
25 IX_MBUF_POOL *pIpsecMbufPool;   /* Mbuf pool pointer */
26
27
28
29 /* Initialize mbuf header pool */
30 void ipsec_glue_mbuf_header_init (void)
31 {
32     pIpsecMbufHdr = IX_MBUF_POOL_MBUF_AREA_ALLOC(IPSEC_GLUE_MBUF_HEADER_COUNT, mbufHdrAreaMemSize);
33
34     /* initialize mbuf header pool */
35     IX_MBUF_POOL_INIT_NO_ALLOC(
36         &pIpsecMbufHdrPool,
37         pIpsecMbufHdr,
38         NULL,
39             IPSEC_GLUE_MBUF_HEADER_COUNT,
40         0,
41         "IXP425 IPSec driver Mbuf Header Pool");
42 }
43
44
45 /* Get mbuf from mbuf header pool */
46 int ipsec_glue_mbuf_header_get (IX_MBUF **pMbufPtr)
47 {
48     if ((IX_MBUF_POOL_GET(pIpsecMbufHdrPool, pMbufPtr)) == IX_SUCCESS)
49     {
50         IX_MBUF_MDATA (*pMbufPtr) = NULL;
51         IX_MBUF_NEXT_PKT_IN_CHAIN_PTR (*pMbufPtr) = NULL;
52         return 0;
53     }
54     else
55         return 1;
56 }
57
58
59 /* Release mbuf back into mbuf header pool */
60 void ipsec_glue_mbuf_header_rel (IX_MBUF *pMbuf)
61 {
62     IX_MBUF_POOL_PUT (pMbuf);
63 }
64
65
66 /* Initialize mbuf pool */
67 void ipsec_glue_mbuf_init (void)
68 {
69
70     /* initialize mbuf pool */
71     IX_MBUF_POOL_INIT(
72         &pIpsecMbufPool,
73             IPSEC_GLUE_MBUF_COUNT,
74         IPSEC_GLUE_MBUF_DATA_SIZE,
75         "IXP425 IPSec driver Mbuf Pool");
76 }
77
78
79 /* Get mbuf from mbuf pool */
80 int ipsec_glue_mbuf_get (IX_MBUF **pMbufPtr)
81 {
82     if ((IX_MBUF_POOL_GET(pIpsecMbufPool, pMbufPtr)) == IX_SUCCESS)
83         return 0;
84     else
85         return 1;
86 }
87
88
89 /* Release mbuf back into mbuf pool */
90 void ipsec_glue_mbuf_rel (IX_MBUF *pMbuf)
91 {
92     IX_MBUF_POOL_PUT (pMbuf);
93 }