All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v6 07/24] rtw89: add MAC files
Date: Fri, 01 Oct 2021 19:13:51 +0300	[thread overview]
Message-ID: <87fstkiuyo.fsf@codeaurora.org> (raw)
In-Reply-To: <20210820043538.12424-8-pkshih@realtek.com> (Ping-Ke Shih's message of "Fri, 20 Aug 2021 12:35:21 +0800")

Ping-Ke Shih <pkshih@realtek.com> writes:

> Provide interfaces to access MAC function blocks including power-on/off
> configuration.
>
> MAC initialization does power-on, and then enable HCI to download firmware.
> The BB, RF, DMAC and CMAC function blocks are enabled, and then configure
> TXRX settings that contains DMAC, CMAC, interrupt mask, and RPQ parameters.
> DMAC is short for data MAC, including data link engine (DLE), HCI function
> control (HFC), MPDU processor, security engine and so on. CMAC is short for
> control MAC, including scheduler, address CAM, RX filter, CCA control,
> TMAC, RMAC, protocol component and so on.
>
> The full MAC initialization is done for normal use case when user does
> network interface up. When device is probing, driver does partial
> initialization to do power-on and download firmware, because we need to
> read hardware capabilities from efuse and firmware.
>
> MAC supports five ports, so we can have five VIFs at most. To control MAC
> port, we control a set of registers, and the most important one among them
> is port_cfg register named R_AX_PORT_CFG_P0. We can turn on/off the port
> function and configure network type (STA or AP mode) by this register.
> The address and BSSID corresponding to this port are given by address
> and BSSID CAM that is set by firmware via H2C command.
>
> Since BT coexistence code needs to access coex registers, some help
> functions are provided to make WiFi-only case work.
>
> To access MAC registers, normally we use rtw89_writeXX/rtw89_readYY, but
> we use rtw89_mac_txpwr_write32_ZZ to access TX power register with proper
> address range checking.
>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

[...]

> +struct rtw89_hfc_prec_cfg rtw_hfc_preccfg_pcie = {
> +	2, 40, 0, 0, 1, 0, 0, 0
> +};

This should be const.

> +static int rtw89_mac_pwr_seq(struct rtw89_dev *rtwdev,
> +			     const struct rtw89_pwr_cfg * const *cfg_seq)
> +{
> +	u32 idx = 0;
> +	const struct rtw89_pwr_cfg *cfg;
> +	int ret;
> +
> +	do {
> +		cfg = cfg_seq[idx];
> +		if (!cfg)
> +			break;
> +
> +		ret = rtw89_mac_sub_pwr_seq(rtwdev, BIT(rtwdev->hal.cv),
> +					    PWR_INTF_MSK_PCIE, cfg);
> +		if (ret)
> +			return -EBUSY;
> +
> +		idx++;
> +	} while (1);

Never ending loop is a bad idea in kernel, please add either a loop
limit or a time limit.

> +static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
> +{
> +#define PWR_ACT 1
> +	const struct rtw89_chip_info *chip = rtwdev->chip;
> +	const struct rtw89_pwr_cfg * const *cfg_seq;
> +	struct rtw89_hal *hal = &rtwdev->hal;
> +	int ret;
> +	u8 val;
> +
> +	if (on)
> +		cfg_seq = chip->pwr_on_seq;
> +	else
> +		cfg_seq = chip->pwr_off_seq;
> +
> +	if (test_bit(RTW89_FLAG_FW_RDY, rtwdev->flags))
> +		__rtw89_leave_ps_mode(rtwdev);
> +
> +	val = rtw89_read8(rtwdev, 0x3F1) & 0x3;

Magic numbers.

> +/* PCIE 64 */
> +struct rtw89_dle_size wde_size0 = {
> +	RTW89_WDE_PG_64, 4095, 1,
> +};
> +
> +/* DLFW */
> +struct rtw89_dle_size wde_size4 = {
> +	RTW89_WDE_PG_64, 0, 4096,
> +};
> +
> +/* PCIE */
> +struct rtw89_dle_size ple_size0 = {
> +	RTW89_PLE_PG_128, 1520, 16,
> +};
> +
> +/* DLFW */
> +struct rtw89_dle_size ple_size4 = {
> +	RTW89_PLE_PG_128, 64, 1472,
> +};
> +
> +/* PCIE 64 */
> +struct rtw89_wde_quota wde_qt0 = {
> +	3792, 196, 0, 107,
> +};
> +
> +/* DLFW */
> +struct rtw89_wde_quota wde_qt4 = {
> +	0, 0, 0, 0,
> +};
> +
> +/* PCIE SCC */
> +struct rtw89_ple_quota ple_qt4 = {
> +	264, 0, 16, 20, 26, 13, 356, 0, 32, 40, 8,
> +};
> +
> +/* PCIE SCC */
> +struct rtw89_ple_quota ple_qt5 = {
> +	264, 0, 32, 20, 64, 13, 1101, 0, 64, 128, 120,
> +};
> +
> +/* DLFW */
> +struct rtw89_ple_quota ple_qt13 = {
> +	0, 0, 16, 48, 0, 0, 0, 0, 0, 0, 0
> +};

These all should be const.

> +static void (*rtw89_mac_c2h_ofld_handler[])(struct rtw89_dev *rtwdev,
> +					    struct sk_buff *c2h, u32 len) = {
> +	[RTW89_MAC_C2H_FUNC_EFUSE_DUMP] = NULL,
> +	[RTW89_MAC_C2H_FUNC_READ_RSP] = NULL,
> +	[RTW89_MAC_C2H_FUNC_PKT_OFLD_RSP] = NULL,
> +	[RTW89_MAC_C2H_FUNC_BCN_RESEND] = NULL,
> +	[RTW89_MAC_C2H_FUNC_MACID_PAUSE] = rtw89_mac_c2h_macid_pause,
> +};
> +
> +static void (*rtw89_mac_c2h_info_handler[])(struct rtw89_dev *rtwdev,
> +					    struct sk_buff *c2h, u32 len) = {
> +	[RTW89_MAC_C2H_FUNC_REC_ACK] = rtw89_mac_c2h_rec_ack,
> +	[RTW89_MAC_C2H_FUNC_DONE_ACK] = rtw89_mac_c2h_done_ack,
> +	[RTW89_MAC_C2H_FUNC_C2H_LOG] = rtw89_mac_c2h_log,
> +};

const?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  reply	other threads:[~2021-10-01 16:14 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20  4:35 [PATCH v6 00/24] rtw89: add Realtek 802.11ax driver Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 01/24] rtw89: add CAM files Ping-Ke Shih
2021-10-01 14:46   ` Kalle Valo
2021-08-20  4:35 ` [PATCH v6 02/24] rtw89: add BT coexistence files Ping-Ke Shih
2021-10-01 15:26   ` Kalle Valo
2021-10-01 17:40     ` Small driver submissions and long feedback cycles Brian Norris
2021-08-20  4:35 ` [PATCH v6 03/24] rtw89: add core and trx files Ping-Ke Shih
2021-10-01 16:26   ` Kalle Valo
2021-10-05  7:16     ` Pkshih
2021-10-05  7:46       ` Kalle Valo
2021-10-05  8:42         ` Arnd Bergmann
2021-10-05  9:32           ` Pkshih
2021-10-05  9:59             ` Arnd Bergmann
2021-10-06  1:35               ` Pkshih
2021-10-06  7:32                 ` Arnd Bergmann
2021-10-06  8:19                   ` Pkshih
2021-08-20  4:35 ` [PATCH v6 04/24] rtw89: add debug files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 05/24] rtw89: add efuse files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 06/24] rtw89: add files to download and communicate with firmware Ping-Ke Shih
2021-10-01 15:55   ` Kalle Valo
2021-08-20  4:35 ` [PATCH v6 07/24] rtw89: add MAC files Ping-Ke Shih
2021-10-01 16:13   ` Kalle Valo [this message]
2021-08-20  4:35 ` [PATCH v6 08/24] rtw89: implement mac80211 ops Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 09/24] rtw89: add pci files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 10/24] rtw89: add phy files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 11/24] rtw89: define register names Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 12/24] rtw89: add regulatory support Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 13/24] rtw89: 8852a: add 8852a specific files Ping-Ke Shih
2021-10-01 16:20   ` Kalle Valo
2021-08-20  4:35 ` [PATCH v6 14/24] rtw89: 8852a: add 8852a RFK files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 15/24] rtw89: 8852a: add 8852a RFK tables Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 16/24] rtw89: 8852a: add 8852a tables (1 of 5) Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 17/24] rtw89: 8852a: add 8852a tables (2 " Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 18/24] rtw89: 8852a: add 8852a tables (3 " Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 19/24] rtw89: 8852a: add 8852a tables (4 " Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 20/24] rtw89: 8852a: add 8852a tables (5 " Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 21/24] rtw89: add ser to recover error reported by firmware Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 22/24] rtw89: add PS files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 23/24] rtw89: add SAR files Ping-Ke Shih
2021-08-20  4:35 ` [PATCH v6 24/24] rtw89: add Kconfig and Makefile Ping-Ke Shih
2021-08-22  3:43   ` kernel test robot
2021-08-22  3:43     ` kernel test robot
2021-08-23  1:37     ` Pkshih
2021-08-23  1:37       ` Pkshih
2021-10-01 15:57   ` Kalle Valo
2021-10-01 16:34 ` [PATCH v6 00/24] rtw89: add Realtek 802.11ax driver Kalle Valo
2021-10-01 16:42   ` Larry Finger
2021-10-01 16:46     ` Kalle Valo
2021-10-01 17:18       ` Larry Finger
2021-10-05  5:46         ` Kalle Valo
2021-10-04  6:46   ` Pkshih
2021-10-05  5:52     ` Kalle Valo
2021-10-06  0:10       ` Brian Norris
2021-10-08  4:14         ` Pkshih
2021-10-08  4:11       ` Pkshih
2021-10-09  8:28         ` Kalle Valo
2021-10-12  1:53           ` Pkshih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fstkiuyo.fsf@codeaurora.org \
    --to=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.