static void ixp_request_wq(struct work_struct *work) { request_t *r = container_of(work, request_t, work); ixp_request(r); }
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 ;-) */ }
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 ;-) */ }