RE: [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
From: Peter Chen
Date: Thu Sep 29 2016 - 05:49:28 EST
>
>This patch adds support to configure data verification through module parameter.
>This parameter can be used to disable data verification in case if one wants to
>measure peak Bulk/Isoc-IN/OUT performance
>
Would configfs parameter 'pattern' can't satisfy you?
Peter
>Signed-off-by: Manish Narani <mnarani@xxxxxxxxxx>
>---
> drivers/usb/gadget/function/f_sourcesink.c | 6 ++++--
> drivers/usb/gadget/function/g_zero.h | 3 +++
> drivers/usb/gadget/legacy/zero.c | 5 +++++
> 3 files changed, 12 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/usb/gadget/function/f_sourcesink.c
>b/drivers/usb/gadget/function/f_sourcesink.c
>index 81274ba..2328d11 100644
>--- a/drivers/usb/gadget/function/f_sourcesink.c
>+++ b/drivers/usb/gadget/function/f_sourcesink.c
>@@ -45,6 +45,7 @@ struct f_sourcesink {
> int cur_alt;
>
> unsigned pattern;
>+ unsigned verify_rx_data;
> unsigned isoc_interval;
> unsigned isoc_maxpacket;
> unsigned isoc_mult;
>@@ -552,7 +553,7 @@ static void source_sink_complete(struct usb_ep *ep, struct
>usb_request *req)
> switch (status) {
>
> case 0: /* normal completion? */
>- if (ep == ss->out_ep) {
>+ if (ss->verify_rx_data && (ep == ss->out_ep)) {
> check_read_data(ss, req);
> if (ss->pattern != 2)
> memset(req->buf, 0x55, req->length); @@ -630,7
>+631,7 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
> req->complete = source_sink_complete;
> if (is_in)
> reinit_write_data(ep, req);
>- else if (ss->pattern != 2)
>+ else if (ss->verify_rx_data && (ss->pattern != 2))
> memset(req->buf, 0x55, req->length);
>
> status = usb_ep_queue(ep, req, GFP_ATOMIC); @@ -866,6 +867,7
>@@ static struct usb_function *source_sink_alloc_func(
> mutex_unlock(&ss_opts->lock);
>
> ss->pattern = ss_opts->pattern;
>+ ss->verify_rx_data = ss_opts->verify_rx_data;
> ss->isoc_interval = ss_opts->isoc_interval;
> ss->isoc_maxpacket = ss_opts->isoc_maxpacket;
> ss->isoc_mult = ss_opts->isoc_mult;
>diff --git a/drivers/usb/gadget/function/g_zero.h
>b/drivers/usb/gadget/function/g_zero.h
>index b3234e7..8e5d20c 100644
>--- a/drivers/usb/gadget/function/g_zero.h
>+++ b/drivers/usb/gadget/function/g_zero.h
>@@ -6,6 +6,7 @@
> #ifndef __G_ZERO_H
> #define __G_ZERO_H
>
>+#define GZERO_VERIFY_RX_DATA 1
> #define GZERO_BULK_BUFLEN 4096
> #define GZERO_QLEN 32
> #define GZERO_ISOC_INTERVAL 4
>@@ -15,6 +16,7 @@
>
> struct usb_zero_options {
> unsigned pattern;
>+ unsigned verify_rx_data;
> unsigned isoc_interval;
> unsigned isoc_maxpacket;
> unsigned isoc_mult;
>@@ -29,6 +31,7 @@ struct usb_zero_options { struct f_ss_opts {
> struct usb_function_instance func_inst;
> unsigned pattern;
>+ unsigned verify_rx_data;
> unsigned isoc_interval;
> unsigned isoc_maxpacket;
> unsigned isoc_mult;
>diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
>index c88f5e0..0087ef8 100644
>--- a/drivers/usb/gadget/legacy/zero.c
>+++ b/drivers/usb/gadget/legacy/zero.c
>@@ -64,6 +64,7 @@ static bool loopdefault = 0; module_param(loopdefault, bool,
>S_IRUGO|S_IWUSR);
>
> static struct usb_zero_options gzero_options = {
>+ .verify_rx_data = GZERO_VERIFY_RX_DATA,
> .isoc_interval = GZERO_ISOC_INTERVAL,
> .isoc_maxpacket = GZERO_ISOC_MAXPACKET,
> .bulk_buflen = GZERO_BULK_BUFLEN,
>@@ -236,6 +237,9 @@ module_param_named(buflen, gzero_options.bulk_buflen,
>uint, 0); module_param_named(pattern, gzero_options.pattern, uint,
>S_IRUGO|S_IWUSR); MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 =
>mod63, 2 = none");
>
>+module_param_named(verify, gzero_options.verify_rx_data, uint,
>+S_IRUGO|S_IWUSR); MODULE_PARM_DESC(verify, "Verification of received
>+data : 0 = No, 1 = Yes");
>+
> module_param_named(isoc_interval, gzero_options.isoc_interval, uint,
> S_IRUGO|S_IWUSR);
> MODULE_PARM_DESC(isoc_interval, "1 - 16"); @@ -294,6 +298,7 @@ static int
>zero_bind(struct usb_composite_dev *cdev)
>
> ss_opts = container_of(func_inst_ss, struct f_ss_opts, func_inst);
> ss_opts->pattern = gzero_options.pattern;
>+ ss_opts->verify_rx_data = gzero_options.verify_rx_data;
> ss_opts->isoc_interval = gzero_options.isoc_interval;
> ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket;
> ss_opts->isoc_mult = gzero_options.isoc_mult;
>--
>2.1.1