From: Jonas Johansson <jonasj76@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Jonas Johansson <jonasj76@gmail.com>,
netdev@vger.kernel.org,
Jonas Johansson <jonas.johansson@westermo.se>
Subject: Re: [PATCH net-next 2/2] mv88e6131: bonding: implement single device trunking
Date: Fri, 20 Feb 2015 16:56:55 +0100 (CET) [thread overview]
Message-ID: <alpine.LNX.2.03.1502201645230.8221@hellgate.skynet> (raw)
In-Reply-To: <20150220152644.GD13797@lunn.ch>
On Fri, 20 Feb 2015, Andrew Lunn wrote:
> On Fri, Feb 20, 2015 at 11:51:13AM +0100, Jonas Johansson wrote:
>> From: Jonas Johansson <jonas.johansson@westermo.se>
>>
>> This patch will use the DSA hardware bonding support hooks to setup trunking
>> for the Marvell 88E6095 device. The implementation only handles trunking in
>> a single device.
>>
>> Hooks:
>> .bond_add_group: Add port to a bond group
>> .bond_del_group: Remove port from a bond group
>> .bond_attach: Attach/activate port in bond group
>> .bond_detach: Detach/inactivate port in bond group
>>
>> Procedure to add/remome port from bond group:
>> Setup trunk learning (Port Association Vector)
>> Setup loop prevention (VLAN Table)
>> Setup load balancing (Trunk Mask Load Balance Table)
>>
>> Procedure to attach/detach port:
>> Change load balancing (Trunk Mask Load Balance Table)
>>
>> Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se>
>> ---
>> drivers/net/dsa/mv88e6131.c | 254 ++++++++++++++++++++++++++++++++++++++++++++
>> drivers/net/dsa/mv88e6xxx.h | 14 +++
>> 2 files changed, 268 insertions(+)
>>
>> diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
>> index 2540ef0..3ba7a0c 100644
>> --- a/drivers/net/dsa/mv88e6131.c
>> +++ b/drivers/net/dsa/mv88e6131.c
>> @@ -382,6 +382,256 @@ mv88e6131_get_ethtool_stats(struct dsa_switch *ds,
>> mv88e6131_hw_stats, port, data);
>> }
>>
>> +/* Trunking */
>> +static int mv88e6131_bond_set_trunk_learning(struct dsa_switch *ds,
>> + int *ports, size_t num)
>> +{
>> + u16 port_vec = 0;
>> + int ret;
>> + int i;
>> +
>> + num = num < MAX_PORTS ? num : MAX_PORTS;
>> +
>> + for (i = 0; i < num; i++)
>> + port_vec |= 1 << ports[i];
>> +
>> + for (i = 0; i < num; i++) {
>> + ret = mv88e6xxx_reg_read(ds, REG_PORT(ports[i]), REG_PORT_PAV);
>> + if (ret < 0)
>> + continue;
>> + ret = (ret & 0xf800) | (port_vec & 0x7ff);
>> + mv88e6xxx_reg_write(ds, REG_PORT(ports[i]), REG_PORT_PAV, ret);
>> + }
>> +
>> + return 0;
>> +}
>
> The mv886060 seems to have the PAV register. So i guess most of the
> Marvell switches support this. Is there anything specific to the 6131
> here? Could this be moved into mv88x6xxx so other switch drivers can
> use it?
>
I guess you are correct, i'll look into it.
>> +
>> +static int mv88e6131_bond_set_loop_prevention(struct dsa_switch *ds,
>> + int *ports, size_t num)
>> +{
>> + u16 port_vec = 0;
>> + int ret;
>> + int i;
>> +
>> + num = num < MAX_PORTS ? num : MAX_PORTS;
>> +
>> + for (i = 0; i < num; i++)
>> + port_vec |= 1 << ports[i];
>> +
>> + for (i = 0; i < num; i++) {
>> + ret = mv88e6xxx_reg_read(ds, REG_PORT(ports[i]), REG_PORT_VLAN_MAP);
>> + if (ret < 0)
>> + continue;
>> + ret &= ~port_vec & 0x7ff;
>> + mv88e6xxx_reg_write(ds, REG_PORT(ports[i]), REG_PORT_VLAN_MAP, ret);
>> + }
>> +
>> + return 0;
>> +}
>
> Same question again, anything specific to the 6131 here?
>
I'll check.
>> +static int mv88e6131_wait_trunk_mask(struct dsa_switch *ds)
>> +{
>> + const int max_retries = 10;
>> + int retries = 0;
>> + int ret;
>> +
>> + /* Wait for update Trunk Mask data */
>> + while (1) {
>> + ret = REG_READ(REG_GLOBAL2, REG_TRUNK_MASK);
>> + if (!(ret & 0x8000))
>> + return ret;
>> + if (retries > max_retries) {
>> + pr_warn("mv88e6131: Timeout waiting for "
>> + "Trunk Mask Table Register Update\n");
>> + return -EBUSY;
>> + }
>> + retries++;
>> + usleep_range(20, 50);
>> + };
>
> This looks a lot like the wait functions what Guenter Roeck added to
> 6352 and i just moved to mv88e6xxx.c. Please use the generic
> infrastructure in the shared code.
>
Seems like the function is doing exactly what I'm looking for.
> Please could you look at all your functions and see what is specific
> to the 6131 and what is generic. Place the generic code into mv88e6xxx
> please so we can all use it.
>
> Thanks
> Andrew
>
Thanks for your review, I'll check if the functions is specific to the
6131 or if it the code could be moved to mv88e6xxx.c.
On vacation a.t.m, back in a week.
next prev parent reply other threads:[~2015-02-20 16:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 10:51 [PATCH net-next 0/2] dsa: implement HW bonding Jonas Johansson
2015-02-20 10:51 ` [PATCH net-next 1/2] dsa: bonding: " Jonas Johansson
2015-02-20 15:12 ` Andrew Lunn
2015-02-20 16:19 ` Jonas Johansson
2015-02-20 16:41 ` Florian Fainelli
2015-02-20 17:56 ` roopa
2015-02-20 19:28 ` Jonas Johansson
2015-02-21 16:57 ` Jiri Pirko
2015-02-21 20:43 ` Andrew Lunn
2015-02-21 21:12 ` Scott Feldman
2015-02-23 15:52 ` Jonas Johansson
2015-02-20 10:51 ` [PATCH net-next 2/2] mv88e6131: bonding: implement single device trunking Jonas Johansson
2015-02-20 15:26 ` Andrew Lunn
2015-02-20 15:56 ` Jonas Johansson [this message]
2015-03-06 17:06 ` Florian Fainelli
2015-03-06 19:23 ` Andrew Lunn
2015-03-06 20:47 ` Florian Fainelli
2015-03-06 21:47 ` Andrew Lunn
2015-03-06 22:43 ` Scott Feldman
2015-03-07 14:38 ` Jiri Pirko
2015-03-07 17:31 ` John Fastabend
2015-02-21 16:40 ` [PATCH net-next 0/2] dsa: implement HW bonding Jiri Pirko
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.1502201645230.8221@hellgate.skynet \
--to=jonasj76@gmail.com \
--cc=andrew@lunn.ch \
--cc=jonas.johansson@westermo.se \
--cc=netdev@vger.kernel.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).