From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: MD Danish Anwar <danishanwar@ti.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Dan Carpenter <dan.carpenter@linaro.org>,
Jan Kiszka <jan.kiszka@siemens.com>,
Javier Carrasco <javier.carrasco.cruz@gmail.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Diogo Ivo <diogo.ivo@siemens.com>,
Simon Horman <horms@kernel.org>,
"Richard Cochran" <richardcochran@gmail.com>,
Paolo Abeni <pabeni@redhat.com>,
"Jakub Kicinski" <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Roger Quadros <rogerq@kernel.org>
Subject: Re: [PATCH net-next v3 3/6] net: ti: icssg-prueth: Add support for HSR frame forward offload
Date: Fri, 30 Aug 2024 16:07:20 +0200 [thread overview]
Message-ID: <728d4ad3-bd32-4bbe-bbd1-cd2c62df1fad@intel.com> (raw)
In-Reply-To: <20240828091901.3120935-4-danishanwar@ti.com>
From: Md Danish Anwar <danishanwar@ti.com>
Date: Wed, 28 Aug 2024 14:48:58 +0530
> Add support for offloading HSR port-to-port frame forward to hardware.
> When the slave interfaces are added to the HSR interface, the PRU cores
> will be stopped and ICSSG HSR firmwares will be loaded to them.
>
> Similarly, when HSR interface is deleted, the PRU cores will be stopped
> and dual EMAC firmware will be loaded to them.
>
> This commit also renames some APIs that are common between switch and
> hsr mode with '_fw_offload' suffix.
[...]
> @@ -726,6 +744,19 @@ static void emac_ndo_set_rx_mode(struct net_device *ndev)
> queue_work(emac->cmd_wq, &emac->rx_mode_work);
> }
>
> +static int emac_ndo_set_features(struct net_device *ndev,
> + netdev_features_t features)
> +{
> + netdev_features_t hsr_feature_present = ndev->features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES;
Maybe you could give this definition and/or this variable shorter names,
so that you won't cross 80 cols?
> + netdev_features_t hsr_feature_wanted = features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES;
(same)
> + bool hsr_change_request = ((hsr_feature_wanted ^ hsr_feature_present) != 0);
You don't need to compare with zero. Just = a ^ b. Type `bool` takes
care of this.
> +
> + if (hsr_change_request)
> + ndev->features = features;
Does it mean you reject any feature change except HSR?
> +
> + return 0;
> +}
> +
> static const struct net_device_ops emac_netdev_ops = {
> .ndo_open = emac_ndo_open,
> .ndo_stop = emac_ndo_stop,
> @@ -737,6 +768,7 @@ static const struct net_device_ops emac_netdev_ops = {
> .ndo_eth_ioctl = icssg_ndo_ioctl,
> .ndo_get_stats64 = icssg_ndo_get_stats64,
> .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name,
> + .ndo_set_features = emac_ndo_set_features,
> };
>
> static int prueth_netdev_init(struct prueth *prueth,
> @@ -865,6 +897,7 @@ static int prueth_netdev_init(struct prueth *prueth,
> ndev->ethtool_ops = &icssg_ethtool_ops;
> ndev->hw_features = NETIF_F_SG;
> ndev->features = ndev->hw_features;
> + ndev->hw_features |= NETIF_F_HW_HSR_FWD;
Why not HSR_OFFLOAD right away, so that you wouldn't need to replace
this line with the mentioned def a commit later?
>
> netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll);
> hrtimer_init(&emac->rx_hrtimer, CLOCK_MONOTONIC,
[...]
> + prueth->hsr_members |= BIT(emac->port_id);
> + if (!prueth->is_switch_mode && !prueth->is_hsr_offload_mode) {
> + if (prueth->hsr_members & BIT(PRUETH_PORT_MII0) &&
> + prueth->hsr_members & BIT(PRUETH_PORT_MII1)) {
> + if (!(emac0->ndev->features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES) &&
> + !(emac1->ndev->features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES))
> + return -EOPNOTSUPP;
> + prueth->is_hsr_offload_mode = true;
> + prueth->default_vlan = 1;
> + emac0->port_vlan = prueth->default_vlan;
> + emac1->port_vlan = prueth->default_vlan;
> + icssg_change_mode(prueth);
> + dev_dbg(prueth->dev, "Enabling HSR offload mode\n");
netdev_dbg()?
> + }
> + }
> +
> + return 0;
> +}
> +
> +static void prueth_hsr_port_unlink(struct net_device *ndev)
> +{
> + struct prueth_emac *emac = netdev_priv(ndev);
> + struct prueth *prueth = emac->prueth;
> + struct prueth_emac *emac0;
> + struct prueth_emac *emac1;
> +
> + emac0 = prueth->emac[PRUETH_MAC0];
> + emac1 = prueth->emac[PRUETH_MAC1];
> +
> + prueth->hsr_members &= ~BIT(emac->port_id);
> + if (prueth->is_hsr_offload_mode) {
> + prueth->is_hsr_offload_mode = false;
> + emac0->port_vlan = 0;
> + emac1->port_vlan = 0;
> + prueth->hsr_dev = NULL;
> + prueth_emac_restart(prueth);
> + dev_dbg(prueth->dev, "Enabling Dual EMAC mode\n");
(same here and in all the places below)
> + }
> +}
Thanks,
Olek
next prev parent reply other threads:[~2024-08-30 14:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 9:18 [PATCH net-next v3 0/6] Introduce HSR offload support for ICSSG MD Danish Anwar
2024-08-28 9:18 ` [PATCH net-next v3 1/6] net: ti: icss-iep: Move icss_iep structure MD Danish Anwar
2024-08-28 9:18 ` [PATCH net-next v3 2/6] net: ti: icssg-prueth: Stop hardcoding def_inc MD Danish Anwar
2024-08-28 9:18 ` [PATCH net-next v3 3/6] net: ti: icssg-prueth: Add support for HSR frame forward offload MD Danish Anwar
2024-08-30 13:27 ` Roger Quadros
2024-08-30 14:00 ` Andrew Lunn
2024-09-02 5:51 ` Anwar, Md Danish
2024-09-02 13:02 ` Andrew Lunn
2024-09-03 9:34 ` MD Danish Anwar
2024-09-02 5:28 ` Anwar, Md Danish
2024-08-30 14:07 ` Alexander Lobakin [this message]
2024-09-04 9:54 ` MD Danish Anwar
2024-08-28 9:18 ` [PATCH net-next v3 4/6] net: ti: icssg-prueth: Enable HSR Tx Packet duplication offload MD Danish Anwar
2024-08-30 13:30 ` Roger Quadros
2024-09-02 5:35 ` Anwar, Md Danish
2024-08-28 9:19 ` [PATCH net-next v3 5/6] net: ti: icssg-prueth: Add multicast filtering support in HSR mode MD Danish Anwar
2024-08-30 13:30 ` Roger Quadros
2024-08-28 9:19 ` [PATCH net-next v3 6/6] net: ti: icssg-prueth: Enable HSR Tx Tag and Rx Tag offload MD Danish Anwar
2024-08-30 13:36 ` Roger Quadros
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=728d4ad3-bd32-4bbe-bbd1-cd2c62df1fad@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew@lunn.ch \
--cc=dan.carpenter@linaro.org \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=diogo.ivo@siemens.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jan.kiszka@siemens.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rogerq@kernel.org \
--cc=srk@ti.com \
--cc=vigneshr@ti.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