All of lore.kernel.org
 help / color / mirror / Atom feed
* [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero
@ 2016-09-29  8:48 Manish Narani
  2016-09-29  9:16 ` Peter Chen
  2016-09-29 11:25 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Manish Narani @ 2016-09-29  8:48 UTC (permalink / raw)
  To: balbi, gregkh, k.opasiak, r.baldyga, peter.chen, mnarani,
	John.Youn, eu, i.kotrasinsk, linux-usb, linux-kernel
  Cc: anuragku, punnaia

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

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-30 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29  8:48 [LINUX PATCH] usb: gadget: Configure data verification through module parameter in gadget zero Manish Narani
2016-09-29  9:16 ` Peter Chen
2016-09-29 11:25 ` Greg KH
2016-09-30 11:13   ` Manish Narani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.