From owner-svn-src-head@freebsd.org Tue Jun 19 00:38:30 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53E8410097E1; Tue, 19 Jun 2018 00:38:30 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ED2B57C275; Tue, 19 Jun 2018 00:38:29 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFD573E99; Tue, 19 Jun 2018 00:38:29 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5J0cTwS088000; Tue, 19 Jun 2018 00:38:29 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5J0cSkZ087994; Tue, 19 Jun 2018 00:38:28 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201806190038.w5J0cSkZ087994@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Tue, 19 Jun 2018 00:38:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335351 - in head/sys/dev/rtwn: rtl8812a rtl8812a/usb rtl8821a/usb X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in head/sys/dev/rtwn: rtl8812a rtl8812a/usb rtl8821a/usb X-SVN-Commit-Revision: 335351 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2018 00:38:30 -0000 Author: avos Date: Tue Jun 19 00:38:28 2018 New Revision: 335351 URL: https://svnweb.freebsd.org/changeset/base/335351 Log: rtwn(4): decode some bit fields + merge duplicate code. Add macros for R12A_RXDMA_PRO register (descriptions were seen in the RTL8822B vendor driver) and merge 2 r21au_init_burstlen() copies. No functional change intended. Modified: head/sys/dev/rtwn/rtl8812a/r12a_reg.h head/sys/dev/rtwn/rtl8812a/usb/r12au.h head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c head/sys/dev/rtwn/rtl8821a/usb/r21au.h head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c Modified: head/sys/dev/rtwn/rtl8812a/r12a_reg.h ============================================================================== --- head/sys/dev/rtwn/rtl8812a/r12a_reg.h Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8812a/r12a_reg.h Tue Jun 19 00:38:28 2018 (r335351) @@ -58,6 +58,16 @@ /* Bits for R92C_LEDCFG2. */ #define R12A_LEDCFG2_ENA 0x20 +/* Bits for R12A_RXDMA_PRO. */ +#define R12A_DMA_MODE 0x02 +#define R12A_BURST_CNT_M 0x0c +#define R12A_BURST_CNT_S 2 +#define R12A_BURST_SZ_M 0x30 +#define R12A_BURST_SZ_S 4 +#define R12A_BURST_SZ_USB3 0 +#define R12A_BURST_SZ_USB2 1 +#define R12A_BURST_SZ_USB1 2 + /* Bits for R12A_CCK_CHECK. */ #define R12A_CCK_CHECK_BCN1 0x20 #define R12A_CCK_CHECK_5GHZ 0x80 Modified: head/sys/dev/rtwn/rtl8812a/usb/r12au.h ============================================================================== --- head/sys/dev/rtwn/rtl8812a/usb/r12au.h Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8812a/usb/r12au.h Tue Jun 19 00:38:28 2018 (r335351) @@ -37,6 +37,7 @@ */ /* r12au_init.c */ void r12au_init_rx_agg(struct rtwn_softc *); +void r12au_init_burstlen_usb2(struct rtwn_softc *); void r12au_init_burstlen(struct rtwn_softc *); void r12au_init_ampdu_fwhw(struct rtwn_softc *); void r12au_init_ampdu(struct rtwn_softc *); Modified: head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c ============================================================================== --- head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c Tue Jun 19 00:38:28 2018 (r335351) @@ -72,19 +72,32 @@ r12au_init_rx_agg(struct rtwn_softc *sc) } void +r12au_init_burstlen_usb2(struct rtwn_softc *sc) +{ + const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); + + if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { + /* Set burst packet length to 512 B. */ + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB2)); + } else { + /* Set burst packet length to 64 B. */ + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB1)); + } +} + +void r12au_init_burstlen(struct rtwn_softc *sc) { - if (rtwn_read_1(sc, R92C_TYPE_ID + 3) & 0x80) { - if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { - /* Set burst packet length to 512 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x20, 0x1e); - } else { - /* Set burst packet length to 64 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x10, 0x2e); - } - } else { /* USB 3.0 */ + const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); + + if (rtwn_read_1(sc, R92C_TYPE_ID + 3) & 0x80) + r12au_init_burstlen_usb2(sc); + else { /* USB 3.0 */ /* Set burst packet length to 1 KB. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x30, 0x0e); + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB3)); rtwn_setbits_1(sc, 0xf008, 0x18, 0); } Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au.h ============================================================================== --- head/sys/dev/rtwn/rtl8821a/usb/r21au.h Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8821a/usb/r21au.h Tue Jun 19 00:38:28 2018 (r335351) @@ -37,7 +37,6 @@ */ /* r21au_init.c */ void r21au_init_tx_agg(struct rtwn_softc *); -void r21au_init_burstlen(struct rtwn_softc *); /* r21au_dfs.c */ void r21au_chan_check(void *, int); Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c ============================================================================== --- head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c Tue Jun 19 00:38:28 2018 (r335351) @@ -135,7 +135,7 @@ r21a_attach_private(struct rtwn_softc *sc) rs->rs_fix_spur = rtwn_nop_softc_chan; rs->rs_set_band_2ghz = r21a_set_band_2ghz; rs->rs_set_band_5ghz = r21a_set_band_5ghz; - rs->rs_init_burstlen = r21au_init_burstlen; + rs->rs_init_burstlen = r12au_init_burstlen_usb2; rs->rs_init_ampdu_fwhw = r21a_init_ampdu_fwhw; rs->rs_crystalcap_write = r21a_crystalcap_write; #ifndef RTWN_WITHOUT_UCODE Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c ============================================================================== --- head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c Tue Jun 19 00:27:30 2018 (r335350) +++ head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c Tue Jun 19 00:38:28 2018 (r335351) @@ -70,14 +70,3 @@ r21au_init_tx_agg(struct rtwn_softc *sc) rtwn_write_1(sc, R21A_DWBCN1_CTRL, uc->tx_agg_desc_num << 1); } -void -r21au_init_burstlen(struct rtwn_softc *sc) -{ - if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { - /* Set burst packet length to 512 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x20, 0x1e); - } else { - /* Set burst packet length to 64 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x10, 0x2e); - } -}