@ -1,5 +1,6 @@
/* Multi pattern matcher */
# include "suricata.h"
# include "suricata-common.h"
# include "decode.h"
@ -19,6 +20,8 @@
# include "detect-uricontent.h"
# include "util-mpm-b2g-cuda.h"
# include "tmqh-simple.h"
# include "util-enum.h"
# include "util-debug.h"
@ -88,18 +91,31 @@ uint32_t PacketPatternScan(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
p - > payload_len ) ;
SCReturnInt ( ret ) ;
# else
p - > cuda_done = 0 ;
/* if the user has enabled cuda support, but is not using the cuda mpm
* algo , then we shouldn ' t take the path of the dispatcher . Call the mpm
* directly */
if ( det_ctx - > sgh - > mpm_ctx - > mpm_type ! = MPM_B2G_CUDA ) {
uint32_t ret ;
ret = mpm_table [ det_ctx - > sgh - > mpm_ctx - > mpm_type ] . Scan ( det_ctx - > sgh - > mpm_ctx ,
& det_ctx - > mtc ,
& det_ctx - > pmq ,
p - > payload ,
p - > payload_len ) ;
SCReturnInt ( ret ) ;
}
p - > cuda_search = 0 ;
p - > cuda_free_packet = 0 ;
p - > cuda_mpm_ctx = det_ctx - > sgh - > mpm_ctx ;
p - > cuda_mtc = & det_ctx - > mtc ;
p - > cuda_pmq = & det_ctx - > pmq ;
/* this outq is unique to this detection thread instance. The dispatcher thread
* would use this queue to pump the packets back to this detection thread once
* it has processed the packet */
p - > cuda_outq = & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ;
B2gCudaPushPacketTo_tv_CMB2_RC ( p ) ;
SCMutexLock ( & p - > cuda_scan_mutex_q ) ;
SCondWait ( & p - > cuda_scan_cond_q , & p - > cuda_scan_mutex_q ) ;
p - > cuda_done = 1 ;
SCMutexUnlock ( & p - > cuda_scan_mutex_q ) ;
SCReturnInt ( p - > cuda_matches ) ;
/* wait on the detection thread instance */
Packet * out_p = TmqhInputSimpleOnQ ( & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ) ;
SCReturnInt ( out_p - > cuda_matches ) ;
# endif
}
@ -124,6 +140,16 @@ uint32_t UriPatternScan(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
uri , uri_len ) ;
SCReturnInt ( ret ) ;
# else
/* if the user has enabled cuda support, but is not using the cuda mpm
* algo , then we shouldn ' t take the path of the dispatcher . Call the mpm
* directly */
if ( det_ctx - > sgh - > mpm_uri_ctx - > mpm_type ! = MPM_B2G_CUDA ) {
ret = mpm_table [ det_ctx - > sgh - > mpm_uri_ctx - > mpm_type ] . Scan
( det_ctx - > sgh - > mpm_uri_ctx , & det_ctx - > mtcu , & det_ctx - > pmq ,
uri , uri_len ) ;
SCReturnInt ( ret ) ;
}
Packet * p = malloc ( sizeof ( Packet ) ) ;
if ( p = = NULL ) {
SCLogError ( SC_ERR_MEM_ALLOC , " Error allocating memory " ) ;
@ -131,23 +157,19 @@ uint32_t UriPatternScan(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
}
memset ( p , 0 , sizeof ( Packet ) ) ;
SCMutexInit ( & p - > cuda_scan_mutex_q , NULL ) ;
SCCondInit ( & p - > cuda_scan_cond_q , NULL ) ;
//p->cuda_done = 0;
p - > cuda_free_packet = 1 ;
//p->cuda_search = 0;
p - > cuda_mpm_ctx = det_ctx - > sgh - > mpm_uri_ctx ;
p - > cuda_mtc = & det_ctx - > mtcu ;
p - > cuda_pmq = & det_ctx - > pmq ;
p - > payload = uri ;
p - > payload_len = uri_len ;
/* this outq is unique to this detection thread instance. The dispatcher thread
* would use this queue to pump the packets back to this detection thread once
* it has processed the packet */
p - > cuda_outq = & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ;
B2gCudaPushPacketTo_tv_CMB2_RC ( p ) ;
SCMutexLock ( & p - > cuda_scan_mutex_q ) ;
SCondWait ( & p - > cuda_scan_cond_q , & p - > cuda_scan_mutex_q ) ;
SCMutexUnlock ( & p - > cuda_scan_mutex_q ) ;
ret = p - > cuda_matches ;
p - > cuda_done = 1 ;
Packet * out_p = TmqhInputSimpleOnQ ( & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ) ;
ret = out_p - > cuda_matches ;
free ( p ) ;
SCReturnInt ( ret ) ;
# endif
}
@ -173,17 +195,30 @@ uint32_t PacketPatternMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
p - > payload_len ) ;
SCReturnInt ( ret ) ;
# else
/* if the user has enabled cuda support, but is not using the cuda mpm
* algo , then we shouldn ' t take the path of the dispatcher . Call the mpm
* directly */
if ( det_ctx - > sgh - > mpm_ctx - > mpm_type ! = MPM_B2G_CUDA ) {
uint32_t ret ;
ret = mpm_table [ det_ctx - > sgh - > mpm_ctx - > mpm_type ] . Search ( det_ctx - > sgh - > mpm_ctx ,
& det_ctx - > mtc ,
& det_ctx - > pmq ,
p - > payload ,
p - > payload_len ) ;
SCReturnInt ( ret ) ;
}
p - > cuda_search = 1 ;
p - > cuda_free_packet = 0 ;
p - > cuda_mpm_ctx = det_ctx - > sgh - > mpm_ctx ;
p - > cuda_mtc = & det_ctx - > mtc ;
p - > cuda_pmq = & det_ctx - > pmq ;
SCMutexLock ( & p - > cuda_search_mutex_q ) ;
/* this outq is unique to this detection thread instance. The dispatcher thread
* would use this queue to pump the packets back to this detection thread once
* it has processed the packet */
p - > cuda_outq = & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ;
B2gCudaPushPacketTo_tv_CMB2_RC ( p ) ;
SCondWait ( & p - > cuda_search_cond_q , & p - > cuda_search_mutex_q ) ;
p - > cuda_done = 1 ;
SCMutexUnlock ( & p - > cuda_search_mutex_q ) ;
SCReturnInt ( p - > cuda_matches ) ;
Packet * out_p = TmqhInputSimpleOnQ ( & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ) ;
SCReturnInt ( out_p - > cuda_matches ) ;
# endif
}
@ -206,6 +241,16 @@ uint32_t UriPatternMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
uri_len ) ;
SCReturnInt ( ret ) ;
# else
/* if the user has enabled cuda support, but is not using the cuda mpm
* algo , then we shouldn ' t take the path of the dispatcher . Call the mpm
* directly */
if ( det_ctx - > sgh - > mpm_uri_ctx - > mpm_type ! = MPM_B2G_CUDA ) {
ret = mpm_table [ det_ctx - > sgh - > mpm_uri_ctx - > mpm_type ] . Search
( det_ctx - > sgh - > mpm_uri_ctx , & det_ctx - > mtcu , & det_ctx - > pmq , uri ,
uri_len ) ;
SCReturnInt ( ret ) ;
}
Packet * p = malloc ( sizeof ( Packet ) ) ;
if ( p = = NULL ) {
SCLogError ( SC_ERR_MEM_ALLOC , " Error allocating memory " ) ;
@ -213,23 +258,20 @@ uint32_t UriPatternMatch(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
}
memset ( p , 0 , sizeof ( Packet ) ) ;
SCMutexInit ( & p - > cuda_search_mutex_q , NULL ) ;
SCCondInit ( & p - > cuda_search_cond_q , NULL ) ;
//p->cuda_done = 0;
p - > cuda_free_packet = 1 ;
p - > cuda_search = 1 ;
p - > cuda_mpm_ctx = det_ctx - > sgh - > mpm_uri_ctx ;
p - > cuda_mtc = & det_ctx - > mtcu ;
p - > cuda_pmq = & det_ctx - > pmq ;
p - > payload = uri ;
p - > payload_len = uri_len ;
/* this outq is unique to this detection thread instance. The dispatcher thread
* would use this queue to pump the packets back to this detection thread once
* it has processed the packet */
p - > cuda_outq = & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ;
B2gCudaPushPacketTo_tv_CMB2_RC ( p ) ;
SCMutexLock ( & p - > cuda_search_mutex_q ) ;
SCondWait ( & p - > cuda_search_cond_q , & p - > cuda_search_mutex_q ) ;
SCMutexUnlock ( & p - > cuda_search_mutex_q ) ;
ret = p - > cuda_matches ;
p - > cuda_done = 1 ;
Packet * out_p = TmqhInputSimpleOnQ ( & trans_q [ det_ctx - > cuda_mpm_rc_disp_outq - > id ] ) ;
ret = out_p - > cuda_matches ;
free ( p ) ;
SCReturnInt ( ret ) ;
# endif