add --list-cuda-cards option to list the cuda cards on the system. Add conf parameter to select the cuda device to use. Also change the threshhold limit to 2.4k packets to buffer

remotes/origin/master-1.0.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent 89e3d92cdb
commit 07491f8887

@ -79,7 +79,7 @@ static int run_batcher = 1;
* on the traffic * on the traffic
* \todo make this user configurable, as well allow dynamic update of this * \todo make this user configurable, as well allow dynamic update of this
* variable based on the traffic seen */ * variable based on the traffic seen */
static uint32_t buffer_packet_threshhold = 1280; static uint32_t buffer_packet_threshhold = 2400;
/* flag used by the SIG_ALRM handler to indicate that the batcher TM should queue /* flag used by the SIG_ALRM handler to indicate that the batcher TM should queue
* the buffer to be processed by the Cuda Mpm B2g Batcher Thread for further * the buffer to be processed by the Cuda Mpm B2g Batcher Thread for further
@ -546,6 +546,19 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
/* the sgh to which the incoming packet belongs */ /* the sgh to which the incoming packet belongs */
SigGroupHead *sgh = NULL; SigGroupHead *sgh = NULL;
if (p->flow != NULL) {
/* Get the stored sgh from the flow (if any). Make sure we're not using
* the sgh for icmp error packets part of the same stream. */
if (p->proto == p->flow->proto) { /* filter out icmp */
if (p->flowflags & FLOW_PKT_TOSERVER && p->flow->flags & FLOW_SGH_TOSERVER) {
sgh = p->flow->sgh_toserver;
} else if (p->flowflags & FLOW_PKT_TOCLIENT && p->flow->flags & FLOW_SGH_TOCLIENT) {
sgh = p->flow->sgh_toclient;
}
}
}
if (sgh == NULL) {
/* get the signature group head to which this packet belongs. If it belongs /* get the signature group head to which this packet belongs. If it belongs
* to no sgh, we don't need to buffer this packet. * to no sgh, we don't need to buffer this packet.
* \todo Get rid of this, once we get the sgh from the flow */ * \todo Get rid of this, once we get the sgh from the flow */
@ -554,6 +567,7 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
SCLogDebug("No SigGroupHead match for this packet"); SCLogDebug("No SigGroupHead match for this packet");
return TM_ECODE_OK; return TM_ECODE_OK;
} }
}
/* if the payload is less than the maximum content length in this sgh we /* if the payload is less than the maximum content length in this sgh we
* don't need to run the PM on this packet. Chuck the packet out */ * don't need to run the PM on this packet. Chuck the packet out */
@ -747,7 +761,7 @@ void SCCudaPBSetUpQueuesAndBuffers(void)
/* \todo This needs to be changed ASAP. This can't exceed max_pending_packets. /* \todo This needs to be changed ASAP. This can't exceed max_pending_packets.
* Also we need to make this user configurable and allow dynamic updaes * Also we need to make this user configurable and allow dynamic updaes
* based on live traffic */ * based on live traffic */
buffer_packet_threshhold = 1280; buffer_packet_threshhold = 2400;
return; return;
} }

@ -355,6 +355,7 @@ int main(int argc, char **argv)
#endif #endif
int dump_config = 0; int dump_config = 0;
int list_unittests = 0; int list_unittests = 0;
int list_cuda_cards = 0;
int daemon = 0; int daemon = 0;
char *user_name = NULL; char *user_name = NULL;
char *group_name = NULL; char *group_name = NULL;
@ -412,6 +413,7 @@ int main(int argc, char **argv)
{"pcap-buffer-size", required_argument, 0, 0}, {"pcap-buffer-size", required_argument, 0, 0},
{"unittest-filter", required_argument, 0, 'U'}, {"unittest-filter", required_argument, 0, 'U'},
{"list-unittests", 0, &list_unittests, 1}, {"list-unittests", 0, &list_unittests, 1},
{"list-cuda-cards", 0, &list_cuda_cards, 1},
#ifdef OS_WIN32 #ifdef OS_WIN32
{"service-install", 0, 0, 0}, {"service-install", 0, 0, 0},
{"service-remove", 0, 0, 0}, {"service-remove", 0, 0, 0},
@ -482,6 +484,12 @@ int main(int argc, char **argv)
#else #else
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n"); fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
#endif /* UNITTESTS */
} else if(strcmp((long_opts[option_index]).name, "list-cuda-cards") == 0) {
#ifndef __SC_CUDA_SUPPORT__
fprintf(stderr, "ERROR: Cuda not enabled. Make sure to pass "
"--enable-cuda to configure when building.\n");
exit(EXIT_FAILURE);
#endif /* UNITTESTS */ #endif /* UNITTESTS */
} }
#ifdef OS_WIN32 #ifdef OS_WIN32
@ -690,6 +698,10 @@ int main(int argc, char **argv)
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__
/* Init the CUDA environment */ /* Init the CUDA environment */
SCCudaInitCudaEnvironment(); SCCudaInitCudaEnvironment();
if (list_cuda_cards) {
SCCudaListCards();
exit(EXIT_SUCCESS);
}
#endif #endif
if (!CheckValidDaemonModes(daemon, run_mode)) { if (!CheckValidDaemonModes(daemon, run_mode)) {

@ -65,6 +65,7 @@
#include "tmqh-simple.h" #include "tmqh-simple.h"
#include "conf.h"
#include "util-error.h" #include "util-error.h"
#include "util-debug.h" #include "util-debug.h"
#include "util-unittest.h" #include "util-unittest.h"
@ -226,9 +227,23 @@ int SCCudaHlGetCudaContext(CUcontext *p_context, int handle)
return 0; return 0;
} }
/* Get default log level and format. */
char *cuda_device_id_str = NULL;
int cuda_device_id = SC_CUDA_DEFAULT_DEVICE;
if (ConfGet("cuda.device_id", &cuda_device_id_str) == 1) {
cuda_device_id = atoi(cuda_device_id_str);
if (!SCCudaIsCudaDeviceIdValid(cuda_device_id)) {
SCLogError(SC_ERR_CUDA_ERROR, "Invalid device id \"%s\" supplied "
"in the conf file", cuda_device_id_str);
cuda_device_id = SC_CUDA_DEFAULT_DEVICE;
}
} else {
cuda_device_id = SC_CUDA_DEFAULT_DEVICE;
}
/* Get the device list for this CUDA platform and create a new cuda context */ /* Get the device list for this CUDA platform and create a new cuda context */
devices = SCCudaGetDeviceList(); devices = SCCudaGetDeviceList();
if (SCCudaCtxCreate(p_context, 0, devices->devices[0]->device) == -1) if (SCCudaCtxCreate(p_context, 0, devices->devices[cuda_device_id]->device) == -1)
goto error; goto error;
data->cuda_context = p_context[0]; data->cuda_context = p_context[0];

@ -4069,6 +4069,56 @@ int SCCudaInitCudaEnvironment(void)
return -1; return -1;
} }
/**********************************Cuda_Utility********************************/
/**
* \brief List the cuda cards on the system.
*
*/
void SCCudaListCards(void)
{
int i = 0;
if (devices == NULL) {
SCLogWarning(SC_ERR_CUDA_ERROR, "CUDA engine not initalized! Please "
"initialize the cuda environment using "
"SCCudaInitCudaEnvironment().");
return;
}
printf("CUDA Cards recognized by the suricata CUDA module - \n");
printf("|-----------------------------------------------------------------------------|\n");
printf("| %-10s | %-20s | %-10s | %-10s | %-13s |\n",
"Device Id", " Device Name", " Multi-", "Clock Rate", "Cuda Compute");
printf("| %-10s | %-20s | %-10s | %-10s | %-13s |\n",
"", "", "Processors", " (MHz)", "Capability");
printf("|-----------------------------------------------------------------------------|\n");
for (i = 0; i < devices->count; i++) {
printf("| %-10d | %-20s | %-10d | %-10d | %d.%-11d |\n",
i,
devices->devices[i]->name,
devices->devices[i]->attr_multiprocessor_count,
devices->devices[i]->attr_clock_rate/1000,
devices->devices[i]->major_rev,
devices->devices[i]->minor_rev);
}
printf("|-----------------------------------------------------------------------------|\n");
return;
}
int SCCudaIsCudaDeviceIdValid(int cuda_device_id)
{
if (devices == NULL) {
SCLogWarning(SC_ERR_CUDA_ERROR, "CUDA engine not initalized! Please "
"initialize the cuda environment using "
"SCCudaInitCudaEnvironment().");
return 0;
}
return (cuda_device_id < devices->count);
}
/**********************************Unittests***********************************/ /**********************************Unittests***********************************/
int SCCudaTest01(void) int SCCudaTest01(void)

@ -28,6 +28,7 @@
#include <cuda.h> #include <cuda.h>
#define SC_CUDA_DEFAULT_DEVICE 0
#define SC_CUDA_DEVICE_NAME_MAX_LEN 128 #define SC_CUDA_DEVICE_NAME_MAX_LEN 128
typedef struct SCCudaDevice_ { typedef struct SCCudaDevice_ {
@ -176,6 +177,9 @@ SCCudaDevices *SCCudaGetDeviceList(void);
int SCCudaInitCudaEnvironment(void); int SCCudaInitCudaEnvironment(void);
void SCCudaListCards(void);
int SCCudaIsCudaDeviceIdValid(int);
void SCCudaRegisterTests(void); void SCCudaRegisterTests(void);
#endif /* __SC_CUDA_SUPPORT__ */ #endif /* __SC_CUDA_SUPPORT__ */

@ -120,6 +120,12 @@ threading:
# #
detect_thread_ratio: 1.5 detect_thread_ratio: 1.5
# Select the cuda device to use. The device_id identifies the device to be used
# if one has multiple devices on the system. To find out device_id associated
# with the card(s) on the system run "suricata --list_cuda_cards".
cuda:
device_id: 0
# Select the multi pattern algorithm you want to run for scan/search the # Select the multi pattern algorithm you want to run for scan/search the
# in the engine. The supported algorithms are b2g, b3g and wumanber. # in the engine. The supported algorithms are b2g, b3g and wumanber.
# #

Loading…
Cancel
Save