linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
@ 2025-05-14 10:47 Jinjian Song
  2025-05-16  1:08 ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Jinjian Song @ 2025-05-14 10:47 UTC (permalink / raw)
  To: chandrashekar.devegowda, chiranjeevi.rapolu, haijun.liu,
	m.chetan.kumar, ricardo.martinez, loic.poulain, ryazanov.s.a,
	johannes, davem, edumazet, kuba, pabeni
  Cc: linux-kernel, netdev, linux-doc, angelogioacchino.delregno,
	linux-arm-kernel, matthias.bgg, corbet, linux-mediatek, helgaas,
	danielwinkler, korneld, andrew+netdev, horms, rafael.wang,
	Jinjian Song

The DMA buffer for data plane RX is currently fixed, being parameterized
to allow configuration.

Signed-off-by: Jinjian Song <jinjian.song@fibocom.com>
---
 drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 12 +++++-------
 drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.h |  3 +++
 drivers/net/wwan/t7xx/t7xx_pci.c           | 10 ++++++++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
index 6a7a26085fc7..7848e470432c 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
@@ -49,9 +49,7 @@
 #include "t7xx_netdev.h"
 #include "t7xx_pci.h"
 
-#define DPMAIF_BAT_COUNT		8192
-#define DPMAIF_FRG_COUNT		4814
-#define DPMAIF_PIT_COUNT		(DPMAIF_BAT_COUNT * 2)
+#define DPMAIF_PIT_COUNT		(dpmaif_bat_count * 2)
 
 #define DPMAIF_BAT_CNT_THRESHOLD	30
 #define DPMAIF_PIT_CNT_THRESHOLD	60
@@ -279,7 +277,7 @@ static int t7xx_frag_bat_cur_bid_check(struct dpmaif_rx_queue *rxq,
 	struct dpmaif_bat_request *bat_frag = rxq->bat_frag;
 	struct dpmaif_bat_page *bat_page;
 
-	if (cur_bid >= DPMAIF_FRG_COUNT)
+	if (cur_bid >= dpmaif_frg_count)
 		return -EINVAL;
 
 	bat_page = bat_frag->bat_skb + cur_bid;
@@ -448,7 +446,7 @@ static int t7xx_bat_cur_bid_check(struct dpmaif_rx_queue *rxq, const unsigned in
 	struct dpmaif_bat_skb *bat_skb = rxq->bat_req->bat_skb;
 
 	bat_skb += cur_bid;
-	if (cur_bid >= DPMAIF_BAT_COUNT || !bat_skb->skb)
+	if (cur_bid >= dpmaif_bat_count || !bat_skb->skb)
 		return -EINVAL;
 
 	return 0;
@@ -944,11 +942,11 @@ int t7xx_dpmaif_bat_alloc(const struct dpmaif_ctrl *dpmaif_ctrl, struct dpmaif_b
 
 	if (buf_type == BAT_TYPE_FRAG) {
 		sw_buf_size = sizeof(struct dpmaif_bat_page);
-		bat_req->bat_size_cnt = DPMAIF_FRG_COUNT;
+		bat_req->bat_size_cnt = dpmaif_frg_count;
 		bat_req->pkt_buf_sz = DPMAIF_HW_FRG_PKTBUF;
 	} else {
 		sw_buf_size = sizeof(struct dpmaif_bat_skb);
-		bat_req->bat_size_cnt = DPMAIF_BAT_COUNT;
+		bat_req->bat_size_cnt = dpmaif_bat_count;
 		bat_req->pkt_buf_sz = DPMAIF_HW_BAT_PKTBUF;
 	}
 
diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.h b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.h
index f4e1b69ad426..4709770fc489 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.h
+++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.h
@@ -22,6 +22,9 @@
 
 #include "t7xx_hif_dpmaif.h"
 
+extern uint dpmaif_bat_count;
+extern uint dpmaif_frg_count;
+
 #define NETIF_MASK		GENMASK(4, 0)
 
 #define PKT_TYPE_IP4		0
diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_pci.c
index 8bf63f2dcbbf..021a05b49225 100644
--- a/drivers/net/wwan/t7xx/t7xx_pci.c
+++ b/drivers/net/wwan/t7xx/t7xx_pci.c
@@ -28,6 +28,7 @@
 #include <linux/jiffies.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/pm.h>
@@ -54,6 +55,15 @@
 #define PM_RESOURCE_POLL_TIMEOUT_US	10000
 #define PM_RESOURCE_POLL_STEP_US	100
 
+uint dpmaif_bat_count = 8192;
+uint dpmaif_frg_count = 4814;
+
+module_param(dpmaif_bat_count, uint, 0644);
+MODULE_PARM_DESC(dpmaif_bat_count, "BAT entry count");
+
+module_param(dpmaif_frg_count, uint, 0644);
+MODULE_PARM_DESC(dpmaif_frg_count, "FRG entry count");
+
 static const char * const t7xx_mode_names[] = {
 	[T7XX_UNKNOWN] = "unknown",
 	[T7XX_READY] = "ready",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-14 10:47 [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count Jinjian Song
@ 2025-05-16  1:08 ` Jakub Kicinski
  2025-05-16  3:46   ` Jinjian Song
  2025-05-16 15:43   ` Jakub Kicinski
  0 siblings, 2 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-16  1:08 UTC (permalink / raw)
  To: Jinjian Song
  Cc: chandrashekar.devegowda, chiranjeevi.rapolu, haijun.liu,
	m.chetan.kumar, ricardo.martinez, loic.poulain, ryazanov.s.a,
	johannes, davem, edumazet, pabeni, linux-kernel, netdev,
	linux-doc, angelogioacchino.delregno, linux-arm-kernel,
	matthias.bgg, corbet, linux-mediatek, helgaas, danielwinkler,
	korneld, andrew+netdev, horms, rafael.wang

On Wed, 14 May 2025 18:47:28 +0800 Jinjian Song wrote:
> The DMA buffer for data plane RX is currently fixed, being parameterized
> to allow configuration.

Module parameters are discouraged, they are pretty poor as an API since
they apply to all devices in the system. Can you describe what "frg"
and "bat" are ? One of the existing APIs likely covers them.
Please also describe the scope (are they per netdev or some sort of
device level params)?
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-16  1:08 ` Jakub Kicinski
@ 2025-05-16  3:46   ` Jinjian Song
  2025-05-16 15:43   ` Jakub Kicinski
  1 sibling, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2025-05-16  3:46 UTC (permalink / raw)
  To: kuba
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, jinjian.song, johannes, korneld,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mediatek,
	loic.poulain, m.chetan.kumar, matthias.bgg, netdev, pabeni,
	rafael.wang, ricardo.martinez, ryazanov.s.a

>On Wed, 14 May 2025 18:47:28 +0800 Jinjian Song wrote:
>> The DMA buffer for data plane RX is currently fixed, being parameterized
>> to allow configuration.
>
>Module parameters are discouraged, they are pretty poor as an API since
>they apply to all devices in the system. Can you describe what "frg"
>and "bat" are ? One of the existing APIs likely covers them.
>Please also describe the scope (are they per netdev or some sort of
>device level params)?

MTK t7xx data plane hardware use BAT (Buffer Address Table) and FRG (Fragment) BAT
to describle and manager RX buffer, these buffers will apply for a fixed size after
the driver probe, and accompany the life cycle of the driver.

On some platforms, especially those that use swiotlb to manager buffers, without
changing the buffer pool provided by swiotlb, it's needed to adjust the buffers
used by the driver to meet the requirements.
So parameterize these buffers applicable to the MTK t7xx driver to facilitate
different platforms to work with different configurations. 

These prameters are only used for MTK t7xx driver.

Jinjian,
Best Regards.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-16  1:08 ` Jakub Kicinski
  2025-05-16  3:46   ` Jinjian Song
@ 2025-05-16 15:43   ` Jakub Kicinski
  2025-05-20  2:59     ` Jinjian Song
  2025-05-20 19:21     ` Jakub Kicinski
  1 sibling, 2 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-16 15:43 UTC (permalink / raw)
  To: Jinjian Song
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, johannes, korneld, linux-arm-kernel,
	linux-doc, linux-kernel, linux-mediatek, loic.poulain,
	m.chetan.kumar, matthias.bgg, netdev, pabeni, rafael.wang,
	ricardo.martinez, ryazanov.s.a

On Fri, 16 May 2025 11:46:57 +0800 Jinjian Song wrote:
> >Module parameters are discouraged, they are pretty poor as an API since
> >they apply to all devices in the system. Can you describe what "frg"
> >and "bat" are ? One of the existing APIs likely covers them.
> >Please also describe the scope (are they per netdev or some sort of
> >device level params)?  
> 
> MTK t7xx data plane hardware use BAT (Buffer Address Table) and FRG (Fragment) BAT
> to describle and manager RX buffer, these buffers will apply for a fixed size after
> the driver probe, and accompany the life cycle of the driver.
> 
> On some platforms, especially those that use swiotlb to manager buffers, without
> changing the buffer pool provided by swiotlb, it's needed to adjust the buffers
> used by the driver to meet the requirements.
> So parameterize these buffers applicable to the MTK t7xx driver to facilitate
> different platforms to work with different configurations. 

Have you looked at
https://docs.kernel.org/networking/ethtool-netlink.html#rings-set 
?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-16 15:43   ` Jakub Kicinski
@ 2025-05-20  2:59     ` Jinjian Song
  2025-05-20 19:21     ` Jakub Kicinski
  1 sibling, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2025-05-20  2:59 UTC (permalink / raw)
  To: kuba
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, jinjian.song, johannes, korneld,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mediatek,
	loic.poulain, m.chetan.kumar, matthias.bgg, netdev, pabeni,
	rafael.wang, ricardo.martinez, ryazanov.s.a

>On Fri, 16 May 2025 11:46:57 +0800 Jinjian Song wrote:
>> >Module parameters are discouraged, they are pretty poor as an API since
>> >they apply to all devices in the system. Can you describe what "frg"
>> >and "bat" are ? One of the existing APIs likely covers them.
>> >Please also describe the scope (are they per netdev or some sort of
>> >device level params)?  
>> 
>> MTK t7xx data plane hardware use BAT (Buffer Address Table) and FRG (Fragment) BAT
>> to describle and manager RX buffer, these buffers will apply for a fixed size after
>> the driver probe, and accompany the life cycle of the driver.
>> 
>> On some platforms, especially those that use swiotlb to manager buffers, without
>> changing the buffer pool provided by swiotlb, it's needed to adjust the buffers
>> used by the driver to meet the requirements.
>> So parameterize these buffers applicable to the MTK t7xx driver to facilitate
>> different platforms to work with different configurations. 
>
>Have you looked at
>https://docs.kernel.org/networking/ethtool-netlink.html#rings-set 
>?
>

Hi Jakub,
  Thanks, I've just learned this content.
  I think ETHTOOL_STRINGPARAM is a good summary of the ring parameters and can
be referred to and applied to WWAN. However, it seemes that this can't be configured
when the driver is loaded and requires an application through ioctrl. In addition,
directly using this parameter can't well correspond to the multiple buffer representing
BAT in the t7xx driver.

  If it's not feasible to directly add parameters for configuring this RX buffer(BAT/FAG) to 
the mtk_t7xx driver, would it be allowed to add aparameter for a default configuration 
ratio (1/2, 1/4)? Or is it not recommended to use driver parameters for mtk_t7xx driver.

Thanks,
Best Regards. 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-16 15:43   ` Jakub Kicinski
  2025-05-20  2:59     ` Jinjian Song
@ 2025-05-20 19:21     ` Jakub Kicinski
  2025-06-04  9:17       ` Jinjian Song
  2025-06-05 14:12       ` Jakub Kicinski
  1 sibling, 2 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-05-20 19:21 UTC (permalink / raw)
  To: Jinjian Song
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, johannes, korneld, linux-arm-kernel,
	linux-doc, linux-kernel, linux-mediatek, loic.poulain,
	m.chetan.kumar, matthias.bgg, netdev, pabeni, rafael.wang,
	ricardo.martinez, ryazanov.s.a

On Tue, 20 May 2025 10:59:34 +0800 Jinjian Song wrote:
>   If it's not feasible to directly add parameters for configuring this RX buffer(BAT/FAG) to 
> the mtk_t7xx driver, would it be allowed to add aparameter for a default configuration 
> ratio (1/2, 1/4)? Or is it not recommended to use driver parameters for mtk_t7xx driver.

Looks into devlink params then

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-20 19:21     ` Jakub Kicinski
@ 2025-06-04  9:17       ` Jinjian Song
  2025-06-05 14:12       ` Jakub Kicinski
  1 sibling, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2025-06-04  9:17 UTC (permalink / raw)
  To: kuba
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, jinjian.song, johannes, korneld,
	linux-arm-kernel, linux-doc, linux-kernel, linux-mediatek,
	loic.poulain, m.chetan.kumar, matthias.bgg, netdev, pabeni,
	rafael.wang, ricardo.martinez, ryazanov.s.a

>On Tue, 20 May 2025 10:59:34 +0800 Jinjian Song wrote:
>>   If it's not feasible to directly add parameters for configuring this RX buffer(BAT/FAG) to 
>> the mtk_t7xx driver, would it be allowed to add aparameter for a default configuration 
>> ratio (1/2, 1/4)? Or is it not recommended to use driver parameters for mtk_t7xx driver.
>
>Looks into devlink params then
>

Hi Jakub,

The parameters are used by data plane to request RX DMA buffers for the entrire lifetime of
the driver, so it's best to determine them at the driver load time. Adjusting them after the
driver has been probed could introduce complex issues (e.g., the DMA buffers may already be
in use for communication when the parameters are changed. While devlink appears to support
parameter configuration via driver reload and runtime adjustment, both of these occur after
the driver has been probed, which doesn't seem very friendly to the overall logic.

Thanks.

Jinjian,
Best Regards.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-05-20 19:21     ` Jakub Kicinski
  2025-06-04  9:17       ` Jinjian Song
@ 2025-06-05 14:12       ` Jakub Kicinski
  2025-06-06 10:00         ` Jinjian Song
  1 sibling, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2025-06-05 14:12 UTC (permalink / raw)
  To: Jinjian Song
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, johannes, korneld, linux-arm-kernel,
	linux-doc, linux-kernel, linux-mediatek, loic.poulain,
	m.chetan.kumar, matthias.bgg, netdev, pabeni, rafael.wang,
	ricardo.martinez, ryazanov.s.a

On Wed,  4 Jun 2025 17:17:22 +0800 Jinjian Song wrote:
> The parameters are used by data plane to request RX DMA buffers for the entrire lifetime of
> the driver, so it's best to determine them at the driver load time. Adjusting them after the
> driver has been probed could introduce complex issues (e.g., the DMA buffers may already be
> in use for communication when the parameters are changed. While devlink appears to support
> parameter configuration via driver reload and runtime adjustment, both of these occur after
> the driver has been probed, which doesn't seem very friendly to the overall logic.

no.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count
  2025-06-05 14:12       ` Jakub Kicinski
@ 2025-06-06 10:00         ` Jinjian Song
  0 siblings, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2025-06-06 10:00 UTC (permalink / raw)
  To: kuba, Jinjian Song
  Cc: andrew+netdev, angelogioacchino.delregno, chandrashekar.devegowda,
	chiranjeevi.rapolu, corbet, danielwinkler, davem, edumazet,
	haijun.liu, helgaas, horms, johannes, korneld, linux-arm-kernel,
	linux-doc, linux-kernel, linux-mediatek, loic.poulain,
	m.chetan.kumar, matthias.bgg, netdev, pabeni, rafael.wang,
	ricardo.martinez, ryazanov.s.a

From: Jakub Kicinski <kuba@kernel.org>

>On Wed,  4 Jun 2025 17:17:22 +0800 Jinjian Song wrote:
>> The parameters are used by data plane to request RX DMA buffers for the entrire lifetime of
>> the driver, so it's best to determine them at the driver load time. Adjusting them after the
>> driver has been probed could introduce complex issues (e.g., the DMA buffers may already be
>> in use for communication when the parameters are changed. While devlink appears to support
>> parameter configuration via driver reload and runtime adjustment, both of these occur after
>> the driver has been probed, which doesn't seem very friendly to the overall logic.
>
>no.
>

Hi Jakub,

Could we configue this parameter of mtk_t7xx through Kconfig?

Thanks.

Jinjian,
Best Regards.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-06-06 10:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-14 10:47 [net-next v1] net: wwan: t7xx: Parameterize data plane RX BAT and FAG count Jinjian Song
2025-05-16  1:08 ` Jakub Kicinski
2025-05-16  3:46   ` Jinjian Song
2025-05-16 15:43   ` Jakub Kicinski
2025-05-20  2:59     ` Jinjian Song
2025-05-20 19:21     ` Jakub Kicinski
2025-06-04  9:17       ` Jinjian Song
2025-06-05 14:12       ` Jakub Kicinski
2025-06-06 10:00         ` Jinjian Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).