From: Govindarajulu Varadarajan <_govind-KK0ffGbhmjU@public.gmane.org>
To: Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [net-next PATCH v2 3/3] drivers: net: cpsw: Add support for multicast/broadcast rate limit
Date: Wed, 9 Jul 2014 19:09:58 +0530 (IST) [thread overview]
Message-ID: <alpine.LNX.2.03.1407091904170.16937@ws.cisco> (raw)
In-Reply-To: <1404890050-4020-4-git-send-email-mugunthanvnm-l0cyMroinI0@public.gmane.org>
On Wed, 9 Jul 2014, Mugunthan V N wrote:
> Add support for multicast/broadcast rate limit feature via ethtool coalesce.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>
> ---
> drivers/net/ethernet/ti/cpsw.c | 80 ++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 78 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index a6117e6..2a984e6 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -403,6 +403,8 @@ struct cpsw_priv {
> bool irq_enabled;
> struct cpts *cpts;
> u32 emac_port;
> + u32 rx_max_mcast;
> + u32 rx_max_bcast;
> };
>
> struct cpsw_stats {
> @@ -871,11 +873,13 @@ static int cpsw_get_coalesce(struct net_device *ndev,
> struct cpsw_priv *priv = netdev_priv(ndev);
>
> coal->rx_coalesce_usecs = priv->coal_intvl;
> + coal->rx_max_mcast = priv->rx_max_mcast;
> + coal->rx_max_bcast = priv->rx_max_bcast;
> return 0;
> }
>
> -static int cpsw_set_coalesce(struct net_device *ndev,
> - struct ethtool_coalesce *coal)
> +static int cpsw_set_coalesce_usecs(struct net_device *ndev,
> + struct ethtool_coalesce *coal)
> {
> struct cpsw_priv *priv = netdev_priv(ndev);
> u32 int_ctrl;
> @@ -933,6 +937,74 @@ static int cpsw_set_coalesce(struct net_device *ndev,
> return 0;
> }
>
> +static int cpsw_set_coalesce_mcast(struct net_device *ndev,
> + struct ethtool_coalesce *coal)
> +{
> + struct cpsw_priv *priv = netdev_priv(ndev);
> + int port;
> +
> + priv->rx_max_mcast = coal->rx_max_mcast;
> +
> + if (priv->data.dual_emac)
> + port = priv->emac_port;
> + else
> + port = priv->data.active_slave;
> +
> + cpsw_ale_control_set(priv->ale, port, ALE_PORT_MCAST_LIMIT,
> + coal->rx_max_mcast);
> +
> + dev_dbg(priv->dev, "rx_max_mcast set to %d\n", priv->rx_max_mcast);
> + return 0;
> +}
> +
> +static int cpsw_set_coalesce_bcast(struct net_device *ndev,
> + struct ethtool_coalesce *coal)
> +{
> + struct cpsw_priv *priv = netdev_priv(ndev);
> + int port;
> +
> + priv->rx_max_bcast = coal->rx_max_bcast;
> +
> + if (priv->data.dual_emac)
> + port = priv->emac_port + 1;
> + else
> + port = priv->data.active_slave + 1;
> +
> + cpsw_ale_control_set(priv->ale, port, ALE_PORT_BCAST_LIMIT,
> + coal->rx_max_bcast);
Both cpsw_set_coalesce_bcast & cpsw_set_coalesce_mcast always return 0.
May be you can return result of cpsw_ale_control_set()?
> +
> + dev_dbg(priv->dev, "rx_max_mcast set to %d\n", priv->rx_max_bcast);
> + return 0;
> +}
> +
> +static int cpsw_set_coalesce(struct net_device *ndev,
> + struct ethtool_coalesce *coal)
> +{
> + int ret = -EINVAL;
> +
> + if (coal->rx_coalesce_usecs) {
> + ret = cpsw_set_coalesce_usecs(ndev, coal);
> + if (ret) {
> + dev_err(&ndev->dev, "set rx-usecs failed\n");
> + return ret;
> + }
> + }
> +
> + ret = cpsw_set_coalesce_mcast(ndev, coal);
> + if (ret) {
> + dev_err(&ndev->dev, "set coalesce rx-max-mcast failed\n");
> + return ret;
> + }
So that ret check here will be meaningful.
thanks
> +
> + ret = cpsw_set_coalesce_bcast(ndev, coal);
> + if (ret) {
> + dev_err(&ndev->dev, "set coalesce rx-max-bcast failed\n");
> + return ret;
> + }
> +
> + return ret;
> +}
> +
> static int cpsw_get_sset_count(struct net_device *ndev, int sset)
> {
> switch (sset) {
> @@ -1227,6 +1299,10 @@ static int cpsw_ndo_open(struct net_device *ndev)
> /* enable statistics collection only on all ports */
> __raw_writel(0x7, &priv->regs->stat_port_en);
>
> + /* Enable rate limit feature in the switch for rx only */
> + cpsw_ale_control_set(priv->ale, 0, ALE_RATE_LIMIT, 1);
> + cpsw_ale_control_set(priv->ale, 0, ALE_RATE_LIMIT_TX, 0);
> +
> if (WARN_ON(!priv->data.rx_descs))
> priv->data.rx_descs = 128;
>
> --
> 2.0.0.390.gcb682f8
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2014-07-09 13:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 7:14 [net-next PATCH v2 0/3] Broadcast/Multicast rate limit via Ethtool Coalesce Mugunthan V N
2014-07-09 7:14 ` [net-next PATCH v2 1/3] net: ethtool: Add Multicast and broadcast rate limit coalescing feature Mugunthan V N
2014-07-09 7:14 ` [net-next PATCH v2 2/3] drivers: net: cpsw: remove redundancy check Mugunthan V N
2014-07-09 7:14 ` [net-next PATCH v2 3/3] drivers: net: cpsw: Add support for multicast/broadcast rate limit Mugunthan V N
[not found] ` <1404890050-4020-4-git-send-email-mugunthanvnm-l0cyMroinI0@public.gmane.org>
2014-07-09 13:39 ` Govindarajulu Varadarajan [this message]
[not found] ` <1404890050-4020-1-git-send-email-mugunthanvnm-l0cyMroinI0@public.gmane.org>
2014-07-09 23:44 ` [net-next PATCH v2 0/3] Broadcast/Multicast rate limit via Ethtool Coalesce David Miller
[not found] ` <20140709.164420.157865201153845876.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-07-17 6:13 ` Mugunthan V N
[not found] ` <53C76990.3000304-l0cyMroinI0@public.gmane.org>
2014-07-17 12:53 ` David Laight
[not found] ` <063D6719AE5E284EB5DD2968C1650D6D172768B0-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2014-07-18 5:37 ` Mugunthan V N
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=alpine.LNX.2.03.1407091904170.16937@ws.cisco \
--to=_govind-kk0ffgbhmju@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mugunthanvnm-l0cyMroinI0@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).