mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: "Sanjuán García, Jorge" <Jorge.SanjuanGarcia@duagon.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	<s-vadapalli@ti.com>
Subject: Re: [PATCH 2/3] net: ethernet: ti: am65-cpsw: Introduce rx_packet_max member
Date: Tue, 2 Jan 2024 15:40:55 +0530	[thread overview]
Message-ID: <e0337cfa-9744-7451-1fef-7f43f3b6cbe0@ti.com> (raw)
In-Reply-To: <20240102081825.14635-3-jorge.sanjuangarcia@duagon.com>

Hello,

On 02-01-2024 13:49, Sanjuán García, Jorge wrote:
> The value written to the register AM65_CPSW_PORT_REG_RX_MAXLEN
> is currently fixed to what AM65_CPSW_MAX_PACKET_SIZE defines. This
> patch prepares the driver so that the maximum received frame length
> can be configured in future updates.
> 
> Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
> ---

For patches which add new features, please use the subject prefix
[PATCH net-next].

>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 ++++++++-----
>   drivers/net/ethernet/ti/am65-cpsw-nuss.h |  2 ++
>   2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c 
> b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 378d69b8cb14..a920146d7a60 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -151,9 +151,11 @@ static void am65_cpsw_port_set_sl_mac(struct am65_cpsw_port 
> *slave,
> 
>   static void am65_cpsw_sl_ctl_reset(struct am65_cpsw_port *port)
>   {
> +       struct am65_cpsw_common *common = port->common;
> +
>           cpsw_sl_reset(port->slave.mac_sl, 100);
>           /* Max length register has to be restored after MAC SL reset */
> -       writel(AM65_CPSW_MAX_PACKET_SIZE,
> +       writel(common->rx_packet_max,
>                  port->port_base + AM65_CPSW_PORT_REG_RX_MAXLEN);

Prior to this patch, since the RX Packet size was hard-coded, it was
being set to the same value across all ports. However, please note that
there are per-port registers:
port->port_base + AM65_CPSW_PORT_REG_RX_MAXLEN
So, wouldn't it be better to define the "rx_packet_max" member within
"struct am65_cpsw_port", rather than "struct am65_cpsw_common"?
The same question applies to the following sections as well.

I went through patch 3/3 of this series and the device-tree property:
max-frame-size
is being used to fetch the value for "rx_packet_max". But, isn't
max-frame-size a port specific parameter? Shouldn't it then be stored as
a member of "struct am65_cpsw_port".

>   }
> 
> @@ -455,7 +457,7 @@ static int am65_cpsw_nuss_common_open(struct 
> am65_cpsw_common *common)
>                  AM65_CPSW_CTL_VLAN_AWARE | AM65_CPSW_CTL_P0_RX_PAD,
>                  common->cpsw_base + AM65_CPSW_REG_CTL);
>           /* Max length register */
> -       writel(AM65_CPSW_MAX_PACKET_SIZE,
> +       writel(common->rx_packet_max,
>                  host_p->port_base + AM65_CPSW_PORT_REG_RX_MAXLEN);
>           /* set base flow_id */
>           writel(common->rx_flow_id_base,
> @@ -507,7 +509,7 @@ static int am65_cpsw_nuss_common_open(struct 
> am65_cpsw_common *common)
> 
>           for (i = 0; i < common->rx_chns.descs_num; i++) {
>                   skb = __netdev_alloc_skb_ip_align(NULL,
> -                                                 AM65_CPSW_MAX_PACKET_SIZE,
> +                                                 common->rx_packet_max,
>                                                     GFP_KERNEL);
>                   if (!skb) {
>                           ret = -ENOMEM;
> @@ -848,7 +850,7 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_common 
> *common,
> 
>           k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);
> 
> -       new_skb = netdev_alloc_skb_ip_align(ndev, AM65_CPSW_MAX_PACKET_SIZE);
> +       new_skb = netdev_alloc_skb_ip_align(ndev, common->rx_packet_max);
>           if (new_skb) {
>                   ndev_priv = netdev_priv(ndev);
>                   am65_cpsw_nuss_set_offload_fwd_mark(skb, 
> ndev_priv->offload_fwd_mark);
> @@ -2196,7 +2198,7 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common 
> *common, u32 port_idx)
>           eth_hw_addr_set(port->ndev, port->slave.mac_addr);
> 
>           port->ndev->min_mtu = AM65_CPSW_MIN_PACKET_SIZE;
> -       port->ndev->max_mtu = AM65_CPSW_MAX_PACKET_SIZE -
> +       port->ndev->max_mtu = common->rx_packet_max -
>                                 (VLAN_ETH_HLEN + ETH_FCS_LEN);
>           port->ndev->hw_features = NETIF_F_SG |
>                                     NETIF_F_RXCSUM |
> @@ -2926,6 +2928,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
>                   return -ENOENT;
> 
>           common->rx_flow_id_base = -1;
> +       common->rx_packet_max = AM65_CPSW_MAX_PACKET_SIZE;
>           init_completion(&common->tdown_complete);
>           common->tx_ch_num = AM65_CPSW_DEFAULT_TX_CHNS;
>           common->pf_p0_rx_ptype_rrobin = false;
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h 
> b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> index f3dad2ab9828..141160223d73 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h
> @@ -130,6 +130,8 @@ struct am65_cpsw_common {
>           u32                     tx_ch_rate_msk;
>           u32                     rx_flow_id_base;
> 
> +       int                     rx_packet_max;
> +
>           struct am65_cpsw_tx_chn tx_chns[AM65_CPSW_MAX_TX_QUEUES];
>           struct completion       tdown_complete;
>           atomic_t                tdown_cnt;

...

-- 
Regards,
Siddharth.

  reply	other threads:[~2024-01-02 10:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02  8:19 [PATCH 0/3] net: ethernet: ti: am65-cpsw: Allow for MTU values Sanjuán García, Jorge
2024-01-02  8:19 ` [PATCH 1/3] net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames Sanjuán García, Jorge
2024-01-02  9:53   ` Siddharth Vadapalli
2024-01-02  8:19 ` [PATCH 2/3] net: ethernet: ti: am65-cpsw: Introduce rx_packet_max member Sanjuán García, Jorge
2024-01-02 10:10   ` Siddharth Vadapalli [this message]
2024-01-02  8:19 ` [PATCH 3/3] net: ethernet: ti: am65-cpsw: Add device tree property to set max MTU Sanjuán García, Jorge
2024-01-02 10:33   ` Siddharth Vadapalli
2024-01-02 15:27     ` Sanjuán García, Jorge
2024-01-03  1:42   ` Andrew Lunn
2024-01-03 10:11     ` Sanjuán García, Jorge
2024-01-03 13:39       ` Andrew Lunn

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=e0337cfa-9744-7451-1fef-7f43f3b6cbe0@ti.com \
    --to=s-vadapalli@ti.com \
    --cc=Jorge.SanjuanGarcia@duagon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®