suricata
source-mpipe.h
Go to the documentation of this file.
1 /* Copyright (C) 2011-2013 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Tom DeCanio <decanio.tom@gmail.com>
22  * \author Ken Steele, Tilera Corporation <suricata@tilera.com>
23  */
24 
25 #ifndef __SOURCE_MPIPE_H__
26 #define __SOURCE_MPIPE_H__
27 
28 #ifdef HAVE_MPIPE
29 
30 #include <gxio/mpipe.h>
31 #include <tmc/cpus.h>
32 
33 #define MPIPE_FREE_PACKET(p) MpipeFreePacket((p))
34 
35 #define MPIPE_COPY_MODE_NONE 0
36 #define MPIPE_COPY_MODE_TAP 1
37 #define MPIPE_COPY_MODE_IPS 2
38 
39 #define MPIPE_IFACE_NAME_LENGTH 8
40 
41 typedef struct MpipeIfaceConfig_
42 {
43  char iface[MPIPE_IFACE_NAME_LENGTH];
44  int copy_mode;
45  char *out_iface;
46 } MpipeIfaceConfig;
47 
48 typedef struct MpipePeer_
49 {
50  int channel;
51  char iface[MPIPE_IFACE_NAME_LENGTH];
52 } MpipePeer;
53 
54 /* per interface TAP/IPS configuration */
55 typedef struct MpipePeerVars_
56 {
57  gxio_mpipe_equeue_t *peer_equeue;
58  void (*ReleasePacket)(struct Packet_ *);
59  int copy_mode;
60 } MpipePeerVars;
61 
62 /* per packet Mpipe vars */
63 typedef struct MpipePacketVars_
64 {
65  /* TileGX mpipe stuff */
66  struct {
67  uint_reg_t channel : 5;
68  uint_reg_t l2_size : 14;
69  uint_reg_t size : 3;
70  uint_reg_t bucket_id : 13;
71  uint_reg_t nr : 1;
72  uint_reg_t cs : 1;
73  uint_reg_t va : 42;
74  uint_reg_t stack_idx : 5;
75  } idesc;
76 
77  /* packetpool this was allocated from */
78  uint8_t rank;
79 
80  gxio_mpipe_equeue_t *peer_equeue;
81 } MpipePacketVars;
82 
83 int MpipeLiveRegisterDevice(char *);
84 int MpipeLiveGetDeviceCount(void);
85 char *MpipeLiveGetDevice(int);
86 void MpipeFreePacket(void *arg);
87 void TmModuleReceiveMpipeRegister (void);
88 void TmModuleDecodeMpipeRegister (void);
89 
90 TmEcode ReceiveMpipeInit(void);
91 
92 #endif /* HAVE_MPIPE */
93 #endif /* __SOURCE_MPIPE_H__ */