netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-omap@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] drivers: net:ethernet: cpsw: add support for VLAN
Date: Thu, 31 Jan 2013 16:39:26 +0530	[thread overview]
Message-ID: <510A50E6.8090504@ti.com> (raw)
In-Reply-To: <20130130220243.GB22847@electric-eye.fr.zoreil.com>

On 1/31/2013 3:32 AM, Francois Romieu wrote:
> Mugunthan V N <mugunthanvnm@ti.com> :
> [...]
>> diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
>> index 6ddd028..99696bf 100644
>> --- a/Documentation/devicetree/bindings/net/cpsw.txt
>> +++ b/Documentation/devicetree/bindings/net/cpsw.txt
>> @@ -24,6 +24,8 @@ Required properties:
>>   Optional properties:
>>   - ti,hwmods		: Must be "cpgmac0"
>>   - no_bd_ram		: Must be 0 or 1
>> +- default_vlan		: Specifies Default VLAN for non tagged packets
>> +			  ALE processing
> Isn't it a device-tree hack for what should belong to a common API ?
Its a hardware feature which stack will not be aware of. It is used in 
the ALE filtering
process with a non-tagged packet arrives.
>
> [...]
>> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
>> index a40750e..6c66f01 100644
>> --- a/drivers/net/ethernet/ti/cpsw.c
>> +++ b/drivers/net/ethernet/ti/cpsw.c
> [...]
>> @@ -607,14 +611,41 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
>>   	}
>>   }
>>   
>> +static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
>> +{
>> +	writel(priv->data.default_vlan, &priv->host_port_regs->port_vlan);
>> +	if (priv->version == CPSW_VERSION_1) {
>> +		slave_write(&priv->slaves[0], priv->data.default_vlan,
>> +			    CPSW1_PORT_VLAN);
>> +		slave_write(&priv->slaves[1], priv->data.default_vlan,
>> +			    CPSW1_PORT_VLAN);
>> +	} else {
>> +		slave_write(&priv->slaves[0], priv->data.default_vlan,
>> +			    CPSW2_PORT_VLAN);
>> +		slave_write(&priv->slaves[1], priv->data.default_vlan,
>> +			    CPSW2_PORT_VLAN);
>> +	}
>> +	cpsw_ale_add_vlan(priv->ale, priv->data.default_vlan,
>> +			ALE_ALL_PORTS << priv->host_port,
>> +			ALE_ALL_PORTS << priv->host_port,
>> +			ALE_ALL_PORTS << priv->host_port,
>> +			(BIT(1) | BIT(2)) << priv->host_port);
>> +}
> static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
> {
> 	const int vlan = priv->data.default_vlan;
> 	const int port = priv->host_port;
> 	u32 reg;
> 	int i;
>
> 	reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
> 	      CPSW2_PORT_VLAN;
>
> 	writel(vlan, &priv->host_port_regs->port_vlan);
>
> 	for (int i = 0; i < 2; i++)
> 		slave_write(priv->slaves + i, vlan, reg);
>
> 	cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
> 			  ALE_ALL_PORTS << port, ALE_ALL_PORTS << port,
> 			  (BIT(1) | BIT(2)) << port);
> }
>
> ... or somewhere between both. Your call.
Will modify the code as this looks simpler
>
> [...]
>> @@ -933,6 +967,55 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
>>   }
>>   #endif
>>   
>> +static inline void cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
>> +				unsigned short vid)
>> +{
>> +	cpsw_ale_add_vlan(priv->ale, vid, ALE_ALL_PORTS << priv->host_port,
>> +			0, ALE_ALL_PORTS << priv->host_port,
>> +			(BIT(1) | BIT(2)) << priv->host_port);
> "(BIT(1) | BIT(2))" is repeated a couple of times.
Will replace with port number defines.
>
> [...]
>> +static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
>> +		unsigned short vid)
>> +{
>> +	struct cpsw_priv *priv = netdev_priv(ndev);
>> +
>> +	if (vid == priv->data.default_vlan)
>> +		return 0;
>> +
>> +	spin_lock(&priv->lock);
>> +
>> +	dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
>> +	cpsw_add_vlan_ale_entry(priv, vid);
>> +
>> +	spin_unlock(&priv->lock);
>> +	return 0;
>> +}
>> +
>> +static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
>> +		unsigned short vid)
>> +{
>> +	struct cpsw_priv *priv = netdev_priv(ndev);
>> +
>> +	if (vid == priv->data.default_vlan)
>> +		return 0;
>> +
>> +	spin_lock(&priv->lock);
>> +
>> +	dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
>> +	cpsw_ale_del_vlan(priv->ale, vid, 0);
>> +	cpsw_ale_del_ucast(priv->ale, priv->mac_addr,
>> +			   priv->host_port, ALE_VLAN, vid);
>> +	cpsw_ale_del_mcast(priv->ale, priv->ndev->broadcast, 0, ALE_VLAN, vid);
>> +
>> +	spin_unlock(&priv->lock);
> What are you trying to achieve with the lock ?
>
> It is not used anywhere else and both cpsw_ndo_vlan_rx_{add, kill}_vid are
> called under RTNL.
Will remove the lock from both apis

Regards
Mugunthan V N

      reply	other threads:[~2013-01-31 11:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30 19:07 [PATCH v2 0/2] Add CPSW VLAN Support Mugunthan V N
2013-01-30 19:07 ` [PATCH v2 1/2] drivers: net: cpsw: Add helper functions for VLAN ALE implementation Mugunthan V N
2013-01-30 22:02   ` Francois Romieu
2013-01-31 11:09     ` Mugunthan V N
2013-01-31 21:43       ` Francois Romieu
2013-01-30 19:07 ` [PATCH v2 2/2] drivers: net:ethernet: cpsw: add support for VLAN Mugunthan V N
2013-01-30 22:02   ` Francois Romieu
2013-01-31 11:09     ` Mugunthan V N [this message]

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=510A50E6.8090504@ti.com \
    --to=mugunthanvnm@ti.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.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;
as well as URLs for NNTP newsgroup(s).