2020-05-23 21:33:42

by Pascal Terjan

[permalink] [raw]
Subject: [PATCH] staging: rtl8723bs: Use shared header constants

This is one of the 9 drivers redefining rfc1042_header.

Signed-off-by: Pascal Terjan <[email protected]>
---
drivers/staging/rtl8723bs/core/rtw_recv.c | 15 ++++++---------
drivers/staging/rtl8723bs/include/rtw_recv.h | 2 --
drivers/staging/rtl8723bs/os_dep/recv_linux.c | 5 +++--
3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 5245098b9ecf..dc58822924b4 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -10,14 +10,11 @@
#include <rtw_debug.h>
#include <linux/jiffies.h>
#include <rtw_recv.h>
+#include <net/cfg80211.h>

static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};

-u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-
static void rtw_signal_stat_timer_hdl(struct timer_list *t);

void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
@@ -1625,11 +1622,11 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
/* convert hdr + possible LLC headers into Ethernet header */
/* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
- if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
- (memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) &&
- (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
- /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
- !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
+ if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
+ memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
+ memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
+ /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
+ !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) {
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
bsnaphdr = true;
} else
diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h
index 98c3e92245b7..a851b818ef0e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtw_recv.h
@@ -38,8 +38,6 @@
#define RX_MAX_QUEUE 2

#define MAX_SUBFRAME_COUNT 64
-extern u8 rtw_rfc1042_header[];
-extern u8 rtw_bridge_tunnel_header[];

/* for Rx reordering buffer control */
struct recv_reorder_ctrl
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index 2a7b9922b1d4..eb4d1c3008fe 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -9,6 +9,7 @@
#include <drv_types.h>
#include <rtw_debug.h>
#include <linux/jiffies.h>
+#include <net/cfg80211.h>

void rtw_os_free_recvframe(union recv_frame *precvframe)
{
@@ -71,9 +72,9 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8
eth_type = RTW_GET_BE16(&sub_skb->data[6]);

if (sub_skb->len >= 8 &&
- ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) &&
+ ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
- !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) {
+ !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) {
/*
* remove RFC1042 or Bridge-Tunnel encapsulation and replace
* EtherType
--
2.27.0.rc0.183.gde8f92d652-goog


2020-05-27 10:41:06

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8723bs: Use shared header constants

On Sat, May 23, 2020 at 10:29:19PM +0100, Pascal Terjan wrote:
> This is one of the 9 drivers redefining rfc1042_header.

I do not understand what this changelog is trying to say. Can you fix
this up to be more explicit and detained and resend?

thanks,

greg k-h

2020-05-27 19:51:19

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8723bs: Use shared header constants

On Sat, May 23, 2020 at 10:29:19PM +0100, Pascal Terjan wrote:
> This is one of the 9 drivers redefining rfc1042_header.
>

This is how the patch looks like in my email client:

https://marc.info/?l=linux-driver-devel&m=159026973821890&w=2

Do you see how the subject is far away from the body of the commit
message? I normally only read the subject or the body when I'm
reviewing patches so it's good if the body is clear on its own. Maybe
write something like:

"This driver creates a local definitions of "rtw_rfc1042_header" and
"rtw_bridge_tunnel_header" but it should just use the standard definitions
from cfg80211.h."

> void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
> @@ -1625,11 +1622,11 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
> psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
> /* convert hdr + possible LLC headers into Ethernet header */
> /* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
> - if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
> - (memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) &&
> - (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
> - /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> - !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
> + if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
> + memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
> + memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
> + /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> + !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) {
> /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
> bsnaphdr = true;

Your indenting is correct, but I would probably do that in a separate
patch. It makes it harder to review. Also probably delete the
commented out code. Do you see how if we don't touch the indenting then
it doesn't raise the question about if we should delete the comments as
well?

regards,
dan carpenter

2020-05-27 20:35:33

by Pascal Terjan

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8723bs: Use shared header constants

On Wed, 27 May 2020 at 20:48, Dan Carpenter <[email protected]> wrote:
>
> On Sat, May 23, 2020 at 10:29:19PM +0100, Pascal Terjan wrote:
> > This is one of the 9 drivers redefining rfc1042_header.
> >
>
> This is how the patch looks like in my email client:
>
> https://marc.info/?l=linux-driver-devel&m=159026973821890&w=2
>
> Do you see how the subject is far away from the body of the commit
> message? I normally only read the subject or the body when I'm
> reviewing patches so it's good if the body is clear on its own. Maybe
> write something like:
>
> "This driver creates a local definitions of "rtw_rfc1042_header" and
> "rtw_bridge_tunnel_header" but it should just use the standard definitions
> from cfg80211.h."

Thanks, I see both together when writing the commit message and need
to remember they are actually separate.

> > void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
> > @@ -1625,11 +1622,11 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
> > psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
> > /* convert hdr + possible LLC headers into Ethernet header */
> > /* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
> > - if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
> > - (memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) &&
> > - (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
> > - /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> > - !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
> > + if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
> > + memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
> > + memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
> > + /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> > + !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) {
> > /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
> > bsnaphdr = true;
>
> Your indenting is correct, but I would probably do that in a separate
> patch. It makes it harder to review. Also probably delete the
> commented out code. Do you see how if we don't touch the indenting then
> it doesn't raise the question about if we should delete the comments as
> well?

I initially didn't want to change it but checkpatch was sad which
makes me sad, maybe I should have cleaned up this area in a first
trivial patch before touching that line.

2020-05-27 20:53:57

by Pascal Terjan

[permalink] [raw]
Subject: [PATCH v2] staging: rtl8723bs: Use common packet header constants

This driver contains a local version of the rfc1042 header and bridge
tunnel header constants which are available from cfg80211.h, switch to
those.

Signed-off-by: Pascal Terjan <[email protected]>
---
v2: improve description and drop confusing cosmetic changes

drivers/staging/rtl8723bs/core/rtw_recv.c | 9 +++------
drivers/staging/rtl8723bs/include/rtw_recv.h | 2 --
drivers/staging/rtl8723bs/os_dep/recv_linux.c | 5 +++--
3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 5245098b9ecf..7e1da0e35812 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -10,14 +10,11 @@
#include <rtw_debug.h>
#include <linux/jiffies.h>
#include <rtw_recv.h>
+#include <net/cfg80211.h>

static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};

-u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-
static void rtw_signal_stat_timer_hdl(struct timer_list *t);

void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
@@ -1625,11 +1622,11 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
/* convert hdr + possible LLC headers into Ethernet header */
/* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
- if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
+ if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
(memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) &&
(memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
/* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
- !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
+ !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) {
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
bsnaphdr = true;
} else
diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h
index 98c3e92245b7..a851b818ef0e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtw_recv.h
@@ -38,8 +38,6 @@
#define RX_MAX_QUEUE 2

#define MAX_SUBFRAME_COUNT 64
-extern u8 rtw_rfc1042_header[];
-extern u8 rtw_bridge_tunnel_header[];

/* for Rx reordering buffer control */
struct recv_reorder_ctrl
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index 2a7b9922b1d4..eb4d1c3008fe 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -9,6 +9,7 @@
#include <drv_types.h>
#include <rtw_debug.h>
#include <linux/jiffies.h>
+#include <net/cfg80211.h>

void rtw_os_free_recvframe(union recv_frame *precvframe)
{
@@ -71,9 +72,9 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8
eth_type = RTW_GET_BE16(&sub_skb->data[6]);

if (sub_skb->len >= 8 &&
- ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) &&
+ ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
- !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) {
+ !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) {
/*
* remove RFC1042 or Bridge-Tunnel encapsulation and replace
* EtherType
--
2.27.0.rc0.183.gde8f92d652-goog

2020-05-28 09:18:53

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: rtl8723bs: Use shared header constants

On Wed, May 27, 2020 at 09:33:03PM +0100, Pascal Terjan wrote:
> On Wed, 27 May 2020 at 20:48, Dan Carpenter <[email protected]> wrote:
> > > /* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
> > > - if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
> > > - (memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) &&
> > > - (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
> > > - /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> > > - !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) {
> > > + if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
> > > + memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) &&
> > > + memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) ||
> > > + /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
> > > + !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) {
> > > /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
> > > bsnaphdr = true;
> >
> > Your indenting is correct, but I would probably do that in a separate
> > patch. It makes it harder to review. Also probably delete the
> > commented out code. Do you see how if we don't touch the indenting then
> > it doesn't raise the question about if we should delete the comments as
> > well?
>
> I initially didn't want to change it but checkpatch was sad which
> makes me sad, maybe I should have cleaned up this area in a first
> trivial patch before touching that line.

Just ignore checkpatch in this case because it's not a warning that your
patch introduced.

Say if you re-name a function, then you *must* re-indent the parameters
because that's a warning the change introduces. If there is a
checkpatch warning and it's on a line that you touch then you can change
that. But once you start changing other nearby lines you might run into
trouble.

The other thing that you fixed is you removed unnecessary parentheses
and that's good but it actually broke my review script for renaming
variables. (Attached). I do `cat email.txt | rename_rev.pl -a` It's
easier in mutt.

regards,
dan carpenter


Attachments:
(No filename) (2.16 kB)
rename_rev.pl (11.35 kB)
Download all attachments

2020-05-28 10:09:16

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v2] staging: rtl8723bs: Use common packet header constants

On Wed, May 27, 2020 at 09:51:00PM +0100, Pascal Terjan wrote:
> This driver contains a local version of the rfc1042 header and bridge
> tunnel header constants which are available from cfg80211.h, switch to
> those.
>
> Signed-off-by: Pascal Terjan <[email protected]>
> ---
> v2: improve description and drop confusing cosmetic changes

Perfect! Thanks.

Reviewed-by: Dan Carpenter <[email protected]>

regards,
dan carpenter