diff mbox series

[07/10] rtw88: Add rtw8723du chipset support

Message ID 20220518082318.3898514-8-s.hauer@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series RTW88: Add support for USB variants | expand

Commit Message

Sascha Hauer May 18, 2022, 8:23 a.m. UTC
Add support for the rtw8723du chipset based on
https://github.com/ulli-kroll/rtw88-usb.git

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/wireless/realtek/rtw88/Kconfig    | 11 +++++
 drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
 drivers/net/wireless/realtek/rtw88/rtw8723d.c | 19 +++++++++
 drivers/net/wireless/realtek/rtw88/rtw8723d.h |  1 +
 .../net/wireless/realtek/rtw88/rtw8723du.c    | 40 +++++++++++++++++++
 .../net/wireless/realtek/rtw88/rtw8723du.h    | 13 ++++++
 6 files changed, 87 insertions(+)
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.c
 create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.h

Comments

kernel test robot May 18, 2022, 4:55 p.m. UTC | #1
Hi Sascha,

I love your patch! Perhaps something to improve:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main v5.18-rc7 next-20220518]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Sascha-Hauer/RTW88-Add-support-for-USB-variants/20220518-162621
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20220519/202205190028.z15SPbJx-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/0a06adba364ef264404e3c7ae111a71f0d74c5a9
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sascha-Hauer/RTW88-Add-support-for-USB-variants/20220518-162621
        git checkout 0a06adba364ef264404e3c7ae111a71f0d74c5a9
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/wireless/realtek/rtw88/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/realtek/rtw88/util.c:119:6: warning: no previous prototype for 'rtw_collect_sta_iter' [-Wmissing-prototypes]
     119 | void rtw_collect_sta_iter(void *data, struct ieee80211_sta *sta)
         |      ^~~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/realtek/rtw88/util.c:165:6: warning: no previous prototype for 'rtw_collect_vif_iter' [-Wmissing-prototypes]
     165 | void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
         |      ^~~~~~~~~~~~~~~~~~~~


vim +/rtw_collect_sta_iter +119 drivers/net/wireless/realtek/rtw88/util.c

1c99f6652d3fbb Sascha Hauer 2022-05-18  118  
1c99f6652d3fbb Sascha Hauer 2022-05-18 @119  void rtw_collect_sta_iter(void *data, struct ieee80211_sta *sta)
1c99f6652d3fbb Sascha Hauer 2022-05-18  120  {
1c99f6652d3fbb Sascha Hauer 2022-05-18  121  	struct rtw_iter_stas_data *iter_stas = data;
1c99f6652d3fbb Sascha Hauer 2022-05-18  122  	struct rtw_stas_entry *stas_entry;
1c99f6652d3fbb Sascha Hauer 2022-05-18  123  
1c99f6652d3fbb Sascha Hauer 2022-05-18  124  	stas_entry = kmalloc(sizeof(*stas_entry), GFP_ATOMIC);
1c99f6652d3fbb Sascha Hauer 2022-05-18  125  	if (!stas_entry)
1c99f6652d3fbb Sascha Hauer 2022-05-18  126  		return;
1c99f6652d3fbb Sascha Hauer 2022-05-18  127  
1c99f6652d3fbb Sascha Hauer 2022-05-18  128  	stas_entry->sta = sta;
1c99f6652d3fbb Sascha Hauer 2022-05-18  129  	list_add_tail(&stas_entry->list, &iter_stas->list);
1c99f6652d3fbb Sascha Hauer 2022-05-18  130  }
1c99f6652d3fbb Sascha Hauer 2022-05-18  131  
1c99f6652d3fbb Sascha Hauer 2022-05-18  132  void rtw_iterate_stas(struct rtw_dev *rtwdev,
1c99f6652d3fbb Sascha Hauer 2022-05-18  133  		      void (*iterator)(void *data,
1c99f6652d3fbb Sascha Hauer 2022-05-18  134  				       struct ieee80211_sta *sta),
1c99f6652d3fbb Sascha Hauer 2022-05-18  135  				       void *data)
1c99f6652d3fbb Sascha Hauer 2022-05-18  136  {
1c99f6652d3fbb Sascha Hauer 2022-05-18  137  	struct rtw_iter_stas_data iter_data;
1c99f6652d3fbb Sascha Hauer 2022-05-18  138  	struct rtw_stas_entry *sta_entry, *tmp;
1c99f6652d3fbb Sascha Hauer 2022-05-18  139  
1c99f6652d3fbb Sascha Hauer 2022-05-18  140  	iter_data.rtwdev = rtwdev;
1c99f6652d3fbb Sascha Hauer 2022-05-18  141  	INIT_LIST_HEAD(&iter_data.list);
1c99f6652d3fbb Sascha Hauer 2022-05-18  142  
1c99f6652d3fbb Sascha Hauer 2022-05-18  143  	ieee80211_iterate_stations_atomic(rtwdev->hw, rtw_collect_sta_iter,
1c99f6652d3fbb Sascha Hauer 2022-05-18  144  					  &iter_data);
1c99f6652d3fbb Sascha Hauer 2022-05-18  145  
1c99f6652d3fbb Sascha Hauer 2022-05-18  146  	list_for_each_entry_safe(sta_entry, tmp, &iter_data.list,
1c99f6652d3fbb Sascha Hauer 2022-05-18  147  				 list) {
1c99f6652d3fbb Sascha Hauer 2022-05-18  148  		list_del_init(&sta_entry->list);
1c99f6652d3fbb Sascha Hauer 2022-05-18  149  		iterator(data, sta_entry->sta);
1c99f6652d3fbb Sascha Hauer 2022-05-18  150  		kfree(sta_entry);
1c99f6652d3fbb Sascha Hauer 2022-05-18  151  	}
1c99f6652d3fbb Sascha Hauer 2022-05-18  152  }
1c99f6652d3fbb Sascha Hauer 2022-05-18  153  
1c99f6652d3fbb Sascha Hauer 2022-05-18  154  struct rtw_vifs_entry {
1c99f6652d3fbb Sascha Hauer 2022-05-18  155  	struct list_head list;
1c99f6652d3fbb Sascha Hauer 2022-05-18  156  	struct ieee80211_vif *vif;
1c99f6652d3fbb Sascha Hauer 2022-05-18  157  	u8 mac[ETH_ALEN];
1c99f6652d3fbb Sascha Hauer 2022-05-18  158  };
1c99f6652d3fbb Sascha Hauer 2022-05-18  159  
1c99f6652d3fbb Sascha Hauer 2022-05-18  160  struct rtw_iter_vifs_data {
1c99f6652d3fbb Sascha Hauer 2022-05-18  161  	struct rtw_dev *rtwdev;
1c99f6652d3fbb Sascha Hauer 2022-05-18  162  	struct list_head list;
1c99f6652d3fbb Sascha Hauer 2022-05-18  163  };
1c99f6652d3fbb Sascha Hauer 2022-05-18  164  
1c99f6652d3fbb Sascha Hauer 2022-05-18 @165  void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1c99f6652d3fbb Sascha Hauer 2022-05-18  166  {
1c99f6652d3fbb Sascha Hauer 2022-05-18  167  	struct rtw_iter_vifs_data *iter_stas = data;
1c99f6652d3fbb Sascha Hauer 2022-05-18  168  	struct rtw_vifs_entry *vifs_entry;
1c99f6652d3fbb Sascha Hauer 2022-05-18  169  
1c99f6652d3fbb Sascha Hauer 2022-05-18  170  	vifs_entry = kmalloc(sizeof(*vifs_entry), GFP_ATOMIC);
1c99f6652d3fbb Sascha Hauer 2022-05-18  171  	if (!vifs_entry)
1c99f6652d3fbb Sascha Hauer 2022-05-18  172  		return;
1c99f6652d3fbb Sascha Hauer 2022-05-18  173  
1c99f6652d3fbb Sascha Hauer 2022-05-18  174  	vifs_entry->vif = vif;
1c99f6652d3fbb Sascha Hauer 2022-05-18  175  	ether_addr_copy(vifs_entry->mac, mac);
1c99f6652d3fbb Sascha Hauer 2022-05-18  176  	list_add_tail(&vifs_entry->list, &iter_stas->list);
1c99f6652d3fbb Sascha Hauer 2022-05-18  177  }
1c99f6652d3fbb Sascha Hauer 2022-05-18  178
Ping-Ke Shih May 20, 2022, 7:47 a.m. UTC | #2
On Wed, 2022-05-18 at 10:23 +0200, Sascha Hauer wrote:
> Add support for the rtw8723du chipset based on
> https://github.com/ulli-kroll/rtw88-usb.git
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/net/wireless/realtek/rtw88/Kconfig    | 11 +++++
>  drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
>  drivers/net/wireless/realtek/rtw88/rtw8723d.c | 19 +++++++++
>  drivers/net/wireless/realtek/rtw88/rtw8723d.h |  1 +
>  .../net/wireless/realtek/rtw88/rtw8723du.c    | 40 +++++++++++++++++++
>  .../net/wireless/realtek/rtw88/rtw8723du.h    | 13 ++++++
>  6 files changed, 87 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.c
>  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.h
> 
> 

[...]

> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> new file mode 100644
> index 0000000000000..910f64c168131
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> @@ -0,0 +1,40 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> +/* Copyright(c) 2018-2019  Realtek Corporation
> + */
> +
> +#include <linux/module.h>
> +#include <linux/usb.h>
> +#include "main.h"
> +#include "rtw8723du.h"
> +#include "usb.h"
> +
> +static const struct usb_device_id rtw_8723du_id_table[] = {
> +	/*
> +	 * ULLI :
> +	 * ID found in rtw8822bu sources
> +	 */

checkpatch.pl will tell us this comment block should be

/* ULLI :
 * ID found in rtw8822bu sources
 */

But, I think we can just "/* ULLI: ID found in rtw8822bu sources */" 
if we really want to keep this comment.


[...]

> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> new file mode 100644
> index 0000000000000..2e069f65c0551
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
> +/* Copyright(c) 2018-2019  Realtek Corporation
> + */
> +
> +#ifndef __RTW_8723DU_H_
> +#define __RTW_8723DU_H_
> +
> +/* USB Vendor/Product IDs */
> +#define RTW_USB_VENDOR_ID_REALTEK		0x0BDA

rtw8821cu.h and rtw8822bu.h define this too.
Can we move it to usb.h?


> +
> +extern struct rtw_chip_info rtw8723d_hw_spec;
> +
> +#endif


Ping-Ke
Sascha Hauer May 20, 2022, 8:16 a.m. UTC | #3
On Fri, May 20, 2022 at 07:47:44AM +0000, Pkshih wrote:
> On Wed, 2022-05-18 at 10:23 +0200, Sascha Hauer wrote:
> > Add support for the rtw8723du chipset based on
> > https://github.com/ulli-kroll/rtw88-usb.git
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/net/wireless/realtek/rtw88/Kconfig    | 11 +++++
> >  drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
> >  drivers/net/wireless/realtek/rtw88/rtw8723d.c | 19 +++++++++
> >  drivers/net/wireless/realtek/rtw88/rtw8723d.h |  1 +
> >  .../net/wireless/realtek/rtw88/rtw8723du.c    | 40 +++++++++++++++++++
> >  .../net/wireless/realtek/rtw88/rtw8723du.h    | 13 ++++++
> >  6 files changed, 87 insertions(+)
> >  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.c
> >  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.h
> > 
> > 
> 
> [...]
> 
> > diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> > b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> > new file mode 100644
> > index 0000000000000..910f64c168131
> > --- /dev/null
> > +++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> > @@ -0,0 +1,40 @@
> > +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> > +/* Copyright(c) 2018-2019  Realtek Corporation
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/usb.h>
> > +#include "main.h"
> > +#include "rtw8723du.h"
> > +#include "usb.h"
> > +
> > +static const struct usb_device_id rtw_8723du_id_table[] = {
> > +	/*
> > +	 * ULLI :
> > +	 * ID found in rtw8822bu sources
> > +	 */
> 
> checkpatch.pl will tell us this comment block should be
> 
> /* ULLI :
>  * ID found in rtw8822bu sources
>  */
> 
> But, I think we can just "/* ULLI: ID found in rtw8822bu sources */" 
> if we really want to keep this comment.

I'll drop this comment.

> > +
> > +#ifndef __RTW_8723DU_H_
> > +#define __RTW_8723DU_H_
> > +
> > +/* USB Vendor/Product IDs */
> > +#define RTW_USB_VENDOR_ID_REALTEK		0x0BDA
> 
> rtw8821cu.h and rtw8822bu.h define this too.
> Can we move it to usb.h?

Yes.

Sascha
Icenowy Zheng May 30, 2022, 6:34 a.m. UTC | #4
在 2022-05-18星期三的 10:23 +0200,Sascha Hauer写道:
> Add support for the rtw8723du chipset based on
> https://github.com/ulli-kroll/rtw88-usb.git
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Reported-by: kernel test robot <lkp@intel.com>
> ---
>  drivers/net/wireless/realtek/rtw88/Kconfig    | 11 +++++
>  drivers/net/wireless/realtek/rtw88/Makefile   |  3 ++
>  drivers/net/wireless/realtek/rtw88/rtw8723d.c | 19 +++++++++
>  drivers/net/wireless/realtek/rtw88/rtw8723d.h |  1 +
>  .../net/wireless/realtek/rtw88/rtw8723du.c    | 40
> +++++++++++++++++++
>  .../net/wireless/realtek/rtw88/rtw8723du.h    | 13 ++++++
>  6 files changed, 87 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.c
>  create mode 100644 drivers/net/wireless/realtek/rtw88/rtw8723du.h
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig
> b/drivers/net/wireless/realtek/rtw88/Kconfig
> index 1624c5db69bac..ad1ac453015a9 100644
> --- a/drivers/net/wireless/realtek/rtw88/Kconfig
> +++ b/drivers/net/wireless/realtek/rtw88/Kconfig
> @@ -64,6 +64,17 @@ config RTW88_8723DE
>  
>           802.11n PCIe wireless network adapter
>  
> +config RTW88_8723DU
> +       tristate "Realtek 8723DU USB wireless network adapter"
> +       depends on USB
> +       select RTW88_CORE
> +       select RTW88_USB
> +       select RTW88_8723D
> +       help
> +         Select this option will enable support for 8723DU chipset
> +
> +         802.11n USB wireless network adapter
> +
>  config RTW88_8821CE
>         tristate "Realtek 8821CE PCI wireless network adapter"
>         depends on PCI
> diff --git a/drivers/net/wireless/realtek/rtw88/Makefile
> b/drivers/net/wireless/realtek/rtw88/Makefile
> index 9e095f8181483..eb26c215fcde3 100644
> --- a/drivers/net/wireless/realtek/rtw88/Makefile
> +++ b/drivers/net/wireless/realtek/rtw88/Makefile
> @@ -38,6 +38,9 @@ rtw88_8723d-objs              := rtw8723d.o
> rtw8723d_table.o
>  obj-$(CONFIG_RTW88_8723DE)     += rtw88_8723de.o
>  rtw88_8723de-objs              := rtw8723de.o
>  
> +obj-$(CONFIG_RTW88_8723DU)     += rtw88_8723du.o
> +rtw88_8723du-objs              := rtw8723du.o
> +
>  obj-$(CONFIG_RTW88_8821C)      += rtw88_8821c.o
>  rtw88_8821c-objs               := rtw8821c.o rtw8821c_table.o
>  
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> index ad2b323a0423c..ccd23902756e1 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> @@ -210,6 +210,12 @@ static void rtw8723de_efuse_parsing(struct
> rtw_efuse *efuse,
>         ether_addr_copy(efuse->addr, map->e.mac_addr);
>  }
>  
> +static void rtw8723du_efuse_parsing(struct rtw_efuse *efuse,
> +                                   struct rtw8723d_efuse *map)
> +{
> +       ether_addr_copy(efuse->addr, map->u.mac_addr);
> +}
> +
>  static int rtw8723d_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
>  {
>         struct rtw_efuse *efuse = &rtwdev->efuse;
> @@ -239,6 +245,9 @@ static int rtw8723d_read_efuse(struct rtw_dev
> *rtwdev, u8 *log_map)
>         case RTW_HCI_TYPE_PCIE:
>                 rtw8723de_efuse_parsing(efuse, map);
>                 break;
> +       case RTW_HCI_TYPE_USB:
> +               rtw8723du_efuse_parsing(efuse, map);
> +               break;
>         default:
>                 /* unsupported now */
>                 return -ENOTSUPP;
> @@ -1945,6 +1954,15 @@ static void rtw8723d_pwr_track(struct rtw_dev
> *rtwdev)
>         dm_info->pwr_trk_triggered = false;
>  }
>  
> +static void rtw8723d_fill_txdesc_checksum(struct rtw_dev *rtwdev,
> +                                         struct rtw_tx_pkt_info
> *pkt_info,
> +                                         u8 *txdesc)
> +{
> +       size_t words = 32 / 2; /* calculate the first 32 bytes (16
> words) */
> +
> +       fill_txdesc_checksum_common(txdesc, words);
> +}
> +
>  static struct rtw_chip_ops rtw8723d_ops = {
>         .phy_set_param          = rtw8723d_phy_set_param,
>         .read_efuse             = rtw8723d_read_efuse,
> @@ -1965,6 +1983,7 @@ static struct rtw_chip_ops rtw8723d_ops = {
>         .config_bfee            = NULL,
>         .set_gid_table          = NULL,
>         .cfg_csi_rate           = NULL,
> +       .fill_txdesc_checksum   = rtw8723d_fill_txdesc_checksum,
>  
>         .coex_set_init          = rtw8723d_coex_cfg_init,
>         .coex_set_ant_switch    = NULL,
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
> b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
> index 41d35174a5425..8113bd97edf57 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
> @@ -70,6 +70,7 @@ struct rtw8723d_efuse {
>         u8 country_code[2];
>         u8 res[3];
>         struct rtw8723de_efuse e;
> +       struct rtw8723de_efuse u;

The code here looks ridiculously wrong.

Should there be a rtw8723du_efuse struct and an union here?

BTW I found that Ulli's rtw88-usb repo has the same error, but I doubt
whether 8723du support is tested there.

>  };
>  
>  /* phy status page0 */
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> new file mode 100644
> index 0000000000000..910f64c168131
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
> @@ -0,0 +1,40 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
> +/* Copyright(c) 2018-2019  Realtek Corporation
> + */
> +
> +#include <linux/module.h>
> +#include <linux/usb.h>
> +#include "main.h"
> +#include "rtw8723du.h"
> +#include "usb.h"
> +
> +static const struct usb_device_id rtw_8723du_id_table[] = {
> +       /*
> +        * ULLI :
> +        * ID found in rtw8822bu sources
> +        */
> +       { USB_DEVICE_AND_INTERFACE_INFO(RTW_USB_VENDOR_ID_REALTEK,
> +                                       0xD723,
> +                                       0xff, 0xff, 0xff),
> +         .driver_info = (kernel_ulong_t)&(rtw8723d_hw_spec) }, /*
> 8723DU 1*1 */
> +       { },
> +};
> +MODULE_DEVICE_TABLE(usb, rtw_8723du_id_table);
> +
> +static int rtw8723du_probe(struct usb_interface *intf,
> +                           const struct usb_device_id *id)
> +{
> +       return rtw_usb_probe(intf, id);
> +}
> +
> +static struct usb_driver rtw_8723du_driver = {
> +       .name = "rtw_8723du",
> +       .id_table = rtw_8723du_id_table,
> +       .probe = rtw8723du_probe,
> +       .disconnect = rtw_usb_disconnect,
> +};
> +module_usb_driver(rtw_8723du_driver);
> +
> +MODULE_AUTHOR("Hans Ulli Kroll <linux@ulli-kroll.de>");
> +MODULE_DESCRIPTION("Realtek 802.11n wireless 8723du driver");
> +MODULE_LICENSE("Dual BSD/GPL");
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> new file mode 100644
> index 0000000000000..2e069f65c0551
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
> +/* Copyright(c) 2018-2019  Realtek Corporation
> + */
> +
> +#ifndef __RTW_8723DU_H_
> +#define __RTW_8723DU_H_
> +
> +/* USB Vendor/Product IDs */
> +#define RTW_USB_VENDOR_ID_REALTEK              0x0BDA
> +
> +extern struct rtw_chip_info rtw8723d_hw_spec;
> +
> +#endif
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/Kconfig b/drivers/net/wireless/realtek/rtw88/Kconfig
index 1624c5db69bac..ad1ac453015a9 100644
--- a/drivers/net/wireless/realtek/rtw88/Kconfig
+++ b/drivers/net/wireless/realtek/rtw88/Kconfig
@@ -64,6 +64,17 @@  config RTW88_8723DE
 
 	  802.11n PCIe wireless network adapter
 
+config RTW88_8723DU
+	tristate "Realtek 8723DU USB wireless network adapter"
+	depends on USB
+	select RTW88_CORE
+	select RTW88_USB
+	select RTW88_8723D
+	help
+	  Select this option will enable support for 8723DU chipset
+
+	  802.11n USB wireless network adapter
+
 config RTW88_8821CE
 	tristate "Realtek 8821CE PCI wireless network adapter"
 	depends on PCI
diff --git a/drivers/net/wireless/realtek/rtw88/Makefile b/drivers/net/wireless/realtek/rtw88/Makefile
index 9e095f8181483..eb26c215fcde3 100644
--- a/drivers/net/wireless/realtek/rtw88/Makefile
+++ b/drivers/net/wireless/realtek/rtw88/Makefile
@@ -38,6 +38,9 @@  rtw88_8723d-objs		:= rtw8723d.o rtw8723d_table.o
 obj-$(CONFIG_RTW88_8723DE)	+= rtw88_8723de.o
 rtw88_8723de-objs		:= rtw8723de.o
 
+obj-$(CONFIG_RTW88_8723DU)	+= rtw88_8723du.o
+rtw88_8723du-objs		:= rtw8723du.o
+
 obj-$(CONFIG_RTW88_8821C)	+= rtw88_8821c.o
 rtw88_8821c-objs		:= rtw8821c.o rtw8821c_table.o
 
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
index ad2b323a0423c..ccd23902756e1 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
@@ -210,6 +210,12 @@  static void rtw8723de_efuse_parsing(struct rtw_efuse *efuse,
 	ether_addr_copy(efuse->addr, map->e.mac_addr);
 }
 
+static void rtw8723du_efuse_parsing(struct rtw_efuse *efuse,
+				    struct rtw8723d_efuse *map)
+{
+	ether_addr_copy(efuse->addr, map->u.mac_addr);
+}
+
 static int rtw8723d_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 {
 	struct rtw_efuse *efuse = &rtwdev->efuse;
@@ -239,6 +245,9 @@  static int rtw8723d_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 	case RTW_HCI_TYPE_PCIE:
 		rtw8723de_efuse_parsing(efuse, map);
 		break;
+	case RTW_HCI_TYPE_USB:
+		rtw8723du_efuse_parsing(efuse, map);
+		break;
 	default:
 		/* unsupported now */
 		return -ENOTSUPP;
@@ -1945,6 +1954,15 @@  static void rtw8723d_pwr_track(struct rtw_dev *rtwdev)
 	dm_info->pwr_trk_triggered = false;
 }
 
+static void rtw8723d_fill_txdesc_checksum(struct rtw_dev *rtwdev,
+					  struct rtw_tx_pkt_info *pkt_info,
+					  u8 *txdesc)
+{
+	size_t words = 32 / 2; /* calculate the first 32 bytes (16 words) */
+
+	fill_txdesc_checksum_common(txdesc, words);
+}
+
 static struct rtw_chip_ops rtw8723d_ops = {
 	.phy_set_param		= rtw8723d_phy_set_param,
 	.read_efuse		= rtw8723d_read_efuse,
@@ -1965,6 +1983,7 @@  static struct rtw_chip_ops rtw8723d_ops = {
 	.config_bfee		= NULL,
 	.set_gid_table		= NULL,
 	.cfg_csi_rate		= NULL,
+	.fill_txdesc_checksum	= rtw8723d_fill_txdesc_checksum,
 
 	.coex_set_init		= rtw8723d_coex_cfg_init,
 	.coex_set_ant_switch	= NULL,
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
index 41d35174a5425..8113bd97edf57 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
@@ -70,6 +70,7 @@  struct rtw8723d_efuse {
 	u8 country_code[2];
 	u8 res[3];
 	struct rtw8723de_efuse e;
+	struct rtw8723de_efuse u;
 };
 
 /* phy status page0 */
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.c b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
new file mode 100644
index 0000000000000..910f64c168131
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.c
@@ -0,0 +1,40 @@ 
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) 2018-2019  Realtek Corporation
+ */
+
+#include <linux/module.h>
+#include <linux/usb.h>
+#include "main.h"
+#include "rtw8723du.h"
+#include "usb.h"
+
+static const struct usb_device_id rtw_8723du_id_table[] = {
+	/*
+	 * ULLI :
+	 * ID found in rtw8822bu sources
+	 */
+	{ USB_DEVICE_AND_INTERFACE_INFO(RTW_USB_VENDOR_ID_REALTEK,
+					0xD723,
+					0xff, 0xff, 0xff),
+	  .driver_info = (kernel_ulong_t)&(rtw8723d_hw_spec) }, /* 8723DU 1*1 */
+	{ },
+};
+MODULE_DEVICE_TABLE(usb, rtw_8723du_id_table);
+
+static int rtw8723du_probe(struct usb_interface *intf,
+			    const struct usb_device_id *id)
+{
+	return rtw_usb_probe(intf, id);
+}
+
+static struct usb_driver rtw_8723du_driver = {
+	.name = "rtw_8723du",
+	.id_table = rtw_8723du_id_table,
+	.probe = rtw8723du_probe,
+	.disconnect = rtw_usb_disconnect,
+};
+module_usb_driver(rtw_8723du_driver);
+
+MODULE_AUTHOR("Hans Ulli Kroll <linux@ulli-kroll.de>");
+MODULE_DESCRIPTION("Realtek 802.11n wireless 8723du driver");
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723du.h b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
new file mode 100644
index 0000000000000..2e069f65c0551
--- /dev/null
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723du.h
@@ -0,0 +1,13 @@ 
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
+/* Copyright(c) 2018-2019  Realtek Corporation
+ */
+
+#ifndef __RTW_8723DU_H_
+#define __RTW_8723DU_H_
+
+/* USB Vendor/Product IDs */
+#define RTW_USB_VENDOR_ID_REALTEK		0x0BDA
+
+extern struct rtw_chip_info rtw8723d_hw_spec;
+
+#endif