netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/2] cdc_ncm refactoring
@ 2015-06-02  9:08 Enrico Mioso
       [not found] ` <1433236115-5594-1-git-send-email-mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Enrico Mioso @ 2015-06-02  9:08 UTC (permalink / raw)
  To: youtux-Re5JQEeQqe8AvxtiuMwx3w, Greg KH,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Enrico Mioso

I changed my mind, and decided to try in following this new way.
This series splits the cdc_ncm_ndp function in two parts:
- one that finds NDP blocks already present in the SKB being sent out
- one that pushes new ones, starting from where the _find function left.

After this splitting it seems more easy to modify the location where the NDP is 
disposed.
What do you think about this?

>From now on, I need a little bit of help: I think we might work on the 
cdc_ncm_ndp16_push function, still I am open to any suggestion.

Let me know if you like this.
Enrico

Enrico Mioso (2):
  cdc_ncm: add the currently processed NDP frame to global driver data
  cdc_ncm: split the cdc_ncm_ndp funciton

 drivers/net/usb/cdc_ncm.c   | 30 +++++++++++++++++++++---------
 include/linux/usb/cdc_ncm.h |  1 +
 2 files changed, 22 insertions(+), 9 deletions(-)

-- 
2.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH RFC 1/2] cdc_ncm: add the currently processed NDP frame to global driver data
       [not found] ` <1433236115-5594-1-git-send-email-mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-06-02  9:08   ` Enrico Mioso
  2015-06-02  9:08   ` [PATCH RFC 2/2] cdc_ncm: split the cdc_ncm_ndp funciton Enrico Mioso
  1 sibling, 0 replies; 3+ messages in thread
From: Enrico Mioso @ 2015-06-02  9:08 UTC (permalink / raw)
  To: youtux-Re5JQEeQqe8AvxtiuMwx3w, Greg KH,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Enrico Mioso

This is useful to split up the cdc_ncm_ndp function later on.
The resulting code will be anyway stateful.

Signed-Off-By: Enrico Mioso <mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 include/linux/usb/cdc_ncm.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 7c9b484..9172256 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -100,6 +100,7 @@ struct cdc_ncm_ctx {
 	struct sk_buff *tx_curr_skb;
 	struct sk_buff *tx_rem_skb;
 	__le32 tx_rem_sign;
+	struct usb_cdc_ncm_ndp16 *tx_curr_ndp16;
 
 	spinlock_t mtx;
 	atomic_t stop;
-- 
2.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH RFC 2/2] cdc_ncm: split the cdc_ncm_ndp funciton
       [not found] ` <1433236115-5594-1-git-send-email-mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2015-06-02  9:08   ` [PATCH RFC 1/2] cdc_ncm: add the currently processed NDP frame to global driver data Enrico Mioso
@ 2015-06-02  9:08   ` Enrico Mioso
  1 sibling, 0 replies; 3+ messages in thread
From: Enrico Mioso @ 2015-06-02  9:08 UTC (permalink / raw)
  To: youtux-Re5JQEeQqe8AvxtiuMwx3w, Greg KH,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Enrico Mioso

Split this function in two new ones:
- cdc_ncm_ndp16_find: finds an NDP block in the chain mathcing a supplied
  signature; a pointer to it is returned in case of success;
- cdc_ncm_ndp16_push: create and add to skb a new NDP block;

cdc_ncm_ndp16_push refers to the last NDP visited by cdc_ncm_ndp16_find, hence
this code is stateful.

Signed-Off-By: Enrico Mioso <mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/net/usb/cdc_ncm.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 8067b8f..3c837d6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -980,7 +980,7 @@ static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remai
 /* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly
  * allocating a new one within skb
  */
-static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign, size_t reserve)
+static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp16_find(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign)
 {
 	struct usb_cdc_ncm_ndp16 *ndp16 = NULL;
 	struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
@@ -988,12 +988,20 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_
 
 	/* follow the chain of NDPs, looking for a match */
 	while (ndpoffset) {
-		ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset);
-		if  (ndp16->dwSignature == sign)
-			return ndp16;
+		ctx->tx_curr_ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset);
+		if (ctx->tx_curr_ndp16->dwSignature == sign)
+			ndp16 = ctx->tx_curr_ndp16;
 		ndpoffset = le16_to_cpu(ndp16->wNextNdpIndex);
 	}
+  
+  return ndp16;
+}
 
+static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp16_push(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign, size_t reserve)
+{
+	struct usb_cdc_ncm_ndp16 *ndp16 = ctx->tx_curr_ndp16;
+	struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
+  
 	/* align new NDP */
 	cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
 
@@ -1070,11 +1078,15 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
 				break;
 		}
 
-		/* get the appropriate NDP for this skb */
-		ndp16 = cdc_ncm_ndp(ctx, skb_out, sign, skb->len + ctx->tx_modulus + ctx->tx_remainder);

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

end of thread, other threads:[~2015-06-02  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02  9:08 [PATCH RFC 0/2] cdc_ncm refactoring Enrico Mioso
     [not found] ` <1433236115-5594-1-git-send-email-mrkiko.rs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-02  9:08   ` [PATCH RFC 1/2] cdc_ncm: add the currently processed NDP frame to global driver data Enrico Mioso
2015-06-02  9:08   ` [PATCH RFC 2/2] cdc_ncm: split the cdc_ncm_ndp funciton Enrico Mioso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).