linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Ajay.Kathat@microchip.com>
To: <lkml@SDF.ORG>
Cc: <Adham.Abozaeid@microchip.com>, <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v2] wilc1000: Use crc7 in lib/ rather than a private copy
Date: Tue, 24 Mar 2020 07:19:47 +0000	[thread overview]
Message-ID: <c4c804d5-afeb-76e4-4fc6-fe56225ece5e@microchip.com> (raw)
In-Reply-To: <20200323170516.GB3769@SDF.ORG>

Hi George,

On 23/03/20 10:35 pm, George Spelvin wrote:
> 
>> Earlier, I also tried to replace crc7 by using existing library but it
>> gave different results with 'crc7_be()' because I didn't modify '0x7f'
>> to '0xfe'.
> 
> I had an afterthought that maybe documenting this in <linux/crc7.h>
> would be useful, since you're unlikely to be the last person to
> make this mistake.
> 
> Something like:
> 
> /*
>  * Generate a CRC with the polynomial x^7 + x^3 + 1 and big-endian
>  * bit order.  (Thus, the polynomial is 0x89.)  The result is in the
>  * most-significant 7 bits of the crc variable.
>  *
>  * This is where most protocols want the CRC (the lsbit is past the
>  * end of CRC coverage and is used for something else), but differs
>  * from most example code, which computes the CRC in the lsbits and
>  * does an explicit 1-bit shift at the end.
>  *
>  * Because the state is maintained left-aligned, the common "preset
>  * to all ones" CRC variant requires the crc be preset to 0xfe.
>  * (Right-aligned example code will show a preset to 0x7f.)
>  */
> 
> Feel free to add that to the patch (preserving my S-o-b) if you like.
> 

Sounds good. I will try to add these comments in a separate patch for
'linux/crc7.h'.

>> Thanks again for submitting the patch.
> 
> Thank you for writing the whole driver!  I know it can be a real PITA;
> Linux kernel developers Really Really Want drivers in a common style
> and using existing kernel facilities as much as possible, but you're
> usually starting from some internal driver that has its own,
> very different, support library.
> 

Over multiple code reviews and contribution from community has helped to
bring this driver to follow kernel recommendations. I hope the driver
will be soon out of staging.

> BTW, one thing I noticed at cfg80211.c:1132:
>         *cookie = prandom_u32();
>         priv->tx_cookie = *cookie;
> 
> I don't know what the cookie is for, but I notice that *cookie
> and priv->tx_cookie are both 64-bit data types.
> 
> Should that be "(u64)prandom_u32() << 32 | prandom_u32()"
> (since there is no prandom_u64())?


Actually, the cookie is used to match the management action frame
requests with its response status received from wilc1000 device.
The driver assign the cookie value for transmit management frame
received from user space and later while publishing status back it uses
the same cookie value. It's validation is taken care in user space  e.g
wpa_supplicant.

Even though the application expects u64-bit value but passing upscaled
u32-bit random value(prandom_u32() alone) should be enough for this case.

Regards,
Ajay

  reply	other threads:[~2020-03-24  7:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-22 12:04 [PATCH] wilc1000: Use crc7 in lib/ rather than a private copy George Spelvin
2020-03-23  5:03 ` Ajay.Kathat
2020-03-23  6:45   ` George Spelvin
2020-03-23  8:22     ` Ajay.Kathat
2020-03-23 14:14       ` [PATCH v2] " George Spelvin
2020-03-23 16:29         ` Ajay.Kathat
2020-03-26 14:54         ` Ajay.Kathat
2020-03-26 14:57           ` Greg KH
2020-03-23 17:05       ` George Spelvin
2020-03-24  7:19         ` Ajay.Kathat [this message]
2020-03-26 19:28 George Spelvin
2020-03-27  7:03 ` Ajay.Kathat
2020-03-27 15:32   ` George Spelvin

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=c4c804d5-afeb-76e4-4fc6-fe56225ece5e@microchip.com \
    --to=ajay.kathat@microchip.com \
    --cc=Adham.Abozaeid@microchip.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lkml@SDF.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 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).