2012-11-01 15:21:37

by Dmytro Milinevskyy

[permalink] [raw]
Subject: [PATCH] usb: gadget: ncm: correct endianess conversion

Convert USB descriptor's fields to CPU byte order before using locally
in USB NCM gadget driver.
Tested on MIPS32 big-endian device.

Signed-off-by: Dmytro Milinevskyy <[email protected]>
---
drivers/usb/gadget/f_ncm.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index b651b52..a7cdd47 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
USB_CDC_NCM_NTB32_SUPPORTED)
static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
- .wLength = sizeof ntb_parameters,
+ .wLength = cpu_to_le16(sizeof(ntb_parameters)),
.bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
.dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
.wNdpInDivisor = cpu_to_le16(4),
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether
*port,
struct sk_buff *skb2;
int ncb_len = 0;
__le16 *tmp;
- int div = ntb_parameters.wNdpInDivisor;
- int rem = ntb_parameters.wNdpInPayloadRemainder;
+ int div;
+ int rem;
int pad;
- int ndp_align = ntb_parameters.wNdpInAlignment;
+ int ndp_align;
int ndp_pad;
unsigned max_size = ncm->port.fixed_in_len;
struct ndp_parser_opts *opts = ncm->parser_opts;
unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
+ div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
+ rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
+ ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
+
ncb_len += opts->nth_size;
ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
ncb_len += ndp_pad;
--
1.8.0


2012-11-02 11:47:50

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hello.

On 01-11-2012 19:16, Dmytro Milinevskyy wrote:

> Convert USB descriptor's fields to CPU byte order before using locally in USB
> NCM gadget driver.
> Tested on MIPS32 big-endian device.

> Signed-off-by: Dmytro Milinevskyy <[email protected]>
> ---
> drivers/usb/gadget/f_ncm.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)

> diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
> index b651b52..a7cdd47 100644
> --- a/drivers/usb/gadget/f_ncm.c
> +++ b/drivers/usb/gadget/f_ncm.c
[...]
> @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
> struct sk_buff *skb2;
> int ncb_len = 0;
> __le16 *tmp;
> - int div = ntb_parameters.wNdpInDivisor;
> - int rem = ntb_parameters.wNdpInPayloadRemainder;
> + int div;
> + int rem;
> int pad;
> - int ndp_align = ntb_parameters.wNdpInAlignment;
> + int ndp_align;
> int ndp_pad;
> unsigned max_size = ncm->port.fixed_in_len;
> struct ndp_parser_opts *opts = ncm->parser_opts;
> unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
> + div = le16_to_cpu(ntb_parameters.wNdpInDivisor);

Probably corrupt patch -- there shouldn't be spaces before '+'.

WBR, Sergei

2012-11-04 14:30:27

by Dmytro Milinevskyy

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hum, you are right. It's pain to send anything via thunderbird.
Resending.

br,
-- dmytro

On Fri, Nov 2, 2012 at 12:46 PM, Sergei Shtylyov <[email protected]> wrote:
> Hello.
>
>
> On 01-11-2012 19:16, Dmytro Milinevskyy wrote:
>
>> Convert USB descriptor's fields to CPU byte order before using locally in
>> USB
>> NCM gadget driver.
>> Tested on MIPS32 big-endian device.
>
>
>> Signed-off-by: Dmytro Milinevskyy <[email protected]>
>> ---
>> drivers/usb/gadget/f_ncm.c | 12 ++++++++----
>>
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>
>
>> diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
>> index b651b52..a7cdd47 100644
>> --- a/drivers/usb/gadget/f_ncm.c
>> +++ b/drivers/usb/gadget/f_ncm.c
>
> [...]
>>
>> @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether
>> *port,
>>
>> struct sk_buff *skb2;
>> int ncb_len = 0;
>> __le16 *tmp;
>> - int div = ntb_parameters.wNdpInDivisor;
>> - int rem = ntb_parameters.wNdpInPayloadRemainder;
>> + int div;
>> + int rem;
>>
>> int pad;
>> - int ndp_align = ntb_parameters.wNdpInAlignment;
>> + int ndp_align;
>> int ndp_pad;
>>
>> unsigned max_size = ncm->port.fixed_in_len;
>> struct ndp_parser_opts *opts = ncm->parser_opts;
>> unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
>> + div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
>
>
> Probably corrupt patch -- there shouldn't be spaces before '+'.
>
> WBR, Sergei
>

2012-11-04 14:30:30

by Dmytro Milinevskyy

[permalink] [raw]
Subject: [PATCH] usb: gadget: ncm: correct endianess conversion

Convert USB descriptor's fields to CPU byte order before using locally in USB NCM gadget driver.
Tested on MIPS32 big-endian device.

Signed-off-by: Dmytro Milinevskyy <[email protected]>
---
drivers/usb/gadget/f_ncm.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index b651b52..a7cdd47 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
USB_CDC_NCM_NTB32_SUPPORTED)

static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
- .wLength = sizeof ntb_parameters,
+ .wLength = cpu_to_le16(sizeof(ntb_parameters)),
.bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
.dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
.wNdpInDivisor = cpu_to_le16(4),
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
struct sk_buff *skb2;
int ncb_len = 0;
__le16 *tmp;
- int div = ntb_parameters.wNdpInDivisor;
- int rem = ntb_parameters.wNdpInPayloadRemainder;
+ int div;
+ int rem;
int pad;
- int ndp_align = ntb_parameters.wNdpInAlignment;
+ int ndp_align;
int ndp_pad;
unsigned max_size = ncm->port.fixed_in_len;
struct ndp_parser_opts *opts = ncm->parser_opts;
unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;

+ div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
+ rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
+ ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
+
ncb_len += opts->nth_size;
ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
ncb_len += ndp_pad;
--
1.8.0

2012-11-06 11:33:58

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

On Sun, Nov 04, 2012 at 03:30:21PM +0100, Dmytro Milinevskyy wrote:
> Convert USB descriptor's fields to CPU byte order before using locally in USB NCM gadget driver.
> Tested on MIPS32 big-endian device.
>
> Signed-off-by: Dmytro Milinevskyy <[email protected]>

doesn't apply:

$ patch -p1 --dry-run < patch.diff
patching file drivers/usb/gadget/f_ncm.c
patch: **** malformed patch at line 31: @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,

can you use git-send-email ?

> ---
> drivers/usb/gadget/f_ncm.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
> index b651b52..a7cdd47 100644
> --- a/drivers/usb/gadget/f_ncm.c
> +++ b/drivers/usb/gadget/f_ncm.c
> @@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
> USB_CDC_NCM_NTB32_SUPPORTED)
> static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
> - .wLength = sizeof ntb_parameters,
> + .wLength = cpu_to_le16(sizeof(ntb_parameters)),
> .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
> .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
> .wNdpInDivisor = cpu_to_le16(4),
> @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
> struct sk_buff *skb2;
> int ncb_len = 0;
> __le16 *tmp;
> - int div = ntb_parameters.wNdpInDivisor;
> - int rem = ntb_parameters.wNdpInPayloadRemainder;
> + int div;
> + int rem;
> int pad;
> - int ndp_align = ntb_parameters.wNdpInAlignment;
> + int ndp_align;
> int ndp_pad;
> unsigned max_size = ncm->port.fixed_in_len;
> struct ndp_parser_opts *opts = ncm->parser_opts;
> unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
> + div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
> + rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
> + ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
> +
> ncb_len += opts->nth_size;
> ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
> ncb_len += ndp_pad;
> --
> 1.8.0
>
>

--
balbi


Attachments:
(No filename) (2.02 kB)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-11-07 13:14:23

by Dmytro Milinevskyy

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Unfortunately I have some issues with git send-email.
I've attached the patch itself ..

regards,
-- dmytro

On Tue, Nov 6, 2012 at 12:27 PM, Felipe Balbi <[email protected]> wrote:
> On Sun, Nov 04, 2012 at 03:30:21PM +0100, Dmytro Milinevskyy wrote:
>> Convert USB descriptor's fields to CPU byte order before using locally in USB NCM gadget driver.
>> Tested on MIPS32 big-endian device.
>>
>> Signed-off-by: Dmytro Milinevskyy <[email protected]>
>
> doesn't apply:
>
> $ patch -p1 --dry-run < patch.diff
> patching file drivers/usb/gadget/f_ncm.c
> patch: **** malformed patch at line 31: @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
>
> can you use git-send-email ?
>
>> ---
>> drivers/usb/gadget/f_ncm.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
>> index b651b52..a7cdd47 100644
>> --- a/drivers/usb/gadget/f_ncm.c
>> +++ b/drivers/usb/gadget/f_ncm.c
>> @@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
>> USB_CDC_NCM_NTB32_SUPPORTED)
>> static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
>> - .wLength = sizeof ntb_parameters,
>> + .wLength = cpu_to_le16(sizeof(ntb_parameters)),
>> .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
>> .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
>> .wNdpInDivisor = cpu_to_le16(4),
>> @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
>> struct sk_buff *skb2;
>> int ncb_len = 0;
>> __le16 *tmp;
>> - int div = ntb_parameters.wNdpInDivisor;
>> - int rem = ntb_parameters.wNdpInPayloadRemainder;
>> + int div;
>> + int rem;
>> int pad;
>> - int ndp_align = ntb_parameters.wNdpInAlignment;
>> + int ndp_align;
>> int ndp_pad;
>> unsigned max_size = ncm->port.fixed_in_len;
>> struct ndp_parser_opts *opts = ncm->parser_opts;
>> unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
>> + div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
>> + rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
>> + ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
>> +
>> ncb_len += opts->nth_size;
>> ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
>> ncb_len += ndp_pad;
>> --
>> 1.8.0
>>
>>
>
> --
> balbi


Attachments:
0001-usb-gadget-ncm-correct-endianess-conversion.patch (1.84 kB)

2012-11-08 14:12:59

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hi,

(please, never top-post)

On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
> Unfortunately I have some issues with git send-email.
> I've attached the patch itself ..

I'll apply it like that this time, but try to figure out how to send
patches properly. We have some very helpful hints on
Documentation/email-clients.txt which are hugely underused ;-)

--
balbi


Attachments:
(No filename) (388.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-11-08 19:08:20

by Dmytro Milinevskyy

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

On Thu, Nov 8, 2012 at 3:06 PM, Felipe Balbi <[email protected]> wrote:
> Hi,
>
> (please, never top-post)
>
got it!

> On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
>> Unfortunately I have some issues with git send-email.
>> I've attached the patch itself ..
>
> I'll apply it like that this time, but try to figure out how to send
> patches properly. We have some very helpful hints on
> Documentation/email-clients.txt which are hugely underused ;-)
>
well, I try to follow the rules as much as possible as long as tools work ... =)

regards,
-- dmytro

> --
> balbi

2012-11-08 19:36:45

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hi,

On Thu, Nov 08, 2012 at 08:07:57PM +0100, Dmytro Milinevskyy wrote:
> > On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
> >> Unfortunately I have some issues with git send-email.
> >> I've attached the patch itself ..
> >
> > I'll apply it like that this time, but try to figure out how to send
> > patches properly. We have some very helpful hints on
> > Documentation/email-clients.txt which are hugely underused ;-)
> >
> well, I try to follow the rules as much as possible as long as tools
> work ... =)

git send-email has thousands of users and it works fine for them
(including myself). Maybe you just misconfigured it ?!? ;-)

cheers

--
balbi


Attachments:
(No filename) (678.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-11-09 09:32:12

by Dmytro Milinevskyy

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hi Felipe,

On Thu, Nov 8, 2012 at 8:30 PM, Felipe Balbi <[email protected]> wrote:
> Hi,
>
> On Thu, Nov 08, 2012 at 08:07:57PM +0100, Dmytro Milinevskyy wrote:
>> > On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
>> >> Unfortunately I have some issues with git send-email.
>> >> I've attached the patch itself ..
>> >
>> > I'll apply it like that this time, but try to figure out how to send
>> > patches properly. We have some very helpful hints on
>> > Documentation/email-clients.txt which are hugely underused ;-)
>> >
>> well, I try to follow the rules as much as possible as long as tools
>> work ... =)
>
> git send-email has thousands of users and it works fine for them
> (including myself). Maybe you just misconfigured it ?!? ;-)
>
No, I was using it in the past w/o any issue.
In fact initial versions of the patch were sent exactly with git-send-email.

However I lost my internet connection at home(some issues with ISP)
and at work place network environment somehow blocks
git-send-email(though thunderbird still can connect to the smtp server
..).

thanks,
-- dmytro

> cheers
>
> --
> balbi

2012-11-09 12:00:00

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hi,

On Fri, Nov 09, 2012 at 10:31:47AM +0100, Dmytro Milinevskyy wrote:
> Hi Felipe,
>
> On Thu, Nov 8, 2012 at 8:30 PM, Felipe Balbi <[email protected]> wrote:
> > Hi,
> >
> > On Thu, Nov 08, 2012 at 08:07:57PM +0100, Dmytro Milinevskyy wrote:
> >> > On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
> >> >> Unfortunately I have some issues with git send-email.
> >> >> I've attached the patch itself ..
> >> >
> >> > I'll apply it like that this time, but try to figure out how to send
> >> > patches properly. We have some very helpful hints on
> >> > Documentation/email-clients.txt which are hugely underused ;-)
> >> >
> >> well, I try to follow the rules as much as possible as long as tools
> >> work ... =)
> >
> > git send-email has thousands of users and it works fine for them
> > (including myself). Maybe you just misconfigured it ?!? ;-)
> >
> No, I was using it in the past w/o any issue.
> In fact initial versions of the patch were sent exactly with git-send-email.
>
> However I lost my internet connection at home(some issues with ISP)
> and at work place network environment somehow blocks
> git-send-email(though thunderbird still can connect to the smtp server
> ..).

I don't think smtp server can make that distinction. Except for the
message-id, there's nothing there which would help smtp server to figure
out you're using git send-email. On top of that, it would be just extra
work to maintain rules to block a tool which is essentially just sending
an email.

Make sure you're not missing some authentication with the mail server on
your git send-email configuration.

my 2 cents.

--
balbi


Attachments:
(No filename) (1.60 kB)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-11-10 18:30:14

by Dmytro Milinevskyy

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: ncm: correct endianess conversion

Hi,

On Fri, Nov 9, 2012 at 12:53 PM, Felipe Balbi <[email protected]> wrote:
> Hi,
>
> On Fri, Nov 09, 2012 at 10:31:47AM +0100, Dmytro Milinevskyy wrote:
>> Hi Felipe,
>>
>> On Thu, Nov 8, 2012 at 8:30 PM, Felipe Balbi <[email protected]> wrote:
>> > Hi,
>> >
>> > On Thu, Nov 08, 2012 at 08:07:57PM +0100, Dmytro Milinevskyy wrote:
>> >> > On Wed, Nov 07, 2012 at 02:14:00PM +0100, Dmytro Milinevskyy wrote:
>> >> >> Unfortunately I have some issues with git send-email.
>> >> >> I've attached the patch itself ..
>> >> >
>> >> > I'll apply it like that this time, but try to figure out how to send
>> >> > patches properly. We have some very helpful hints on
>> >> > Documentation/email-clients.txt which are hugely underused ;-)
>> >> >
>> >> well, I try to follow the rules as much as possible as long as tools
>> >> work ... =)
>> >
>> > git send-email has thousands of users and it works fine for them
>> > (including myself). Maybe you just misconfigured it ?!? ;-)
>> >
>> No, I was using it in the past w/o any issue.
>> In fact initial versions of the patch were sent exactly with git-send-email.
>>
>> However I lost my internet connection at home(some issues with ISP)
>> and at work place network environment somehow blocks
>> git-send-email(though thunderbird still can connect to the smtp server
>> ..).
>
> I don't think smtp server can make that distinction. Except for the
> message-id, there's nothing there which would help smtp server to figure
> out you're using git send-email. On top of that, it would be just extra
> work to maintain rules to block a tool which is essentially just sending
> an email.
>
> Make sure you're not missing some authentication with the mail server on
> your git send-email configuration.
>
> my 2 cents.

Thanks a lot, I very appreciate your help.
I even tried to use same laptop with same version of git I used to
send the patch for the first time but it didn't help.
Likely there's a network configuration that is blocking
git-send-email. I will try to figure it out with our system
administrators.

cheers,
-- dmytro

> --
> balbi