From: Enrico Mioso <mrkiko.rs@gmail.com>
To: netdev@vger.kernel.org
Cc: Enrico Mioso <mrkiko.rs@gmail.com>
Subject: [RFC PATCH 6/6] cdc_ncm: factor out NDP preparation and frame linking
Date: Mon, 29 Dec 2014 11:09:48 +0100 [thread overview]
Message-ID: <1419847788-25610-7-git-send-email-mrkiko.rs@gmail.com> (raw)
In-Reply-To: <1419847788-25610-1-git-send-email-mrkiko.rs@gmail.com>
To some extent, factor out NDP preparation and frame linking.
This is the change I like less - but I plan to revisit this once (in case) we
change the way the entire cdc_ncm_fill_tx_frame works.
Signed-Off-By: Enrico Mioso <mrkiko.rs@gmail.com>
---
drivers/net/usb/cdc_ncm.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index babfaee..b21aab8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1044,6 +1044,20 @@ cdc_ncm_finalize_nth16(struct usb_cdc_ncm_nth16 *nth16, struct sk_buff *skb)
return nth16;
}
+u16
+cdc_ncm_calculate_ndp16(struct usb_cdc_ncm_ndp16 *ndp16, struct sk_buff *skb, struct sk_buff *next_skb) {
+ u16 ndplen, index;
+
+ ndplen = le16_to_cpu(ndp16->wLength);
+ index = (ndplen - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16) - 1;
+
+ /* OK, add this skb */
+ ndp16->dpe16[index].wDatagramLength = cpu_to_le16(skb->len);
+ ndp16->dpe16[index].wDatagramIndex = cpu_to_le16(next_skb->len);
+ ndp16->wLength = cpu_to_le16(ndplen + sizeof(struct usb_cdc_ncm_dpe16));
+ return index;
+}
+
struct sk_buff *
cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
{
@@ -1051,7 +1065,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
struct usb_cdc_ncm_nth16 *nth16;
struct usb_cdc_ncm_ndp16 *ndp16;
struct sk_buff *skb_out;
- u16 n = 0, index, ndplen;
+ u16 n = 0, index;
u8 ready2send = 0;
/* if there is a remaining skb, it gets priority */
@@ -1124,13 +1138,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
}
/* calculate frame number within this NDP */
- ndplen = le16_to_cpu(ndp16->wLength);
- index = (ndplen - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16) - 1;
-
- /* OK, add this skb */
- ndp16->dpe16[index].wDatagramLength = cpu_to_le16(skb->len);
- ndp16->dpe16[index].wDatagramIndex = cpu_to_le16(skb_out->len);
- ndp16->wLength = cpu_to_le16(ndplen + sizeof(struct usb_cdc_ncm_dpe16));
+ index = cdc_ncm_calculate_ndp16(ndp16, skb, skb_out);
memcpy(skb_put(skb_out, skb->len), skb->data, skb->len);
ctx->tx_curr_frame_payload += skb->len; /* count real tx payload data */
dev_kfree_skb_any(skb);
--
2.2.1
prev parent reply other threads:[~2014-12-29 10:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-29 10:09 [RFC PATCH 0/6] cdc_ncm: some basic refactoring Enrico Mioso
2014-12-29 10:09 ` [RFC PATCH 1/6] cdc_ncm: factor out skb allocation and finalizzing Enrico Mioso
2014-12-29 10:09 ` [RFC PATCH 2/6] cdc_ncm: be more precise in comments for cdc_ncm_prepare_skb_ncm16 Enrico Mioso
2014-12-29 13:29 ` Sergei Shtylyov
2014-12-29 13:37 ` Enrico Mioso
2014-12-29 10:09 ` [RFC PATCH 3/6] cdc_ncm: add needed members to cdc_ncm_ctx for refactoring Enrico Mioso
2014-12-29 10:09 ` [RFC PATCH 4/6] cdc_ncm: update specs URL Enrico Mioso
2014-12-29 10:09 ` [RFC PATCH 5/6] cdc_ncm: fix typo Enrico Mioso
2014-12-29 10:09 ` Enrico Mioso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1419847788-25610-7-git-send-email-mrkiko.rs@gmail.com \
--to=mrkiko.rs@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.