Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Jie Luo <quic_luoj@quicinc.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Lei Wei <quic_leiwei@quicinc.com>,
	Suruchi Agarwal <quic_suruchia@quicinc.com>,
	Pavithra R <quic_pavir@quicinc.com>,
	"Simon Horman" <horms@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	<linux-arm-msm@vger.kernel.org>, <netdev@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-hardening@vger.kernel.org>,
	<quic_kkumarcs@quicinc.com>, <quic_linchen@quicinc.com>,
	<srinivas.kandagatla@linaro.org>,
	<bartosz.golaszewski@linaro.org>, <john@phrozen.org>
Subject: Re: [PATCH net-next v3 04/14] net: ethernet: qualcomm: Initialize PPE buffer management for IPQ9574
Date: Thu, 20 Feb 2025 22:38:03 +0800	[thread overview]
Message-ID: <c592c262-5928-476f-ac2a-615c44d67277@quicinc.com> (raw)
In-Reply-To: <a79027ed-012c-4771-982c-b80b55ab0c8a@lunn.ch>



On 2/11/2025 9:22 PM, Andrew Lunn wrote:
>> +	/* Configure BM flow control related threshold. */
>> +	PPE_BM_PORT_FC_SET_WEIGHT(bm_fc_val, port_cfg.weight);
>> +	PPE_BM_PORT_FC_SET_RESUME_OFFSET(bm_fc_val, port_cfg.resume_offset);
>> +	PPE_BM_PORT_FC_SET_RESUME_THRESHOLD(bm_fc_val, port_cfg.resume_ceil);
>> +	PPE_BM_PORT_FC_SET_DYNAMIC(bm_fc_val, port_cfg.dynamic);
>> +	PPE_BM_PORT_FC_SET_REACT_LIMIT(bm_fc_val, port_cfg.in_fly_buf);
>> +	PPE_BM_PORT_FC_SET_PRE_ALLOC(bm_fc_val, port_cfg.pre_alloc);
> 
> ...
> 
>> +#define PPE_BM_PORT_FC_CFG_TBL_ADDR		0x601000
>> +#define PPE_BM_PORT_FC_CFG_TBL_ENTRIES		15
>> +#define PPE_BM_PORT_FC_CFG_TBL_INC		0x10
>> +#define PPE_BM_PORT_FC_W0_REACT_LIMIT		GENMASK(8, 0)
>> +#define PPE_BM_PORT_FC_W0_RESUME_THRESHOLD	GENMASK(17, 9)
>> +#define PPE_BM_PORT_FC_W0_RESUME_OFFSET		GENMASK(28, 18)
>> +#define PPE_BM_PORT_FC_W0_CEILING_LOW		GENMASK(31, 29)
>> +#define PPE_BM_PORT_FC_W1_CEILING_HIGH		GENMASK(7, 0)
>> +#define PPE_BM_PORT_FC_W1_WEIGHT		GENMASK(10, 8)
>> +#define PPE_BM_PORT_FC_W1_DYNAMIC		BIT(11)
>> +#define PPE_BM_PORT_FC_W1_PRE_ALLOC		GENMASK(22, 12)
>> +
>> +#define PPE_BM_PORT_FC_SET_REACT_LIMIT(tbl_cfg, value)	\
>> +	u32p_replace_bits((u32 *)tbl_cfg, value, PPE_BM_PORT_FC_W0_REACT_LIMIT)
>> +#define PPE_BM_PORT_FC_SET_RESUME_THRESHOLD(tbl_cfg, value)	\
>> +	u32p_replace_bits((u32 *)tbl_cfg, value, PPE_BM_PORT_FC_W0_RESUME_THRESHOLD)
> 
> Where is u32p_replace_bits()?

u32p_replace_bits is defined by the macro __MAKE_OP(32) in the header
file "include/linux/bitfield.h".

> 
> This cast does not look good. 

Yes, we can remove the cast.

> And this does not look like anything any
> other driver does. I suspect you are not using FIELD_PREP() etc when
> you should.
> 
> https://elixir.bootlin.com/linux/v6.14-rc2/source/include/linux/bitfield.h
> 
> 	Andrew

The PPE_BM_XXX macros defined here write to either of two different
32bit words in the register table, and the actual word used (0 or 1)
is hidden within the macro. For example, the below macro.

#define PPE_BM_PORT_FC_SET_CEILING_HIGH(tbl_cfg, value)	\
	u32p_replace_bits((u32 *)(tbl_cfg) + 0x1, value,
	PPE_BM_PORT_FC_W1_CEILING_HIGH)

We could have used FIELD_PREP as well for this purpose. However using
u32p_replace_bits() seemed more convenient and cleaner in this case,
since with FIELD_PREP, we would have needed an assignment statement to
be defined in the macro implementation. We also noticed many other
drivers using u32_replace_bits(). Hope this is ok.



  reply	other threads:[~2025-02-20 14:38 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09 14:29 [PATCH net-next v3 00/14] Add PPE driver for Qualcomm IPQ9574 SoC Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 01/14] dt-bindings: net: Add PPE " Luo Jie
2025-02-10  2:47   ` Jie Gan
2025-02-11 14:02     ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 02/14] docs: networking: Add PPE driver documentation " Luo Jie
2025-02-10  2:15   ` Bagas Sanjaya
2025-02-11 12:36     ` Lei Wei
2025-02-09 14:29 ` [PATCH net-next v3 03/14] net: ethernet: qualcomm: Add PPE driver for " Luo Jie
2025-02-10  2:12   ` Jie Gan
2025-02-11 13:04     ` Andrew Lunn
2025-02-12  1:49       ` Jie Gan
2025-02-11 13:58     ` Jie Luo
2025-02-12  1:58       ` Jie Gan
2025-02-14  6:09         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 04/14] net: ethernet: qualcomm: Initialize PPE buffer management for IPQ9574 Luo Jie
2025-02-11 13:14   ` Andrew Lunn
2025-02-19 13:00     ` Jie Luo
2025-02-11 13:22   ` Andrew Lunn
2025-02-20 14:38     ` Jie Luo [this message]
2025-02-20 15:09       ` Andrew Lunn
2025-03-06 10:01         ` Jie Luo
2025-03-06 15:29           ` Andrew Lunn
2025-03-11 10:44             ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 05/14] net: ethernet: qualcomm: Initialize PPE queue " Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 06/14] net: ethernet: qualcomm: Initialize the PPE scheduler settings Luo Jie
2025-02-11 13:32   ` Andrew Lunn
2025-02-20 14:50     ` Jie Luo
2025-02-20 15:12       ` Andrew Lunn
2025-02-28 15:24         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 07/14] net: ethernet: qualcomm: Initialize PPE queue settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 08/14] net: ethernet: qualcomm: Initialize PPE service code settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 09/14] net: ethernet: qualcomm: Initialize PPE port control settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 10/14] net: ethernet: qualcomm: Initialize PPE RSS hash settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 11/14] net: ethernet: qualcomm: Initialize PPE queue to Ethernet DMA ring mapping Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 12/14] net: ethernet: qualcomm: Initialize PPE L2 bridge settings Luo Jie
2025-02-09 14:29 ` [PATCH net-next v3 13/14] net: ethernet: qualcomm: Add PPE debugfs support for PPE counters Luo Jie
2025-02-11 13:55   ` Andrew Lunn
2025-02-14  7:53     ` Jie Luo
2025-02-14 14:02       ` Andrew Lunn
2025-02-18 11:16         ` Jie Luo
2025-02-09 14:29 ` [PATCH net-next v3 14/14] MAINTAINERS: Add maintainer for Qualcomm PPE driver Luo Jie

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=c592c262-5928-476f-ac2a-615c44d67277@quicinc.com \
    --to=quic_luoj@quicinc.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=john@phrozen.org \
    --cc=kees@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=quic_kkumarcs@quicinc.com \
    --cc=quic_leiwei@quicinc.com \
    --cc=quic_linchen@quicinc.com \
    --cc=quic_pavir@quicinc.com \
    --cc=quic_suruchia@quicinc.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox