Пример #1
0
int
ocfbench_init(void)
{
	int i, jstart, jstop;

	printk("Crypto Speed tests\n");

	requests = kmalloc(sizeof(request_t) * request_q_len, GFP_KERNEL);
	if (!requests) {
		printk("malloc failed\n");
		return -EINVAL;
	}

	for (i = 0; i < request_q_len; i++) {
		/* +64 for return data */
		requests[i].buffer = kmalloc(request_size + 128, GFP_DMA);
		if (!requests[i].buffer) {
			printk("malloc failed\n");
			return -EINVAL;
		}
		memset(requests[i].buffer, '0' + i, request_size + 128);
	}

	/*
	 * OCF benchmark
	 */
	printk("OCF: testing ...\n");
	ocf_init();
	total = outstanding = 0;
	jstart = jiffies;
	for (i = 0; i < request_q_len; i++) {
		outstanding++;
		ocf_request(&requests[i]);
	}
	while (outstanding > 0)
		schedule();
	jstop = jiffies;

	printk("OCF: %d requests of %d bytes in %d jiffies\n", total, request_size,
			jstop - jstart);

#ifdef BENCH_IXP_ACCESS_LIB
	/*
	 * IXP benchmark
	 */
	printk("IXP: testing ...\n");
	ixp_init();
	total = outstanding = 0;
	jstart = jiffies;
	for (i = 0; i < request_q_len; i++) {
		outstanding++;
		ixp_request(&requests[i]);
	}
	while (outstanding > 0)
		schedule();
	jstop = jiffies;

	printk("IXP: %d requests of %d bytes in %d jiffies\n", total, request_size,
			jstop - jstart);
#endif /* BENCH_IXP_ACCESS_LIB */

	for (i = 0; i < request_q_len; i++)
		kfree(requests[i].buffer);
	kfree(requests);
	return -EINVAL; /* always fail to load so it can be re-run quickly ;-) */
}
Пример #2
0
int
ocfbench_init(void)
{
	int i,j, jstart, jstop;

	printk("Crypto Speed tests\n");

	requests = kmalloc(sizeof(request_t) * request_q_len, GFP_KERNEL);
	if (!requests) {
		printk("malloc failed\n");
		return -EINVAL;
	}

	if(request_size %8 != 0) {
		printk("request_size must be a multiple of 8!!! \n");
	}
	
	for (i = 0; i < request_q_len; i++) {
		/* +64 for return data */
		requests[i].buffer = kmalloc(request_size + 128, GFP_DMA);
		if (!requests[i].buffer) {
			printk("malloc failed\n");
			return -EINVAL;
		}
#ifdef DECC
		requests[i].encrypt = 1;
		requests[i].index = i;
#endif
	for(j=0; j < request_size + 128; j++)
		*(char *)(((char *)requests[i].buffer) + j ) = 0x2;

	}

#ifdef DECC
	requests2 = kmalloc(sizeof(request_t) * request_q_len, GFP_KERNEL);
	if (!requests) {
		printk("malloc failed\n");
		return -EINVAL;
	}

	for (i = 0; i < request_q_len; i++) {
		/* +64 for return data */
		requests2[i].buffer = kmalloc(request_size + 128, GFP_DMA);
		if (!requests2[i].buffer) {
			printk("malloc failed\n");
			return -EINVAL;
		}
		memcpy(requests2[i].buffer, requests[i].buffer, request_size);
	}
#endif
	/*
	 * OCF benchmark
	 */
	printk("OCF: testing ...\n");
	ocf_init();
	total = outstanding = 0;
	jstart = jiffies;
	for (i = 0; i < request_q_len; i++) {
		outstanding++;
		ocf_request(&requests[i]);
	}

	while (outstanding > 0) {
#if 0
		if(jiffies - jstart > 500){
			return -EINVAL;	
		}
#endif
		schedule();
	}
	jstop = jiffies;

	printk("OCF: %d requests of %d bytes in %d jiffies\n", total, request_size,
			jstop - jstart);

#ifdef DECC
	for (i = 0; i < request_q_len; i++) {
		if(memcmp(requests2[i].buffer, requests[i].buffer, request_size) != 0){
			printk("buf %d is differnt \n",i);
			printk("ORIGINAL: \n");
			hexdump(requests2[i].buffer, request_size);
			printk("AFTER \n");
			hexdump(requests[i].buffer, request_size);
			break;
		}
	}
	
#ifdef BOTH
	for (i = 0; i < request_q_len; i++) {
		if(memcmp(requests[i].buffer + request_size + 32, requests[i].buffer + request_size + 64, 16) != 0){
			printk("buf %d is differnt \n",i);
			printk("ORIGINAL: \n");
			hexdump(requests[i].buffer + request_size + 32, 16);
			printk("AFTER \n");
			hexdump(requests[i].buffer + request_size + 64, 16);
			break;
		}
	}
#endif
#endif

	for (i = 0; i < request_q_len; i++)
		kfree(requests[i].buffer);
	kfree(requests);

#ifdef DECC
	for (i = 0; i < request_q_len; i++)
		kfree(requests2[i].buffer);
	kfree(requests2);
#endif
	crypto_freesession(ocf_cryptoid);

	return -EINVAL; /* always fail to load so it can be re-run quickly ;-) */
}
Пример #3
0
static void
ocf_request_wq(struct work_struct *work)
{
	request_t *r = container_of(work, request_t, work);
	ocf_request(r);
}
Пример #4
0
int
ocfbench_init(void)
{
	int i;
	unsigned long mbps;
	unsigned long flags;

	printk("Crypto Speed tests\n");

	requests = kmalloc(sizeof(request_t) * request_q_len, GFP_KERNEL);
	if (!requests) {
		printk("malloc failed\n");
		return -EINVAL;
	}

	for (i = 0; i < request_q_len; i++) {
		/* +64 for return data */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
		INIT_WORK(&requests[i].work, ocf_request_wq);
#else
		INIT_WORK(&requests[i].work, ocf_request, &requests[i]);
#endif
		requests[i].buffer = kmalloc(request_size + 128, GFP_DMA);
		if (!requests[i].buffer) {
			printk("malloc failed\n");
			return -EINVAL;
		}
		memset(requests[i].buffer, '0' + i, request_size + 128);
	}

	/*
	 * OCF benchmark
	 */
	printk("OCF: testing ...\n");
	if (ocf_init() == -1)
		return -EINVAL;

	spin_lock_init(&ocfbench_counter_lock);
	total = outstanding = 0;
	jstart = jiffies;
	for (i = 0; i < request_q_len; i++) {
		spin_lock_irqsave(&ocfbench_counter_lock, flags);
		outstanding++;
		spin_unlock_irqrestore(&ocfbench_counter_lock, flags);
		ocf_request(&requests[i]);
	}
	while (outstanding > 0)
		schedule();
	jstop = jiffies;

	mbps = 0;
	if (jstop > jstart) {
		mbps = (unsigned long) total * (unsigned long) request_size * 8;
		mbps /= ((jstop - jstart) * 1000) / HZ;
	}
	printk("OCF: %d requests of %d bytes in %d jiffies (%d.%03d Mbps)\n",
			total, request_size, (int)(jstop - jstart),
			((int)mbps) / 1000, ((int)mbps) % 1000);
	ocf_done();

#ifdef BENCH_IXP_ACCESS_LIB
	/*
	 * IXP benchmark
	 */
	printk("IXP: testing ...\n");
	ixp_init();
	total = outstanding = 0;
	jstart = jiffies;
	for (i = 0; i < request_q_len; i++) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
		INIT_WORK(&requests[i].work, ixp_request_wq);
#else
		INIT_WORK(&requests[i].work, ixp_request, &requests[i]);
#endif
		spin_lock_irqsave(&ocfbench_counter_lock, flags);
		outstanding++;
		spin_unlock_irqrestore(&ocfbench_counter_lock, flags);
		ixp_request(&requests[i]);
	}
	while (outstanding > 0)
		schedule();
	jstop = jiffies;

	mbps = 0;
	if (jstop > jstart) {
		mbps = (unsigned long) total * (unsigned long) request_size * 8;
		mbps /= ((jstop - jstart) * 1000) / HZ;
	}
	printk("IXP: %d requests of %d bytes in %d jiffies (%d.%03d Mbps)\n",
			total, request_size, jstop - jstart,
			((int)mbps) / 1000, ((int)mbps) % 1000);
	ixp_done();
#endif /* BENCH_IXP_ACCESS_LIB */

	for (i = 0; i < request_q_len; i++)
		kfree(requests[i].buffer);
	kfree(requests);
	return -EINVAL; /* always fail to load so it can be re-run quickly ;-) */
}