Re: [RFC PATCH 1/5] vsock/virtio: Extend virtio-vsock spec with an "order" field

2024-05-23 Thread Alyssa Ross
(CCing virtio-comment, since this proposes adding a field to a struct
that is standardized[1] in the VIRTIO spec, so changes to the Linux
implementation should presumably be coordinated with changes to the
spec.)

[1]: 
https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.html#x1-4780004

On Fri, May 17, 2024 at 10:46:03PM +0800, Xuewei Niu wrote:
> The "order" field determines the location of the device in the linked list,
> the device with CID 4, having a smallest order, is in the first place, and
> so forth.
>
> Rules:
>
> * It doesn’t have to be continuous;
> * It cannot exist conflicts;
> * It is optional for the mode of a single device, but is required for the
>   mode of multiple devices.
>
> Signed-off-by: Xuewei Niu 
> ---
>  include/uapi/linux/virtio_vsock.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/linux/virtio_vsock.h 
> b/include/uapi/linux/virtio_vsock.h
> index 64738838bee5..b62ec7d2ab1e 100644
> --- a/include/uapi/linux/virtio_vsock.h
> +++ b/include/uapi/linux/virtio_vsock.h
> @@ -43,6 +43,7 @@
>
>  struct virtio_vsock_config {
>   __le64 guest_cid;
> + __le64 order;
>  } __attribute__((packed));
>
>  enum virtio_vsock_event_id {
> --
> 2.34.1
>


signature.asc
Description: PGP signature


Re: [PATCH 5.11 000/306] 5.11.7-rc1 review

2021-03-16 Thread Ross Schmidt
On Mon, Mar 15, 2021 at 02:51:03PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.11.7 release.
> There are 306 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.10 000/290] 5.10.24-rc1 review

2021-03-16 Thread Ross Schmidt
On Mon, Mar 15, 2021 at 02:51:33PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.10.24 release.
> There are 290 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 000/168] 5.4.106-rc1 review

2021-03-16 Thread Ross Schmidt
On Mon, Mar 15, 2021 at 02:53:52PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.4.106 release.
> There are 168 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 4.19 000/120] 4.19.181-rc1 review

2021-03-16 Thread Ross Schmidt
On Mon, Mar 15, 2021 at 02:55:51PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 4.19.181 release.
> There are 120 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.11 00/36] 5.11.6-rc1 review

2021-03-10 Thread Ross Schmidt
On Wed, Mar 10, 2021 at 02:23:13PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.11.6 release.
> There are 36 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.10 00/47] 5.10.23-rc2 review

2021-03-10 Thread Ross Schmidt
On Wed, Mar 10, 2021 at 07:29:23PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.10.23 release.
> There are 47 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 00/24] 5.4.105-rc1 review

2021-03-10 Thread Ross Schmidt
On Wed, Mar 10, 2021 at 02:24:12PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 5.4.105 release.
> There are 24 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 4.19 00/39] 4.19.180-rc1 review

2021-03-10 Thread Ross Schmidt
On Wed, Mar 10, 2021 at 02:24:08PM +0100, gre...@linuxfoundation.org wrote:
> From: Greg Kroah-Hartman 
> 
> This is the start of the stable review cycle for the 4.19.180 release.
> There are 39 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH v4 2/3] xen/events: don't unmask an event channel when an eoi is pending

2021-03-10 Thread Ross Lagerwall
On 2021-03-09 08:57, Ross Lagerwall wrote:
> On 2021-03-09 05:14, Jürgen Groß wrote:
>> On 08.03.21 21:33, Boris Ostrovsky wrote:
>>>
>>> On 3/6/21 11:18 AM, Juergen Gross wrote:
>>>> An event channel should be kept masked when an eoi is pending for it.
>>>> When being migrated to another cpu it might be unmasked, though.
>>>>
>>>> In order to avoid this keep three different flags for each event channel
>>>> to be able to distinguish "normal" masking/unmasking from eoi related
>>>> masking/unmasking and temporary masking. The event channel should only
>>>> be able to generate an interrupt if all flags are cleared.
>>>>
>>>> Cc: sta...@vger.kernel.org
>>>> Fixes: 54c9de89895e0a36047 ("xen/events: add a new late EOI evtchn 
>>>> framework")
>>>> Reported-by: Julien Grall 
>>>> Signed-off-by: Juergen Gross 
>>>> Reviewed-by: Julien Grall 
>>>> ---
>>>> V2:
>>>> - introduce a lock around masking/unmasking
>>>> - merge patch 3 into this one (Jan Beulich)
>>>> V4:
>>>> - don't set eoi masking flag in lateeoi_mask_ack_dynirq()
>>>
>>>
>>> Reviewed-by: Boris Ostrovsky 
>>>
>>>
>>> Ross, are you planning to test this?
>>
>> Just as another data point: With the previous version of the patches
>> a reboot loop of a guest needed max 33 reboots to loose network in
>> my tests (those were IIRC 6 test runs). With this patch version I
>> stopped the test after about 1300 reboots without having seen any
>> problems.
>>
> 
> Thanks, I'll test it today and get back to you.
> 

Tested-by: Ross Lagerwall 

The updated patch seems fine in testing.

Thanks
Ross


Re: [PATCH v4 2/3] xen/events: don't unmask an event channel when an eoi is pending

2021-03-09 Thread Ross Lagerwall
On 2021-03-09 05:14, Jürgen Groß wrote:
> On 08.03.21 21:33, Boris Ostrovsky wrote:
>>
>> On 3/6/21 11:18 AM, Juergen Gross wrote:
>>> An event channel should be kept masked when an eoi is pending for it.
>>> When being migrated to another cpu it might be unmasked, though.
>>>
>>> In order to avoid this keep three different flags for each event channel
>>> to be able to distinguish "normal" masking/unmasking from eoi related
>>> masking/unmasking and temporary masking. The event channel should only
>>> be able to generate an interrupt if all flags are cleared.
>>>
>>> Cc: sta...@vger.kernel.org
>>> Fixes: 54c9de89895e0a36047 ("xen/events: add a new late EOI evtchn 
>>> framework")
>>> Reported-by: Julien Grall 
>>> Signed-off-by: Juergen Gross 
>>> Reviewed-by: Julien Grall 
>>> ---
>>> V2:
>>> - introduce a lock around masking/unmasking
>>> - merge patch 3 into this one (Jan Beulich)
>>> V4:
>>> - don't set eoi masking flag in lateeoi_mask_ack_dynirq()
>>
>>
>> Reviewed-by: Boris Ostrovsky 
>>
>>
>> Ross, are you planning to test this?
> 
> Just as another data point: With the previous version of the patches
> a reboot loop of a guest needed max 33 reboots to loose network in
> my tests (those were IIRC 6 test runs). With this patch version I
> stopped the test after about 1300 reboots without having seen any
> problems.
> 

Thanks, I'll test it today and get back to you.

Ross


Re:

2021-03-06 Thread Ms Ross
I'm the above named person Ms. Siena Ross, It is the situation of
things surrounding me has made me to cry to you because I never knew
things would turn this way after a painful death of my beloved husband
during the Italian corona virus and I became sick since and very
unwell up to the dates so do not be afraid at all.

I have available investment funds worth (US$29.9 million)" I want you
to secure and invest this money partly for the benefit and education
of my 10 Years old son Ross Jr.

Your urgent response will be appreciated as I don't know what tomorrow
will result due to my recently sad medical reports.


Re: [PATCH 5.11 00/12] 5.11.2-rc1 review

2021-02-25 Thread Ross Schmidt
On Thu, Feb 25, 2021 at 10:53:34AM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.11.2 release.
> There are 12 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.10 00/23] 5.10.19-rc1 review

2021-02-25 Thread Ross Schmidt
On Thu, Feb 25, 2021 at 10:53:31AM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.10.19 release.
> There are 23 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 00/17] 5.4.101-rc1 review

2021-02-25 Thread Ross Schmidt
On Thu, Feb 25, 2021 at 10:53:45AM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.4.101 release.
> There are 17 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH v3 2/8] xen/events: don't unmask an event channel when an eoi is pending

2021-02-23 Thread Ross Lagerwall
On 2021-02-19 15:40, Juergen Gross wrote:
> An event channel should be kept masked when an eoi is pending for it.
> When being migrated to another cpu it might be unmasked, though.
> 
> In order to avoid this keep three different flags for each event channel
> to be able to distinguish "normal" masking/unmasking from eoi related
> masking/unmasking and temporary masking. The event channel should only
> be able to generate an interrupt if all flags are cleared.
> 
> Cc: sta...@vger.kernel.org
> Fixes: 54c9de89895e0a36047 ("xen/events: add a new late EOI evtchn framework")
> Reported-by: Julien Grall 
> Signed-off-by: Juergen Gross 

I tested this patch series backported to a 4.19 kernel and found that
when doing a reboot loop of Windows with PV drivers, occasionally it will
end up in a state with some event channels pending and masked in dom0
which breaks networking in the guest.

The issue seems to have been introduced with this patch, though at first
glance it appears correct. I haven't yet looked into why it is happening.
Have you seen anything like this with this patch?

Thanks,
Ross


Re: [PATCH v2 8/8] xen/evtchn: use READ/WRITE_ONCE() for accessing ring indices

2021-02-17 Thread Ross Lagerwall
On 2021-02-11 10:16, Juergen Gross wrote:
> For avoiding read- and write-tearing by the compiler use READ_ONCE()
> and WRITE_ONCE() for accessing the ring indices in evtchn.c.
> 
> Signed-off-by: Juergen Gross 
> ---
> V2:
> - modify all accesses (Julien Grall)
> ---
>  drivers/xen/evtchn.c | 25 -
>  1 file changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
> index 421382c73d88..620008f89dbe 100644
> --- a/drivers/xen/evtchn.c
> +++ b/drivers/xen/evtchn.c
> @@ -162,6 +162,7 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)
>  {
>   struct user_evtchn *evtchn = data;
>   struct per_user_data *u = evtchn->user;
> + unsigned int prod, cons;
>  
>   WARN(!evtchn->enabled,
>"Interrupt for port %u, but apparently not enabled; per-user %p\n",
> @@ -171,10 +172,14 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)
>  
>   spin_lock(&u->ring_prod_lock);
>  
> - if ((u->ring_prod - u->ring_cons) < u->ring_size) {
> - *evtchn_ring_entry(u, u->ring_prod) = evtchn->port;
> + prod = READ_ONCE(u->ring_prod);
> + cons = READ_ONCE(u->ring_cons);
> +
> + if ((prod - cons) < u->ring_size) {
> + *evtchn_ring_entry(u, prod) = evtchn->port;
>   smp_wmb(); /* Ensure ring contents visible */
> - if (u->ring_cons == u->ring_prod++) {
> + if (cons == prod++) {
> + WRITE_ONCE(u->ring_prod, prod);
>   wake_up_interruptible(&u->evtchn_wait);
>   kill_fasync(&u->evtchn_async_queue,
>   SIGIO, POLL_IN);

This doesn't work correctly since now u->ring_prod is only updated if cons == 
prod++.

Ross


Re: [PATCH 5.10 000/104] 5.10.17-rc1 review

2021-02-16 Thread Ross Schmidt
On Mon, Feb 15, 2021 at 04:26:13PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.10.17 release.
> There are 104 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 00/60] 5.4.99-rc1 review

2021-02-16 Thread Ross Schmidt
On Mon, Feb 15, 2021 at 04:26:48PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.4.99 release.
> There are 60 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-12 Thread Ross Schmidt
On Thu, Feb 11, 2021 at 04:01:44PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.10.16 release.
> There are 54 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 00/24] 5.4.98-rc1 review

2021-02-12 Thread Ross Schmidt
On Thu, Feb 11, 2021 at 04:02:23PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.4.98 release.
> There are 24 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 4.19 00/27] 4.19.176-rc2 review

2021-02-12 Thread Ross Schmidt
On Fri, Feb 12, 2021 at 08:55:04AM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.176 release.
> There are 27 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.10 000/120] 5.10.15-rc1 review

2021-02-09 Thread Ross Schmidt
On Mon, Feb 08, 2021 at 03:59:47PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.10.15 release.
> There are 120 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 5.4 00/65] 5.4.97-rc1 review

2021-02-09 Thread Ross Schmidt
On Mon, Feb 08, 2021 at 04:00:32PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.4.97 release.
> There are 65 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 4.19 00/38] 4.19.175-rc1 review

2021-02-09 Thread Ross Schmidt
On Mon, Feb 08, 2021 at 04:00:47PM +0100, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.175 release.
> There are 38 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>

Compiled and booted with no regressions on x86_64.

Tested-by: Ross Schmidt 


thanks,

Ross


Re: [PATCH 2/7] xen/events: don't unmask an event channel when an eoi is pending

2021-02-08 Thread Ross Lagerwall
On 2021-02-06 10:49, Juergen Gross wrote:
> An event channel should be kept masked when an eoi is pending for it.
> When being migrated to another cpu it might be unmasked, though.
> 
> In order to avoid this keep two different flags for each event channel
> to be able to distinguish "normal" masking/unmasking from eoi related
> masking/unmasking. The event channel should only be able to generate
> an interrupt if both flags are cleared.
> 
> Cc: sta...@vger.kernel.org
> Fixes: 54c9de89895e0a36047 ("xen/events: add a new late EOI evtchn framework")
> Reported-by: Julien Grall 
> Signed-off-by: Juergen Gross 
...> +static void lateeoi_ack_dynirq(struct irq_data *data)
> +{
> + struct irq_info *info = info_for_irq(data->irq);
> + evtchn_port_t evtchn = info ? info->evtchn : 0;
> +
> + if (VALID_EVTCHN(evtchn)) {
> + info->eoi_pending = true;
> + mask_evtchn(evtchn);
> + }
> +}

Doesn't this (and the one below) need a call to clear_evtchn() to
actually ack the pending event? Otherwise I can't see what clears
the pending bit.

I tested out this patch but processes using the userspace evtchn device did
not work very well without the clear_evtchn() call.

Ross

> +
> +static void lateeoi_mask_ack_dynirq(struct irq_data *data)
> +{
> + struct irq_info *info = info_for_irq(data->irq);
> + evtchn_port_t evtchn = info ? info->evtchn : 0;
> +
> + if (VALID_EVTCHN(evtchn)) {
> + info->masked = true;
> + info->eoi_pending = true;
> + mask_evtchn(evtchn);
> + }
> +}
> +


[PATCH v2 18/21] staging: rtl8723bs: replace EID_BSSIntolerantChlReport

2020-12-07 Thread Ross Schmidt
Replace unique EID_BSSIntolerantChlReport constant with kernel provided
WLAN_EID_BSS_INTOLERANT_CHL_REPORT from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b6e255f6cdc5..9d172bd23911 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -4160,7 +4160,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
}
}
 
-   pframe = rtw_set_ie(pframe, 
EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen));
+   pframe = rtw_set_ie(pframe, 
WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &(pattrib->pktlen));
 
}
 
-- 
2.25.1



[PATCH v2 21/21] staging: rtl8723bs: remove ELEMENT_ID enum

2020-12-07 Thread Ross Schmidt
The ELEMENT_ID enum is no longer used, remove it.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/wifi.h | 76 
 1 file changed, 76 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 7f482a45705b..fe984fcb66a9 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -387,82 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_  _BEACON_IE_OFFSET_
 
-enum ELEMENT_ID {
-   EID_SsId= 0, /* service set 
identifier (0:32) */
-   EID_SupRates= 1, /* supported rates (1:8) */
-   EID_FHParms = 2, /* FH parameter set (5) */
-   EID_DSParms = 3, /* DS parameter set (1) */
-   EID_CFParms = 4, /* CF parameter set (6) */
-   EID_Tim = 5, /* Traffic 
Information Map (4:254) */
-   EID_IbssParms   = 6, /* IBSS parameter set (2) 
*/
-   EID_Country = 7, /* */
-
-   /*  Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */
-   EID_QBSSLoad= 11,
-   EID_EDCAParms   = 12,
-   EID_TSpec   = 13,
-   EID_TClass  = 14,
-   EID_Schedule= 15,
-   /*  */
-
-   EID_Ctext   = 16, /* challenge 
text*/
-   EID_POWER_CONSTRAINT= 32, /* Power Constraint*/
-
-   /* vivi for WIFITest, 802.11h AP, 20100427 */
-   /*  2010/12/26 MH The definition we can declare always!! */
-   EID_PowerCap= 33,
-   EID_SupportedChannels   = 36,
-   EID_ChlSwitchAnnounce   = 37,
-
-   EID_MeasureRequest  = 38, /*  Measurement Request */
-   EID_MeasureReport   = 39, /*  Measurement Report */
-
-   EID_ERPInfo = 42,
-
-   /*  Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */
-   EID_TSDelay = 43,
-   EID_TCLASProc   = 44,
-   EID_HTCapability= 45,
-   EID_QoSCap  = 46,
-   /*  */
-
-   EID_WPA2= 48,
-   EID_ExtSupRates = 50,
-
-   EID_FTIE= 55, /*  Defined in 
802.11r */
-   EID_Timeout = 56, /*  Defined in 802.11r */
-
-   EID_SupRegulatory   = 59, /*  Supported Requlatory 
Classes 802.11y */
-   EID_HTInfo  = 61,
-   EID_SecondaryChnlOffset = 62,
-
-   EID_BSSCoexistence  = 72, /*  20/40 BSS Coexistence 
*/
-   EID_BSSIntolerantChlReport  = 73,
-   EID_OBSS= 74, /*  Overlapping 
BSS Scan Parameters */
-
-   EID_LinkIdentifier  = 101, /*  Defined in 802.11z */
-   EID_WakeupSchedule  = 102, /*  Defined in 802.11z */
-   EID_ChnlSwitchTimeing   = 104, /*  Defined in 802.11z */
-   EID_PTIControl  = 105, /*  Defined in 802.11z */
-   EID_PUBufferStatus  = 106, /*  Defined in 802.11z */
-
-   EID_EXTCapability   = 127, /*  Extended 
Capabilities */
-   /*  From S19:Aironet IE and S21:AP IP address IE in CCX v1.13, p16 and 
p18. */
-   EID_Aironet = 133, /*  0x85: 
Aironet Element for Cisco CCX */
-   EID_CiscoIP = 149, /*  0x95: IP 
Address IE for Cisco CCX */
-
-   EID_CellPwr = 150, /*  0x96: Cell 
Power Limit IE. Ref. 0x96. */
-
-   EID_CCKM= 156,
-
-   EID_Vendor  = 221, /*  0xDD: Vendor 
Specific */
-
-   EID_WAPI= 68,
-   EID_VHTCapability   = 191, /*  Based on 802.11ac 
D2.0 */
-   EID_VHTOperation= 192, /*  Based on 802.11ac 
D2.0 */
-   EID_OpModeNotification  = 199, /*  Based on 802.11ac D3.0 */
-};
-
 /* ---
Below is the fixed elements...
 -*/
-- 
2.25.1



[PATCH v2 20/21] staging: rtl8723bs: remove unused macros

2020-12-07 Thread Ross Schmidt
Remove many macros from wifi.h and ieee80211.h because they are unused.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/ieee80211.h |  5 -
 drivers/staging/rtl8723bs/include/wifi.h  | 15 ---
 2 files changed, 20 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 20c53c290aa1..d9ff8c8e7f36 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -348,11 +348,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_REASON_JOIN_WRONG_CHANNEL   65534
 #define WLAN_REASON_EXPIRATION_CHK 65535
 
-/* EIDs defined by IEEE 802.11h - END */
-#define WLAN_EID_20_40_BSS_COEXISTENCE 72
-#define WLAN_EID_20_40_BSS_INTOLERANT 73
-#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
-
 #define IEEE80211_MGMT_HDR_LEN 24
 #define IEEE80211_DATA_HDR3_LEN 24
 #define IEEE80211_DATA_HDR4_LEN 30
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 82dfdafb38fc..7f482a45705b 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -387,21 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_  _BEACON_IE_OFFSET_
 
-#define _SUPPORTED_CH_IE_  36
-#define _CH_SWTICH_ANNOUNCE_   37  /* Secondary Channel Offset */
-
-#define _FTIE_ 55
-#define _TIMEOUT_ITVL_IE_  56
-#define _SRC_IE_   59
-
-#define _RIC_Descriptor_IE_75
-#define _LINK_ID_IE_   101
-#define _CH_SWITCH_TIMING_ 104
-#define _PTI_BUFFER_STATUS_106
-#define _EXT_CAP_IE_   127
-
-#define_RESERVED47_47
-
 enum ELEMENT_ID {
EID_SsId= 0, /* service set 
identifier (0:32) */
EID_SupRates= 1, /* supported rates (1:8) */
-- 
2.25.1



[PATCH v2 17/21] staging: rtl8723bs: replace EID_BSSCoexistence

2020-12-07 Thread Ross Schmidt
Replace unique EID_BSSCoexistence constant with kernel provided
WLAN_EID_BSS_COEX_2040 from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index e9b14fc8b10f..b6e255f6cdc5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -4096,7 +4096,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
 
iedata |= BIT(2);/* 20 MHz BSS Width Request */
 
-   pframe = rtw_set_ie(pframe, EID_BSSCoexistence,  1, &iedata, 
&(pattrib->pktlen));
+   pframe = rtw_set_ie(pframe, WLAN_EID_BSS_COEX_2040,  1, 
&iedata, &(pattrib->pktlen));
 
}
 
-- 
2.25.1



[PATCH v2 08/21] staging: rtl8723bs: replace _DSSET_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _DSSET_IE_ macro with kernel provdied WLAN_EID_DS_PARAMS
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c|  2 +-
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 10 +-
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c |  2 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   |  2 +-
 drivers/staging/rtl8723bs/include/wifi.h   |  1 -
 6 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 99a34c059f6d..1514975f23bc 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1019,7 +1019,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
pbss_network->Configuration.Length = 0;
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _DSSET_IE_, &ie_len,
+   WLAN_EID_DS_PARAMS, &ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
if (p && ie_len > 0)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index e0896e128dda..58e29314c8f8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -350,7 +350,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
}
 
/* DS parameter set */
-   ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 
*)&(pdev_network->Configuration.DSConfig), &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 
*)&(pdev_network->Configuration.DSConfig), &sz);
 
/* IBSS Parameter Set */
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b9e612e1e162..1f6c1e441744 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -2543,7 +2543,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : 
rate_len), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
-   pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
 
/* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */
{
@@ -2747,7 +2747,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 
8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
-   pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned 
char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
 
if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
u8 erpinfo = 0;
@@ -2884,7 +2884,7 @@ static int _issue_probereq(struct adapter *padapter,
}
 
if (ch)
-   pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, &ch, 
&pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, &ch, 
&pattrib->pktlen);
 
if (append_wps) {
/* add wps_ie for wps2.0 */
@@ -4509,7 +4509,7 @@ u8 collect_bss_info(struct adapter *padapter, union 
recv_frame *precv_frame, str
return _FAIL;
 
/*  Checking for DSConfig */
-   p = rtw_get_ie(bssid->IEs + ie_offset, _DSSET_IE_, &len, 
bssid->IELength - ie_offset);
+   p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, 
bssid->IELength - ie_offset);
 
bssid->Configuration.DSConfig = 0;
bssid->Configuration.Length = 0;
@@ -5982,7 +5982,7 @@ static int rtw_auto_ap_start_beacon(struct adapter 
*adapter)
} else {
oper_channel = adapter_to_dvobj(adapter)->oper_channel;
}
-   ie = rtw_set_ie(ie, _DSSET_IE_, 1, &oper_channel, &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, &oper_channel, &sz);
 
/* ext supported rates */
if (rateLen > 8) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 5ad2ed6af593..ff5125b33749 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1321,7 +1321,7 @@ int rtw_check_bcn_in

[PATCH v2 05/21] staging: rtl8723bs: replace WLAN_EID_VHT_OP_MODE_NOTIFY

2020-12-07 Thread Ross Schmidt
Replace unique WLAN_EID_VHT_OP_MODE_NOFITY macro with kernel provided
WLAN_EID_OPMODE_NOTIF from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index ff4f493e8dcd..182cc8c0b7d3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1072,7 +1072,7 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
elems->vht_operation = pos;
elems->vht_operation_len = elen;
break;
-   case WLAN_EID_VHT_OP_MODE_NOTIFY:
+   case WLAN_EID_OPMODE_NOTIF:
elems->vht_op_mode_notify = pos;
elems->vht_op_mode_notify_len = elen;
break;
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 880d3f0a32fa..20c53c290aa1 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -352,7 +352,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_EID_20_40_BSS_COEXISTENCE 72
 #define WLAN_EID_20_40_BSS_INTOLERANT 73
 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
-#define WLAN_EID_VHT_OP_MODE_NOTIFY 199
 
 #define IEEE80211_MGMT_HDR_LEN 24
 #define IEEE80211_DATA_HDR3_LEN 24
-- 
2.25.1



[PATCH v2 19/21] staging: rtl8723bs: replace EID_EXTCapability

2020-12-07 Thread Ross Schmidt
Replace unique EID_EXTCapability constant with kernel provided
WLAN_EID_EXT_CAPABILITY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index d05338015744..2c9425e2a1e9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2912,7 +2912,7 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 
*out_ie, uint *pout_len
if (phtpriv->bss_coexist)
SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1);
 
-   rtw_set_ie(out_ie + *pout_len, EID_EXTCapability, 8, cap_content, 
pout_len);
+   rtw_set_ie(out_ie + *pout_len, WLAN_EID_EXT_CAPABILITY, 8, cap_content, 
pout_len);
 }
 
 inline void rtw_set_to_roam(struct adapter *adapter, u8 to_roam)
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 9d172bd23911..fa4b0259c5ae 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3381,9 +3381,9 @@ void issue_assocreq(struct adapter *padapter)
}
break;
 
-   case EID_EXTCapability:
+   case WLAN_EID_EXT_CAPABILITY:
if (padapter->mlmepriv.htpriv.ht_option)
-   pframe = rtw_set_ie(pframe, EID_EXTCapability, 
pIE->Length, pIE->data, &(pattrib->pktlen));
+   pframe = rtw_set_ie(pframe, 
WLAN_EID_EXT_CAPABILITY, pIE->Length, pIE->data, &(pattrib->pktlen));
break;
default:
break;
-- 
2.25.1



[PATCH v2 15/21] staging: rtl8723bs: replace _WAPI_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _WAPI_IE_ macro with kernel provided
WLAN_EID_BSS_AC_ACCESS_DELAY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++--
 drivers/staging/rtl8723bs/include/wifi.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 28d5892d8bda..be4cffce4f5d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -623,8 +623,8 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, 
u16 *wapi_len)
while (cnt < in_len) {
authmode = in_ie[cnt];
 
-   /* if (authmode == _WAPI_IE_) */
-   if (authmode == _WAPI_IE_ && (!memcmp(&in_ie[cnt+6], wapi_oui1, 
4) ||
+   /* if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY) */
+   if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY && 
(!memcmp(&in_ie[cnt+6], wapi_oui1, 4) ||
!memcmp(&in_ie[cnt+6], wapi_oui2, 4))) {
if (wapi_ie) {
memcpy(wapi_ie, &in_ie[cnt], in_ie[cnt+1]+2);
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index e221d4574f32..29621fce6a83 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -393,7 +393,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 #define _FTIE_ 55
 #define _TIMEOUT_ITVL_IE_  56
 #define _SRC_IE_   59
-#define _WAPI_IE_  68
 
 #define _RIC_Descriptor_IE_75
 #define _MME_IE_   76 /* 802.11w 
Management MIC element */
-- 
2.25.1



[PATCH v2 16/21] staging: rtl8723bs: replace _MME_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _MME_IE_ macro with kernel provided WLAN_EID_MMIE from
linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 2 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +-
 drivers/staging/rtl8723bs/include/wifi.h  | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 33f5d3c5ac36..a83d8f7f611c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -1819,7 +1819,7 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 
*precvframe)
/* save the frame body + MME */
memcpy(BIP_AAD+BIP_AAD_SIZE, pframe+WLAN_HDR_A3_LEN, 
pattrib->pkt_len-WLAN_HDR_A3_LEN);
/* find MME IE pointer */
-   p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, _MME_IE_, &len, 
pattrib->pkt_len-WLAN_HDR_A3_LEN);
+   p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, WLAN_EID_MMIE, &len, 
pattrib->pkt_len-WLAN_HDR_A3_LEN);
/* Baron */
if (p) {
u16 keyid = 0;
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 187a2aa77a55..41632fa0b3c8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -1292,7 +1292,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, 
_pkt *pkt, struct xmit
pmlmeext->mgnt_80211w_IPN++;
 
/* add MME IE with MIC all zero, MME string doesn't include 
element id and length */
-   pframe = rtw_set_ie(pframe, _MME_IE_, 16,
+   pframe = rtw_set_ie(pframe, WLAN_EID_MMIE, 16,
MME, &pattrib->pktlen);
pattrib->last_txcmdsz = pattrib->pktlen;
/*  total frame length - header length */
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 29621fce6a83..82dfdafb38fc 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -395,7 +395,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 #define _SRC_IE_   59
 
 #define _RIC_Descriptor_IE_75
-#define _MME_IE_   76 /* 802.11w 
Management MIC element */
 #define _LINK_ID_IE_   101
 #define _CH_SWITCH_TIMING_ 104
 #define _PTI_BUFFER_STATUS_106
-- 
2.25.1



[PATCH v2 11/21] staging: rtl8723bs: replace _COUNTRY_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _COUNTRY_IE_ macro with kernel provided WLAN_EID_COUNTRY
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 drivers/staging/rtl8723bs/include/wifi.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 546e4a31142b..319a99833a49 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -4788,7 +4788,7 @@ static void process_80211d(struct adapter *padapter, 
struct wlan_bssid_ex *bssid
u8 noc; /*  number of channel */
u8 j, k;
 
-   ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, 
&len, bssid->IELength - _FIXED_IE_LENGTH_);
+   ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, 
WLAN_EID_COUNTRY, &len, bssid->IELength - _FIXED_IE_LENGTH_);
if (!ie)
return;
if (len < 6)
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 3adeb3c23a3c..6df50468200e 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_  _BEACON_IE_OFFSET_
 
-#define _COUNTRY_IE_   7
 #define _CHLGETXT_IE_  16
 #define _SUPPORTED_CH_IE_  36
 #define _CH_SWTICH_ANNOUNCE_   37  /* Secondary Channel Offset */
-- 
2.25.1



[PATCH v2 12/21] staging: rtl8723bs: replace _CHLGETXT_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _CHLGETXT_IE_ macro with kernel provided WLAN_EID_CHALLENGE
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 
 drivers/staging/rtl8723bs/include/wifi.h  | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 319a99833a49..93380493e8dc 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1028,7 +1028,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
/* checking for challenging txt... */
DBG_871X("checking for challenging txt...\n");
 
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + 
_AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len,
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + 
_AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&ie_len,
len - WLAN_HDR_A3_LEN - 
_AUTH_IE_OFFSET_ - 4);
 
if ((p == NULL) || (ie_len <= 0)) {
@@ -1124,7 +1124,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union 
recv_frame *precv_fram
if (seq == 2) {
if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
 /*  legendary shared system */
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 
_AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len,
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 
_AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len,
pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_);
 
if (p == NULL) {
@@ -3026,7 +3026,7 @@ void issue_auth(struct adapter *padapter, struct sta_info 
*psta, unsigned short
 
/*  added challenging text... */
if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) 
&& (use_shared_key == 1))
-   pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, 
psta->chg_txt, &(pattrib->pktlen));
+   pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, 
psta->chg_txt, &(pattrib->pktlen));
 
} else {
memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), 
ETH_ALEN);
@@ -3066,7 +3066,7 @@ void issue_auth(struct adapter *padapter, struct sta_info 
*psta, unsigned short
 
/*  then checking to see if sending challenging text... */
if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & 
WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) {
-   pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, 
pmlmeinfo->chg_txt, &(pattrib->pktlen));
+   pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, 
pmlmeinfo->chg_txt, &(pattrib->pktlen));
 
SetPrivacy(fctrl);
 
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 6df50468200e..2f13bbe38f74 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_  _BEACON_IE_OFFSET_
 
-#define _CHLGETXT_IE_  16
 #define _SUPPORTED_CH_IE_  36
 #define _CH_SWTICH_ANNOUNCE_   37  /* Secondary Channel Offset */
 #define _ERPINFO_IE_   42
-- 
2.25.1



[PATCH v2 14/21] staging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _EXT_SUPPORTEDRATES_IE_ macro with kernel provided
WLAN_EID_EXT_SUPP_RATES from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c|  2 +-
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 18 +-
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c |  2 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   |  4 ++--
 drivers/staging/rtl8723bs/include/wifi.h   |  1 -
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 5e93a85cb6ce..b6f944b37b08 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1043,7 +1043,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* get ext_supported rates */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _EXT_SUPPORTEDRATES_IE_,
+   WLAN_EID_EXT_SUPP_RATES,
&ie_len,
pbss_network->IELength - _BEACON_IE_OFFSET_
);
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index b899f511ff9f..28d5892d8bda 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -344,7 +344,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
 
if (rateLen > 8) {
ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, 
pdev_network->SupportedRates, &sz);
-   /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz); */
+   /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz); */
} else {
ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, 
pdev_network->SupportedRates, &sz);
}
@@ -357,7 +357,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 
*)&(pdev_network->Configuration.ATIMWindow), &sz);
 
if (rateLen > 8) {
-   ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz);
}
 
/* HT Cap. */
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 5d56fbf0c1fe..e9b14fc8b10f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -783,7 +783,7 @@ unsigned int OnBeacon(struct adapter *padapter, union 
recv_frame *precv_frame)
u8 *p = NULL;
u32 ielen = 0;
 
-   p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + 
_BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, precv_frame->u.hdr.len - 
sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_);
+   p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + 
_BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, precv_frame->u.hdr.len - 
sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_);
if (p && ielen > 0) {
if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) {
/* Invalid value 0x2D is detected in Extended Supported 
Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */
@@ -1284,7 +1284,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
memcpy(supportRate, p+2, ie_len);
supportRateNum = ie_len;
 
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, 
_EXT_SUPPORTEDRATES_IE_, &ie_len,
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, 
WLAN_EID_EXT_SUPP_RATES, &ie_len,
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
if (p !=  NULL) {
 
@@ -2561,7 +2561,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
 
/*  EXTERNDED SUPPORTED RATE */
if (rate_len > 8) {
-   pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len 
- 8), (cur_network->SupportedRates + 8), &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len 
- 8), (cur_network->SupportedRates + 8), &pattrib->pktlen);
}
 
 
@@ -2764,7 +2764,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
 
/*  EXTERNDED SUPPORTED RATE */
if (rate_len > 8) {
-   pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, 
(rate_len - 8), (cur_network->SupportedRates + 8), &patt

[PATCH v2 13/21] staging: rtl8723bs: replace _ERPINFO_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _ERPINFO_IE_ macro with kernel provided WLAN_EID_ERP_INFO
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c| 12 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  |  6 +++---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c  |  2 +-
 drivers/staging/rtl8723bs/include/wifi.h   |  1 -
 5 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 139350288d1b..5e93a85cb6ce 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1059,7 +1059,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* parsing ERP_IE */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _ERPINFO_IE_,
+   WLAN_EID_ERP_INFO,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
@@ -1585,7 +1585,7 @@ static void update_bcn_erpinfo_ie(struct adapter 
*padapter)
/* parsing ERP_IE */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _ERPINFO_IE_,
+   WLAN_EID_ERP_INFO,
&len,
(pnetwork->IELength - _BEACON_IE_OFFSET_)
);
@@ -1768,7 +1768,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _ERPINFO_IE_:
+   case WLAN_EID_ERP_INFO:
 
update_bcn_erpinfo_ie(padapter);
 
@@ -1964,7 +1964,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, 
struct sta_info *psta)
 
if (pmlmepriv->num_sta_non_erp == 1) {
beacon_updated = true;
-   update_beacon(padapter, _ERPINFO_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_ERP_INFO, 
NULL, true);
}
}
} else {
@@ -1975,7 +1975,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, 
struct sta_info *psta)
 
if (pmlmepriv->num_sta_non_erp == 0) {
beacon_updated = true;
-   update_beacon(padapter, _ERPINFO_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_ERP_INFO, 
NULL, true);
}
}
}
@@ -2086,7 +2086,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, 
struct sta_info *psta)
pmlmepriv->num_sta_non_erp--;
if (pmlmepriv->num_sta_non_erp == 0) {
beacon_updated = true;
-   update_beacon(padapter, _ERPINFO_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true);
}
}
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 93380493e8dc..5d56fbf0c1fe 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1705,7 +1705,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union 
recv_frame *precv_frame)
HT_info_handler(padapter, pIE);
break;
 
-   case _ERPINFO_IE_:
+   case WLAN_EID_ERP_INFO:
ERP_IE_handler(padapter, pIE);
break;
 
@@ -2555,7 +2555,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned 
char *)(&ATIMWindow), &pattrib->pktlen);
 
/* ERP IE */
-   pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, 
&pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, 
&pattrib->pktlen);
}
 
 
@@ -2758,7 +2758,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, 
(unsigned char *)(&ATIMWindow), &pattrib->pktlen);
 
/* ERP IE */
-   pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, 
&pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, 
&erpinfo, &pattrib->pktlen);
}
 
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index ff5125b33749..e8e91e24c04d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1479,7 +1479,7 @@ void update_beacon_info(struct adapter *padapter, u8 
*pframe, uint pkt_len, stru
bwmode_upd

[PATCH v2 07/21] staging: rtl8723bs: replace _SUPPORTEDRATES_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _SUPPORTEDRATES_IE_ macro with kernel provided
WLAN_EID_SUPP_RATES from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   |  4 ++--
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 24 +--
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  2 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  |  6 ++---
 drivers/staging/rtl8723bs/include/wifi.h  |  1 -
 6 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index aaa7edbebe2c..99a34c059f6d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -110,7 +110,7 @@ static void update_BCNTIM(struct adapter *padapter)
/*  get supported rates len */
p = rtw_get_ie(
pie + _BEACON_IE_OFFSET_,
-   _SUPPORTEDRATES_IE_, &tmp_len,
+   WLAN_EID_SUPP_RATES, &tmp_len,
(pnetwork_mlmeext->IELength - 
_BEACON_IE_OFFSET_)
);
if (p)
@@ -1031,7 +1031,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/*  get supported rates */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _SUPPORTEDRATES_IE_,
+   WLAN_EID_SUPP_RATES,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index daaa826add35..e0896e128dda 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -343,10 +343,10 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
rateLen = rtw_get_rateset_len(pdev_network->SupportedRates);
 
if (rateLen > 8) {
-   ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, 
pdev_network->SupportedRates, &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, 
pdev_network->SupportedRates, &sz);
/* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz); */
} else {
-   ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, 
pdev_network->SupportedRates, &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, 
pdev_network->SupportedRates, &sz);
}
 
/* DS parameter set */
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 983fcaae6eca..b9e612e1e162 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1271,7 +1271,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
goto OnAssocReqFail;
 
/*  check if the supported rate is ok */
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, 
_SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, 
WLAN_EID_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
if (p == NULL) {
DBG_871X("Rx a sta assoc-req which supported rate is empty!\n");
/*  use our own rate set as statoin used */
@@ -2540,7 +2540,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
 
/*  supported rates... */
rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : 
rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : 
rate_len), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pattrib->pktlen);
@@ -2744,7 +2744,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
 
/*  supported rates... */
rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
-   pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 
8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 
8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen);
 
/*  DS parameter set */
pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char 
*)&(cur_network->Configuration.DSConfig), &pa

[PATCH v2 10/21] staging: rtl8723bs: replace _IBSS_PARA_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _IBSS_PARA_IE_ macro with kernel provided
WLAN_EID_IBSS_PARAMS from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 4 ++--
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   | 2 +-
 drivers/staging/rtl8723bs/include/wifi.h   | 1 -
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 58e29314c8f8..b899f511ff9f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -354,7 +354,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
 
/* IBSS Parameter Set */
 
-   ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 
*)&(pdev_network->Configuration.ATIMWindow), &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 
*)&(pdev_network->Configuration.ATIMWindow), &sz);
 
if (rateLen > 8) {
ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), 
(pdev_network->SupportedRates + 8), &sz);
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 1f6c1e441744..546e4a31142b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -2552,7 +2552,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
/*  IBSS Parameter Set... */
/* ATIMWindow = cur->Configuration.ATIMWindow; */
ATIMWindow = 0;
-   pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char 
*)(&ATIMWindow), &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned 
char *)(&ATIMWindow), &pattrib->pktlen);
 
/* ERP IE */
pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, 
&pattrib->pktlen);
@@ -2755,7 +2755,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
/*  IBSS Parameter Set... */
/* ATIMWindow = cur->Configuration.ATIMWindow; */
ATIMWindow = 0;
-   pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, 
(unsigned char *)(&ATIMWindow), &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, 
(unsigned char *)(&ATIMWindow), &pattrib->pktlen);
 
/* ERP IE */
pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, 
&pattrib->pktlen);
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
index ac6677212086..f6073ecef2e2 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
@@ -189,7 +189,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 
*pframe, u32 *pLength)
/*  IBSS Parameter Set... */
/* ATIMWindow = cur->Configuration.ATIMWindow; */
ATIMWindow = 0;
-   pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char 
*)(&ATIMWindow), &pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned 
char *)(&ATIMWindow), &pktlen);
}
 
 
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index dc11ba28d469..3adeb3c23a3c 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
 
 #define _FIXED_IE_LENGTH_  _BEACON_IE_OFFSET_
 
-#define _IBSS_PARA_IE_ 6
 #define _COUNTRY_IE_   7
 #define _CHLGETXT_IE_  16
 #define _SUPPORTED_CH_IE_  36
-- 
2.25.1



[PATCH v2 09/21] staging: rtl8723bs: replace _TIM_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _TIM_IE_ macro with kernel provided WLAN_EID_DS_PARAMS
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   | 10 +-
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |  2 +-
 drivers/staging/rtl8723bs/core/rtw_recv.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  8 
 drivers/staging/rtl8723bs/include/wifi.h  |  1 -
 5 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 1514975f23bc..139350288d1b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -76,7 +76,7 @@ static void update_BCNTIM(struct adapter *padapter)
 
p = rtw_get_ie(
pie + _FIXED_IE_LENGTH_,
-   _TIM_IE_,
+   WLAN_EID_TIM,
&tim_ielen,
pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_
);
@@ -133,7 +133,7 @@ static void update_BCNTIM(struct adapter *padapter)
memcpy(pbackup_remainder_ie, premainder_ie, 
remainder_ielen);
}
 
-   *dst_ie++ = _TIM_IE_;
+   *dst_ie++ = WLAN_EID_TIM;
 
if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 
0x00fe))
tim_ielen = 5;
@@ -301,7 +301,7 @@ void expire_timeout_chk(struct adapter *padapter)
 
/* to update bcn with tim_bitmap for 
this station */
pstapriv->tim_bitmap |= BIT(psta->aid);
-   update_beacon(padapter, _TIM_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_TIM, 
NULL, true);
 
if (!pmlmeext->active_keep_alive_check)
continue;
@@ -922,7 +922,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
);
 
if (pmlmeext->bstart_bss) {
-   update_beacon(padapter, _TIM_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_TIM, NULL, true);
 
 #ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will  tx beacon when bcn 
interrupt coming in. */
/* issue beacon frame */
@@ -1762,7 +1762,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _TIM_IE_:
+   case WLAN_EID_TIM:
 
update_BCNTIM(padapter);
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 1d0a7690acde..3fe79169a811 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -1703,7 +1703,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
pstapriv->sta_dz_bitmap &= ~BIT(0);
 
if (update_tim)
-   update_beacon(padapter, _TIM_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_TIM, NULL, 
true);
} else {/* re check again */
rtw_chk_hi_queue_cmd(padapter);
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 2bb501f2113c..3c9dbd7443d9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1158,7 +1158,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, 
union recv_frame *precv_
 
/* update BCN for TIM IE */
/* update_BCNTIM(padapter); */
-   update_beacon(padapter, _TIM_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_TIM, 
NULL, true);
}
 
/* spin_unlock_bh(&psta->sleep_q.lock); */
@@ -1184,7 +1184,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, 
union recv_frame *precv_
 
/* update BCN for TIM IE */
/* update_BCNTIM(padapter); */
-   update_beacon(padapter, _TIM_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_TIM, 
NULL, true);
}
}
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index f9ef7dc84e55..1d62ce501e80 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -2251,7 +2251,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter 
*padapter, struct xmit_fr
 

[PATCH v2 06/21] staging: rtl8723bs: replace _SSID_IE_

2020-12-07 Thread Ross Schmidt
Replace unique _SSID_IE_ macro with kernel provided WLAN_EID_SSID from
linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   |  4 ++--
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 +--
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  2 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  |  6 +++---
 drivers/staging/rtl8723bs/include/wifi.h  |  1 -
 6 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index e44c01de3b10..aaa7edbebe2c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -100,7 +100,7 @@ static void update_BCNTIM(struct adapter *padapter)
/* get ssid_ie len */
p = rtw_get_ie(
pie + _BEACON_IE_OFFSET_,
-   _SSID_IE_,
+   WLAN_EID_SSID,
&tmp_len,
(pnetwork_mlmeext->IELength - 
_BEACON_IE_OFFSET_)
);
@@ -1004,7 +1004,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* SSID */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _SSID_IE_,
+   WLAN_EID_SSID,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 182cc8c0b7d3..daaa826add35 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -326,7 +326,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
ie += 2;
 
/* SSID */
-   ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, 
pdev_network->Ssid.Ssid, &sz);
+   ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->Ssid.SsidLength, 
pdev_network->Ssid.Ssid, &sz);
 
/* supported rates */
if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b829264b8aff..983fcaae6eca 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -728,7 +728,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union 
recv_frame *precv_frame)
 
 #endif /* CONFIG_AUTO_AP_MODE */
 
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, 
_SSID_IE_, (int *)&ielen,
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, 
WLAN_EID_SSID, (int *)&ielen,
len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
 
 
@@ -1251,7 +1251,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
 
/*  now we should check all the fields... */
/*  checking SSID */
-   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len,
+   p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SSID, 
&ie_len,
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
 
if (!p || ie_len == 0) {
@@ -2536,7 +2536,7 @@ void issue_beacon(struct adapter *padapter, int 
timeout_ms)
pattrib->pktlen += 2;
 
/*  SSID */
-   pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, 
cur_network->Ssid.Ssid, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 
cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen);
 
/*  supported rates... */
rate_len = rtw_get_rateset_len(cur_network->SupportedRates);
@@ -2692,7 +2692,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
u8 buf[MAX_IE_SZ];
u8 *ies = 
pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr);
 
-   ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, _SSID_IE_, 
&ssid_ielen,
+   ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, 
WLAN_EID_SSID, &ssid_ielen,
(pframe-ies)-_FIXED_IE_LENGTH_);
 
ssid_ielen_diff = cur_network->Ssid.SsidLength - 
ssid_ielen;
@@ -2740,7 +2740,7 @@ void issue_probersp(struct adapter *padapter, unsigned 
char *da, u8 is_valid_p2p
/* below for ad-hoc mode */
 
/*  SSID */
-   pframe = rtw_set_ie(pframe, _SSID_IE_, 
cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen);
+   pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 
cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen);
 

[PATCH v2 04/21] staging: rtl8723bs: use WLAN_EID_HT_OPERATION

2020-12-07 Thread Ross Schmidt
Replace unique _HT_EXTRA_INFO_IE_ and _HT_ADD_INFO_IE_ macros with kernel
provided WLAN_EID_HT_OPERATION from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c| 10 +-
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c  |  8 
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  |  8 
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c |  6 +++---
 drivers/staging/rtl8723bs/include/wifi.h   |  2 --
 6 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 7cab9889140e..e44c01de3b10 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -855,7 +855,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
/* set channel, bwmode */
p = rtw_get_ie(
(pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)),
-   _HT_ADD_INFO_IE_,
+   WLAN_EID_HT_OPERATION,
&ie_len,
(pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie))
);
@@ -1235,7 +1235,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* parsing HT_INFO_IE */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _HT_ADD_INFO_IE_,
+   WLAN_EID_HT_OPERATION,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
@@ -1786,7 +1786,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _HT_ADD_INFO_IE_:
+   case WLAN_EID_HT_OPERATION:
 
update_bcn_htinfo_ie(padapter);
 
@@ -2053,7 +2053,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, 
struct sta_info *psta)
 
if (rtw_ht_operation_update(padapter) > 0) {
update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
-   update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true);
}
 
/* update associated stations cap. */
@@ -2117,7 +2117,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, 
struct sta_info *psta)
 
if (rtw_ht_operation_update(padapter) > 0) {
update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
-   update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true);
}
 
/* update associated stations cap. */
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 4ab34d71b09b..ff4f493e8dcd 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1217,7 +1217,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
pnetwork->BcnInfo.ht_cap_info = 0;
}
/* parsing HT_INFO_IE */
-   p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, 
_HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
+   p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, 
WLAN_EID_HT_OPERATION, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
if (p && len > 0) {
pht_info = (struct HT_info_element *)(p + 2);
pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0];
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 1d4e565a314b..d05338015744 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2616,7 +2616,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
/* TDLS: TODO 40? */
operation_bw = CHANNEL_WIDTH_40;
} else {
-   p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len);
+   p = rtw_get_ie(in_ie, WLAN_EID_HT_OPERATION, &ielen, in_len);
if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
struct HT_info_element *pht_info = (struct 
HT_info_element *)(p+2);
 
@@ -2724,10 +2724,10 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
phtpriv->ht_option = true;
 
if (in_ie) {
-   p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len);
+   p = rtw_get_ie(in_ie, WLAN_EID_HT_OPERATION, &ielen, in_len);
if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
out_len = *pout_len;
-   pframe = rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, 
ielen, p+2, pout_le

[PATCH v2 01/21] staging: rtl8723bs: use WLAN_EID_HT_CAPABILITY

2020-12-07 Thread Ross Schmidt
Replace unique WLAN_EID_HT_CAP, _HT_CAPABILITY_IE_, and EID_HTCapability
with kernel provided WLAN_EID_HT_CAPABILITY from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c|  8 
 drivers/staging/rtl8723bs/core/rtw_cmd.c   |  2 +-
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme.c  |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 14 +++---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h  |  1 -
 drivers/staging/rtl8723bs/include/wifi.h   |  1 -
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c |  6 +++---
 9 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 04d5852d0d3e..87605d425a31 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1172,7 +1172,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* parsing HT_CAP_IE */
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _HT_CAPABILITY_IE_,
+   WLAN_EID_HT_CAPABILITY,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
@@ -1774,7 +1774,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _HT_CAPABILITY_IE_:
+   case WLAN_EID_HT_CAPABILITY:
 
update_bcn_htcap_ie(padapter);
 
@@ -2052,7 +2052,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, 
struct sta_info *psta)
}
 
if (rtw_ht_operation_update(padapter) > 0) {
-   update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false);
+   update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
}
 
@@ -2116,7 +2116,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, 
struct sta_info *psta)
}
 
if (rtw_ht_operation_update(padapter) > 0) {
-   update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false);
+   update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true);
}
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index f6160f1cca43..1d0a7690acde 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -842,7 +842,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
}
 
phtpriv->ht_option = false;
-   ptmp = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, 
&tmp_len, pnetwork->network.IELength-12);
+   ptmp = rtw_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY, 
&tmp_len, pnetwork->network.IELength-12);
if (pregistrypriv->ht_enable && ptmp && tmp_len > 0) {
/*  Added by Albert 2010/06/23 */
/*  For the WEP mode, we will use the bg mode to do the 
connection to avoid some IOT issue. */
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index e80b957f947f..23ba4160ab21 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -1056,7 +1056,7 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
elems->timeout_int = pos;
elems->timeout_int_len = elen;
break;
-   case WLAN_EID_HT_CAP:
+   case WLAN_EID_HT_CAPABILITY:
elems->ht_capabilities = pos;
elems->ht_capabilities_len = elen;
break;
@@ -1209,7 +1209,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
 
/* get bwmode and ch_offset */
/* parsing HT_CAP_IE */
-   p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, 
_HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
+   p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, 
WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_);
if (p && len > 0) {
pht_cap = (struct ieee80211_ht_cap *)(p + 2);
pnetwork->BcnInfo.ht_cap_info = 
le16_to_cpu(pht_cap->cap_info);
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b1737fbeb33f..f32cf36ea949 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2718,7 +2718,7 @@ unsigned int rtw_restr

[PATCH v2 03/21] staging: rtl8723bs: use WLAN_EID_RSN

2020-12-07 Thread Ross Schmidt
Replace unique _WPA2_IE_ID_, EID_WPA2, and _RSN_IE_2_ with kernel provided
WLAN_EID_RSN from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c  | 4 ++--
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c   | 6 +++---
 drivers/staging/rtl8723bs/core/rtw_mlme.c| 8 
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c| 4 ++--
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c   | 2 +-
 drivers/staging/rtl8723bs/include/rtw_security.h | 2 --
 drivers/staging/rtl8723bs/include/wifi.h | 1 -
 7 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index c8953b442734..7cab9889140e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1080,7 +1080,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_;
p = rtw_get_ie(
ie + _BEACON_IE_OFFSET_,
-   _RSN_IE_2_,
+   WLAN_EID_RSN,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_)
);
@@ -1780,7 +1780,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _RSN_IE_2_:
+   case WLAN_EID_RSN:
 
update_bcn_rsn_ie(padapter);
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 86a5114d1241..4ab34d71b09b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -424,7 +424,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int 
*wpa_ie_len, int limit)
 
 unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
 {
-   return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
+   return rtw_get_ie(pie, WLAN_EID_RSN, rsn_ie_len, limit);
 }
 
 int rtw_get_wpa_cipher_suite(u8 *s)
@@ -544,7 +544,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
return _FAIL;
}
 
-   if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) 
{
+   if ((*rsn_ie != WLAN_EID_RSN) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) 
{
return _FAIL;
}
 
@@ -683,7 +683,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 
*rsn_len, u8 *wpa_ie
*wpa_len = in_ie[cnt+1]+2;
cnt += in_ie[cnt+1]+2;  /* get next */
} else {
-   if (authmode == _WPA2_IE_ID_) {
+   if (authmode == WLAN_EID_RSN) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2));
 
if (rsn_ie) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 50129a3e67e0..1d4e565a314b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -736,7 +736,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
bselected = false;
 
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
-   p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
+   p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
if (p && ie_len > 0)
bselected = true;
else
@@ -2361,13 +2361,13 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 
*in_ie, u8 *out_ie, uint in
if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == 
Ndis802_11AuthModeWPAPSK))
authmode = WLAN_EID_VENDOR_SPECIFIC;
if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == 
Ndis802_11AuthModeWPA2PSK))
-   authmode = _WPA2_IE_ID_;
+   authmode = WLAN_EID_RSN;
 
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
memcpy(out_ie+ielength, psecuritypriv->wps_ie, 
psecuritypriv->wps_ie_len);
 
ielength += psecuritypriv->wps_ie_len;
-   } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == 
_WPA2_IE_ID_)) {
+   } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == 
WLAN_EID_RSN)) {
/* copy RSN or SSN */
memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], 
psecuritypriv->supplicant_ie[1]+2);
/* debug for CONFIG_IEEE

[PATCH v2 02/21] staging: rtl8723bs: use WLAN_EID_VENDOR_SPECIFIC

2020-12-07 Thread Ross Schmidt
Replace unique WLAN_EID_GENERIC, _WPA_IE_ID_, _SSN_IE_1_, and
_VENDOR_SPECIFIC_IE_ macros with kernel provided WLAN_EID_VENDOR_SPECIFIC
from linux/ieee80211.h.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   |  6 +++---
 .../staging/rtl8723bs/core/rtw_ieee80211.c| 12 +--
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  6 +++---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 +--
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  6 +++---
 drivers/staging/rtl8723bs/include/ieee80211.h |  1 -
 .../staging/rtl8723bs/include/rtw_security.h  |  1 -
 drivers/staging/rtl8723bs/include/wifi.h  |  2 --
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  4 ++--
 .../staging/rtl8723bs/os_dep/ioctl_linux.c|  8 
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |  2 +-
 11 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 87605d425a31..c8953b442734 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1110,7 +1110,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) {
p = rtw_get_ie(
p,
-   _SSN_IE_1_,
+   WLAN_EID_VENDOR_SPECIFIC,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len 
+ 2))
);
@@ -1146,7 +1146,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) {
p = rtw_get_ie(
p,
-   _VENDOR_SPECIFIC_IE_,
+   WLAN_EID_VENDOR_SPECIFIC,
&ie_len,
(pbss_network->IELength - _BEACON_IE_OFFSET_ - 
(ie_len + 2))
);
@@ -1792,7 +1792,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 
*oui, u8 tx)
 
break;
 
-   case _VENDOR_SPECIFIC_IE_:
+   case WLAN_EID_VENDOR_SPECIFIC:
 
update_bcn_vendor_spec_ie(padapter, oui);
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 23ba4160ab21..86a5114d1241 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -383,7 +383,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int 
*wpa_ie_len, int limit)
__le16 le_tmp;
 
while (1) {
-   pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new);
+   pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &len, 
limit_new);
 
if (pbuf) {
/* check if oui matches... */
@@ -471,7 +471,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher, int *pairwis
return _FAIL;
}
 
-   if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) ||
+   if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || (*(wpa_ie+1) != 
(u8)(wpa_ie_len - 2)) ||
   (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) {
return _FAIL;
}
@@ -667,7 +667,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 
*rsn_len, u8 *wpa_ie
while (cnt < in_len) {
authmode = in_ie[cnt];
 
-   if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], 
&wpa_oui[0], 4))) {
+   if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && 
(!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, 
in_ie[cnt+1]+2));
 
if (wpa_ie) {
@@ -715,7 +715,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
 
eid = ie_ptr[0];
 
-   if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) {
+   if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 
4))) {
/* DBG_8192C("==> found WPS_IE.\n"); */
*wps_ielen = ie_ptr[1]+2;
match = true;
@@ -749,7 +749,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint 
*wps_ielen)
while (cnt < in_len) {
eid = in_ie[cnt];
 
-   if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 
4))) {
+   if ((eid == WLAN_EID_VENDOR_SPECIFIC) && 
(!memcmp(&in_ie[cnt+2], wps_oui, 4))) {
wpsie_ptr = &in_ie[cnt];
 
if (wps_ie)
@@ -788,7 +788,7 @@ u8 *rtw_get_wps_attr(u8

[PATCH v2 00/21] replace unique macros and ELEMENT_ID

2020-12-07 Thread Ross Schmidt
This patch set replaces many macros and the ELEMENT_ID enum with the
ieee80211_eid enum from linux/ieee80211.h. In several cases more than
one macro or constant is replaced by one constant. As suggested, each
constant replacement is separated into a distinct patch.

Changes in v2:
- Single patch divided into per-constant replacement patches

v1 can be found here:
https://lore.kernel.org/driverdev-devel/20201206034517.4276-10-ross.schm@gmail.com/

Ross Schmidt (21):
  staging: rtl8723bs: use WLAN_EID_HT_CAPABILITY
  staging: rtl8723bs: use WLAN_EID_VENDOR_SPECIFIC
  staging: rtl8723bs: use WLAN_EID_RSN
  staging: rtl8723bs: use WLAN_EID_HT_OPERATION
  staging: rtl8723bs: replace WLAN_EID_VHT_OP_MODE_NOTIFY
  staging: rtl8723bs: replace _SSID_IE_
  staging: rtl8723bs: replace _SUPPORTEDRATES_IE_
  staging: rtl8723bs: replace _DSSET_IE_
  staging: rtl8723bs: replace _TIM_IE_
  staging: rtl8723bs: replace _IBSS_PARA_IE_
  staging: rtl8723bs: replace _COUNTRY_IE_
  staging: rtl8723bs: replace _CHLGETXT_IE_
  staging: rtl8723bs: replace _ERPINFO_IE_
  staging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_
  staging: rtl8723bs: replace _WAPI_IE_
  staging: rtl8723bs: replace _MME_IE_
  staging: rtl8723bs: replace EID_BSSCoexistence
  staging: rtl8723bs: replace EID_BSSIntolerantChlReport
  staging: rtl8723bs: replace EID_EXTCapability
  staging: rtl8723bs: remove unused macros
  staging: rtl8723bs: remove ELEMENT_ID enum

 drivers/staging/rtl8723bs/core/rtw_ap.c   |  62 
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |   4 +-
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  44 +++---
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  26 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 146 +-
 drivers/staging/rtl8723bs/core/rtw_recv.c |   4 +-
 drivers/staging/rtl8723bs/core/rtw_security.c |   2 +-
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  26 ++--
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  12 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  |  20 +--
 drivers/staging/rtl8723bs/include/ieee80211.h |   8 -
 .../staging/rtl8723bs/include/rtw_security.h  |   3 -
 drivers/staging/rtl8723bs/include/wifi.h  | 108 -
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c |   4 +-
 .../staging/rtl8723bs/os_dep/ioctl_linux.c|  14 +-
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |   2 +-
 16 files changed, 183 insertions(+), 302 deletions(-)

-- 
2.25.1



[PATCH 07/10] staging: rtl8723bs: replace RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK

2020-12-05 Thread Ross Schmidt
Replace unique macro RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK with kernel
provided IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK.  The other
IEEE80211_ADDBA_* and IEEE_DELBA_* macros are duplicates already defined
in linux/ieee80211.h, remove them.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 +++---
 drivers/staging/rtl8723bs/include/wifi.h  | 7 ---
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 0743e56582ba..166b5369b003 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3943,7 +3943,7 @@ void issue_action_BA(struct adapter *padapter, unsigned 
char *raddr, unsigned ch
/*  TID */
BA_para_set |= (status << 2) & 
IEEE80211_ADDBA_PARAM_TID_MASK;
/*  max buffer size is 8 MSDU */
-   BA_para_set |= (8 << 6) & 
RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
+   BA_para_set |= (8 << 6) & 
IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
} else {
BA_para_set = (0x1002 | ((status & 0xf) << 2)); 
/* immediate ack & 64 buffer size */
}
@@ -3994,8 +3994,8 @@ void issue_action_BA(struct adapter *padapter, unsigned 
char *raddr, unsigned ch
if (hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter) &&
padapter->driver_rx_ampdu_factor == 0xFF) {
/*  max buffer size is 8 MSDU */
-   BA_para_set &= 
~RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
-   BA_para_set |= (8 << 6) & 
RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
+   BA_para_set &= 
~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
+   BA_para_set |= (8 << 6) & 
IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
}
 
if (pregpriv->ampdu_amsdu == 0)/* disabled */
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 2e8ca191c608..c3a4a0bad0d7 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -653,13 +653,6 @@ struct ADDBA_request {
 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT   0x0004
 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT   0x0010
 
-/* block-ack parameters */
-#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
-#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
-#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
-#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
-#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
-
 /*
  * A-PMDU buffer sizes
  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
-- 
2.25.1



[PATCH 02/10] staging: rtl8723bs: replace WIFI_REASON_CODE

2020-12-05 Thread Ross Schmidt
Replace unique macros and WIFI_REASON_CODE enum with the kernel provided
ieee80211_reasoncode.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  4 +--
 drivers/staging/rtl8723bs/include/wifi.h  | 36 ---
 2 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index ab4876507198..6dab68033941 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1210,7 +1210,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
 
pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (!pstat) {
-   status = _RSON_CLS2_;
+   status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
goto asoc_class2_error;
}
 
@@ -1226,7 +1226,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
/*  check if this stat has been successfully authenticated/assocated */
if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) {
if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) {
-   status = _RSON_CLS2_;
+   status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
goto asoc_class2_error;
} else {
pstat->state &= (~WIFI_FW_ASSOC_SUCCESS);
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 8e0ec95c1339..fe9c3a4ffe7f 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -88,42 +88,6 @@ enum WIFI_FRAME_SUBTYPE {
 WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE),
 };
 
-enum WIFI_REASON_CODE  {
-   _RSON_RESERVED_ = 0,
-   _RSON_UNSPECIFIED_  = 1,
-   _RSON_AUTH_NO_LONGER_VALID_ = 2,
-   _RSON_DEAUTH_STA_LEAVING_   = 3,
-   _RSON_INACTIVITY_   = 4,
-   _RSON_UNABLE_HANDLE_= 5,
-   _RSON_CLS2_ = 6,
-   _RSON_CLS3_ = 7,
-   _RSON_DISAOC_STA_LEAVING_   = 8,
-   _RSON_ASOC_NOT_AUTH_= 9,
-
-   /*  WPA reason */
-   _RSON_INVALID_IE_   = 13,
-   _RSON_MIC_FAILURE_  = 14,
-   _RSON_4WAY_HNDSHK_TIMEOUT_  = 15,
-   _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
-   _RSON_DIFF_IE_  = 17,
-   _RSON_MLTCST_CIPHER_NOT_VALID_  = 18,
-   _RSON_UNICST_CIPHER_NOT_VALID_  = 19,
-   _RSON_AKMP_NOT_VALID_   = 20,
-   _RSON_UNSUPPORT_RSNE_VER_   = 21,
-   _RSON_INVALID_RSNE_CAP_ = 22,
-   _RSON_IEEE_802DOT1X_AUTH_FAIL_  = 23,
-
-   /* belowing are Realtek definition */
-   _RSON_PMK_NOT_AVAILABLE_= 24,
-   _RSON_TDLS_TEAR_TOOFAR_ = 25,
-   _RSON_TDLS_TEAR_UN_RSN_ = 26,
-};
-
-/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) */
-/* IEEE 802.11h */
-#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
-#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
-
 enum WIFI_REG_DOMAIN {
DOMAIN_FCC  = 1,
DOMAIN_IC   = 2,
-- 
2.25.1



[PATCH 09/10] staging: rtl8723bs: remove LIST_CONTAINOR

2020-12-05 Thread Ross Schmidt
Remove unnecessary macro for container_of and call it directly.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   | 16 +++---
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 18 +++
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  6 ++---
 drivers/staging/rtl8723bs/core/rtw_recv.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c  | 12 +-
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 22 +--
 .../staging/rtl8723bs/hal/rtl8723bs_xmit.c|  6 ++---
 .../rtl8723bs/include/osdep_service_linux.h   |  4 
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  6 ++---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 10 -
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c |  2 +-
 12 files changed, 52 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 27446156ed34..04d5852d0d3e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -223,7 +223,7 @@ void expire_timeout_chk(struct adapter *padapter)
}
#endif
while (phead != plist) {
-   psta = LIST_CONTAINOR(plist, struct sta_info, auth_list);
+   psta = container_of(plist, struct sta_info, auth_list);
 
plist = get_next(plist);
 
@@ -268,7 +268,7 @@ void expire_timeout_chk(struct adapter *padapter)
}
#endif
while (phead != plist) {
-   psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
+   psta = container_of(plist, struct sta_info, asoc_list);
plist = get_next(plist);
 #ifdef CONFIG_AUTO_AP_MODE
if (psta->isrc)
@@ -1344,7 +1344,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = get_next(phead);
 
while (phead != plist) {
-   paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, 
list);
+   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
plist = get_next(plist);
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1405,7 +1405,7 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 
*addr)
plist = get_next(phead);
 
while (phead != plist) {
-   paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, 
list);
+   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
plist = get_next(plist);
 
if (
@@ -1912,7 +1912,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = LIST_CONTAINOR(plist, struct sta_info, 
asoc_list);
+   psta = container_of(plist, struct sta_info, asoc_list);
 
plist = get_next(plist);
 
@@ -2193,7 +2193,7 @@ void rtw_sta_flush(struct adapter *padapter)
 
/* free sta asoc_queue */
while (phead != plist) {
-   psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
+   psta = container_of(plist, struct sta_info, asoc_list);
 
plist = get_next(plist);
 
@@ -2297,7 +2297,7 @@ void rtw_ap_restore_network(struct adapter *padapter)
while (phead != plist) {
int stainfo_offset;
 
-   psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
+   psta = container_of(plist, struct sta_info, asoc_list);
plist = get_next(plist);
 
stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
@@ -2402,7 +2402,7 @@ void stop_ap_mode(struct adapter *padapter)
phead = get_list_head(pacl_node_q);
plist = get_next(phead);
while (phead != plist) {
-   paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, 
list);
+   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
plist = get_next(plist);
 
if (paclnode->valid) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 4e1301261a01..f6160f1cca43 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -287,7 +287,7 @@ struct  cmd_obj *_rtw_dequeue_cmd(struct __queue *queue)
if (list_empty(&(queue->queue)))
obj = NULL;
else {
-   obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, 
list);
+   obj = container_of(get_next(&(queue->queue)), struct cmd_obj, 
list);
list_del_init(&obj->list);
}
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index e20e0ce4a2c5..f05fcf9892e5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c

[PATCH 04/10] staging: rtl8723bs: replace HT_CAP_AMPDU_FACTOR

2020-12-05 Thread Ross Schmidt
Replace unique HT_CAP_AMPDU_FACTOR enum with kernel provided
ieee80211_max_ampdu_length_exp enum.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 12 ++--
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c |  2 +-
 drivers/staging/rtl8723bs/hal/sdio_halinit.c  |  2 +-
 drivers/staging/rtl8723bs/include/wifi.h  |  7 ---
 5 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 001cce312f05..e20e0ce4a2c5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2580,7 +2580,7 @@ void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 
*out_ie, uint *pout_len)
 unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 
*out_ie, uint in_len, uint *pout_len, u8 channel)
 {
u32 ielen, out_len;
-   enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor;
+   enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor;
unsigned char *p, *pframe;
struct ieee80211_ht_cap ht_capie;
u8 cbw40_enable = 0, stbc_rx_enable = 0, rf_type = 0, operation_bw = 0;
@@ -2698,7 +2698,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
 
if (padapter->driver_rx_ampdu_factor != 0xFF)
max_rx_ampdu_factor =
- (enum HT_CAP_AMPDU_FACTOR)padapter->driver_rx_ampdu_factor;
+ (enum 
ieee80211_max_ampdu_length_exp)padapter->driver_rx_ampdu_factor;
else
rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR,
&max_rx_ampdu_factor);
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 239c89ce7dc9..0743e56582ba 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -3880,7 +3880,7 @@ void issue_action_BA(struct adapter *padapter, unsigned 
char *raddr, unsigned ch
u16 reason_code;
u16 BA_timeout_value;
u16 BA_starting_seqctrl = 0;
-   enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor;
+   enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor;
struct xmit_frame   *pmgntframe;
struct pkt_attrib   *pattrib;
u8  *pframe;
@@ -3975,18 +3975,18 @@ void issue_action_BA(struct adapter *padapter, unsigned 
char *raddr, unsigned ch
pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char 
*)(&status), &(pattrib->pktlen));
if (padapter->driver_rx_ampdu_factor != 0xFF)
max_rx_ampdu_factor =
- (enum 
HT_CAP_AMPDU_FACTOR)padapter->driver_rx_ampdu_factor;
+ (enum 
ieee80211_max_ampdu_length_exp)padapter->driver_rx_ampdu_factor;
else
rtw_hal_get_def_var(padapter,
HW_VAR_MAX_RX_AMPDU_FACTOR, 
&max_rx_ampdu_factor);
 
-   if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor)
+   if (IEEE80211_HT_MAX_AMPDU_64K == max_rx_ampdu_factor)
BA_para_set = 
((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer 
size */
-   else if (MAX_AMPDU_FACTOR_32K == max_rx_ampdu_factor)
+   else if (IEEE80211_HT_MAX_AMPDU_32K == 
max_rx_ampdu_factor)
BA_para_set = 
((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer 
size */
-   else if (MAX_AMPDU_FACTOR_16K == max_rx_ampdu_factor)
+   else if (IEEE80211_HT_MAX_AMPDU_16K == 
max_rx_ampdu_factor)
BA_para_set = 
((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer 
size */
-   else if (MAX_AMPDU_FACTOR_8K == max_rx_ampdu_factor)
+   else if (IEEE80211_HT_MAX_AMPDU_8K == 
max_rx_ampdu_factor)
BA_para_set = 
((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer 
size */
else
BA_para_set = 
((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer 
size */
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index de8caa6cd418..84e963909283 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -4373,7 +4373,7 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum 
HAL_

[PATCH 08/10] staging: rtl8723bs: remove unused macros

2020-12-05 Thread Ross Schmidt
Remove many macros from wifi.h because they are unused.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/wifi.h | 33 
 1 file changed, 33 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index c3a4a0bad0d7..41de2605c517 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -643,39 +643,6 @@ struct ADDBA_request {
 #define IEEE80211_HT_CAP_TXBF_TX_NDP   0x0010
 #define IEEE80211_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP   0x0400
 
-/* 802.11n HT IE masks */
-#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
-#define IEEE80211_HT_IE_CHA_SEC_NONE   0x00
-#define IEEE80211_HT_IE_CHA_SEC_ABOVE  0x01
-#define IEEE80211_HT_IE_CHA_SEC_BELOW  0x03
-#define IEEE80211_HT_IE_CHA_WIDTH  0x04
-#define IEEE80211_HT_IE_HT_PROTECTION  0x0003
-#define IEEE80211_HT_IE_NON_GF_STA_PRSNT   0x0004
-#define IEEE80211_HT_IE_NON_HT_STA_PRSNT   0x0010
-
-/*
- * A-PMDU buffer sizes
- * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
- */
-#define IEEE80211_MIN_AMPDU_BUF 0x8
-
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK   ((u8) BIT(0) | BIT(1))
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE  ((u8) BIT(0))
-#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW  ((u8) BIT(0) | BIT(1))
-#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH  ((u8) BIT(2))
-#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3))
-#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY  ((u8) BIT(4))
-#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY  ((u8) BIT(5))
-
-#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6))
-#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT   ((u16) BIT(7))
-#define HT_INFO_STBC_PARAM_SECONDARY_BCN   ((u16) BIT(8))
-#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED   ((u16) BIT(9))
-#define HT_INFO_STBC_PARAM_PCO_ACTIVE  ((u16) BIT(10))
-#define HT_INFO_STBC_PARAM_PCO_PHASE   ((u16) BIT(11))
-
-
-
 /* endif */
 
 /* ===WPS Section === */
-- 
2.25.1



[PATCH 03/10] staging: rtl8723bs: replace cap_* macros

2020-12-05 Thread Ross Schmidt
Replace unique cap_* macros with kernel provided WLAN_CAPABILITY_*
macros.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c|  2 +-
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c |  6 +++---
 drivers/staging/rtl8723bs/core/rtw_mlme.c  |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 12 ++--
 drivers/staging/rtl8723bs/include/ieee80211.h  |  4 
 drivers/staging/rtl8723bs/include/wifi.h   | 12 
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c |  4 ++--
 7 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index a2b39ae56d89..984b9f5a83ac 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1980,7 +1980,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, 
struct sta_info *psta)
}
}
 
-   if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) {
+   if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) {
if (!psta->no_short_slot_time_set) {
psta->no_short_slot_time_set = 1;
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 8d61be5bd250..e80b957f947f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -314,13 +314,13 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
/* capability info */
*(u16 *)ie = 0;
 
-   *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
+   *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS);
 
if (pregistrypriv->preamble == PREAMBLE_SHORT)
-   *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
+   *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
 
if (pdev_network->Privacy)
-   *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
+   *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
 
sz += 2;
ie += 2;
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 351178ab78c5..001cce312f05 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -424,8 +424,8 @@ int is_same_network(struct wlan_bssid_ex *src, struct 
wlan_bssid_ex *dst, u8 fea
((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, 
src->Ssid.SsidLength))) &&
((s_cap & WLAN_CAPABILITY_IBSS) ==
(d_cap & WLAN_CAPABILITY_IBSS)) &&
-   ((s_cap & WLAN_CAPABILITY_BSS) ==
-   (d_cap & WLAN_CAPABILITY_BSS));
+   ((s_cap & WLAN_CAPABILITY_ESS) ==
+   (d_cap & WLAN_CAPABILITY_ESS));
 
 }
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 6dab68033941..239c89ce7dc9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -4600,7 +4600,7 @@ void start_create_ibss(struct adapter *padapter)
/* update capability */
caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork);
update_capinfo(padapter, caps);
-   if (caps&cap_IBSS) {/* adhoc master */
+   if (caps&WLAN_CAPABILITY_IBSS) {/* adhoc master */
val8 = 0xcf;
rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
 
@@ -4655,7 +4655,7 @@ void start_clnt_join(struct adapter *padapter)
/* update capability */
caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork);
update_capinfo(padapter, caps);
-   if (caps&cap_ESS) {
+   if (caps&WLAN_CAPABILITY_ESS) {
Set_MSR(padapter, WIFI_FW_STATION_STATE);
 
val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc 
: 0xcf;
@@ -4681,7 +4681,7 @@ void start_clnt_join(struct adapter *padapter)
(REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) 
+ beacon_timeout);
 
pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
-   } else if (caps&cap_IBSS) { /* adhoc client */
+   } else if (caps&WLAN_CAPABILITY_IBSS) { /* adhoc client */
Set_MSR(padapter, WIFI_FW_ADHOC_STATE);
 
val8 = 0xcf;
@@ -5952,9 +5952,9 @@ static int rtw_auto_ap_start_beacon(struct adapter 
*adapter)
 
/* capability info */
*(u16 *)ie = 0;
-   *(u16 *)ie |= cpu_to_le16(cap_ESS);
-   *(u16 *)ie |= cpu_to_le16(cap_ShortPremble);
-   /* u16*)ie |= cpu_to_le16(cap_Privacy); */
+   *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_ESS);
+   *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
+   /* u16*)ie |= cpu_to_le16(WL

[PATCH 06/10] staging: rtl8723bs: remove WLAN_HT_CAP_SM_PS_* macros

2020-12-05 Thread Ross Schmidt
The WLAN_HT_CAP_SM_PS_* macro family is already defined in
linux/ieee80211.h, remove them.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/wifi.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 2fb1687ecabf..2e8ca191c608 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -666,13 +666,6 @@ struct ADDBA_request {
  */
 #define IEEE80211_MIN_AMPDU_BUF 0x8
 
-
-/* Spatial Multiplexing Power Save Modes */
-#define WLAN_HT_CAP_SM_PS_STATIC   0
-#define WLAN_HT_CAP_SM_PS_DYNAMIC  1
-#define WLAN_HT_CAP_SM_PS_INVALID  2
-#define WLAN_HT_CAP_SM_PS_DISABLED 3
-
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK   ((u8) BIT(0) | BIT(1))
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE  ((u8) BIT(0))
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW  ((u8) BIT(0) | BIT(1))
-- 
2.25.1



[PATCH 01/10] staging: rtl8723bs: replace unique macros and WIFI_STATUS_CODE

2020-12-05 Thread Ross Schmidt
Replace many unique macros and WIFI_STATUS_CODE enum with kernel
provided ieee80211_statuscode. A duplicate
WLAN_STATUS_ASSOC_DENIED_NOSHORT macro is also removed.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 54 +--
 drivers/staging/rtl8723bs/include/ieee80211.h |  3 --
 drivers/staging/rtl8723bs/include/wifi.h  | 51 --
 3 files changed, 27 insertions(+), 81 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 8c40ef43ff94..ab4876507198 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -940,13 +940,13 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
DBG_871X("auth rejected due to bad alg [alg =%d, auth_mib =%d] 
%02X%02X%02X%02X%02X%02X\n",
algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], 
sa[4], sa[5]);
 
-   status = _STATS_NO_SUPP_ALG_;
+   status = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
 
goto auth_fail;
}
 
if (rtw_access_ctrl(padapter, sa) == false) {
-   status = _STATS_UNABLE_HANDLE_STA_;
+   status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
goto auth_fail;
}
 
@@ -958,7 +958,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
pstat = rtw_alloc_stainfo(pstapriv, sa);
if (pstat == NULL) {
DBG_871X(" Exceed the upper limit of supported 
clients...\n");
-   status = _STATS_UNABLE_HANDLE_STA_;
+   status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
goto auth_fail;
}
 
@@ -999,7 +999,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
if ((pstat->auth_seq + 1) != seq) {
DBG_871X("(1)auth rejected because out of seq [rx_seq =%d, 
exp_seq =%d]!\n",
seq, pstat->auth_seq+1);
-   status = _STATS_OUT_OF_AUTH_SEQ_;
+   status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
 
@@ -1012,7 +1012,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
} else {
DBG_871X("(2)auth rejected because out of seq [rx_seq 
=%d, exp_seq =%d]!\n",
seq, pstat->auth_seq+1);
-   status = _STATS_OUT_OF_AUTH_SEQ_;
+   status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
} else { /*  shared system or auto authentication */
@@ -1033,7 +1033,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
 
if ((p == NULL) || (ie_len <= 0)) {
DBG_871X("auth rejected because challenge 
failure!(1)\n");
-   status = _STATS_CHALLENGE_FAIL_;
+   status = WLAN_STATUS_CHALLENGE_FAIL;
goto auth_fail;
}
 
@@ -1044,13 +1044,13 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
pstat->expire_to =  pstapriv->assoc_to;
} else {
DBG_871X("auth rejected because challenge 
failure!\n");
-   status = _STATS_CHALLENGE_FAIL_;
+   status = WLAN_STATUS_CHALLENGE_FAIL;
goto auth_fail;
}
} else {
DBG_871X("(3)auth rejected because out of seq [rx_seq 
=%d, exp_seq =%d]!\n",
seq, pstat->auth_seq+1);
-   status = _STATS_OUT_OF_AUTH_SEQ_;
+   status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
}
@@ -1059,7 +1059,7 @@ unsigned int OnAuth(struct adapter *padapter, union 
recv_frame *precv_frame)
/*  Now, we are going to issue_auth... */
pstat->auth_seq = seq + 1;
 
-   issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_));
+   issue_auth(padapter, pstat, (unsigned short)(WLAN_STATUS_SUCCESS));
 
if (pstat->state & WIFI_FW_AUTH_SUCCESS)
pstat->auth_seq = 0;
@@ -1178,7 +1178,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
int i, ie_len, wpa_ie_len, left;
unsigned char   supportRate[16];
int supportRateNum;
-   unsigned short  sta

[PATCH 10/10] staging: rtl8723bs: replace unique macros and ELEMENT_ID

2020-12-05 Thread Ross Schmidt
Replace unique macros and ELEMENT_ID with kernel provided ieee80211_eid
enum.

In a several cases multiple macros or constants are replaced by one
constant.

WLAN_EID_HT_CAP, _HT_CAPABILITY_IE_, and EID_HTCapability are replace by
WLAN_EID_HT_CAPABILITY.

_WPA2_IE_ID_, EID_WPA2, and _RSN_IE_2_ are replaced by WLAN_EID_RSN.

_HT_EXTRA_INFO_IE_ and _HT_ADD_INFO_IE_ are replaced by
WLAN_EID_HT_OPERATION.

WLAN_EID_GENERIC, _WPA_IE_ID_, _SSN_IE_1_, and _VENDOR_SPECIFIC_IE_ are
replaced by WLAN_EID_VENDOR_SPECIFIC.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   |  62 
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |   4 +-
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  44 +++---
 drivers/staging/rtl8723bs/core/rtw_mlme.c |  26 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 146 +-
 drivers/staging/rtl8723bs/core/rtw_recv.c |   4 +-
 drivers/staging/rtl8723bs/core/rtw_security.c |   2 +-
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  26 ++--
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  12 +-
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  |  20 +--
 drivers/staging/rtl8723bs/include/ieee80211.h |   8 -
 .../staging/rtl8723bs/include/rtw_security.h  |   3 -
 drivers/staging/rtl8723bs/include/wifi.h  | 108 -
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c |   4 +-
 .../staging/rtl8723bs/os_dep/ioctl_linux.c|  14 +-
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |   2 +-
 16 files changed, 183 insertions(+), 302 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 04d5852d0d3e..b6f944b37b08 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -76,7 +76,7 @@ static void update_BCNTIM(struct adapter *padapter)
 
p = rtw_get_ie(
pie + _FIXED_IE_LENGTH_,
-   _TIM_IE_,
+   WLAN_EID_TIM,
&tim_ielen,
pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_
);
@@ -100,7 +100,7 @@ static void update_BCNTIM(struct adapter *padapter)
/* get ssid_ie len */
p = rtw_get_ie(
pie + _BEACON_IE_OFFSET_,
-   _SSID_IE_,
+   WLAN_EID_SSID,
&tmp_len,
(pnetwork_mlmeext->IELength - 
_BEACON_IE_OFFSET_)
);
@@ -110,7 +110,7 @@ static void update_BCNTIM(struct adapter *padapter)
/*  get supported rates len */
p = rtw_get_ie(
pie + _BEACON_IE_OFFSET_,
-   _SUPPORTEDRATES_IE_, &tmp_len,
+   WLAN_EID_SUPP_RATES, &tmp_len,
(pnetwork_mlmeext->IELength - 
_BEACON_IE_OFFSET_)
);
if (p)
@@ -133,7 +133,7 @@ static void update_BCNTIM(struct adapter *padapter)
memcpy(pbackup_remainder_ie, premainder_ie, 
remainder_ielen);
}
 
-   *dst_ie++ = _TIM_IE_;
+   *dst_ie++ = WLAN_EID_TIM;
 
if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 
0x00fe))
tim_ielen = 5;
@@ -301,7 +301,7 @@ void expire_timeout_chk(struct adapter *padapter)
 
/* to update bcn with tim_bitmap for 
this station */
pstapriv->tim_bitmap |= BIT(psta->aid);
-   update_beacon(padapter, _TIM_IE_, NULL, 
true);
+   update_beacon(padapter, WLAN_EID_TIM, 
NULL, true);
 
if (!pmlmeext->active_keep_alive_check)
continue;
@@ -855,7 +855,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
/* set channel, bwmode */
p = rtw_get_ie(
(pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)),
-   _HT_ADD_INFO_IE_,
+   WLAN_EID_HT_OPERATION,
&ie_len,
(pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie))
);
@@ -922,7 +922,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
);
 
if (pmlmeext->bstart_bss) {
-   update_beacon(padapter, _TIM_IE_, NULL, true);
+   update_beacon(padapter, WLAN_EID_TIM, NULL, true);
 
 #ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will  tx beacon when bcn 
interrupt coming in. */
/* issue beacon frame */
@@ -1004,7 +1004,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  i

[PATCH 05/10] staging: rtl8723bs: replace OP_MODE_* and HT_INFO_OPERATION_MODE_* macros

2020-12-05 Thread Ross Schmidt
Replace unique OP_MODE_* and HT_INFO_OPERATION_MODE_* macro families
with kernel provided IEEE80211_HT_OP_MODE_* macros.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c  | 30 
 drivers/staging/rtl8723bs/include/wifi.h | 13 --
 2 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 984b9f5a83ac..27446156ed34 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1842,28 +1842,28 @@ static int rtw_ht_operation_update(struct adapter 
*padapter)
DBG_871X("%s current operation mode = 0x%X\n",
   __func__, pmlmepriv->ht_op_mode);
 
-   if (!(pmlmepriv->ht_op_mode & 
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)
+   if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
&& pmlmepriv->num_sta_ht_no_gf) {
pmlmepriv->ht_op_mode |=
-   HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
+   IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
op_mode_changes++;
} else if ((pmlmepriv->ht_op_mode &
-   HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) &&
+   IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
   pmlmepriv->num_sta_ht_no_gf == 0) {
pmlmepriv->ht_op_mode &=
-   ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
+   ~IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
op_mode_changes++;
}
 
-   if (!(pmlmepriv->ht_op_mode & 
HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
+   if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) &&
(pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) {
-   pmlmepriv->ht_op_mode |= 
HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
+   pmlmepriv->ht_op_mode |= IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
op_mode_changes++;
} else if ((pmlmepriv->ht_op_mode &
-   HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
+   IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) &&
   (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) {
pmlmepriv->ht_op_mode &=
-   ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
+   ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
op_mode_changes++;
}
 
@@ -1873,20 +1873,20 @@ static int rtw_ht_operation_update(struct adapter 
*padapter)
 */
new_op_mode = 0;
if (pmlmepriv->num_sta_no_ht ||
-   (pmlmepriv->ht_op_mode & 
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT))
-   new_op_mode = OP_MODE_MIXED;
+   (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT))
+   new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
else if (
(le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & 
IEEE80211_HT_CAP_SUP_WIDTH)
&& pmlmepriv->num_sta_ht_20mhz)
-   new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED;
+   new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
else if (pmlmepriv->olbc_ht)
-   new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS;
+   new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
else
-   new_op_mode = OP_MODE_PURE;
+   new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
 
-   cur_op_mode = pmlmepriv->ht_op_mode & 
HT_INFO_OPERATION_MODE_OP_MODE_MASK;
+   cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION;
if (cur_op_mode != new_op_mode) {
-   pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK;
+   pmlmepriv->ht_op_mode &= ~IEEE80211_HT_OP_MODE_PROTECTION;
pmlmepriv->ht_op_mode |= new_op_mode;
op_mode_changes++;
}
diff --git a/drivers/staging/rtl8723bs/include/wifi.h 
b/drivers/staging/rtl8723bs/include/wifi.h
index 9c92b5020fbc..2fb1687ecabf 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -673,12 +673,6 @@ struct ADDBA_request {
 #define WLAN_HT_CAP_SM_PS_INVALID  2
 #define WLAN_HT_CAP_SM_PS_DISABLED 3
 
-
-#define OP_MODE_PURE0
-#define OP_MODE_MAY_BE_LEGACY_STAS  1
-#define OP_MODE_20MHZ_HT_STA_ASSOCED2
-#define OP_MODE_MIXED   3
-
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK   ((u8) BIT(0) | BIT(1))
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE  ((u8) BIT(0))
 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW  ((u8) BIT(0) | BIT(1))
@

[PATCH 04/10] staging: rtl8723bs: clean up open ended lines

2020-11-09 Thread Ross Schmidt
Move declarations to fix coding style issues and clear checkpatch
checks.

CHECK: Lines should not end with a '('

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_efuse.c|  44 +--
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  13 +-
 .../staging/rtl8723bs/core/rtw_ioctl_set.c|  10 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  16 +-
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  |   7 +-
 drivers/staging/rtl8723bs/core/rtw_recv.c |  38 +--
 drivers/staging/rtl8723bs/core/rtw_security.c | 261 ++
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c  |  42 ++-
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  17 +-
 9 files changed, 147 insertions(+), 301 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c 
b/drivers/staging/rtl8723bs/core/rtw_efuse.c
index 8794638468e6..32ca10f01413 100644
--- a/drivers/staging/rtl8723bs/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c
@@ -303,12 +303,7 @@ bool   bPseudoTest)
 }
 
 /*  11/16/2008 MH Write one byte to reald Efuse. */
-u8
-efuse_OneByteWrite(
-struct adapter *padapter,
-u16addr,
-u8 data,
-bool   bPseudoTest)
+u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool 
bPseudoTest)
 {
u8 tmpidx = 0;
u8 bResult = false;
@@ -456,12 +451,7 @@ Efuse_ReadAllMap(
u8 efuseType,
u8 *Efuse,
boolbPseudoTest);
-void
-Efuse_ReadAllMap(
-   struct adapter *padapter,
-   u8 efuseType,
-   u8 *Efuse,
-   boolbPseudoTest)
+void Efuse_ReadAllMap(struct adapter *padapter, u8 efuseType, u8 *Efuse, bool 
bPseudoTest)
 {
u16 mapLen = 0;
 
@@ -492,11 +482,7 @@ Efuse_ReadAllMap(
  * 11/12/2008  MHC Create Version 0.
  *
  *---*/
-static void
-efuse_ShadowRead1Byte(
-struct adapter *padapter,
-u16Offset,
-   u8 *Value)
+static void efuse_ShadowRead1Byte(struct adapter *padapter, u16 Offset, u8 
*Value)
 {
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
 
@@ -505,11 +491,7 @@ u16Offset,
 }  /*  EFUSE_ShadowRead1Byte */
 
 /* Read Two Bytes */
-static void
-efuse_ShadowRead2Byte(
-struct adapter *padapter,
-u16Offset,
-   u16 *Value)
+static void efuse_ShadowRead2Byte(struct adapter *padapter, u16 Offset, u16 
*Value)
 {
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
 
@@ -519,11 +501,7 @@ u16Offset,
 }  /*  EFUSE_ShadowRead2Byte */
 
 /* Read Four Bytes */
-static void
-efuse_ShadowRead4Byte(
-struct adapter *padapter,
-u16Offset,
-   u32 *Value)
+static void efuse_ShadowRead4Byte(struct adapter *padapter, u16 Offset, u32 
*Value)
 {
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
 
@@ -550,10 +528,7 @@ u16Offset,
  * 11/13/2008  MHC Create Version 0.
  *
  *---*/
-void EFUSE_ShadowMapUpdate(
-   struct adapter *padapter,
-   u8 efuseType,
-   boolbPseudoTest)
+void EFUSE_ShadowMapUpdate(struct adapter *padapter, u8 efuseType, bool 
bPseudoTest)
 {
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
u16 mapLen = 0;
@@ -586,12 +561,7 @@ void EFUSE_ShadowMapUpdate(
  * 11/12/2008  MHC Create Version 0.
  *
  *---*/
-void
-EFUSE_ShadowRead(
-   struct adapter *padapter,
-   u8 Type,
-   u16 Offset,
-   u32 *Value)
+void EFUSE_ShadowRead(struct adapter *padapter, u8 Type, u16 Offset, u32 
*Value)
 {
if (Type == 1)
efuse_ShadowRead1Byte(padapter, Offset, (u8 *)Value);
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 066dd9cbb60d..8d61be5bd250 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -119,14 +119,11 @@ u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int 
len, unsigned char *sourc
 }
 
 /*  rtw_set_ie will update frame length */
-u8 *rtw_set_ie
-(
-   u8 *pbuf,
-   sint index,
-   uint len,
-   u8 *source,
-   uint *frlen /* frame length */
-)
+u8 *rtw_set_ie(u8 *pbuf,
+  sint index,
+  uint len,
+  u8 *source,
+  uint *frlen) /* frame length */
 {
*pbuf = (u8)index;
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c 
b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index e0bab0a71f00..3adeca6f20ec 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -657,12 +657,10 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter)
if (IsSupportedHT(psta->wireless_mode)) {
rtw_hal_get_

[PATCH 10/10] staging: rtl8723bs: clean up leading space

2020-11-09 Thread Ross Schmidt
Convert spaces to tabs to fix coding style issues and clear checkpatch
warnings.

WARNING: please, no spaces at the start of a line

Signed-off-by: Ross Schmidt 
---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 80 +--
 .../staging/rtl8723bs/os_dep/osdep_service.c  |  2 +-
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 294c4f406fcc..6c38eb239381 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -985,23 +985,23 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
if (psecuritypriv->PMKIDIndex == 16)
psecuritypriv->PMKIDIndex = 0;
}
-} else if (pPMK->cmd == IW_PMKSA_REMOVE) {
-DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n");
-intReturn = true;
+   } else if (pPMK->cmd == IW_PMKSA_REMOVE) {
+   DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n");
+   intReturn = true;
for (j = 0; j < NUM_PMKID_CACHE; j++) {
if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, 
strIssueBssid, ETH_ALEN)) {
/*  BSSID is matched, the same AP => Remove 
this PMKID information and reset it. */
-
eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
-psecuritypriv->PMKIDList[j].bUsed = false;
+   
eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
+   psecuritypriv->PMKIDList[j].bUsed = false;
break;
}
}
-} else if (pPMK->cmd == IW_PMKSA_FLUSH) {
-DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n");
-memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * 
NUM_PMKID_CACHE);
-psecuritypriv->PMKIDIndex = 0;
-intReturn = true;
-}
+   } else if (pPMK->cmd == IW_PMKSA_FLUSH) {
+   DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n");
+   memset(&psecuritypriv->PMKIDList[0], 0x00, 
sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+   psecuritypriv->PMKIDIndex = 0;
+   intReturn = true;
+   }
return intReturn;
 }
 
@@ -,8 +,8 @@ static int rtw_wx_get_nick(struct net_device *dev,
 }
 
 static int rtw_wx_read32(struct net_device *dev,
-struct iw_request_info *info,
-union iwreq_data *wrqu, char *extra)
+struct iw_request_info *info,
+union iwreq_data *wrqu, char *extra)
 {
struct adapter *padapter;
struct iw_point *p;
@@ -2282,8 +2282,8 @@ static int rtw_wx_read32(struct net_device *dev,
 }
 
 static int rtw_wx_write32(struct net_device *dev,
-struct iw_request_info *info,
-union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
 {
struct adapter *padapter = rtw_netdev_priv(dev);
 
@@ -2319,8 +2319,8 @@ static int rtw_wx_write32(struct net_device *dev,
 }
 
 static int rtw_wx_read_rf(struct net_device *dev,
-struct iw_request_info *info,
-union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
 {
struct adapter *padapter = rtw_netdev_priv(dev);
u32 path, addr, data32;
@@ -2340,8 +2340,8 @@ static int rtw_wx_read_rf(struct net_device *dev,
 }
 
 static int rtw_wx_write_rf(struct net_device *dev,
-struct iw_request_info *info,
-union iwreq_data *wrqu, char *extra)
+  struct iw_request_info *info,
+  union iwreq_data *wrqu, char *extra)
 {
struct adapter *padapter = rtw_netdev_priv(dev);
u32 path, addr, data32;
@@ -2375,8 +2375,8 @@ static int dummy(struct net_device *dev, struct 
iw_request_info *a,
 }
 
 static int rtw_wx_set_channel_plan(struct net_device *dev,
-   struct iw_request_info *info,
-   union iwreq_data *wrqu, char *extra)
+  struct iw_request_info *info,
+  union iwreq_data *wrqu, char *extra)
 {
struct adapter *padapter = rtw_netdev_priv(dev);
u8 channel_plan_req = (u8)(*((int *)wrqu));
@@ -2425,8 +2425,8 @@ static  int rtw_drvext_hdl(struct net_device *dev, struct 
iw_request_info *info,
 }
 
 static int r

[PATCH 07/10] staging: rtl8723bs: clean up trailing statements

2020-11-09 Thread Ross Schmidt
Move trailing statements to the next line to fix coding style issues and
clear checkpatch errors.

ERROR: trailing statements should be on next line

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c| 9 ++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 385705aafa5c..7676056913d8 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -2870,7 +2870,8 @@ static struct sta_info *rtw_sta_info_get_by_idx(const int 
idx, struct sta_priv *
 
/* check asoc_queue */
while (phead != plist) {
-   if (idx == i) psta = LIST_CONTAINOR(plist, struct sta_info, 
asoc_list);
+   if (idx == i)
+   psta = LIST_CONTAINOR(plist, struct sta_info, 
asoc_list);
plist = get_next(plist);
i++;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 773e4816fbc4..9c00469deeab 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -3151,7 +3151,8 @@ static int rtw_dbg_port(struct net_device *dev,
 #endif
case 0xaa:
{
-   if ((extra_arg & 0x7F) > 0x3F) 
extra_arg = 0xFF;
+   if ((extra_arg & 0x7F) > 0x3F)
+   extra_arg = 0xFF;
DBG_871X("chang data rate to 
:0x%02x\n", extra_arg);
padapter->fix_rate = extra_arg;
}
@@ -4934,7 +4935,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, 
union iwreq_data *wrq_
count = 0;
do {
str = strsep(&ptr, delim);
-   if (NULL == str) break;
+   if (NULL == str)
+   break;
sscanf(str, "%i", &temp);
buffer[count++] = (u8)temp;
} while (1);
@@ -4952,7 +4954,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, 
union iwreq_data *wrq_
count = 0;
do {
str = strsep(&ptr, delim);
-   if (NULL == str) break;
+   if (NULL == str)
+   break;
sscanf(str, "%i", &temp);
((s32 *)buffer)[count++] = (s32)temp;
} while (1);
-- 
2.25.1



[PATCH 06/10] staging: rtl8723bs: clean up switch case indentation

2020-11-09 Thread Ross Schmidt
Move cases to align with switch indentation to fix coding style issues
and clear checkpatch errors.

ERROR: switch and case should be at the same indent

Signed-off-by: Ross Schmidt 
---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 219 +-
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   |  14 +-
 2 files changed, 116 insertions(+), 117 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 783daa30f1d7..773e4816fbc4 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -664,49 +664,49 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char 
*pie, unsigned short ie
pairwise_cipher = WPA_CIPHER_NONE;
 
switch (group_cipher) {
-   case WPA_CIPHER_NONE:
-   padapter->securitypriv.dot118021XGrpPrivacy = 
_NO_PRIVACY_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11EncryptionDisabled;
-   break;
-   case WPA_CIPHER_WEP40:
-   padapter->securitypriv.dot118021XGrpPrivacy = 
_WEP40_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
-   break;
-   case WPA_CIPHER_TKIP:
-   padapter->securitypriv.dot118021XGrpPrivacy = 
_TKIP_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption2Enabled;
-   break;
-   case WPA_CIPHER_CCMP:
-   padapter->securitypriv.dot118021XGrpPrivacy = 
_AES_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption3Enabled;
-   break;
-   case WPA_CIPHER_WEP104:
-   padapter->securitypriv.dot118021XGrpPrivacy = 
_WEP104_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
-   break;
+   case WPA_CIPHER_NONE:
+   padapter->securitypriv.dot118021XGrpPrivacy = 
_NO_PRIVACY_;
+   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11EncryptionDisabled;
+   break;
+   case WPA_CIPHER_WEP40:
+   padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_;
+   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
+   break;
+   case WPA_CIPHER_TKIP:
+   padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_;
+   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption2Enabled;
+   break;
+   case WPA_CIPHER_CCMP:
+   padapter->securitypriv.dot118021XGrpPrivacy = _AES_;
+   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption3Enabled;
+   break;
+   case WPA_CIPHER_WEP104:
+   padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_;
+   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
+   break;
}
 
switch (pairwise_cipher) {
-   case WPA_CIPHER_NONE:
-   padapter->securitypriv.dot11PrivacyAlgrthm = 
_NO_PRIVACY_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11EncryptionDisabled;
-   break;
-   case WPA_CIPHER_WEP40:
-   padapter->securitypriv.dot11PrivacyAlgrthm = 
_WEP40_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
-   break;
-   case WPA_CIPHER_TKIP:
-   padapter->securitypriv.dot11PrivacyAlgrthm = 
_TKIP_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption2Enabled;
-   break;
-   case WPA_CIPHER_CCMP:
-   padapter->securitypriv.dot11PrivacyAlgrthm = 
_AES_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption3Enabled;
-   break;
-   case WPA_CIPHER_WEP104:
-   padapter->securitypriv.dot11PrivacyAlgrthm = 
_WEP104_;
-   padapter->securitypriv.ndisencryptstatus = 
Ndis802_11Encryption1Enabled;
-  

[PATCH 09/10] staging: rtl8723bs: clean up pointer locations

2020-11-09 Thread Ross Schmidt
Move pointer locations to fix coding style issues and clear checkpatch
errors.

ERROR: "foo * bar" should be "foo *bar"

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/rtw_io.h|  2 +-
 drivers/staging/rtl8723bs/include/rtw_mlme.h  | 14 +++---
 drivers/staging/rtl8723bs/include/rtw_mp.h| 10 +-
 drivers/staging/rtl8723bs/include/rtw_pwrctrl.h   |  6 +++---
 drivers/staging/rtl8723bs/include/rtw_recv.h  |  4 ++--
 drivers/staging/rtl8723bs/include/rtw_security.h  | 12 ++--
 drivers/staging/rtl8723bs/include/rtw_xmit.h  |  8 
 drivers/staging/rtl8723bs/include/sta_info.h  |  2 +-
 drivers/staging/rtl8723bs/include/wifi.h  | 10 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 14 +++---
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c|  8 
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 10 +-
 12 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h 
b/drivers/staging/rtl8723bs/include/rtw_io.h
index 2581b5165d1b..b7076b590d84 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -345,7 +345,7 @@ extern void free_io_queue(struct adapter *adapter);
 extern void async_bus_io(struct io_queue *pio_q);
 extern void bus_sync_io(struct io_queue *pio_q);
 extern u32 _ioreq2rwmem(struct io_queue *pio_q);
-extern void dev_power_down(struct adapter * Adapter, u8 bpwrup);
+extern void dev_power_down(struct adapter *Adapter, u8 bpwrup);
 
 #define PlatformEFIOWrite1Byte(_a, _b, _c) \
rtw_write8(_a, _b, _c)
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h 
b/drivers/staging/rtl8723bs/include/rtw_mlme.h
index 07efb74831eb..ea0dd156051e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h
@@ -559,15 +559,15 @@ static inline void set_scanned_network_val(struct 
mlme_priv *pmlmepriv, sint val
 
 extern u16 rtw_get_capability(struct wlan_bssid_ex *bss);
 extern void rtw_update_scanned_network(struct adapter *adapter, struct 
wlan_bssid_ex *target);
-extern void rtw_disconnect_hdl_under_linked(struct adapter * adapter, struct 
sta_info *psta, u8 free_assoc);
+extern void rtw_disconnect_hdl_under_linked(struct adapter *adapter, struct 
sta_info *psta, u8 free_assoc);
 extern void rtw_generate_random_ibss(u8 *pibss);
-extern struct wlan_network* rtw_find_network(struct __queue *scanned_queue, u8 
*addr);
-extern struct wlan_network* rtw_get_oldest_wlan_network(struct __queue 
*scanned_queue);
+extern struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 
*addr);
+extern struct wlan_network *rtw_get_oldest_wlan_network(struct __queue 
*scanned_queue);
 struct wlan_network *_rtw_find_same_network(struct __queue *scanned_queue, 
struct wlan_network *network);
 
-extern void rtw_free_assoc_resources(struct adapter * adapter, int 
lock_scanned_queue);
-extern void rtw_indicate_disconnect(struct adapter * adapter);
-extern void rtw_indicate_connect(struct adapter * adapter);
+extern void rtw_free_assoc_resources(struct adapter *adapter, int 
lock_scanned_queue);
+extern void rtw_indicate_disconnect(struct adapter *adapter);
+extern void rtw_indicate_connect(struct adapter *adapter);
 void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
 void rtw_scan_abort(struct adapter *adapter);
 
@@ -600,7 +600,7 @@ extern void _rtw_free_network(struct mlme_priv *pmlmepriv, 
struct wlan_network *
 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct 
wlan_network *pnetwork);
 
 
-extern struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, 
u8 *addr);
+extern struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, 
u8 *addr);
 
 extern sint rtw_if_up(struct adapter *padapter);
 
diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h 
b/drivers/staging/rtl8723bs/include/rtw_mp.h
index 4d156eab029c..ab7cd51ce681 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mp.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mp.h
@@ -31,7 +31,7 @@ struct mp_wiparam {
u32 io_value;
 };
 
-typedef void(*wi_act_func)(void* padapter);
+typedef void(*wi_act_func)(void *padapter);
 
 struct mp_tx {
u8 stop;
@@ -478,13 +478,13 @@ void Hal_SetChannel(struct adapter *padapter);
 void Hal_SetAntennaPathPower(struct adapter *padapter);
 s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther);
 s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable);
-void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable);
+void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable);
 void Hal_GetThermalMeter(struct adapter *padapter, u8 *value);
 void Hal_mpt_SwitchRfSetting(struct adapter *padapter);
-void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14);
+void Hal_MPT_CCKTxPowerAdjust(struct adapter *A

[PATCH 01/10] staging: rtl8723bs: clean up line spacing

2020-11-09 Thread Ross Schmidt
Add or remove lines to fix coding style issues and clear checkpatch.

WARNING: Missing a blank line after declarations
CHECK: Please use a blank line after function/struct/union/enum declarations
CHECK: Please don't use multiple blank lines

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 29 ---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c  |  7 +
 .../staging/rtl8723bs/core/rtw_wlan_util.c| 12 +++-
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  3 ++
 4 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 81c15895f646..894e7beae96f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -1008,7 +1008,6 @@ static void shift_row(u8 *in, u8 *out)
out[15] = in[11];
 }
 
-
 static void mix_column(u8 *in, u8 *out)
 {
sint i;
@@ -1098,7 +1097,6 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
}
 }
 
-
 //
 /* construct_mic_iv()   */
 /* Builds the MIC IV from header fields and PN  */
@@ -1145,7 +1143,6 @@ static void construct_mic_iv(
mic_iv[15] = (unsigned char) (payload_length % 256);
 }
 
-
 //
 /* construct_mic_header1()  */
 /* Builds the first MIC header block from   */
@@ -1183,7 +1180,6 @@ static void construct_mic_header1(
mic_header1[15] = mpdu[15];
 }
 
-
 //
 /* construct_mic_header2()  */
 /* Builds the last MIC header block from*/
@@ -1211,7 +1207,6 @@ static void construct_mic_header2(
mic_header2[6] = 0x00;
mic_header2[7] = 0x00; /* mpdu[23]; */
 
-
if (!qc_exists && a4_exists) {
for (i = 0; i < 6; i++)
mic_header2[8+i] = mpdu[24+i];   /* A4 */
@@ -1277,7 +1272,6 @@ static void construct_ctr_preload(
ctr_preload[15] =  (unsigned char) (c % 256);
 }
 
-
 //
 /* bitwise_xor()*/
 /* A 128 bit, bitwise exclusive or  */
@@ -1291,7 +1285,6 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
}
 }
 
-
 static sint aes_cipher(u8 *key, uint   hdrlen,
u8 *pframe, uint plen)
 {
@@ -1314,7 +1307,6 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
 
frsubtype = frsubtype>>4;
 
-
memset((void *)mic_iv, 0, 16);
memset((void *)mic_header1, 0, 16);
memset((void *)mic_header2, 0, 16);
@@ -1377,7 +1369,6 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
qc_exists
);
 
-
payload_remainder = plen % 16;
num_blocks = plen / 16;
 
@@ -1484,7 +1475,6 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
 u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
 {  /*  exclude ICV */
 
-
/*static*/
 /* unsigned char message[MAX_MSG_SIZE]; */
 
@@ -1551,13 +1541,11 @@ static sint aes_decipher(u8 *key, uint  hdrlen,
u8 padded_buffer[16];
u8 mic[8];
 
-
uint frtype  = GetFrameType(pframe);
uint frsubtype  = GetFrameSubType(pframe);
 
frsubtype = frsubtype>>4;
 
-
memset((void *)mic_iv, 0, 16);
memset((void *)mic_header1, 0, 16);
memset((void *)mic_header2, 0, 16);
@@ -1603,7 +1591,6 @@ static sint aes_decipher(u8 *key, uinthdrlen,
} else
qc_exists = 0;
 
-
/*  now, decrypt pframe with hdrlen offset and plen long */
 
payload_index = hdrlen + 8; /*  8 is for extiv */
@@ -1649,7 +1636,6 @@ static sint aes_decipher(u8 *key, uinthdrlen,
if ((hdrlen + plen+8) <= MAX_MSG_SIZE)
memcpy((void *)message, pframe, (hdrlen + plen+8)); /* 8 is for 
ext iv len */
 
-
pn_vector[0] = pframe[hdrlen];
pn_vector[1] = pframe[hdrlen+1];
pn_vector[2] = pframe[hdrlen+4];
@@ -1657,8 +1643,6 @@ static sint aes_decipher(u8 *key, uinthdrlen,
pn_vector[4] = pframe[hdrlen+6];
pn_vector[5] = pframe[hdrlen+7];
 
-
-
construct_mic_iv(
mic_iv,
qc_exists,
@@ -1682,7 +1666,6 @@ static sint aes_decipher(u8 *key, uinthdrlen,
qc_exists
);
 
-
payload_remainder = (plen-8) % 16;
num_blocks = (plen-8) / 16;
 
@@ -1808,14 +1791,11 @@ static sint aes_decipher(u8 *key, uint  hdrlen,
 u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
 {  /*  exclude ICV */
 
-
/*static*/
 /* unsigned char message[MAX_MSG_SIZE]; */
 
-
/* Intermediate Buffers */
 
-
sintlength;
u8 *pfram

[PATCH 05/10] staging: rtl8723bs: clean up open braces

2020-11-09 Thread Ross Schmidt
Move braces to fix coding style issues and clear checkpatch errors.
Some braces are removed for single statements.

ERROR: open brace '{' following function definitions go on the next line
ERROR: that open brace { should be on the previous line

Signed-off-by: Ross Schmidt 
---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 167 ++
 1 file changed, 54 insertions(+), 113 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 736f1a6ac118..385705aafa5c 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1746,8 +1746,7 @@ static int rtw_cfg80211_set_cipher(struct security_priv 
*psecuritypriv, u32 ciph
return -ENOTSUPP;
}
 
-   if (ucast)
-   {
+   if (ucast) {
psecuritypriv->ndisencryptstatus = ndisencryptstatus;
 
/* if (psecuritypriv->dot11PrivacyAlgrthm >= _AES_) */
@@ -1819,10 +1818,8 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter 
*padapter, u8 *pie, size_t iel
}
 
pwpa = rtw_get_wpa_ie(buf, &wpa_ielen, ielen);
-   if (pwpa && wpa_ielen > 0)
-   {
-   if (rtw_parse_wpa_ie(pwpa, wpa_ielen+2, &group_cipher, 
&pairwise_cipher, NULL) == _SUCCESS)
-   {
+   if (pwpa && wpa_ielen > 0) {
+   if (rtw_parse_wpa_ie(pwpa, wpa_ielen+2, &group_cipher, 
&pairwise_cipher, NULL) == _SUCCESS) {
padapter->securitypriv.dot11AuthAlgrthm = 
dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype = 
Ndis802_11AuthModeWPAPSK;
memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0], 
wpa_ielen+2);
@@ -1832,10 +1829,8 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter 
*padapter, u8 *pie, size_t iel
}
 
pwpa2 = rtw_get_wpa2_ie(buf, &wpa2_ielen, ielen);
-   if (pwpa2 && wpa2_ielen > 0)
-   {
-   if (rtw_parse_wpa2_ie(pwpa2, wpa2_ielen+2, &group_cipher, 
&pairwise_cipher, NULL) == _SUCCESS)
-   {
+   if (pwpa2 && wpa2_ielen > 0) {
+   if (rtw_parse_wpa2_ie(pwpa2, wpa2_ielen+2, &group_cipher, 
&pairwise_cipher, NULL) == _SUCCESS) {
padapter->securitypriv.dot11AuthAlgrthm = 
dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype = 
Ndis802_11AuthModeWPA2PSK;
memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0], 
wpa2_ielen+2);
@@ -1845,13 +1840,10 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter 
*padapter, u8 *pie, size_t iel
}
 
if (group_cipher == 0)
-   {
group_cipher = WPA_CIPHER_NONE;
-   }
+
if (pairwise_cipher == 0)
-   {
pairwise_cipher = WPA_CIPHER_NONE;
-   }
 
switch (group_cipher)
{
@@ -1954,8 +1946,7 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, 
struct net_device *ndev,
goto exit;
}
 
-   if (!params->ssid || !params->ssid_len)
-   {
+   if (!params->ssid || !params->ssid_len) {
ret = -EINVAL;
goto exit;
}
@@ -1981,8 +1972,7 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, 
struct net_device *ndev,
ret = rtw_cfg80211_set_auth_type(psecuritypriv, 
NL80211_AUTHTYPE_OPEN_SYSTEM);
rtw_set_802_11_authentication_mode(padapter, 
psecuritypriv->ndisauthtype);
 
-   if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false)
-   {
+   if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) {
ret = -1;
goto exit;
}
@@ -2004,8 +1994,7 @@ static int cfg80211_rtw_leave_ibss(struct wiphy *wiphy, 
struct net_device *ndev)
 
rtw_set_to_roam(padapter, 0);
 
-   if (check_fwstate(&padapter->mlmepriv, _FW_LINKED))
-   {
+   if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
rtw_scan_abort(padapter);
LeaveAllPowerSaveMode(padapter);
 
@@ -2041,8 +2030,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, 
struct net_device *ndev,
sme->privacy, sme->key, sme->key_len, sme->key_idx);
 
 
-   if (adapter_wdev_data(padapter)->block == true)
-   {
+   if (adapter_wdev_data(padapter)->block == true) {
ret = -EBUSY;
DBG_871X("%s wdev_priv.block is set\n", __func__);
goto exit;
@@ -2059,8 +2047,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, 
struct net_device *ndev,
goto exit;
}
 
-   if (!sme->ssid || !sme->ssid_len)
-   {
+   if (!sme->ssid || !sme->ssid_len) {
ret = -EINVAL;
 

[PATCH 08/10] staging: rtl8723bs: clean up logical continuations

2020-11-09 Thread Ross Schmidt
Move operators to fix coding style issues and clear checkpatch checks.

CHECK: Logical continuations should be on the previous line

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  | 41 +++
 drivers/staging/rtl8723bs/core/rtw_recv.c | 27 ++--
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  6 +--
 drivers/staging/rtl8723bs/core/rtw_xmit.c |  6 +--
 4 files changed, 34 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 90e222a9c93b..5b05d1eaa328 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -451,9 +451,8 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, 
u8 smart_ps, u8 bcn_a
hal_btcoex_LpsNotify(padapter, ps_mode);
}
} else {
-   if ((PS_RDY_CHECK(padapter) && 
check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE))
-   || ((hal_btcoex_IsBtControlLps(padapter))
-   && (hal_btcoex_IsLpsOn(padapter)))
+   if ((PS_RDY_CHECK(padapter) && 
check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) ||
+   ((hal_btcoex_IsBtControlLps(padapter)) && 
(hal_btcoex_IsLpsOn(padapter)))
) {
u8 pslv;
 
@@ -472,8 +471,8 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, 
u8 smart_ps, u8 bcn_a
if (pwrpriv->alives == 0)
pslv = PS_STATE_S0;
 
-   if (!(hal_btcoex_IsBtDisabled(padapter))
-   && (hal_btcoex_IsBtControlLps(padapter))) {
+   if (!(hal_btcoex_IsBtDisabled(padapter)) &&
+   (hal_btcoex_IsBtControlLps(padapter))) {
u8 val8;
 
val8 = hal_btcoex_LpsVal(padapter);
@@ -688,9 +687,9 @@ void LPS_Leave_check(struct adapter *padapter)
while (1) {
mutex_lock(&pwrpriv->lock);
 
-   if (padapter->bSurpriseRemoved
-   || !(padapter->hw_init_completed)
-   || (pwrpriv->pwr_mode == PS_MODE_ACTIVE))
+   if (padapter->bSurpriseRemoved ||
+   !(padapter->hw_init_completed) ||
+   (pwrpriv->pwr_mode == PS_MODE_ACTIVE))
bReady = true;
 
mutex_unlock(&pwrpriv->lock);
@@ -897,8 +896,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, 
u32 task)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S0;
 
-   if (!(hal_btcoex_IsBtDisabled(padapter))
-   && hal_btcoex_IsBtControlLps(padapter)) {
+   if (!(hal_btcoex_IsBtDisabled(padapter)) && 
hal_btcoex_IsBtControlLps(padapter)) {
u8 val8;
 
val8 = hal_btcoex_LpsVal(padapter);
@@ -910,8 +908,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, 
u32 task)
 
unregister_task_alive(pwrctrl, task);
 
-   if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE)
-   && pwrctrl->bFwCurrentInPSMode) {
+   if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && 
pwrctrl->bFwCurrentInPSMode) {
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
 ("%s: cpwm = 0x%02x alives = 0x%08x\n",
  __func__, pwrctrl->cpwm, pwrctrl->alives));
@@ -1038,8 +1035,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S0;
 
-   if (!(hal_btcoex_IsBtDisabled(padapter))
-   && hal_btcoex_IsBtControlLps(padapter)) {
+   if (!(hal_btcoex_IsBtDisabled(padapter)) && 
hal_btcoex_IsBtControlLps(padapter)) {
u8 val8;
 
val8 = hal_btcoex_LpsVal(padapter);
@@ -1051,8 +1047,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
 
unregister_task_alive(pwrctrl, XMIT_ALIVE);
 
-   if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE)
-   && pwrctrl->bFwCurrentInPSMode) {
+   if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && 
pwrctrl->bFwCurrentInPSMode) {
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
 ("%s: cpwm = 0x%02x alives = 0x%08x\n",
  __func__, pwrctrl->cpwm, pwrctrl->alives));
@@ -1080,8 +1075,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter)
pwrctrl = adapter_to_pwrctl(padapter);
pslv = PS_STATE_S0;
 
-   if (!(hal_btcoex_IsBtDisabled(padapter))
-   && hal_btcoex_IsBtControlLps(padapter)) {
+   

[PATCH 02/10] staging: rtl8723bs: clean up braces

2020-11-09 Thread Ross Schmidt
Add or remove braces or remove lines to fix coding style issues and
clear checkpatch.

WARNING: braces {} are not necessary for single statement blocks
WARNING: braces {} are not necessary for any arm of this statement
CHECK: Unbalanced braces around else statement
CHECK: braces {} should be used on all arms of this statement
CHECK: Blank lines aren't necessary before a close brace '}'
CHECK: Blank lines aren't necessary after an open brace '{'

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 42 ++-
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c  | 11 +
 .../staging/rtl8723bs/core/rtw_wlan_util.c| 23 ++
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 23 ++
 4 files changed, 52 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 894e7beae96f..85f1164f7960 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -1336,8 +1336,9 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
hdrlen += 2;
 
qc_exists = 1;
-   } else
+   } else {
qc_exists = 0;
+   }
 
pn_vector[0] = pframe[hdrlen];
pn_vector[1] = pframe[hdrlen+1];
@@ -1393,9 +1394,9 @@ static sint aes_cipher(u8 *key, uint  hdrlen,
if (payload_remainder > 0) {
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
-   for (j = 0; j < payload_remainder; j++) {
+   for (j = 0; j < payload_remainder; j++)
padded_buffer[j] = pframe[payload_index++];
-   }
+
bitwise_xor(aes_out, padded_buffer, chain_buffer);
aes128k128d(key, chain_buffer, aes_out);
}
@@ -1576,20 +1577,21 @@ static sint aes_decipher(u8 *key, uint  hdrlen,
((frtype|frsubtype) == WIFI_DATA_CFPOLL) ||
((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) {
qc_exists = 1;
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN) {
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
hdrlen += 2;
-   }
+
} else if ((frtype == WIFI_DATA) && /* only for data packet . add for 
CONFIG_IEEE80211W, none 11w also can use */
   ((frsubtype == 0x08) ||
   (frsubtype == 0x09) ||
   (frsubtype == 0x0a) ||
   (frsubtype == 0x0b))) {
-   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN) {
+   if (hdrlen !=  WLAN_HDR_A3_QOS_LEN)
hdrlen += 2;
-   }
+
qc_exists = 1;
-   } else
+   } else {
qc_exists = 0;
+   }
 
/*  now, decrypt pframe with hdrlen offset and plen long */
 
@@ -1623,9 +1625,9 @@ static sint aes_decipher(u8 *key, uinthdrlen,
 
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
-   for (j = 0; j < payload_remainder; j++) {
+   for (j = 0; j < payload_remainder; j++)
padded_buffer[j] = pframe[payload_index+j];
-   }
+
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, padded_buffer, chain_buffer);
for (j = 0; j < payload_remainder; j++)
@@ -1690,9 +1692,9 @@ static sint aes_decipher(u8 *key, uinthdrlen,
if (payload_remainder > 0) {
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
-   for (j = 0; j < payload_remainder; j++) {
+   for (j = 0; j < payload_remainder; j++)
padded_buffer[j] = message[payload_index++];
-   }
+
bitwise_xor(aes_out, padded_buffer, chain_buffer);
aes128k128d(key, chain_buffer, aes_out);
}
@@ -1736,9 +1738,9 @@ static sint aes_decipher(u8 *key, uinthdrlen,
 
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
-   for (j = 0; j < payload_remainder; j++) {
+   for (j = 0; j < payload_remainder; j++)
padded_buffer[j] = message[payload_index+j];
-   }
+
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, padded_buffer, chain_buffer);
for (j = 0; j < payload_remainder; j++)
@@ -1758,9 +1760,8 @@ static sint aes_decipher(u8 *key, uinthdrlen,
 
for (j = 0; j < 16; j++)
padded_buffer[j] = 0x00;
-   for (j = 0; j < 8; j++) {
+   for (j = 0; j < 8; j++)
padded_buffer[j] = message[j+hdrlen+8+plen-8];
-   }
 
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, padded_buffer, cha

[PATCH 03/10] staging: rtl8723bs: clean up space before tabs

2020-11-09 Thread Ross Schmidt
Remove spaces before tabs to fix coding style issues and clear
checkpatch warnings.

WARNING: please, no space before tabs

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_pwrctrl.c  | 16 +++
 drivers/staging/rtl8723bs/core/rtw_recv.c | 42 +-
 drivers/staging/rtl8723bs/core/rtw_security.c | 44 +--
 .../staging/rtl8723bs/core/rtw_wlan_util.c| 34 +++---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 20 -
 5 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c 
b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 0d8aa7a2469e..8fe1d7429760 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -1340,8 +1340,8 @@ void rtw_ps_deny(struct adapter *padapter, enum 
PS_DENY_REASON reason)
 {
struct pwrctrl_priv *pwrpriv;
 
-/* DBG_871X("+" FUNC_ADPT_FMT ": Request PS deny for %d (0x%08X)\n", */
-/* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
+   /* DBG_871X("+" FUNC_ADPT_FMT ": Request PS deny for %d (0x%08X)\n", */
+   /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
 
pwrpriv = adapter_to_pwrctl(padapter);
 
@@ -1353,8 +1353,8 @@ void rtw_ps_deny(struct adapter *padapter, enum 
PS_DENY_REASON reason)
pwrpriv->ps_deny |= BIT(reason);
mutex_unlock(&pwrpriv->lock);
 
-/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
-/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
+   /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
+   /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
 }
 
 /*
@@ -1366,8 +1366,8 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum 
PS_DENY_REASON reason)
struct pwrctrl_priv *pwrpriv;
 
 
-/* DBG_871X("+" FUNC_ADPT_FMT ": Cancel PS deny for %d(0x%08X)\n", */
-/* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
+   /* DBG_871X("+" FUNC_ADPT_FMT ": Cancel PS deny for %d(0x%08X)\n", */
+   /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
 
pwrpriv = adapter_to_pwrctl(padapter);
 
@@ -1379,8 +1379,8 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum 
PS_DENY_REASON reason)
pwrpriv->ps_deny &= ~BIT(reason);
mutex_unlock(&pwrpriv->lock);
 
-/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
-/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
+   /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
+   /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
 }
 
 /*
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 26e72decb07e..c854aa3ff992 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -25,7 +25,7 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv 
*psta_recvpriv)
spin_lock_init(&psta_recvpriv->lock);
 
/* for (i = 0; iblk_strms[i]); */
+   /* _rtw_init_queue(&psta_recvpriv->blk_strms[i]); */
 
_rtw_init_queue(&psta_recvpriv->defrag_q);
 }
@@ -55,7 +55,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct 
adapter *padapter)
 
precvpriv->precv_frame_buf = (u8 
*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), 
RXFRAME_ALIGN_SZ);
/* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + 
RXFRAME_ALIGN_SZ - */
-   /*  ((SIZE_PTR) 
(precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */
+   /* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) 
&(RXFRAME_ALIGN_SZ-1)); */
 
precvframe = (union recv_frame *) precvpriv->precv_frame_buf;
 
@@ -316,9 +316,9 @@ sint recvframe_chkmic(struct adapter *adapter,  union 
recv_frame *precvframe)
u8 *pframe, *payload, *pframemic;
u8 *mickey;
/* u8 *iv, rxdata_key_idx = 0; */
-   struct  sta_info*stainfo;
-   struct  rx_pkt_attrib   *prxattrib = &precvframe->u.hdr.attrib;
-   struct  security_priv *psecuritypriv = &adapter->securitypriv;
+   struct sta_info *stainfo;
+   struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib;
+   struct security_priv *psecuritypriv = &adapter->securitypriv;
 
struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
@@ -340,7 +340,7 @@ sint recvframe_chkmic(struct adapter *adapter,  union 
recv_frame *precvframe)
 
RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, 
("\n recvframe_chkmic: bcmc key\n"));
 

[PATCH 2/9] staging: rtl8723bs: use %pM format for MAC addresses

2020-11-04 Thread Ross Schmidt
Use %pM format instead of custom printing code.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/hal/sdio_halinit.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c 
b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
index e42d8c18e1ae..08abfb8ec4c7 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
@@ -1231,19 +1231,8 @@ static void Hal_EfuseParseMACAddr_8723BS(
}
 /* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */
 
-   RT_TRACE(
-   _module_hci_hal_init_c_,
-   _drv_notice_,
-   (
-   "Hal_EfuseParseMACAddr_8723BS: Permanent Address = 
%02x-%02x-%02x-%02x-%02x-%02x\n",
-   pEEPROM->mac_addr[0],
-   pEEPROM->mac_addr[1],
-   pEEPROM->mac_addr[2],
-   pEEPROM->mac_addr[3],
-   pEEPROM->mac_addr[4],
-   pEEPROM->mac_addr[5]
-   )
-   );
+   RT_TRACE(_module_hci_hal_init_c_, _drv_notice_,
+("Hal_EfuseParseMACAddr_8723BS: Permanent Address = %pM\n", 
pEEPROM->mac_addr));
 }
 
 static void Hal_EfuseParseBoardType_8723BS(
-- 
2.25.1



[PATCH 9/9] staging: rtl8723bs: replace ieee80211_back_actioncode

2020-11-04 Thread Ross Schmidt
Replace the unique rtw_ieee80211_back_actioncode with the standard
provided ieee80211_back_actioncode.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 16 
 drivers/staging/rtl8723bs/include/ieee80211.h |  7 ---
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index c113902877bd..1a6cae5f9895 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1944,21 +1944,21 @@ unsigned int OnAction_back(struct adapter *padapter, 
union recv_frame *precv_fra
action = frame_body[1];
DBG_871X("%s, action =%d\n", __func__, action);
switch (action) {
-   case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */
+   case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */
 
memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), 
sizeof(struct ADDBA_request));
/* process_addba_req(padapter, (u8 
*)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */
process_addba_req(padapter, (u8 
*)&(pmlmeinfo->ADDBA_req), addr);
 
if (pmlmeinfo->accept_addba_req) {
-   issue_action_BA(padapter, addr, 
RTW_WLAN_ACTION_ADDBA_RESP, 0);
+   issue_action_BA(padapter, addr, 
WLAN_ACTION_ADDBA_RESP, 0);
} else {
-   issue_action_BA(padapter, addr, 
RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */
+   issue_action_BA(padapter, addr, 
WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */
}
 
break;
 
-   case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
+   case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
status = get_unaligned_le16(&frame_body[3]);
tid = ((frame_body[5] >> 2) & 0x7);
 
@@ -1981,7 +1981,7 @@ unsigned int OnAction_back(struct adapter *padapter, 
union recv_frame *precv_fra
/* DBG_871X("marc: ADDBA RSP: %x\n", 
pmlmeinfo->agg_enable_bitmap); */
break;
 
-   case RTW_WLAN_ACTION_DELBA: /* DELBA */
+   case WLAN_ACTION_DELBA: /* DELBA */
if ((frame_body[3] & BIT(3)) == 0) {
psta->htpriv.agg_enable_bitmap &=
~BIT((frame_body[3] >> 4) & 0xf);
@@ -4199,7 +4199,7 @@ unsigned int send_delba(struct adapter *padapter, u8 
initiator, u8 *addr)
for (tid = 0; tid < MAXTID; tid++) {
if (psta->recvreorder_ctrl[tid].enable) {
DBG_871X("rx agg disable tid(%d)\n", tid);
-   issue_action_BA(padapter, addr, 
RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
+   issue_action_BA(padapter, addr, 
WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
psta->recvreorder_ctrl[tid].enable = false;
psta->recvreorder_ctrl[tid].indicate_seq = 
0x;
#ifdef DBG_RX_SEQ
@@ -4213,7 +4213,7 @@ unsigned int send_delba(struct adapter *padapter, u8 
initiator, u8 *addr)
for (tid = 0; tid < MAXTID; tid++) {
if (psta->htpriv.agg_enable_bitmap & BIT(tid)) {
DBG_871X("tx agg disable tid(%d)\n", tid);
-   issue_action_BA(padapter, addr, 
RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
+   issue_action_BA(padapter, addr, 
WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
 
@@ -6529,7 +6529,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char 
*pbuf)
/* pmlmeinfo->ADDBA_retry_count = 0; */
/* pmlmeinfo->candidate_tid_bitmap |= (0x1 << pparm->tid); */
/* psta->htpriv.candidate_tid_bitmap |= BIT(pparm->tid); */
-   issue_action_BA(padapter, pparm->addr, 
RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid);
+   issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, 
(u16)pparm->tid);
/* _set_timer(&pmlmeext->ADDBA_timer, ADDBA_TO); */
_set_timer(&psta->addba_retry_timer, ADDBA_TO);
} else {
diff --git a/drivers/staging/rtl8723bs/i

[PATCH 7/9] staging: rtl8723bs: replace rtw_ieee80211_spectrum_mgmt_actioncode

2020-11-04 Thread Ross Schmidt
Replace the unique rtw_ieee80211_mgmt_actioncode enum with the provided
standard ieee80211_spectrum_mgmt_actioncode.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +-
 drivers/staging/rtl8723bs/include/ieee80211.h | 10 --
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 3bb80db51562..cdb1d2b06f1b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1891,11 +1891,11 @@ unsigned int on_action_spct(struct adapter *padapter, 
union recv_frame *precv_fr
 
action = frame_body[1];
switch (action) {
-   case RTW_WLAN_ACTION_SPCT_MSR_REQ:
-   case RTW_WLAN_ACTION_SPCT_MSR_RPRT:
-   case RTW_WLAN_ACTION_SPCT_TPC_REQ:
-   case RTW_WLAN_ACTION_SPCT_TPC_RPRT:
-   case RTW_WLAN_ACTION_SPCT_CHL_SWITCH:
+   case WLAN_ACTION_SPCT_MSR_REQ:
+   case WLAN_ACTION_SPCT_MSR_RPRT:
+   case WLAN_ACTION_SPCT_TPC_REQ:
+   case WLAN_ACTION_SPCT_TPC_RPRT:
+   case WLAN_ACTION_SPCT_CHL_SWITCH:
break;
default:
break;
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index e2a6b92ba3ba..06aacafd2340 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -893,16 +893,6 @@ enum rtw_ieee80211_category {
RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
 };
 
-/* SPECTRUM_MGMT action code */
-enum rtw_ieee80211_spectrum_mgmt_actioncode {
-   RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
-   RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
-   RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
-   RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
-   RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
-   RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
-};
-
 enum _PUBLIC_ACTION {
ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
ACT_PUBLIC_DSE_ENABLE = 1,
-- 
2.25.1



[PATCH 4/9] staging: rtl8723bs: remove NDEV_FMT macro

2020-11-04 Thread Ross Schmidt
Remove unnecessary macro for %s and call it directly.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/include/osdep_service_linux.h | 1 -
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c   | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h 
b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 498d5474010c..24386aa9ee1b 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -123,7 +123,6 @@ static inline void rtw_netif_stop_queue(struct net_device 
*pnetdev)
 
 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
 
-#define NDEV_FMT "%s"
 #define NDEV_ARG(ndev) ndev->name
 #define ADPT_FMT "%s"
 #define ADPT_ARG(adapter) adapter->pnetdev->name
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 5dfa2fa24c76..736f1a6ac118 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -2574,7 +2574,7 @@ static int rtw_cfg80211_add_monitor_if(struct adapter 
*padapter, char *name, str
}
 
if (pwdev_priv->pmon_ndev) {
-   DBG_871X(FUNC_ADPT_FMT" monitor interface exist: "NDEV_FMT"\n",
+   DBG_871X(FUNC_ADPT_FMT" monitor interface exist: %s\n",
FUNC_ADPT_ARG(padapter), 
NDEV_ARG(pwdev_priv->pmon_ndev));
ret = -EBUSY;
goto out;
-- 
2.25.1



[PATCH 5/9] staging: rtl8723bs: remove ADPT_FMT macro

2020-11-04 Thread Ross Schmidt
Remove unnecessary macro for %s and call it directly.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c |  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c|  4 ++--
 drivers/staging/rtl8723bs/core/rtw_security.c|  4 ++--
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c   |  6 +++---
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 12 ++--
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c   |  2 +-
 .../staging/rtl8723bs/include/osdep_service_linux.h  |  1 -
 7 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 4e11cd97cc01..d0772b4fe15d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -503,7 +503,7 @@ int rtw_cmd_thread(void *context)
 
cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time);
if (cmd_process_time > 1000) {
-   DBG_871X(ADPT_FMT "cmd= %d process_time= %lu > 1 sec\n",
+   DBG_871X("%s cmd= %d process_time= %lu > 1 sec\n",
 ADPT_ARG(pcmd->padapter), pcmd->cmdcode,
 cmd_process_time);
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index f81ab2541554..a0bb25031f1a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -5108,7 +5108,7 @@ void report_surveydone_event(struct adapter *padapter)
psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct 
C2HEvent_Header));
psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt;
 
-   DBG_871X("survey done event(%x) band:%d for "ADPT_FMT"\n", 
psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter));
+   DBG_871X("survey done event(%x) band:%d for %s\n", 
psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter));
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
 
@@ -5585,7 +5585,7 @@ void _linked_info_dump(struct adapter *padapter)
 
if (padapter->bLinkInfoDump) {
 
-   DBG_871X("\n ["ADPT_FMT"] linked status check 
===\n", ADPT_ARG(padapter));
+   DBG_871X("\n [%s] linked status check 
===\n", ADPT_ARG(padapter));
 
if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
rtw_hal_get_def_var(padapter, 
HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB);
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 82e26acb772c..81c15895f646 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -2372,12 +2372,12 @@ u8 rtw_handle_tkip_countermeasure(struct adapter 
*adapter, const char *caller)
if (securitypriv->btkip_countermeasure) {
unsigned long passing_ms = jiffies_to_msecs(jiffies - 
securitypriv->btkip_countermeasure_time);
if (passing_ms > 60*1000) {
-   DBG_871X_LEVEL(_drv_always_, "%s("ADPT_FMT") 
countermeasure time:%lus > 60s\n",
+   DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure 
time:%lus > 60s\n",
caller, ADPT_ARG(adapter), passing_ms/1000);
securitypriv->btkip_countermeasure = false;
securitypriv->btkip_countermeasure_time = 0;
} else {
-   DBG_871X_LEVEL(_drv_always_, "%s("ADPT_FMT") 
countermeasure time:%lus < 60s\n",
+   DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure 
time:%lus < 60s\n",
caller, ADPT_ARG(adapter), passing_ms/1000);
status = _FAIL;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index e1c278501779..eda91b78a543 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -304,7 +304,7 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch)
 
for (i = 0; i < dvobj->iface_nums; i++) {
struct adapter *iface = dvobj->padapters[i];
-   cnt += scnprintf(msg+cnt, len-cnt, " ["ADPT_FMT":", 
ADPT_ARG(iface));
+   cnt += scnprintf(msg+cnt, len-cnt, " [%s:", 
ADPT_ARG(iface));
if (iface->mlmeextpriv.cur_channel == ch)

[PATCH 6/9] staging: rtl8723bs: replace rtw_ieee80211_ht_cap

2020-11-04 Thread Ross Schmidt
Replace the unique rtw_ieee80211_ht_cap struct with the provided standard
ieee80211_ht_cap.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   |  6 +++---
 .../staging/rtl8723bs/core/rtw_ioctl_set.c|  2 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 20 +--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  8 
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  4 ++--
 drivers/staging/rtl8723bs/hal/hal_com.c   |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h |  4 ++--
 drivers/staging/rtl8723bs/include/rtw_ht.h|  2 +-
 drivers/staging/rtl8723bs/include/wifi.h  | 16 ---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 10 +-
 10 files changed, 29 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index d9a55bee83a3..a2b39ae56d89 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1179,7 +1179,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
if (p && ie_len > 0) {
u8 rf_type = 0;
u8 max_rx_ampdu_factor = 0;
-   struct rtw_ieee80211_ht_cap *pht_cap = (struct 
rtw_ieee80211_ht_cap *)(p + 2);
+   struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap 
*)(p + 2);
 
pHT_caps_ie = p;
 
@@ -1225,8 +1225,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
 
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
if (rf_type == RF_1T1R) {
-   pht_cap->supp_mcs_set[0] = 0xff;
-   pht_cap->supp_mcs_set[1] = 0x0;
+   pht_cap->mcs.rx_mask[0] = 0xff;
+   pht_cap->mcs.rx_mask[1] = 0x0;
}
 
memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len);
diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c 
b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index d44b33e7a0a9..e0bab0a71f00 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -661,7 +661,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter)
rf_type,
((psta->bw_mode == CHANNEL_WIDTH_40)?1:0),
short_GI,
-   psta->htpriv.ht_cap.supp_mcs_set
+   psta->htpriv.ht_cap.mcs.rx_mask
);
} else {
while ((pcur_bss->SupportedRates[i] != 0) && 
(pcur_bss->SupportedRates[i] != 0xFF)) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b5226a517b91..351178ab78c5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -2582,7 +2582,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
u32 ielen, out_len;
enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor;
unsigned char *p, *pframe;
-   struct rtw_ieee80211_ht_cap ht_capie;
+   struct ieee80211_ht_cap ht_capie;
u8 cbw40_enable = 0, stbc_rx_enable = 0, rf_type = 0, operation_bw = 0;
struct registry_priv *pregistrypriv = &padapter->registrypriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2593,7 +2593,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
 
out_len = *pout_len;
 
-   memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap));
+   memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
 
ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_DSSSCCK40);
 
@@ -2660,7 +2660,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
}
 
/* fill default supported_mcs_set */
-   memcpy(ht_capie.supp_mcs_set, pmlmeext->default_supported_mcs_set, 16);
+   memcpy(ht_capie.mcs.rx_mask, pmlmeext->default_supported_mcs_set, 16);
 
/* update default supported_mcs_set */
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
@@ -2670,7 +2670,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
if (stbc_rx_enable)
ht_capie.cap_info |= 
cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */
 
-   set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R);
+   set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_1R);
break;
 
case RF_2T2R:
@@ -2681,11 +2681,11 @@ unsigned int rtw_restructure_ht_ie(struct adapter 
*padapter, u8 *in_ie, u8 *out_
 
#ifdef CONFIG_DISABLE_MCS13TO15
if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WID

[PATCH 8/9] staging: rtl8723bs: replace rtw_ieee80211_ht_actioncode

2020-11-04 Thread Ross Schmidt
Replace the unique rtw_ieee80211_ht_actioncode enum with the provided
standard ieee80211_ht_actioncode.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h | 12 
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index cdb1d2b06f1b..c113902877bd 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -2145,7 +2145,7 @@ unsigned int OnAction_ht(struct adapter *padapter, union 
recv_frame *precv_frame
 
action = frame_body[1];
switch (action) {
-   case RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING:
+   case WLAN_HT_ACTION_COMPRESSED_BF:
break;
default:
break;
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 06aacafd2340..cd8f6d006a38 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -920,18 +920,6 @@ enum rtw_ieee80211_back_actioncode {
RTW_WLAN_ACTION_DELBA = 2,
 };
 
-/* HT features action code */
-enum rtw_ieee80211_ht_actioncode {
-   RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0,
-   RTW_WLAN_ACTION_HT_SM_PS = 1,
-   RTW_WLAN_ACTION_HT_PSMP = 2,
-   RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3,
-   RTW_WLAN_ACTION_HT_CSI = 4,
-   RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5,
-   RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6,
-   RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7,
-};
-
 /* BACK (block-ack) parties */
 enum rtw_ieee80211_back_parties {
RTW_WLAN_BACK_RECIPIENT = 0,
-- 
2.25.1



[PATCH 1/9] staging: rtl8723bs: remove MAC_FMT macro

2020-11-04 Thread Ross Schmidt
Remove unnecessary macro for %pM and call it directly.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   | 39 +--
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |  2 +-
 .../staging/rtl8723bs/core/rtw_ieee80211.c|  2 +-
 .../staging/rtl8723bs/core/rtw_ioctl_set.c|  4 +-
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 24 +-
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 47 +--
 drivers/staging/rtl8723bs/core/rtw_recv.c | 22 -
 .../staging/rtl8723bs/core/rtw_wlan_util.c|  6 +--
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 10 ++--
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  |  4 +-
 drivers/staging/rtl8723bs/include/ieee80211.h |  1 -
 .../staging/rtl8723bs/include/osdep_service.h |  3 --
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 14 +++---
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 16 +++
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   |  8 ++--
 drivers/staging/rtl8723bs/os_dep/recv_linux.c |  2 +-
 16 files changed, 93 insertions(+), 111 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index afe7023a9e8e..d9a55bee83a3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -182,7 +182,7 @@ u8 chk_sta_is_alive(struct sta_info *psta)
 {
#ifdef DBG_EXPIRATION_CHK
DBG_871X(
-   "sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, 
%s%ssq_len:%u\n"
+   "sta:%pM, rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, 
%s%ssq_len:%u\n"
, MAC_ARG(psta->hwaddr)
, psta->rssi_stat.UndecoratedSmoothedPWDB
/*  STA_RX_PKTS_ARG(psta) */
@@ -297,7 +297,7 @@ void expire_timeout_chk(struct adapter *padapter)
psta->expire_to = pstapriv->expire_to;
psta->state |= WIFI_STA_ALIVE_CHK_STATE;
 
-   /* DBG_871X("alive chk, sta:" MAC_FMT " 
is at ps mode!\n", MAC_ARG(psta->hwaddr)); */
+   /* DBG_871X("alive chk, sta:%pM is at 
ps mode!\n", MAC_ARG(psta->hwaddr)); */
 
/* to update bcn with tim_bitmap for 
this station */
pstapriv->tim_bitmap |= BIT(psta->aid);
@@ -319,7 +319,7 @@ void expire_timeout_chk(struct adapter *padapter)
list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--;
DBG_871X(
-   "asoc expire "MAC_FMT", state = 0x%x\n",
+   "asoc expire %pM, state = 0x%x\n",
MAC_ARG(psta->hwaddr),
psta->state
);
@@ -332,7 +332,7 @@ void expire_timeout_chk(struct adapter *padapter)
) / 2)
) {
DBG_871X(
-   "%s sta:"MAC_FMT", sleepq_len:%u, 
free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n",
+   "%s sta:%pM, sleepq_len:%u, 
free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n",
__func__,
MAC_ARG(psta->hwaddr),
psta->sleepq_len,
@@ -372,7 +372,7 @@ void expire_timeout_chk(struct adapter *padapter)
psta->keep_alive_trycnt++;
if (ret == _SUCCESS) {
DBG_871X(
-   "asoc check, sta(" MAC_FMT ") is 
alive\n",
+   "asoc check, sta(%pM) is alive\n",
MAC_ARG(psta->hwaddr)
);
psta->expire_to = pstapriv->expire_to;
@@ -387,10 +387,8 @@ void expire_timeout_chk(struct adapter *padapter)
}
 
psta->keep_alive_trycnt = 0;
-   DBG_871X(
-   "asoc expire "MAC_FMT", state = 0x%x\n",
-   MAC_ARG(psta->hwaddr),
-   psta->state);
+   DBG_871X("asoc expire %pM, state = 0x%x\n", 
MAC_ARG(psta->hwaddr),
+psta->state);
spin_lock_bh(&pstapriv->asoc_list_lock);
if (list_empty(&psta->asoc_list) == false) {
   

[PATCH 3/9] staging: rtl8723bs: remove IP_FMT macro

2020-11-04 Thread Ross Schmidt
Remove unnecessary macro for %pI4 and call it directly.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c  | 4 ++--
 drivers/staging/rtl8723bs/include/ieee80211.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c 
b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
index a6d870d663a4..93c93cdaadaf 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
@@ -416,7 +416,7 @@ static void ConstructARPResponse(
SET_ARP_PKT_TARGET_MAC_ADDR(pARPRspPkt, 
get_my_bssid(&(pmlmeinfo->network)));
SET_ARP_PKT_TARGET_IP_ADDR(pARPRspPkt, pIPAddress);
DBG_871X("%s Target Mac Addr:%pM\n", __func__, 
MAC_ARG(get_my_bssid(&(pmlmeinfo->network;
-   DBG_871X("%s Target IP Addr" IP_FMT "\n", __func__, 
IP_ARG(pIPAddress));
+   DBG_871X("%s Target IP Addr:%pI4\n", __func__, 
IP_ARG(pIPAddress));
}
 
*pLength += 28;
@@ -738,7 +738,7 @@ static void ConstructProbeRsp(struct adapter *padapter, u8 
*pframe, u32 *pLength
memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
 
DBG_871X("%s FW Mac Addr:%pM\n", __func__, MAC_ARG(mac));
-   DBG_871X("%s FW IP Addr" IP_FMT "\n", __func__, IP_ARG(StaAddr));
+   DBG_871X("%s FW IP Addr:%pI4\n", __func__, IP_ARG(StaAddr));
 
SetSeqNum(pwlanhdr, 0);
SetFrameSubType(fctrl, WIFI_PROBERSP);
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h 
b/drivers/staging/rtl8723bs/include/ieee80211.h
index 902c710c1155..5cd307cb48a5 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -845,7 +845,6 @@ enum ieee80211_state {
 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
 #define DEFAULT_FTS 2346
 #define MAC_ARG(x) (x)
-#define IP_FMT "%pI4"
 #define IP_ARG(x) (x)
 
 static inline int is_multicast_mac_addr(const u8 *addr)
-- 
2.25.1



Re: [PATCH 07/13] x86: Secure Launch kernel early boot stub

2020-10-21 Thread Ross Philipson
On 10/21/20 12:18 PM, Arvind Sankar wrote:
> On Wed, Oct 21, 2020 at 05:28:33PM +0200, Daniel Kiper wrote:
>> On Mon, Oct 19, 2020 at 01:18:22PM -0400, Arvind Sankar wrote:
>>> On Mon, Oct 19, 2020 at 04:51:53PM +0200, Daniel Kiper wrote:
>>>> On Fri, Oct 16, 2020 at 04:51:51PM -0400, Arvind Sankar wrote:
>>>>> On Thu, Oct 15, 2020 at 08:26:54PM +0200, Daniel Kiper wrote:
>>>>>>
>>>>>> I am discussing with Ross the other option. We can create
>>>>>> .rodata.mle_header section and put it at fixed offset as
>>>>>> kernel_info is. So, we would have, e.g.:
>>>>>>
>>>>>> arch/x86/boot/compressed/vmlinux.lds.S:
>>>>>> .rodata.kernel_info KERNEL_INFO_OFFSET : {
>>>>>> *(.rodata.kernel_info)
>>>>>> }
>>>>>> ASSERT(ABSOLUTE(kernel_info) == KERNEL_INFO_OFFSET, "kernel_info 
>>>>>> at bad address!")
>>>>>>
>>>>>> .rodata.mle_header MLE_HEADER_OFFSET : {
>>>>>> *(.rodata.mle_header)
>>>>>> }
>>>>>> ASSERT(ABSOLUTE(mle_header) == MLE_HEADER_OFFSET, "mle_header at 
>>>>>> bad address!")
>>>>>>
>>>>>> arch/x86/boot/compressed/sl_stub.S:
>>>>>> #define mleh_rva(X) (((X) - mle_header) + MLE_HEADER_OFFSET)
>>>>>>
>>>>>> .section ".rodata.mle_header", "a"
>>>>>>
>>>>>> SYM_DATA_START(mle_header)
>>>>>> .long   0x9082ac5a/* UUID0 */
>>>>>> .long   0x74a7476f/* UUID1 */
>>>>>> .long   0xa2555c0f/* UUID2 */
>>>>>> .long   0x42b651cb/* UUID3 */
>>>>>> .long   0x0034/* MLE header size */
>>>>>> .long   0x00020002/* MLE version 2.2 */
>>>>>> .long   mleh_rva(sl_stub_entry)/* Linear entry point of MLE 
>>>>>> (virt. address) */
>>>>>> .long   0x/* First valid page of MLE */
>>>>>> .long   0x/* Offset within binary of first byte of 
>>>>>> MLE */
>>>>>> .long   0x/* Offset within binary of last byte + 1 
>>>>>> of MLE */
>>>>>> .long   0x0223/* Bit vector of MLE-supported 
>>>>>> capabilities */
>>>>>> .long   0x/* Starting linear address of command line 
>>>>>> (unused) */
>>>>>> .long   0x/* Ending linear address of command line 
>>>>>> (unused) */
>>>>>> SYM_DATA_END(mle_header)
>>>>>>
>>>>>> Of course MLE_HEADER_OFFSET has to be defined as a constant somewhere.
>>>>>> Anyway, is it acceptable?
>>>>
>>>> What do you think about my MLE_HEADER_OFFSET and related stuff proposal?
>>>>
>>>
>>> I'm wondering if it would be easier to just allow relocations in these
>>> special "header" sections. I need to check how easy/hard it is to do
>>> that without triggering linker warnings.
>>
>> Ross and I still bouncing some ideas. We came to the conclusion that
>> putting mle_header into kernel .rodata.kernel_info section or even
>> arch/x86/boot/compressed/kernel_info.S file would be the easiest thing
>> to do at this point. Of course I would suggest some renaming too. E.g.
>> .rodata.kernel_info to .rodata.kernel_headers, etc. Does it make sense
>> for you?
>>
>> Daniel
> 
> I haven't been able to come up with any different options that don't
> require post-processing of the kernel image. Allowing relocations in
> specific sections seems to not be possible with lld, and anyway would
> require the fields to be 64-bit sized so it doesn't really help.
> 
> Putting mle_header into kernel_info seems like a reasonable thing to me,
> and if you do that, putting it into kernel_info.S would seem to be
> necessary?  Would you also have a fixed field with the offset of the

That seems like a reasonable place for it to go.

> mle_header from kernel_info?  That seems nicer than having the
> bootloader scan the variable data for magic strings.

Yes kernel_info will have a field to the offset of the mle_header. I
agree that would be nicer.

Thanks
Ross

> 



Re: [PATCH 07/13] x86: Secure Launch kernel early boot stub

2020-10-19 Thread Ross Philipson
On 10/19/20 1:06 PM, Arvind Sankar wrote:
> On Mon, Oct 19, 2020 at 10:38:08AM -0400, Ross Philipson wrote:
>> On 10/16/20 4:51 PM, Arvind Sankar wrote:
>>> On Thu, Oct 15, 2020 at 08:26:54PM +0200, Daniel Kiper wrote:
>>>>
>>>> I am discussing with Ross the other option. We can create
>>>> .rodata.mle_header section and put it at fixed offset as
>>>> kernel_info is. So, we would have, e.g.:
>>>>
>>>> arch/x86/boot/compressed/vmlinux.lds.S:
>>>> .rodata.kernel_info KERNEL_INFO_OFFSET : {
>>>> *(.rodata.kernel_info)
>>>> }
>>>> ASSERT(ABSOLUTE(kernel_info) == KERNEL_INFO_OFFSET, "kernel_info 
>>>> at bad address!")
>>>>
>>>> .rodata.mle_header MLE_HEADER_OFFSET : {
>>>> *(.rodata.mle_header)
>>>> }
>>>> ASSERT(ABSOLUTE(mle_header) == MLE_HEADER_OFFSET, "mle_header at 
>>>> bad address!")
>>>>
>>>> arch/x86/boot/compressed/sl_stub.S:
>>>> #define mleh_rva(X) (((X) - mle_header) + MLE_HEADER_OFFSET)
>>>>
>>>> .section ".rodata.mle_header", "a"
>>>>
>>>> SYM_DATA_START(mle_header)
>>>> .long   0x9082ac5a/* UUID0 */
>>>> .long   0x74a7476f/* UUID1 */
>>>> .long   0xa2555c0f/* UUID2 */
>>>> .long   0x42b651cb/* UUID3 */
>>>> .long   0x0034/* MLE header size */
>>>> .long   0x00020002/* MLE version 2.2 */
>>>> .long   mleh_rva(sl_stub_entry)/* Linear entry point of MLE 
>>>> (virt. address) */
>>>> .long   0x/* First valid page of MLE */
>>>> .long   0x/* Offset within binary of first byte of MLE 
>>>> */
>>>> .long   0x/* Offset within binary of last byte + 1 of 
>>>> MLE */
>>>> .long   0x0223/* Bit vector of MLE-supported capabilities 
>>>> */
>>>> .long   0x/* Starting linear address of command line 
>>>> (unused) */
>>>> .long   0x/* Ending linear address of command line 
>>>> (unused) */
>>>> SYM_DATA_END(mle_header)
>>>>
>>>> Of course MLE_HEADER_OFFSET has to be defined as a constant somewhere.
>>>> Anyway, is it acceptable?
>>>>
>>>> There is also another problem. We have to put into mle_header size of
>>>> the Linux kernel image. Currently it is done by the bootloader but
>>>> I think it is not a role of the bootloader. The kernel image should
>>>> provide all data describing its properties and do not rely on the
>>>> bootloader to do that. Ross and I investigated various options but we
>>>> did not find a good/simple way to do that. Could you suggest how we
>>>> should do that or at least where we should take a look to get some
>>>> ideas?
>>>>
>>>> Daniel
>>>
>>> What exactly is the size you need here? Is it just the size of the
>>> protected mode image, that's startup_32 to _edata. Or is it the size of
>>
>> It is the size of the protected mode image. Though how to reference
>> those symbols to get the size might all more relocation issues.
>>
> 
> Ok, then I think mleh_rva(_edata) should get you that -- I assume you
> don't want to include the uninitialized data in the size? The kernel
> will access memory beyond _edata (upto the init_size in the setup
> header), but that's not part of the image itself.

Yea we basically want the size of the image. There is nothing to measure
beyond the image as loaded into memory by the bootloader. rva(_edata)
seems to be the ticket.

Thanks
Ross

> 



Re: [PATCH 07/13] x86: Secure Launch kernel early boot stub

2020-10-19 Thread Ross Philipson
On 10/16/20 4:51 PM, Arvind Sankar wrote:
> On Thu, Oct 15, 2020 at 08:26:54PM +0200, Daniel Kiper wrote:
>>
>> I am discussing with Ross the other option. We can create
>> .rodata.mle_header section and put it at fixed offset as
>> kernel_info is. So, we would have, e.g.:
>>
>> arch/x86/boot/compressed/vmlinux.lds.S:
>> .rodata.kernel_info KERNEL_INFO_OFFSET : {
>> *(.rodata.kernel_info)
>> }
>> ASSERT(ABSOLUTE(kernel_info) == KERNEL_INFO_OFFSET, "kernel_info at 
>> bad address!")
>>
>> .rodata.mle_header MLE_HEADER_OFFSET : {
>> *(.rodata.mle_header)
>> }
>> ASSERT(ABSOLUTE(mle_header) == MLE_HEADER_OFFSET, "mle_header at bad 
>> address!")
>>
>> arch/x86/boot/compressed/sl_stub.S:
>> #define mleh_rva(X) (((X) - mle_header) + MLE_HEADER_OFFSET)
>>
>> .section ".rodata.mle_header", "a"
>>
>> SYM_DATA_START(mle_header)
>> .long   0x9082ac5a/* UUID0 */
>> .long   0x74a7476f/* UUID1 */
>> .long   0xa2555c0f/* UUID2 */
>> .long   0x42b651cb/* UUID3 */
>> .long   0x0034/* MLE header size */
>> .long   0x00020002/* MLE version 2.2 */
>> .long   mleh_rva(sl_stub_entry)/* Linear entry point of MLE 
>> (virt. address) */
>> .long   0x/* First valid page of MLE */
>> .long   0x/* Offset within binary of first byte of MLE */
>> .long   0x/* Offset within binary of last byte + 1 of 
>> MLE */
>> .long   0x0223/* Bit vector of MLE-supported capabilities */
>> .long   0x/* Starting linear address of command line 
>> (unused) */
>> .long   0x/* Ending linear address of command line 
>> (unused) */
>> SYM_DATA_END(mle_header)
>>
>> Of course MLE_HEADER_OFFSET has to be defined as a constant somewhere.
>> Anyway, is it acceptable?
>>
>> There is also another problem. We have to put into mle_header size of
>> the Linux kernel image. Currently it is done by the bootloader but
>> I think it is not a role of the bootloader. The kernel image should
>> provide all data describing its properties and do not rely on the
>> bootloader to do that. Ross and I investigated various options but we
>> did not find a good/simple way to do that. Could you suggest how we
>> should do that or at least where we should take a look to get some
>> ideas?
>>
>> Daniel
> 
> What exactly is the size you need here? Is it just the size of the
> protected mode image, that's startup_32 to _edata. Or is it the size of

It is the size of the protected mode image. Though how to reference
those symbols to get the size might all more relocation issues.

> the whole bzImage file, or something else? I guess the same question
> applies to "first valid page of MLE" and "first byte of MLE", and the

Because of the way the launch environment is setup, both "first valid
page of MLE" and "first byte of MLE" are always zero so nothing to have
to sort out there. The only fields that need to be updated are "Linear
entry point of MLE" and "Offset within binary of last byte + 1 of MLE".

Thanks
Ross

> linear entry point -- are those all relative to startup_32 or do they
> need to be relative to the start of the bzImage, i.e. you have to add
> the size of the real-mode boot stub?
> 
> If you need to include the size of the bzImage file, that's not known
> when the files in boot/compressed are built. It's only known after the
> real-mode stub is linked. arch/x86/boot/tools/build.c fills in various
> details in the setup header and creates the bzImage file, but it does
> not currently modify anything in the protected-mode portion of the
> compressed kernel (i.e. arch/x86/boot/compressed/vmlinux, which then
> gets converted to binary format as arch/x86/boot/vmlinux.bin), so it
> would need to be extended if you need to modify the MLE header to
> include the bzImage size or anything depending on the size of the
> real-mode stub.
> 



Re: [PATCH] x86/boot: Place kernel_info at a fixed offset

2020-10-05 Thread Ross Philipson
On 9/29/20 5:04 PM, Arvind Sankar wrote:
> There are use cases for storing the offset of a symbol in kernel_info.
> For example, the trenchboot series [0] needs to store the offset of the
> Measured Launch Environment header in kernel_info.
> 
> Since commit (note: commit ID from tip/master)
> 
>   527afc212231 ("x86/boot: Check that there are no run-time relocations")
> 
> run-time relocations are not allowed in the compressed kernel, so simply
> using the symbol in kernel_info, as
> 
>   .long   symbol
> 
> will cause a linker error because this is not position-independent.
> 
> With kernel_info being a separate object file and in a different section
> from startup_32, there is no way to calculate the offset of a symbol
> from the start of the image in a position-independent way.
> 
> To enable such use cases, put kernel_info into its own section which is
> placed at a predetermined offset (KERNEL_INFO_OFFSET) via the linker
> script. This will allow calculating the symbol offset in a
> position-independent way, by adding the offset from the start of
> kernel_info to KERNEL_INFO_OFFSET.
> 
> Ensure that kernel_info is aligned, and use the SYM_DATA.* macros
> instead of bare labels. This stores the size of the kernel_info
> structure in the ELF symbol table.

I pulled this change in and made all the changes to remove other code
that was causing relocations in the compressed kernel. I tested it and
it is working well. Thanks for all the help.

Tested-by: Ross Philipson 

> 
> Signed-off-by: Arvind Sankar 
> Cc: Ross Philipson 
> [0] 
> https://urldefense.com/v3/__https://lore.kernel.org/lkml/1600959521-24158-8-git-send-email-ross.philip...@oracle.com/__;!!GqivPVa7Brio!JiEGSToX4gewsr8DY0iWrRR7oTzMZl1b-WBsZ1U6M7dCJXuGzIrF-5qVqN4v8LEys8M$
>  
> ---

[snip]


[PATCH 3/8] staging: rtl8723bs: replace _RND8 with round_up()

2020-10-03 Thread Ross Schmidt
Use round_up instead of inline _RND8.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c|  2 +-
 drivers/staging/rtl8723bs/include/osdep_service.h | 11 ---
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c 
b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index b9ccaad748ea..1fbf89cb72d0 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -369,7 +369,7 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
}
}
 
-   pkt_offset = _RND8(pkt_offset);
+   pkt_offset = round_up(pkt_offset, 8);
precvbuf->pdata += pkt_offset;
ptr = precvbuf->pdata;
precvframe = NULL;
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index 8f0e5cbf485b..c5e9a4eebd27 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -132,17 +132,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, 
void *parg3, void *par
 
 #define _RND(sz, r) sz)+((r)-1))/(r))*(r))
 
-static inline u32 _RND8(u32 sz)
-{
-
-   u32 val;
-
-   val = ((sz >> 3) + ((sz & 7) ? 1 : 0)) << 3;
-
-   return val;
-
-}
-
 #ifndef MAC_FMT
 #define MAC_FMT "%pM"
 #endif
-- 
2.26.2



[PATCH 8/8] staging: rtl8723bs: replace _cancel_timer with del_timer_sync

2020-10-03 Thread Ross Schmidt
Replace _cancel_timer with API function del_timer_sync.

One instance of del_timer_sync is moved and an unnecessary pair of spin
locks are removed.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c |  3 +--
 drivers/staging/rtl8723bs/core/rtw_mlme.c| 16 ++--
 drivers/staging/rtl8723bs/hal/sdio_ops.c |  3 +--
 .../rtl8723bs/include/osdep_service_linux.h  |  6 --
 4 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 047ec5167f86..2abe205e3453 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -2034,7 +2034,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter,  
struct cmd_obj *pcmd)
 
 void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
 {
-   u8 timer_cancelled;
struct sta_info *psta = NULL;
struct wlan_network *pwlan = NULL;
struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2049,7 +2048,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, 
struct cmd_obj *pcmd)
_set_timer(&pmlmepriv->assoc_timer, 1);
}
 
-   _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
+   del_timer_sync(&pmlmepriv->assoc_timer);
 
spin_lock_bh(&pmlmepriv->lock);
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index e65c5a870b46..9531ba54e95b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -814,7 +814,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
 void rtw_surveydone_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
-   u8 timer_cancelled = false;
struct  mlme_priv *pmlmepriv = &(adapter->mlmepriv);
 
spin_lock_bh(&pmlmepriv->lock);
@@ -827,22 +826,12 @@ void rtw_surveydone_event_callback(struct adapter 
*adapter, u8 *pbuf)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv)));
 
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
-   /* u8 timer_cancelled; */
-
-   timer_cancelled = true;
-   /* _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); 
*/
-
+   del_timer_sync(&pmlmepriv->scan_to_timer);
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
} else {
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, 
survey done event comes too late!\n", get_fwstate(pmlmepriv)));
}
-   spin_unlock_bh(&pmlmepriv->lock);
-
-   if (timer_cancelled)
-   _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
-
-   spin_lock_bh(&pmlmepriv->lock);
 
rtw_set_signal_stat_timer(&adapter->recvpriv);
 
@@ -1298,7 +1287,6 @@ static void rtw_joinbss_update_network(struct adapter 
*padapter, struct wlan_net
 void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
 {
static u8 retry;
-   u8 timer_cancelled;
struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL;
struct  sta_priv *pstapriv = &adapter->stapriv;
struct  mlme_priv *pmlmepriv = &(adapter->mlmepriv);
@@ -1392,7 +1380,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
}
 
/* s5. Cancel assoc_timer */
-   _cancel_timer(&pmlmepriv->assoc_timer, 
&timer_cancelled);
+   del_timer_sync(&pmlmepriv->assoc_timer);
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancel 
assoc_timer\n"));
 
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 465f51b99d39..369f55d11519 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -945,8 +945,7 @@ void sd_int_dpc(struct adapter *adapter)
if (hal->sdio_hisr & SDIO_HISR_CPWM1) {
struct reportpwrstate_parm report;
 
-   u8 bcancelled;
-   _cancel_timer(&(pwrctl->pwr_rpwm_timer), &bcancelled);
+   del_timer_sync(&(pwrctl->pwr_rpwm_timer));
 
report.state = SdioLocalCmd52Read1Byte(adapter, 
SDIO_REG_HCPWM1_8723B);
 
diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h 
b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 4a5bdb93e75d..498d5474010c 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -83,12 +83,6 @@ static inline void _set_timer(_timer *ptimer, u32 delay_time)

[PATCH 6/8] staging: rtl8723bs: replace RTW_GET_LE16 with get_unaligned_le16

2020-10-03 Thread Ross Schmidt
Replace RTW_GET_LE16 macro with get_unaligned_le16.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c   | 5 +++--
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c| 4 ++--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 7 ---
 drivers/staging/rtl8723bs/include/osdep_service.h | 2 --
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index a76e81330756..4f270d509ad3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 
 extern unsigned char RTW_WPA_OUI[];
 extern unsigned char WMM_OUI[];
@@ -995,12 +996,12 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* beacon interval */
p = rtw_get_beacon_interval_from_ie(ie);/* ie + 8;  8: TimeStamp, 
2: Beacon Interval 2:Capability */
/* pbss_network->Configuration.BeaconPeriod = le16_to_cpu(*(unsigned 
short*)p); */
-   pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p);
+   pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p);
 
/* capability */
/* cap = *(unsigned short *)rtw_get_capability_from_ie(ie); */
/* cap = le16_to_cpu(cap); */
-   cap = RTW_GET_LE16(ie);
+   cap = get_unaligned_le16(ie);
 
/* SSID */
p = rtw_get_ie(
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 977f0ed53ad7..3b7a3c220032 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -500,7 +500,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int 
*group_cipher, int *pairwis
/* pairwise_cipher */
if (left >= 2) {
/* count = le16_to_cpu(*(u16*)pos); */
-   count = RTW_GET_LE16(pos);
+   count = get_unaligned_le16(pos);
pos += 2;
left -= 2;
 
@@ -570,7 +570,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int 
*group_cipher, int *pairwi
/* pairwise_cipher */
if (left >= 2) {
  /* count = le16_to_cpu(*(u16*)pos); */
-   count = RTW_GET_LE16(pos);
+   count = get_unaligned_le16(pos);
pos += 2;
left -= 2;
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 6db637701063..b912ad2f4b72 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static struct mlme_handler mlme_sta_tbl[] = {
{WIFI_ASSOCREQ, "OnAssocReq",   &OnAssocReq},
@@ -1213,7 +1214,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union 
recv_frame *precv_frame)
goto asoc_class2_error;
}
 
-   capab_info = RTW_GET_LE16(pframe + WLAN_HDR_A3_LEN);
+   capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN);
/* capab_info = le16_to_cpu(*(unsigned short *)(pframe + 
WLAN_HDR_A3_LEN)); */
 
left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
@@ -1959,7 +1960,7 @@ unsigned int OnAction_back(struct adapter *padapter, 
union recv_frame *precv_fra
break;
 
case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
-   status = RTW_GET_LE16(&frame_body[3]);
+   status = get_unaligned_le16(&frame_body[3]);
tid = ((frame_body[5] >> 2) & 0x7);
 
if (status == 0) {
@@ -1989,7 +1990,7 @@ unsigned int OnAction_back(struct adapter *padapter, 
union recv_frame *precv_fra
~BIT((frame_body[3] >> 4) & 0xf);
 
/* reason_code = frame_body[4] | (frame_body[5] 
<< 8); */
-   reason_code = RTW_GET_LE16(&frame_body[4]);
+   reason_code = 
get_unaligned_le16(&frame_body[4]);
} else if ((frame_body[3] & BIT(3)) == BIT(3)) {
tid = (frame_body[3] >> 4) & 0x0F;
 
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index a26c8db302e0..2f7e1665b6b1 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -152,8 +152,6 @@ extern void rtw_free_netdev(struct net_device * netdev);
 
 #define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
 
-#define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
-
 void rtw_buf_free(u8 **buf, u32 *buf_len);
 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
 
-- 
2.26.2



[PATCH 4/8] staging: rtl8723bs: remove unused macros

2020-10-03 Thread Ross Schmidt
Remove several macros in osdep_service.h because they are not used.

Signed-off-by: Ross Schmidt 
---
 .../staging/rtl8723bs/include/osdep_service.h | 57 ---
 1 file changed, 57 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index c5e9a4eebd27..da4aa3e71a4b 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -151,68 +151,11 @@ extern void rtw_free_netdev(struct net_device * netdev);
 /* Macros for handling unaligned memory accesses */
 
 #define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
-#define RTW_PUT_BE16(a, val)   \
-   do {\
-   (a)[0] = ((u16) (val)) >> 8;\
-   (a)[1] = ((u16) (val)) & 0xff;  \
-   } while (0)
 
 #define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
-#define RTW_PUT_LE16(a, val)   \
-   do {\
-   (a)[1] = ((u16) (val)) >> 8;\
-   (a)[0] = ((u16) (val)) & 0xff;  \
-   } while (0)
 
 #define RTW_GET_BE24(a) u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
 ((u32) (a)[2]))
-#define RTW_PUT_BE24(a, val)   \
-   do {\
-   (a)[0] = (u8) u32) (val)) >> 16) & 0xff);   \
-   (a)[1] = (u8) u32) (val)) >> 8) & 0xff);\
-   (a)[2] = (u8) (((u32) (val)) & 0xff);   \
-   } while (0)
-
-#define RTW_GET_BE32(a) u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
-(((u32) (a)[2]) << 8) | ((u32) (a)[3]))
-#define RTW_PUT_BE32(a, val)   \
-   do {\
-   (a)[0] = (u8) u32) (val)) >> 24) & 0xff);   \
-   (a)[1] = (u8) u32) (val)) >> 16) & 0xff);   \
-   (a)[2] = (u8) u32) (val)) >> 8) & 0xff);\
-   (a)[3] = (u8) (((u32) (val)) & 0xff);   \
-   } while (0)
-
-#define RTW_GET_LE32(a) u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
-(((u32) (a)[1]) << 8) | ((u32) (a)[0]))
-#define RTW_PUT_LE32(a, val)   \
-   do {\
-   (a)[3] = (u8) u32) (val)) >> 24) & 0xff);   \
-   (a)[2] = (u8) u32) (val)) >> 16) & 0xff);   \
-   (a)[1] = (u8) u32) (val)) >> 8) & 0xff);\
-   (a)[0] = (u8) (((u32) (val)) & 0xff);   \
-   } while (0)
-
-#define RTW_GET_BE64(a) u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
-(((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
-(((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
-(((u64) (a)[6]) << 8) | ((u64) (a)[7]))
-#define RTW_PUT_BE64(a, val)   \
-   do {\
-   (a)[0] = (u8) (((u64) (val)) >> 56);\
-   (a)[1] = (u8) (((u64) (val)) >> 48);\
-   (a)[2] = (u8) (((u64) (val)) >> 40);\
-   (a)[3] = (u8) (((u64) (val)) >> 32);\
-   (a)[4] = (u8) (((u64) (val)) >> 24);\
-   (a)[5] = (u8) (((u64) (val)) >> 16);\
-   (a)[6] = (u8) (((u64) (val)) >> 8); \
-   (a)[7] = (u8) (((u64) (val)) & 0xff);   \
-   } while (0)
-
-#define RTW_GET_LE64(a) u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
-(((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
-(((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
-(((u64) (a)[1]) << 8) | ((u64) (a)[0]))
 
 void rtw_buf_free(u8 **buf, u32 *buf_len);
 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
-- 
2.26.2



[PATCH 5/8] staging: rtl8723bs: replace RTW_GET_BE24 with get_unaligned_be24

2020-10-03 Thread Ross Schmidt
Replace RTW_GET_BE24 macro with get_unaligned_be24.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c| 3 ++-
 drivers/staging/rtl8723bs/include/osdep_service.h | 3 ---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index ca98274ae390..977f0ed53ad7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
 u16 RTW_WPA_VERSION = 1;
@@ -874,7 +875,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, 
uint elen,
return -1;
}
 
-   oui = RTW_GET_BE24(pos);
+   oui = get_unaligned_be24(pos);
switch (oui) {
case OUI_MICROSOFT:
/* Microsoft/Wi-Fi information elements are further typed and
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index da4aa3e71a4b..a26c8db302e0 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -154,9 +154,6 @@ extern void rtw_free_netdev(struct net_device * netdev);
 
 #define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
 
-#define RTW_GET_BE24(a) u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
-((u32) (a)[2]))
-
 void rtw_buf_free(u8 **buf, u32 *buf_len);
 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
 
-- 
2.26.2



[PATCH 2/8] staging: rtl8723bs: replace _RND4 with round_up()

2020-10-03 Thread Ross Schmidt
Use round_up instead of inline _RND4.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c  |  2 +-
 drivers/staging/rtl8723bs/hal/sdio_ops.c  |  2 +-
 drivers/staging/rtl8723bs/include/osdep_service.h | 11 ---
 3 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index bd18d1803e27..047ec5167f86 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -469,7 +469,7 @@ int rtw_cmd_thread(void *context)
 
pcmdpriv->cmd_issued_cnt++;
 
-   pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */
+   pcmd->cmdsz = round_up((pcmd->cmdsz), 4);
 
memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
 
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 544d5a093229..465f51b99d39 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -474,7 +474,7 @@ static u32 sdio_write_port(
return _FAIL;
}
 
-   cnt = _RND4(cnt);
+   cnt = round_up(cnt, 4);
HalSdioGetCmdAddr8723BSdio(adapter, addr, cnt >> 2, &addr);
 
if (cnt > psdio->block_transfer_len)
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index ea3f4f3c86d2..8f0e5cbf485b 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -132,17 +132,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, 
void *parg3, void *par
 
 #define _RND(sz, r) sz)+((r)-1))/(r))*(r))
 
-static inline u32 _RND4(u32 sz)
-{
-
-   u32 val;
-
-   val = ((sz >> 2) + ((sz & 3) ? 1 : 0)) << 2;
-
-   return val;
-
-}
-
 static inline u32 _RND8(u32 sz)
 {
 
-- 
2.26.2



[PATCH 1/8] staging: rtl8723bs: replace RND4 with round_up()

2020-10-03 Thread Ross Schmidt
Use round_up instead of define RND4.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_security.c | 6 +++---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 4 ++--
 drivers/staging/rtl8723bs/hal/sdio_ops.c  | 6 +++---
 drivers/staging/rtl8723bs/include/osdep_service.h | 1 -
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c 
b/drivers/staging/rtl8723bs/core/rtw_security.c
index 7f74e1d05b3a..159d32ace2bc 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -260,7 +260,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
arcfour_encrypt(&mycontext, payload+length, 
crc, 4);
 
pframe += pxmitpriv->frag_len;
-   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
+   pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
}
}
 
@@ -716,7 +716,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 
*pxmitframe)
arcfour_encrypt(&mycontext, 
payload+length, crc, 4);
 
pframe += pxmitpriv->frag_len;
-   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
+   pframe = (u8 
*)round_up((SIZE_PTR)(pframe), 4);
}
}
 
@@ -1523,7 +1523,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 
*pxmitframe)
 
aes_cipher(prwskey, pattrib->hdrlen, pframe, 
length);
pframe += pxmitpriv->frag_len;
-   pframe = (u8 *)RND4((SIZE_PTR)(pframe));
+   pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
}
}
 
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 571353404a95..6ecaff9728fd 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -865,7 +865,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
payload = pframe;
 
for (curfragnum = 0; curfragnum < pattrib->nr_frags; 
curfragnum++) {
-   payload = (u8 *)RND4((SIZE_PTR)(payload));
+   payload = (u8 *)round_up((SIZE_PTR)(payload), 
4);
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, 
("===curfragnum =%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 
0x%.2x, 0x%.2x,!!!\n",
curfragnum, *payload, *(payload+1), 
*(payload+2), *(payload+3), *(payload+4), *(payload+5), *(payload+6), 
*(payload+7)));
 
@@ -1209,7 +1209,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt 
*pkt, struct xmit_fram
 
addr = (SIZE_PTR)(pframe);
 
-   mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset;
+   mem_start = (unsigned char *)round_up(addr, 4) + hw_hdr_offset;
memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
}
 
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c 
b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index b6b4adb5a28a..544d5a093229 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -534,7 +534,7 @@ static s32 _sdio_local_read(
if (!mac_pwr_ctrl_on)
return _sd_cmd52_read(intfhdl, addr, cnt, buf);
 
-   n = RND4(cnt);
+   n = round_up(cnt, 4);
tmpbuf = rtw_malloc(n);
if (!tmpbuf)
return -1;
@@ -575,7 +575,7 @@ s32 sdio_local_read(
)
return sd_cmd52_read(intfhdl, addr, cnt, buf);
 
-   n = RND4(cnt);
+   n = round_up(cnt, 4);
tmpbuf = rtw_malloc(n);
if (!tmpbuf)
return -1;
@@ -859,7 +859,7 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter 
*adapter, u32 size)
 
/*  Patch for some SDIO Host 4 bytes issue */
/*  ex. RK3188 */
-   readsize = RND4(size);
+   readsize = round_up(size, 4);
 
/* 3 1. alloc recvbuf */
recv_priv = &adapter->recvpriv;
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index be34e279670b..ea3f4f3c86d2 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -131,7 +131,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, 
void *parg3, void *par
 }
 
 #define _RND(sz, r) sz)+((r)-1))/(r))*(r))
-#define RND4(x)(((x >> 2) + (((x & 3) == 0) ?  0 : 1)) << 2)
 
 static inline u32 _RND4(u32 sz)
 {
-- 
2.26.2



[PATCH 7/8] staging: rtl8723bs: replace RTW_GET_BE16 with get_unaligned_be16

2020-10-03 Thread Ross Schmidt
Replace RTW_GET_BE16 macro with get_unlaligned_be16.

Signed-off-by: Ross Schmidt 
---
 drivers/staging/rtl8723bs/core/rtw_ieee80211.c| 4 ++--
 drivers/staging/rtl8723bs/core/rtw_recv.c | 3 ++-
 drivers/staging/rtl8723bs/include/osdep_service.h | 2 --
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 3 ++-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 3b7a3c220032..c43cca4a3828 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -801,8 +801,8 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 
target_attr_id, u8 *buf_att
 
while (attr_ptr - wps_ie < wps_ielen) {
/*  4 = 2(Attribute ID) + 2(Length) */
-   u16 attr_id = RTW_GET_BE16(attr_ptr);
-   u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2);
+   u16 attr_id = get_unaligned_be16(attr_ptr);
+   u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
u16 attr_len = attr_data_len + 4;
 
/* DBG_871X("%s attr_ptr:%p, id:%u, length:%u\n", __func__, 
attr_ptr, attr_id, attr_data_len); */
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c 
b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 7e1da0e35812..6979f8dbccb8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
 static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
@@ -1906,7 +1907,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union 
recv_frame *prframe)
while (a_len > ETH_HLEN) {
 
/* Offset 12 denote 2 mac address */
-   nSubframe_Length = RTW_GET_BE16(pdata + 12);
+   nSubframe_Length = get_unaligned_be16(pdata + 12);
 
if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
DBG_871X("nRemain_Length is %d and nSubframe_Length is 
: %d\n", a_len, nSubframe_Length);
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h 
b/drivers/staging/rtl8723bs/include/osdep_service.h
index 2f7e1665b6b1..a94b72397ce7 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -150,8 +150,6 @@ extern void rtw_free_netdev(struct net_device * netdev);
 
 /* Macros for handling unaligned memory accesses */
 
-#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
-
 void rtw_buf_free(u8 **buf, u32 *buf_len);
 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
 
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c 
b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index b2a1bbb30df6..900ff3a3b014 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 void rtw_os_free_recvframe(union recv_frame *precvframe)
 {
@@ -69,7 +70,7 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 
nSubframe_Length, u8
skb_reserve(sub_skb, 12);
skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length);
 
-   eth_type = RTW_GET_BE16(&sub_skb->data[6]);
+   eth_type = get_unaligned_be16(&sub_skb->data[6]);
 
if (sub_skb->len >= 8 &&
((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
-- 
2.26.2



Re: [PATCH] x86/boot: Place kernel_info at a fixed offset

2020-09-29 Thread Ross Philipson
On 9/29/20 5:04 PM, Arvind Sankar wrote:
> There are use cases for storing the offset of a symbol in kernel_info.
> For example, the trenchboot series [0] needs to store the offset of the
> Measured Launch Environment header in kernel_info.
> 
> Since commit (note: commit ID from tip/master)
> 
>   527afc212231 ("x86/boot: Check that there are no run-time relocations")
> 
> run-time relocations are not allowed in the compressed kernel, so simply
> using the symbol in kernel_info, as
> 
>   .long   symbol
> 
> will cause a linker error because this is not position-independent.
> 
> With kernel_info being a separate object file and in a different section
> from startup_32, there is no way to calculate the offset of a symbol
> from the start of the image in a position-independent way.
> 
> To enable such use cases, put kernel_info into its own section which is
> placed at a predetermined offset (KERNEL_INFO_OFFSET) via the linker
> script. This will allow calculating the symbol offset in a
> position-independent way, by adding the offset from the start of
> kernel_info to KERNEL_INFO_OFFSET.
> 
> Ensure that kernel_info is aligned, and use the SYM_DATA.* macros
> instead of bare labels. This stores the size of the kernel_info
> structure in the ELF symbol table.

That is great. It looks like just what we will need. Thank you very much.

Acked-by: Ross Philipson 

> 
> Signed-off-by: Arvind Sankar 
> Cc: Ross Philipson 
> [0] 
> https://urldefense.com/v3/__https://lore.kernel.org/lkml/1600959521-24158-8-git-send-email-ross.philip...@oracle.com/__;!!GqivPVa7Brio!JiEGSToX4gewsr8DY0iWrRR7oTzMZl1b-WBsZ1U6M7dCJXuGzIrF-5qVqN4v8LEys8M$
>  
> ---
>  arch/x86/boot/compressed/kernel_info.S | 19 +++
>  arch/x86/boot/compressed/kernel_info.h | 12 
>  arch/x86/boot/compressed/vmlinux.lds.S |  6 ++
>  3 files changed, 33 insertions(+), 4 deletions(-)
>  create mode 100644 arch/x86/boot/compressed/kernel_info.h
> 
> diff --git a/arch/x86/boot/compressed/kernel_info.S 
> b/arch/x86/boot/compressed/kernel_info.S
> index f818ee8fba38..c18f07181dd5 100644
> --- a/arch/x86/boot/compressed/kernel_info.S
> +++ b/arch/x86/boot/compressed/kernel_info.S
> @@ -1,12 +1,23 @@
>  /* SPDX-License-Identifier: GPL-2.0 */
>  
> +#include 
>  #include 
> +#include "kernel_info.h"
>  
> - .section ".rodata.kernel_info", "a"
> +/*
> + * If a field needs to hold the offset of a symbol from the start
> + * of the image, use the macro below, eg
> + *   .long   rva(symbol)
> + * This will avoid creating run-time relocations, which are not
> + * allowed in the compressed kernel.
> + */
> +
> +#define rva(X) (((X) - kernel_info) + KERNEL_INFO_OFFSET)
>  
> - .global kernel_info
> + .section ".rodata.kernel_info", "a"
>  
> -kernel_info:
> + .balign 16
> +SYM_DATA_START(kernel_info)
>   /* Header, Linux top (structure). */
>   .ascii  "LToP"
>   /* Size. */
> @@ -19,4 +30,4 @@ kernel_info:
>  
>  kernel_info_var_len_data:
>   /* Empty for time being... */
> -kernel_info_end:
> +SYM_DATA_END_LABEL(kernel_info, SYM_L_LOCAL, kernel_info_end)
> diff --git a/arch/x86/boot/compressed/kernel_info.h 
> b/arch/x86/boot/compressed/kernel_info.h
> new file mode 100644
> index ..c127f84aec63
> --- /dev/null
> +++ b/arch/x86/boot/compressed/kernel_info.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef BOOT_COMPRESSED_KERNEL_INFO_H
> +#define BOOT_COMPRESSED_KERNEL_INFO_H
> +
> +#ifdef CONFIG_X86_64
> +#define KERNEL_INFO_OFFSET 0x500
> +#else /* 32-bit */
> +#define KERNEL_INFO_OFFSET 0x100
> +#endif
> +
> +#endif /* BOOT_COMPRESSED_KERNEL_INFO_H */
> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S 
> b/arch/x86/boot/compressed/vmlinux.lds.S
> index 112b2375d021..84c7b4de489e 100644
> --- a/arch/x86/boot/compressed/vmlinux.lds.S
> +++ b/arch/x86/boot/compressed/vmlinux.lds.S
> @@ -7,6 +7,7 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT)
>  
>  #include 
>  #include 
> +#include "kernel_info.h"
>  
>  #ifdef CONFIG_X86_64
>  OUTPUT_ARCH(i386:x86-64)
> @@ -27,6 +28,11 @@ SECTIONS
>   HEAD_TEXT
>   _ehead = . ;
>   }
> + .rodata.kernel_info KERNEL_INFO_OFFSET : {
> + *(.rodata.kernel_info)
> + }
> + ASSERT(ABSOLUTE(kernel_info) == KERNEL_INFO_OFFSET, "kernel_info at bad 
> address!")
> +
>   .rodata..compressed : {
>   *(.rodata..compressed)
>   }
> 



Re: [PATCH 07/13] x86: Secure Launch kernel early boot stub

2020-09-29 Thread Ross Philipson
On 9/25/20 3:18 PM, Arvind Sankar wrote:
> On Fri, Sep 25, 2020 at 10:56:43AM -0400, Ross Philipson wrote:
>> On 9/24/20 1:38 PM, Arvind Sankar wrote:
>>> On Thu, Sep 24, 2020 at 10:58:35AM -0400, Ross Philipson wrote:
>>>
>>>> diff --git a/arch/x86/boot/compressed/head_64.S 
>>>> b/arch/x86/boot/compressed/head_64.S
>>>> index 97d37f0..42043bf 100644
>>>> --- a/arch/x86/boot/compressed/head_64.S
>>>> +++ b/arch/x86/boot/compressed/head_64.S
>>>> @@ -279,6 +279,21 @@ SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL)
>>>>  SYM_FUNC_END(efi32_stub_entry)
>>>>  #endif
>>>>  
>>>> +#ifdef CONFIG_SECURE_LAUNCH
>>>> +SYM_FUNC_START(sl_stub_entry)
>>>> +  /*
>>>> +   * On entry, %ebx has the entry abs offset to sl_stub_entry. To
>>>> +   * find the beginning of where we are loaded, sub off from the
>>>> +   * beginning.
>>>> +   */
>>>
>>> This requirement should be added to the documentation. Is it necessary
>>> or can this stub just figure out the address the same way as the other
>>> 32-bit entry points, using the scratch space in bootparams as a little
>>> stack?
>>
>> It is based on the state of the BSP when TXT vectors to the measured
>> launch environment. It is documented in the TXT spec and the SDMs.
>>
> 
> I think it would be useful to add to the x86 boot documentation how
> exactly this new entry point is called, even if it's just adding a link
> to some section of those specs. The doc should also say that an
> mle_header_offset of 0 means the kernel isn't secure launch enabled.

Ok will do.

> 
>>>
>>> For the 32-bit assembler code that's being added, tip/master now has
>>> changes that prevent the compressed kernel from having any runtime
>>> relocations.  You'll need to revise some of the code and the data
>>> structures initial values to avoid creating relocations.
>>
>> Could you elaborate on this some more? I am not sure I see places in the
>> secure launch asm that would be creating relocations like this.
>>
>> Thank you,
>> Ross
>>
> 
> You should see them if you do
>   readelf -r arch/x86/boot/compressed/vmlinux
> 
> In terms of the code, things like:
> 
>   addl%ebx, (sl_gdt_desc + 2)(%ebx)
> 
> will create a relocation, because the linker interprets this as wanting
> the runtime address of sl_gdt_desc, rather than just the offset from
> startup_32.
> 
> https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/tree/arch/x86/boot/compressed/head_64.S*n48__;Iw!!GqivPVa7Brio!JpZWv1cCPZdjD2jbCCGT7P9UIVl_lhX7YjckAnUcvi927jwZI7X3nX0MpIAZOyktJds$
>  
> 
> has a comment with some explanation and a macro that the 32-bit code in
> startup_32 uses to avoid creating relocations.
> 
> Since the SL code is in a different assembler file (and a different
> section), you can't directly use the same macro. I would suggest getting
> rid of sl_stub_entry and entering directly at sl_stub, and then the code
> in sl_stub.S can use sl_stub for the base address, defining the rva()
> macro there as
> 
>   #define rva(X) ((X) - sl_stub)
> 
> You will also need to avoid initializing data with symbol addresses.
> 
>   .long mle_header
>   .long sl_stub_entry
>   .long sl_gdt
> 
> will create relocations. The third one is easy, just replace it with
> sl_gdt - sl_gdt_desc and initialize it at runtime with
> 
>   lealrva(sl_gdt_desc)(%ebx), %eax
>   addl%eax, 2(%eax)
>   lgdt(%eax)
> 
> The other two are more messy, unfortunately there is no easy way to tell
> the linker what we want here. The other entry point addresses (for the
> EFI stub) are populated in a post-processing step after the compressed
> kernel has been linked, we could teach it to also update kernel_info.
> 
> Without that, for kernel_info, you could change it to store the offset
> of the MLE header from kernel_info, instead of from the start of the
> image.
> 
> For the MLE header, it could be moved to .head.text in head_64.S, and
> initialized with
>   .long rva(sl_stub)
> This will also let it be placed at a fixed offset from startup_32, so
> that kernel_info can just be populated with a constant.

Thank you for the detailed reply. I am going to start digging into this now.

Ross

> 



Re: [PATCH 01/13] x86: Secure Launch Kconfig

2020-09-25 Thread Ross Philipson
On 9/24/20 10:08 PM, Randy Dunlap wrote:
> On 9/24/20 7:58 AM, Ross Philipson wrote:
>> Initial bits to bring in Secure Launch functionality. Add Kconfig
>> options for compiling in/out the Secure Launch code.
>>
>> Signed-off-by: Ross Philipson 
> 
> Hi,
> from Documentation/process/coding-style.rst:
> 
> Lines under a ``config`` definition
> are indented with one tab, while help text is indented an additional two
> spaces.

Ok sorry about that. I probably just copied what the previous entry was
doing. Will fix.

Thanks
Ross

> 
>> ---
>>  arch/x86/Kconfig | 36 
>>  1 file changed, 36 insertions(+)
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index 7101ac6..8957981 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -1968,6 +1968,42 @@ config EFI_MIXED
>>  
>> If unsure, say N.
>>  
>> +config SECURE_LAUNCH
>> +bool "Secure Launch support"
>> +default n
>> +depends on X86_64
>> +help
>> +   The Secure Launch feature allows a kernel to be loaded
>> +   directly through an Intel TXT measured launch. Intel TXT
>> +   establishes a Dynamic Root of Trust for Measurement (DRTM)
>> +   where the CPU measures the kernel image. This feature then
>> +   continues the measurement chain over kernel configuration
>> +   information and init images.
>> +
>> +choice
>> +prompt "Select Secure Launch Algorithm for TPM2"
>> +depends on SECURE_LAUNCH
>> +
>> +config SECURE_LAUNCH_SHA1
>> +bool "Secure Launch TPM1 SHA1"
>> +help
>> +   When using Secure Launch and TPM1 is present, use SHA1 hash
>> +   algorithm for measurements.
>> +
>> +config SECURE_LAUNCH_SHA256
>> +bool "Secure Launch TPM2 SHA256"
>> +help
>> +   When using Secure Launch and TPM2 is present, use SHA256 hash
>> +   algorithm for measurements.
>> +
>> +config SECURE_LAUNCH_SHA512
>> +bool "Secure Launch TPM2 SHA512"
>> +help
>> +   When using Secure Launch and TPM2 is present, use SHA512 hash
>> +   algorithm for measurements.
>> +
>> +endchoice
>> +
> 
> 
> thanks.
> 



Re: [PATCH 07/13] x86: Secure Launch kernel early boot stub

2020-09-25 Thread Ross Philipson
On 9/24/20 1:38 PM, Arvind Sankar wrote:
> On Thu, Sep 24, 2020 at 10:58:35AM -0400, Ross Philipson wrote:
>> The Secure Launch (SL) stub provides the entry point for Intel TXT (and
>> later AMD SKINIT) to vector to during the late launch. The symbol
>> sl_stub_entry is that entry point and its offset into the kernel is
>> conveyed to the launching code using the MLE (Measured Launch
>> Environment) header in the structure named mle_header. The offset of the
>> MLE header is set in the kernel_info. The routine sl_stub contains the
>> very early late launch setup code responsible for setting up the basic
>> environment to allow the normal kernel startup_32 code to proceed. It is
>> also responsible for properly waking and handling the APs on Intel
>> platforms. The routine sl_main which runs after entering 64b mode is
>> responsible for measuring configuration and module information before
>> it is used like the boot params, the kernel command line, the TXT heap,
>> an external initramfs, etc.
>>
>> Signed-off-by: Ross Philipson 
> 
> Which version of the kernel is this based on?

git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

master branch

> 
>> diff --git a/arch/x86/boot/compressed/head_64.S 
>> b/arch/x86/boot/compressed/head_64.S
>> index 97d37f0..42043bf 100644
>> --- a/arch/x86/boot/compressed/head_64.S
>> +++ b/arch/x86/boot/compressed/head_64.S
>> @@ -279,6 +279,21 @@ SYM_INNER_LABEL(efi32_pe_stub_entry, SYM_L_LOCAL)
>>  SYM_FUNC_END(efi32_stub_entry)
>>  #endif
>>  
>> +#ifdef CONFIG_SECURE_LAUNCH
>> +SYM_FUNC_START(sl_stub_entry)
>> +/*
>> + * On entry, %ebx has the entry abs offset to sl_stub_entry. To
>> + * find the beginning of where we are loaded, sub off from the
>> + * beginning.
>> + */
> 
> This requirement should be added to the documentation. Is it necessary
> or can this stub just figure out the address the same way as the other
> 32-bit entry points, using the scratch space in bootparams as a little
> stack?

It is based on the state of the BSP when TXT vectors to the measured
launch environment. It is documented in the TXT spec and the SDMs.

> 
>> +leal(startup_32 - sl_stub_entry)(%ebx), %ebx
>> +
>> +/* More room to work in sl_stub in the text section */
>> +jmp sl_stub
>> +
>> +SYM_FUNC_END(sl_stub_entry)
>> +#endif
>> +
>>  .code64
>>  .org 0x200
>>  SYM_CODE_START(startup_64)
>> @@ -537,6 +552,25 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
>>  shrq$3, %rcx
>>  rep stosq
>>  
>> +#ifdef CONFIG_SECURE_LAUNCH
>> +/*
>> + * Have to do the final early sl stub work in 64b area.
>> + *
>> + * *** NOTE ***
>> + *
>> + * Several boot params get used before we get a chance to measure
>> + * them in this call. This is a known issue and we currently don't
>> + * have a solution. The scratch field doesn't matter and loadflags
>> + * have KEEP_SEGMENTS set by the stub code. There is no obvious way
>> + * to do anything about the use of kernel_alignment or init_size
>> + * though these seem low risk.
>> + */
> 
> There are various fields in bootparams that depend on where the
> kernel/initrd and cmdline are loaded in memory. If the entire bootparams
> page is getting measured, does that mean they all have to be at fixed
> addresses on every boot?

Yes that is a very good point. In other places when measuring we make
sure to skip things like addresses and sizes of things outside of the
structure being measured. This needs to be done with boot params too.

> 
> Also KEEP_SEGMENTS support is gone from the kernel since v5.7, since it
> was unused. startup_32 now always loads a GDT and then the segment
> registers. I think this should be ok for you as the only thing the flag
> used to do in the 64-bit kernel was to stop startup_32 from blindly
> loading __BOOT_DS into the segment registers before it had setup its own
> GDT.

Yea this was there to prevent that blind loading of __BOOT_DS. I see it
is gone so I will remove the comment and the place where the flag is set.

> 
> For the 32-bit assembler code that's being added, tip/master now has
> changes that prevent the compressed kernel from having any runtime
> relocations.  You'll need to revise some of the code and the data
> structures initial values to avoid creating relocations.

Could you elaborate on this some more? I am not sure I see places in the
secure launch asm that would be creating relocations like this.

Thank you,
Ross

> 
> Thanks.
> 



[PATCH 00/13] x86: Trenchboot secure dynamic launch Linux kernel support

2020-09-24 Thread Ross Philipson
The Trenchboot project focus on boot security has led to the enabling of
the Linux kernel to be directly invocable by the x86 Dynamic Launch
instruction(s) for establishing a Dynamic Root of Trust for Measurement
(DRTM). The dynamic launch will be initiated by a boot loader with
associated support added to it, for example the first targeted boot
loader will be GRUB2. An integral part of establishing the DRTM involves
measuring everything that is intended to be run (kernel image, initrd,
etc) and everything that will configure that kernel to run (command
line, boot params, etc) into specific PCRs, the DRTM PCRs (17-22), in
the TPM. Another key aspect is the dynamic launch is rooted in hardware,
that is to say the hardware (CPU) is what takes the first measurement
for the chain of integrity measurements. On Intel this is done using
the GETSEC instruction provided by Intel's TXT and the SKINIT
instruction provided by AMD's AMD-V. Information on these technologies
can be readily found online. This patchset introduces Intel TXT support.

To enable the kernel to be launched by GETSEC, a stub must be built
into the setup section of the compressed kernel to handle the specific
state that the dynamic launch process leaves the BSP in. This is
analogous to the EFI stub that is found in the same area. Also this stub
must measure everything that is going to be used as early as possible.
This stub code and subsequent code must also deal with the specific
state that the dynamic launch leaves the APs in.

A quick note on terminology. The larger open source project itself is
called Trenchboot, which is hosted on Github (links below). The kernel
feature enabling the use of the x86 technology is referred to as "Secure
Launch" within the kernel code. As such the prefixes sl_/SL_ or
slaunch/SLAUNCH will be seen in the code. The stub code discussed above
is referred to as the SL stub.

The basic flow is:

 - Entry from the dynamic launch jumps to the SL stub
 - SL stub fixes up the world on the BSP
 - For TXT, SL stub wakes the APs, fixes up their worlds
 - For TXT, APs are left halted waiting for an NMI to wake them
 - SL stub jumps to startup_32
 - SL main runs to measure configuration and module information into the
   DRTM PCRs. It also locates the TPM event log.
 - Kernel boot proceeds normally from this point.
 - During early setup, slaunch_setup() runs to finish some validation
   and setup tasks.
 - The SMP bringup code is modified to wake the waiting APs. APs vector
   to rmpiggy and start up normally from that point.
 - Kernel boot finishes booting normally
 - SL securityfs module is present to allow reading and writing of the
   TPM event log.
 - SEXIT support to leave SMX mode is present on the kexec path and
   the various reboot paths (poweroff, reset, halt).

Links:

The Trenchboot project including documentation:

https://github.com/trenchboot

Intel TXT is documented in its own specification and in the SDM Instruction Set 
volume:

https://www.intel.com/content/dam/www/public/us/en/documents/guides/intel-txt-software-development-guide.pdf
https://software.intel.com/en-us/articles/intel-sdm

AMD SKINIT is documented in the System Programming manual:

https://www.amd.com/system/files/TechDocs/24593.pdf

GRUB2 pre-launch support patchset (WIP):

https://lists.gnu.org/archive/html/grub-devel/2020-05/msg00011.html

Thanks
Ross Philipson and Daniel P. Smith

Daniel P. Smith (4):
  x86: Add early TPM TIS/CRB interface support for Secure Launch
  x86: Add early TPM1.2/TPM2.0 interface support for Secure Launch
  x86: Add early general TPM interface support for Secure Launch
  x86: Secure Launch adding event log securityfs

Ross Philipson (9):
  x86: Secure Launch Kconfig
  x86: Secure Launch main header file
  x86: Add early SHA support for Secure Launch early measurements
  x86: Secure Launch kernel early boot stub
  x86: Secure Launch kernel late boot stub
  x86: Secure Launch SMP bringup support
  kexec: Secure Launch kexec SEXIT support
  reboot: Secure Launch SEXIT support on reboot paths
  tpm: Allow locality 2 to be set when initializing the TPM for Secure
Launch

 Documentation/x86/boot.rst|   9 +
 arch/x86/Kconfig  |  36 ++
 arch/x86/boot/compressed/Makefile |   8 +
 arch/x86/boot/compressed/early_sha1.c | 104 
 arch/x86/boot/compressed/early_sha1.h |  17 +
 arch/x86/boot/compressed/early_sha256.c   |   6 +
 arch/x86/boot/compressed/early_sha512.c   |   6 +
 arch/x86/boot/compressed/head_64.S|  34 +
 arch/x86/boot/compressed/kernel_info.S|   7 +
 arch/x86/boot/compressed/sl_main.c| 390 
 arch/x86/boot/compressed/sl_stub.S| 606 ++
 arch/x86/boot/compressed/tpm/crb.c| 304 +
 arch/x86/boot/compressed/tpm/crb.h|  20 +
 arch/x86/boot/compressed/tpm/tis.c| 215 +++
 arch/x86/boot/

[PATCH 08/13] x86: Secure Launch kernel late boot stub

2020-09-24 Thread Ross Philipson
The routine slaunch_setup is called out of the x86 specific setup_arch
routine during early kernel boot. After determining what platform is
present, various operations specific to that platform occur. This
includes finalizing setting for the platform late launch and verifying
that memory protections are in place.

For TXT, this code also reserves the original compressed kernel setup
area where the APs were left looping so that this memory cannot be used.

Signed-off-by: Ross Philipson 
---
 arch/x86/kernel/Makefile   |   1 +
 arch/x86/kernel/setup.c|   3 +
 arch/x86/kernel/slaunch.c  | 495 +
 drivers/iommu/intel/dmar.c |   4 +
 4 files changed, 503 insertions(+)
 create mode 100644 arch/x86/kernel/slaunch.c

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index e77261d..318366f 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_X86_32)  += tls.o
 obj-$(CONFIG_IA32_EMULATION)   += tls.o
 obj-y  += step.o
 obj-$(CONFIG_INTEL_TXT)+= tboot.o
+obj-$(CONFIG_SECURE_LAUNCH)+= slaunch.o
 obj-$(CONFIG_ISA_DMA_API)  += i8237.o
 obj-$(CONFIG_STACKTRACE)   += stacktrace.o
 obj-y  += cpu/
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 3511736..cae9476 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1009,6 +1010,8 @@ void __init setup_arch(char **cmdline_p)
early_gart_iommu_check();
 #endif
 
+   slaunch_setup();
+
/*
 * partially used pages are not usable - thus
 * we are rounding upwards:
diff --git a/arch/x86/kernel/slaunch.c b/arch/x86/kernel/slaunch.c
new file mode 100644
index 000..e040e32
--- /dev/null
+++ b/arch/x86/kernel/slaunch.c
@@ -0,0 +1,495 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Secure Launch late validation/setup, securityfs exposure and
+ * finalization support.
+ *
+ * Copyright (c) 2020, Oracle and/or its affiliates.
+ * Copyright (c) 2020 Apertus Solutions, LLC
+ *
+ * Author(s):
+ * Daniel P. Smith 
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static u32 sl_flags;
+static struct sl_ap_wake_info ap_wake_info;
+static u64 evtlog_addr;
+static u32 evtlog_size;
+static u64 vtd_pmr_lo_size;
+
+/* This should be plenty of room */
+static u8 txt_dmar[PAGE_SIZE] __aligned(16);
+
+u32 slaunch_get_flags(void)
+{
+   return sl_flags;
+}
+EXPORT_SYMBOL(slaunch_get_flags);
+
+struct sl_ap_wake_info *slaunch_get_ap_wake_info(void)
+{
+   return &ap_wake_info;
+}
+
+struct acpi_table_header *slaunch_get_dmar_table(struct acpi_table_header 
*dmar)
+{
+   /* The DMAR is only stashed and provided via TXT on Intel systems */
+   if (memcmp(txt_dmar, "DMAR", 4))
+   return dmar;
+
+   return (struct acpi_table_header *)(&txt_dmar[0]);
+}
+
+static void __init __noreturn slaunch_txt_reset(void __iomem *txt,
+   const char *msg, u64 error)
+{
+   u64 one = 1, val;
+
+   pr_err("%s", msg);
+
+   /*
+* This performs a TXT reset with a sticky error code. The reads of
+* TXT_CR_E2STS act as barriers.
+*/
+   memcpy_toio(txt + TXT_CR_ERRORCODE, &error, sizeof(u64));
+   memcpy_fromio(&val, txt + TXT_CR_E2STS, sizeof(u64));
+   memcpy_toio(txt + TXT_CR_CMD_NO_SECRETS, &one, sizeof(u64));
+   memcpy_fromio(&val, txt + TXT_CR_E2STS, sizeof(u64));
+   memcpy_toio(txt + TXT_CR_CMD_UNLOCK_MEM_CONFIG, &one, sizeof(u64));
+   memcpy_fromio(&val, txt + TXT_CR_E2STS, sizeof(u64));
+   memcpy_toio(txt + TXT_CR_CMD_RESET, &one, sizeof(u64));
+
+   for ( ; ; )
+   asm volatile ("hlt");
+
+   unreachable();
+}
+
+/*
+ * The TXT heap is too big to map all at once with early_ioremap
+ * so it is done a table at a time.
+ */
+static void __init *txt_early_get_heap_table(void __iomem *txt, u32 type,
+u32 bytes)
+{
+   void *heap;
+   u64 base, size, offset = 0;
+   int i;
+
+   if (type > TXT_SINIT_MLE_DATA_TABLE)
+   slaunch_txt_reset(txt,
+   "Error invalid table type for early heap walk\n",
+   SL_ERROR_HEAP_WALK);
+
+   memcpy_fromio(&base, txt + TXT_CR_HEAP_BASE, sizeof(u64));
+   memcpy_fromio(&size, txt + TXT_CR_HEAP_SIZE, sizeof(u64));
+
+   /* Iterate over heap tables looking for table of "type" */
+   for (i = 0; i < type; i++) {
+

[PATCH 02/13] x86: Secure Launch main header file

2020-09-24 Thread Ross Philipson
Introduce the main Secure Launch header file used in the early SL stub
and the early setup code.

Signed-off-by: Ross Philipson 
---
 include/linux/slaunch.h | 544 
 1 file changed, 544 insertions(+)
 create mode 100644 include/linux/slaunch.h

diff --git a/include/linux/slaunch.h b/include/linux/slaunch.h
new file mode 100644
index 000..88adc69
--- /dev/null
+++ b/include/linux/slaunch.h
@@ -0,0 +1,544 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Main Secure Launch header file.
+ *
+ * Copyright (c) 2020, Oracle and/or its affiliates.
+ */
+
+#ifndef _LINUX_SLAUNCH_H
+#define _LINUX_SLAUNCH_H
+
+/*
+ * Secure Launch Defined State Flags
+ */
+#define SL_FLAG_ACTIVE 0x0001
+#define SL_FLAG_ARCH_SKINIT0x0002
+#define SL_FLAG_ARCH_TXT   0x0004
+
+#ifdef CONFIG_SECURE_LAUNCH
+
+/*
+ * Secure Launch main definitions file.
+ *
+ * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
+ */
+
+#define __SL32_CS  0x0008
+#define __SL32_DS  0x0010
+
+#define SL_CPU_AMD 1
+#define SL_CPU_INTEL   2
+
+#define INTEL_CPUID_MFGID_EBX  0x756e6547 /* Genu */
+#define INTEL_CPUID_MFGID_EDX  0x49656e69 /* ineI */
+#define INTEL_CPUID_MFGID_ECX  0x6c65746e /* ntel */
+
+#define AMD_CPUID_MFGID_EBX0x68747541 /* Auth */
+#define AMD_CPUID_MFGID_EDX0x69746e65 /* enti */
+#define AMD_CPUID_MFGID_ECX0x444d4163 /* cAMD */
+
+/*
+ * Intel Safer Mode Extensions (SMX)
+ *
+ * Intel SMX provides a programming interface to establish a Measured Launched
+ * Environment (MLE). The measurement and protection mechanisms supported by 
the
+ * capabilities of an Intel Trusted Execution Technology (TXT) platform. SMX is
+ * the processor’s programming interface in an Intel TXT platform.
+ *
+ * See Intel SDM Volume 2 - 6.1 "Safer Mode Extensions Reference"
+ */
+
+/*
+ * SMX GETSEC Leaf Functions
+ */
+#define SMX_X86_GETSEC_SEXIT   5
+#define SMX_X86_GETSEC_SMCTRL  7
+#define SMX_X86_GETSEC_WAKEUP  8
+
+/*
+ * Intel Trusted Execution Technology MMIO Registers Banks
+ */
+#define TXT_PUB_CONFIG_REGS_BASE   0xfed3
+#define TXT_PRIV_CONFIG_REGS_BASE  0xfed2
+#define TXT_NR_CONFIG_PAGES ((TXT_PUB_CONFIG_REGS_BASE - \
+ TXT_PRIV_CONFIG_REGS_BASE) >> PAGE_SHIFT)
+
+/*
+ * Intel Trusted Execution Technology (TXT) Registers
+ */
+#define TXT_CR_STS 0x
+#define TXT_CR_ESTS0x0008
+#define TXT_CR_ERRORCODE   0x0030
+#define TXT_CR_CMD_RESET   0x0038
+#define TXT_CR_CMD_CLOSE_PRIVATE   0x0048
+#define TXT_CR_DIDVID  0x0110
+#define TXT_CR_VER_EMIF0x0200
+#define TXT_CR_CMD_UNLOCK_MEM_CONFIG   0x0218
+#define TXT_CR_SINIT_BASE  0x0270
+#define TXT_CR_SINIT_SIZE  0x0278
+#define TXT_CR_MLE_JOIN0x0290
+#define TXT_CR_HEAP_BASE   0x0300
+#define TXT_CR_HEAP_SIZE   0x0308
+#define TXT_CR_SCRATCHPAD  0x0378
+#define TXT_CR_CMD_OPEN_LOCALITY1  0x0380
+#define TXT_CR_CMD_CLOSE_LOCALITY1 0x0388
+#define TXT_CR_CMD_OPEN_LOCALITY2  0x0390
+#define TXT_CR_CMD_CLOSE_LOCALITY2 0x0398
+#define TXT_CR_CMD_SECRETS 0x08e0
+#define TXT_CR_CMD_NO_SECRETS  0x08e8
+#define TXT_CR_E2STS   0x08f0
+
+/* TXTCR_STS status bits */
+#define TXT_SENTER_DONE_STS(1<<0)
+#define TXT_SEXIT_DONE_STS (1<<1)
+
+/*
+ * SINIT/MLE Capabilities Field Bit Definitions
+ */
+#define TXT_SINIT_MLE_CAP_WAKE_GETSEC  0
+#define TXT_SINIT_MLE_CAP_WAKE_MONITOR 1
+
+/*
+ * OS/MLE Secure Launch Specific Definitions
+ */
+#define TXT_OS_MLE_STRUCT_VERSION  1
+#define TXT_OS_MLE_MAX_VARIABLE_MTRRS  32
+
+/*
+ * TXT Heap Table Enumeration
+ */
+#define TXT_BIOS_DATA_TABLE1
+#define TXT_OS_MLE_DATA_TABLE  2
+#define TXT_OS_SINIT_DATA_TABLE3
+#define TXT_SINIT_MLE_DATA_TABLE   4
+
+/*
+ * Secure Launch Defined Error Codes used in MLE-initiated TXT resets.
+ *
+ * TXT Specification
+ * Appendix I ACM Error Codes
+ */
+#define SL_ERROR_GENERIC   0xc0008001
+#define SL_ERROR_TPM_INIT  0xc0008002
+#define SL_ERROR_TPM_INVALID_LOG20 0xc0008003
+#define SL_ERROR_TPM_LOGGING_FAILED0xc0008004
+#define SL_ERROR_TPM_GET_LOC   0xc0008005
+#define SL_ERROR_TPM_EXTEND0xc0008006
+#define SL_ERROR_MTRR_INV_VCNT 0xc0008007
+#define SL_ERROR_MTRR_INV_DEF_TYPE 0xc0008008
+#define SL_ERROR_MTRR_INV_BASE 0xc0008009
+#define SL_ERROR_MTRR_INV_MASK 0xc000800a
+#define SL_ERROR_MSR_INV_MISC_EN   0xc000800b
+#define SL_ERROR_INV_AP_INTERRUPT  0xc000800c
+#define SL_ERROR_RESERVE_AP_WAKE   0xc000800d
+#define SL_ERROR_HEAP_WALK 0xc000800e
+#define SL_ERROR_HEAP_MAP  0xc000800f
+#define SL_ERROR_HEAP_MDR_VALS

[PATCH 01/13] x86: Secure Launch Kconfig

2020-09-24 Thread Ross Philipson
Initial bits to bring in Secure Launch functionality. Add Kconfig
options for compiling in/out the Secure Launch code.

Signed-off-by: Ross Philipson 
---
 arch/x86/Kconfig | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 7101ac6..8957981 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1968,6 +1968,42 @@ config EFI_MIXED
 
   If unsure, say N.
 
+config SECURE_LAUNCH
+   bool "Secure Launch support"
+   default n
+   depends on X86_64
+   help
+  The Secure Launch feature allows a kernel to be loaded
+  directly through an Intel TXT measured launch. Intel TXT
+  establishes a Dynamic Root of Trust for Measurement (DRTM)
+  where the CPU measures the kernel image. This feature then
+  continues the measurement chain over kernel configuration
+  information and init images.
+
+choice
+   prompt "Select Secure Launch Algorithm for TPM2"
+   depends on SECURE_LAUNCH
+
+config SECURE_LAUNCH_SHA1
+   bool "Secure Launch TPM1 SHA1"
+   help
+  When using Secure Launch and TPM1 is present, use SHA1 hash
+  algorithm for measurements.
+
+config SECURE_LAUNCH_SHA256
+   bool "Secure Launch TPM2 SHA256"
+   help
+  When using Secure Launch and TPM2 is present, use SHA256 hash
+  algorithm for measurements.
+
+config SECURE_LAUNCH_SHA512
+   bool "Secure Launch TPM2 SHA512"
+   help
+  When using Secure Launch and TPM2 is present, use SHA512 hash
+  algorithm for measurements.
+
+endchoice
+
 config SECCOMP
def_bool y
prompt "Enable seccomp to safely compute untrusted bytecode"
-- 
1.8.3.1



[PATCH 04/13] x86: Add early TPM TIS/CRB interface support for Secure Launch

2020-09-24 Thread Ross Philipson
From: "Daniel P. Smith" 

The Secure Launch capability that is part of the compressed kernel
requires the ability to send measurements it takes to the TPM. This
commit introduces the necessary code to communicate with the hardware
interface of TPM devices.

Signed-off-by: Daniel P. Smith 
Signed-off-by: Ross Philipson 
---
 arch/x86/boot/compressed/Makefile |   2 +
 arch/x86/boot/compressed/tpm/crb.c| 304 ++
 arch/x86/boot/compressed/tpm/crb.h|  20 ++
 arch/x86/boot/compressed/tpm/tis.c| 215 +
 arch/x86/boot/compressed/tpm/tis.h|  46 +
 arch/x86/boot/compressed/tpm/tpm.h|  48 +
 arch/x86/boot/compressed/tpm/tpm_buff.c   | 121 
 arch/x86/boot/compressed/tpm/tpm_common.h | 127 +
 arch/x86/boot/compressed/tpm/tpmbuff.h|  34 
 arch/x86/boot/compressed/tpm/tpmio.c  |  51 +
 10 files changed, 968 insertions(+)
 create mode 100644 arch/x86/boot/compressed/tpm/crb.c
 create mode 100644 arch/x86/boot/compressed/tpm/crb.h
 create mode 100644 arch/x86/boot/compressed/tpm/tis.c
 create mode 100644 arch/x86/boot/compressed/tpm/tis.h
 create mode 100644 arch/x86/boot/compressed/tpm/tpm.h
 create mode 100644 arch/x86/boot/compressed/tpm/tpm_buff.c
 create mode 100644 arch/x86/boot/compressed/tpm/tpm_common.h
 create mode 100644 arch/x86/boot/compressed/tpm/tpmbuff.h
 create mode 100644 arch/x86/boot/compressed/tpm/tpmio.c

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index 0fd84b9..5515afa 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -99,6 +99,8 @@ efi-obj-$(CONFIG_EFI_STUB) = 
$(objtree)/drivers/firmware/efi/libstub/lib.a
 vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(obj)/early_sha1.o
 vmlinux-objs-$(CONFIG_SECURE_LAUNCH_SHA256) += $(obj)/early_sha256.o
 vmlinux-objs-$(CONFIG_SECURE_LAUNCH_SHA512) += $(obj)/early_sha512.o
+vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(obj)/tpm/tpmio.o 
$(obj)/tpm/tpm_buff.o \
+   $(obj)/tpm/tis.o $(obj)/tpm/crb.o
 
 # The compressed kernel is built with -fPIC/-fPIE so that a boot loader
 # can place it anywhere in memory and it will still run. However, since
diff --git a/arch/x86/boot/compressed/tpm/crb.c 
b/arch/x86/boot/compressed/tpm/crb.c
new file mode 100644
index 000..05c4038
--- /dev/null
+++ b/arch/x86/boot/compressed/tpm/crb.c
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 Apertus Solutions, LLC
+ *
+ * Author(s):
+ *  Daniel P. Smith 
+ */
+
+#include 
+#include "tpm.h"
+#include "tpmbuff.h"
+#include "crb.h"
+#include "tpm_common.h"
+
+#define TPM_LOC_STATE  0x
+#define TPM_LOC_CTRL   0x0008
+#define TPM_LOC_STS0x000C
+#define TPM_CRB_INTF_ID0x0030
+#define TPM_CRB_CTRL_EXT   0x0038
+#define TPM_CRB_CTRL_REQ   0x0040
+#define TPM_CRB_CTRL_STS   0x0044
+#define TPM_CRB_CTRL_CANCEL0x0048
+#define TPM_CRB_CTRL_START 0x004C
+#define TPM_CRB_INT_ENABLE 0x0050
+#define TPM_CRB_INT_STS0x0054
+#define TPM_CRB_CTRL_CMD_SIZE  0x0058
+#define TPM_CRB_CTRL_CMD_LADDR 0x005C
+#define TPM_CRB_CTRL_CMD_HADDR 0x0060
+#define TPM_CRB_CTRL_RSP_SIZE  0x0064
+#define TPM_CRB_CTRL_RSP_ADDR  0x0068
+#define TPM_CRB_DATA_BUFFER0x0080
+
+#define REGISTER(l, r) (((l) << 12) | (r))
+
+static u8 locality = TPM_NO_LOCALITY;
+
+struct tpm_loc_state {
+   union {
+   u8 val;
+   struct {
+   u8 tpm_established:1;
+   u8 loc_assigned:1;
+   u8 active_locality:3;
+   u8 _reserved:2;
+   u8 tpm_reg_valid_sts:1;
+   };
+   };
+} __packed;
+
+struct tpm_loc_ctrl {
+   union {
+   u32 val;
+   struct {
+   u32 request_access:1;
+   u32 relinquish:1;
+   u32 seize:1;
+   u32 reset_establishment_bit:1;
+   u32 _reserved:28;
+   };
+   };
+} __packed;
+
+struct tpm_loc_sts {
+   union {
+   u32 val;
+   struct {
+   u32 granted:1;
+   u32 beenSeized:1;
+   u32 _reserved:30;
+   };
+   };
+} __packed;
+
+struct tpm_crb_ctrl_req {
+   union {
+   u32 val;
+   struct {
+   u32 cmd_ready:1;
+   u32 go_idle:1;
+   u32 _reserved:30;
+   };
+   };
+} __packed;
+
+struct tpm_crb_ctrl_sts {
+   union {
+   u32 val;
+   struct {
+   u32 tpm_sts:1;
+   u32 tpm_idle:1;
+   u32 _reserved:30;
+   };
+   };
+}

[PATCH 06/13] x86: Add early general TPM interface support for Secure Launch

2020-09-24 Thread Ross Philipson
From: "Daniel P. Smith" 

This commit exposes a minimal general interface for the compressed
kernel to request the required TPM operations to send measurements to
a TPM.

Signed-off-by: Daniel P. Smith 
Signed-off-by: Ross Philipson 
---
 arch/x86/boot/compressed/Makefile  |   2 +-
 arch/x86/boot/compressed/tpm/tpm.c | 145 +
 2 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/boot/compressed/tpm/tpm.c

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index a4308d5..35947b9 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -101,7 +101,7 @@ vmlinux-objs-$(CONFIG_SECURE_LAUNCH_SHA256) += 
$(obj)/early_sha256.o
 vmlinux-objs-$(CONFIG_SECURE_LAUNCH_SHA512) += $(obj)/early_sha512.o
 vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(obj)/tpm/tpmio.o 
$(obj)/tpm/tpm_buff.o \
$(obj)/tpm/tis.o $(obj)/tpm/crb.o $(obj)/tpm/tpm1_cmds.o \
-   $(obj)/tpm/tpm2_cmds.o $(obj)/tpm/tpm2_auth.o
+   $(obj)/tpm/tpm2_cmds.o $(obj)/tpm/tpm2_auth.o $(obj)/tpm/tpm.o
 
 # The compressed kernel is built with -fPIC/-fPIE so that a boot loader
 # can place it anywhere in memory and it will still run. However, since
diff --git a/arch/x86/boot/compressed/tpm/tpm.c 
b/arch/x86/boot/compressed/tpm/tpm.c
new file mode 100644
index 000..0fe62d2
--- /dev/null
+++ b/arch/x86/boot/compressed/tpm/tpm.c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 Apertus Solutions, LLC
+ *
+ * Author(s):
+ *  Daniel P. Smith 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "tpm.h"
+#include "tpmbuff.h"
+#include "tis.h"
+#include "crb.h"
+#include "tpm_common.h"
+#include "tpm1.h"
+#include "tpm2.h"
+#include "tpm2_constants.h"
+
+static struct tpm tpm;
+
+static void find_interface_and_family(struct tpm *t)
+{
+   struct tpm_interface_id intf_id;
+   struct tpm_intf_capability intf_cap;
+
+   /* Sort out whether if it is 1.2 */
+   intf_cap.val = tpm_read32(TPM_INTF_CAPABILITY_0);
+   if ((intf_cap.interface_version == TPM12_TIS_INTF_12) ||
+   (intf_cap.interface_version == TPM12_TIS_INTF_13)) {
+   t->family = TPM12;
+   t->intf = TPM_TIS;
+   return;
+   }
+
+   /* Assume that it is 2.0 and TIS */
+   t->family = TPM20;
+   t->intf = TPM_TIS;
+
+   /* Check if the interface is CRB */
+   intf_id.val = tpm_read32(TPM_INTERFACE_ID_0);
+   if (intf_id.interface_type == TPM_CRB_INTF_ACTIVE)
+   t->intf = TPM_CRB;
+}
+
+struct tpm *enable_tpm(void)
+{
+   struct tpm *t = &tpm;
+
+   find_interface_and_family(t);
+
+   switch (t->intf) {
+   case TPM_TIS:
+   if (!tis_init(t))
+   return NULL;
+   break;
+   case TPM_CRB:
+   if (!crb_init(t))
+   return NULL;
+   break;
+   }
+
+   return t;
+}
+
+u8 tpm_request_locality(struct tpm *t, u8 l)
+{
+   u8 ret = TPM_NO_LOCALITY;
+
+   ret = t->ops.request_locality(l);
+
+   if (ret < TPM_MAX_LOCALITY)
+   t->buff = alloc_tpmbuff(t->intf, ret);
+
+   return ret;
+}
+
+void tpm_relinquish_locality(struct tpm *t)
+{
+   t->ops.relinquish_locality();
+
+   free_tpmbuff(t->buff, t->intf);
+}
+
+#define MAX_TPM_EXTEND_SIZE 70 /* TPM2 SHA512 is the largest */
+int tpm_extend_pcr(struct tpm *t, u32 pcr, u16 algo,
+   u8 *digest)
+{
+   int ret = 0;
+
+   if (t->buff == NULL)
+   return -EINVAL;
+
+   if (t->family == TPM12) {
+   struct tpm_digest d;
+
+   if (algo != TPM_ALG_SHA1)
+   return -EINVAL;
+
+   d.pcr = pcr;
+   memcpy((void *)d.digest.sha1.digest,
+   digest, SHA1_DIGEST_SIZE);
+
+   ret = tpm1_pcr_extend(t, &d);
+   } else if (t->family == TPM20) {
+   struct tpml_digest_values *d;
+   u8 buf[MAX_TPM_EXTEND_SIZE];
+
+   d = (struct tpml_digest_values *) buf;
+   d->count = 1;
+   d->digests->alg = algo;
+   switch (algo) {
+   case TPM_ALG_SHA1:
+   memcpy(d->digests->digest, digest, SHA1_SIZE);
+   break;
+   case TPM_ALG_SHA256:
+   memcpy(d->digests->digest, digest, SHA256_SIZE);
+   break;
+   case TPM_ALG_SHA384:
+   memcpy(d->digests->digest, digest, SHA384_SIZE);
+   break;
+   case TPM_ALG_SHA512:
+   memcpy(d->digests->digest, digest, SHA512_SIZE);
+

[PATCH 11/13] kexec: Secure Launch kexec SEXIT support

2020-09-24 Thread Ross Philipson
Prior to running the next kernel via kexec, the Secure Launch code
closes down private SMX resources and does an SEXIT. This allows the
next kernel to start normally without any issues starting the APs etc.

Signed-off-by: Ross Philipson 
---
 arch/x86/kernel/slaunch.c | 70 +++
 kernel/kexec_core.c   |  4 +++
 2 files changed, 74 insertions(+)

diff --git a/arch/x86/kernel/slaunch.c b/arch/x86/kernel/slaunch.c
index 7bdb89e..b2221d8 100644
--- a/arch/x86/kernel/slaunch.c
+++ b/arch/x86/kernel/slaunch.c
@@ -784,3 +784,73 @@ static void __exit slaunch_exit(void)
 late_initcall(slaunch_late_init);
 
 __exitcall(slaunch_exit);
+
+static inline void smx_getsec_sexit(void)
+{
+   asm volatile (".byte 0x0f,0x37\n"
+ : : "a" (SMX_X86_GETSEC_SEXIT));
+}
+
+void slaunch_finalize(int do_sexit)
+{
+   void __iomem *config;
+   u64 one = 1, val;
+
+   if (!(slaunch_get_flags() & (SL_FLAG_ACTIVE|SL_FLAG_ARCH_TXT)))
+   return;
+
+   config = ioremap(TXT_PRIV_CONFIG_REGS_BASE, TXT_NR_CONFIG_PAGES *
+PAGE_SIZE);
+   if (!config) {
+   pr_emerg("Error SEXIT failed to ioremap TXT private reqs\n");
+   return;
+   }
+
+   /* Clear secrets bit for SEXIT */
+   memcpy_toio(config + TXT_CR_CMD_NO_SECRETS, &one, sizeof(u64));
+   memcpy_fromio(&val, config + TXT_CR_E2STS, sizeof(u64));
+
+   /* Unlock memory configurations */
+   memcpy_toio(config + TXT_CR_CMD_UNLOCK_MEM_CONFIG, &one, sizeof(u64));
+   memcpy_fromio(&val, config + TXT_CR_E2STS, sizeof(u64));
+
+   /* Close the TXT private register space */
+   memcpy_fromio(&val, config + TXT_CR_E2STS, sizeof(u64));
+   memcpy_toio(config + TXT_CR_CMD_CLOSE_PRIVATE, &one, sizeof(u64));
+
+   /*
+* Calls to iounmap are not being done because of the state of the
+* system this late in the kexec process. Local IRQs are disabled and
+* iounmap causes a TLB flush which in turn causes a warning. Leaving
+* thse mappings is not an issue since the next kernel is going to
+* completely re-setup memory management.
+*/
+
+   /* Map public registers and do a final read fence */
+   config = ioremap(TXT_PUB_CONFIG_REGS_BASE, TXT_NR_CONFIG_PAGES *
+PAGE_SIZE);
+   if (!config) {
+   pr_emerg("Error SEXIT failed to ioremap TXT public reqs\n");
+   return;
+   }
+
+   memcpy_fromio(&val, config + TXT_CR_E2STS, sizeof(u64));
+
+   pr_emerg("TXT clear secrets bit and unlock memory complete.");
+
+   if (!do_sexit)
+   return;
+
+   if (smp_processor_id() != 0) {
+   pr_emerg("Error TXT SEXIT must be called on CPU 0\n");
+   return;
+   }
+
+   /* Disable SMX mode */
+   cr4_set_bits(X86_CR4_SMXE);
+
+   /* Do the SEXIT SMX operation */
+   smx_getsec_sexit();
+
+   pr_emerg("TXT SEXIT complete.");
+}
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index c19c0da..6b9ac11 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1179,6 +1180,9 @@ int kernel_kexec(void)
cpu_hotplug_enable();
pr_notice("Starting new kernel\n");
machine_shutdown();
+
+   /* Finalize TXT registers and do SEXIT */
+   slaunch_finalize(1);
}
 
machine_kexec(kexec_image);
-- 
1.8.3.1



  1   2   3   4   5   6   7   8   9   10   >