From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev <netdev@vger.kernel.org>, David <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Guenter Roeck <linux@roeck-us.net>,
linux-kernel <linux-kernel@vger.kernel.org>,
kernel <kernel@savoirfairelinux.com>
Subject: Re: [PATCH 1/3] net: dsa: mv88e6xxx: add debugfs interface for VTU
Date: Fri, 26 Jun 2015 11:42:38 -0400 (EDT) [thread overview]
Message-ID: <473155649.316793.1435333358566.JavaMail.zimbra@savoirfairelinux.com> (raw)
In-Reply-To: <20150626152344.GI9469@lunn.ch>
Hi Andrew,
On Jun 26, 2015, at 11:23 AM, Andrew Lunn andrew@lunn.ch wrote:
>> >> +static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
>> >> + struct mv88e6xxx_vtu_entry *entry)
>> >> +{
>> >> + int ret, i;
>> >> +
>> >> + ret = _mv88e6xxx_vtu_wait(ds);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + ret = _mv88e6xxx_reg_write(ds, REG_GLOBAL, GLOBAL_VTU_VID,
>> >> + vid & GLOBAL_VTU_VID_MASK);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + ret = _mv88e6xxx_vtu_cmd(ds, GLOBAL_VTU_OP_VTU_GET_NEXT);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_VID);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + entry->vid = ret & GLOBAL_VTU_VID_MASK;
>> >> + entry->valid = !!(ret & GLOBAL_VTU_VID_VALID);
>> >> +
>> >> + if (entry->valid) {
>> >> + /* Ports 0-3, offsets 0, 4, 8, 12 */
>> >> + ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_DATA_0_3);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + for (i = 0; i < 4; ++i)
>> >> + entry->tags[i] = (ret >> (i * 4)) & 3;
>> >> +
>> >> + /* Ports 4-6, offsets 0, 4, 8 */
>> >> + ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_DATA_4_7);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + for (i = 4; i < 7; ++i)
>> >> + entry->tags[i] = (ret >> ((i - 4) * 4)) & 3;
>> >> +
>> >> + ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_FID);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + entry->fid = ret & GLOBAL_VTU_FID_MASK;
>> >> +
>> >> + ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_SID);
>> >> + if (ret < 0)
>> >> + return ret;
>> >> +
>> >> + entry->sid = ret & GLOBAL_VTU_SID_MASK;
>> >
>> > As you point out in the header file, not all switches have FID and
>> > VID. A quick look at DSDT suggests for both FID and SID:
>> >
>> > DEV_88E6097_FAMILY | DEV_88E6165_FAMILY | DEV_88E6351_FAMILY |
>> > DEV_88E6352_FAMILY
>> >
>> > Please limit access to these registers to just these families.
>>
>> OK. Thanks for pointing this out. I think you meant SID instead of VID.
>
> Yes, my error.
>
>> Would something like the following be correct then?
>>
>> #define GLOBAL_VTU_FID 0x02 /* 6097 6165 6351 6352 */
>> #define GLOBAL_VTU_SID 0x03 /* 6097 6165 6351 6352 */
>
> Yes. I've not annotated all #defines, but here there is a clear
> overlap with the MAC address for some chips, so the comment is
> justified.
>
>> if (mv88e6xxx_6097_family(ds) || mv88e6xxx_6165_family(ds) ||
>> mv88e6xxx_6351_family(ds) || mv88e6xxx_6352_family(ds)) {
>> ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_FID);
>> if (ret < 0)
>> return ret;
>>
>> entry->fid = ret & GLOBAL_VTU_FID_MASK;
>>
>> ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL, GLOBAL_VTU_SID);
>> if (ret < 0)
>> return ret;
>>
>> entry->sid = ret & GLOBAL_VTU_SID_MASK;
>> }
>
> Maybe add an else to set sid and fid to 0?
Sure, done. Thanks for the reviews.
-v
next prev parent reply other threads:[~2015-06-26 15:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 21:46 [PATCH 0/3] net: dsa: mv88e6xxx: dump hardware VLANs Vivien Didelot
2015-06-23 21:46 ` [PATCH 1/3] net: dsa: mv88e6xxx: add debugfs interface for VTU Vivien Didelot
2015-06-26 14:04 ` Andrew Lunn
2015-06-26 15:04 ` Vivien Didelot
2015-06-26 15:23 ` Andrew Lunn
2015-06-26 15:42 ` Vivien Didelot [this message]
2015-06-23 21:46 ` [PATCH 2/3] net: dsa: mv88e6xxx: add support to dump VLANs Vivien Didelot
2015-06-26 14:10 ` Andrew Lunn
2015-06-26 14:36 ` Vivien Didelot
2015-06-23 21:46 ` [PATCH 3/3] net: dsa: mv88e6352: add support for port_vlan_dump Vivien Didelot
2015-06-24 9:22 ` David Miller
2015-06-26 14:12 ` Andrew Lunn
2015-06-26 14:33 ` Vivien Didelot
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=473155649.316793.1435333358566.JavaMail.zimbra@savoirfairelinux.com \
--to=vivien.didelot@savoirfairelinux.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--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).