From: Vladimir Oltean <olteanv@gmail.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
Ralf Baechle <ralf@linux-mips.org>,
Paul Burton <paul.burton@mips.com>,
James Hogan <jhogan@kernel.org>,
linux-mips@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
"Allan W. Nielsen" <allan.nielsen@microchip.com>,
Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
hongbo.wang@nxp.com
Subject: Re: [PATCH net-next v3 1/2] net: mscc: ocelot: Add support for tcam
Date: Thu, 23 Apr 2020 12:18:46 +0300 [thread overview]
Message-ID: <CA+h21hod2kOJP3SApEczq3+hcJFMWZd0UzZPvfYwTAP1h-cMwQ@mail.gmail.com> (raw)
In-Reply-To: <20200423082948.t7sgq4ikrbm4cbnt@soft-dev3.microsemi.net>
On Thu, 23 Apr 2020 at 11:29, Horatiu Vultur
<horatiu.vultur@microchip.com> wrote:
>
> The 04/23/2020 00:26, Vladimir Oltean wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> >
> > Hi Horatiu,
> >
> > On Fri, 31 May 2019 at 10:18, Horatiu Vultur
> > <horatiu.vultur@microchip.com> wrote:
> > >
> > > Add ACL support using the TCAM. Using ACL it is possible to create rules
> > > in hardware to filter/redirect frames.
> > >
> > > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > > ---
[...]
> > > +
> > > +/* Calculate offsets for entry */
> > > +static void is2_data_get(struct vcap_data *data, int ix)
> > > +{
> > > + u32 i, col, offset, count, cnt, base, width = vcap_is2.tg_width;
> > > +
> > > + count = (data->tg_sw == VCAP_TG_HALF ? 2 : 4);
> > > + col = (ix % 2);
> > > + cnt = (vcap_is2.sw_count / count);
> > > + base = (vcap_is2.sw_count - col * cnt - cnt);
> > > + data->tg_value = 0;
> > > + data->tg_mask = 0;
> > > + for (i = 0; i < cnt; i++) {
> > > + offset = ((base + i) * width);
> > > + data->tg_value |= (data->tg_sw << offset);
> > > + data->tg_mask |= GENMASK(offset + width - 1, offset);
> > > + }
> > > +
> > > + /* Calculate key/action/counter offsets */
> > > + col = (count - col - 1);
> > > + data->key_offset = (base * vcap_is2.entry_width) / vcap_is2.sw_count;
> > > + data->counter_offset = (cnt * col * vcap_is2.counter_width);
> > > + i = data->type;
> > > + width = vcap_is2.action_table[i].width;
> > > + cnt = vcap_is2.action_table[i].count;
> > > + data->action_offset =
> > > + (((cnt * col * width) / count) + vcap_is2.action_type_width);
> > > +}
> > > +
[...]
> > > +}
> > > +
> > > +static void is2_entry_set(struct ocelot *ocelot, int ix,
> > > + struct ocelot_ace_rule *ace)
> > > +{
> > > + u32 val, msk, type, type_mask = 0xf, i, count;
> > > + struct ocelot_ace_vlan *tag = &ace->vlan;
> > > + struct ocelot_vcap_u64 payload = { 0 };
> > > + struct vcap_data data = { 0 };
> > > + int row = (ix / 2);
> > > +
> > > + /* Read row */
> > > + vcap_row_cmd(ocelot, row, VCAP_CMD_READ, VCAP_SEL_ALL);
> > > + vcap_cache2entry(ocelot, &data);
> > > + vcap_cache2action(ocelot, &data);
> > > +
> > > + data.tg_sw = VCAP_TG_HALF;
> > > + is2_data_get(&data, ix);
> > > + data.tg = (data.tg & ~data.tg_mask);
> > > + if (ace->prio != 0)
> > > + data.tg |= data.tg_value;
> >
>
> Hi Vladimir,
>
> > This complicated piece of logic here populates the type-group for
> > subwords > 0 unconditionally, and the type-group for subword 0 only if
> > the ACE is enabled.
> >
> > tc filter add dev swp0 ingress protocol ip flower skip_sw src_ip
> > 192.168.1.1 action drop
> > [ 34.172068] is2_entry_set: ace->prio 49152 data tg 0xaa
> > tc filter del dev swp0 ingress pref 49152
> > [ 44.266662] is2_entry_set: ace->prio 0 data tg 0xa0
> >
> > What is the purpose of this? Why can't the entire data->tg be set to
> > zero when deleting it?
> I don't remember exactly but let me try:
>
> In case you have only one entry per row, then you could set the tg to
> have value 0. But in case you have 2 entries(use half keys), you need to
> set the tg to 0 only to the half entry that you delete.
>
> So for example if you have only 1 half entry at subword 1 then the tg
> should be 0xa0. Then when you add a new entry on the same row but at
> subword 0 then the tg should have the value 0xaa.
> The value 0xaa, comes from the fact that the type group for half entry
> is 0x2 and this needs to be set for each subword. And IS2 has 4 subwords
> therefore 0b10101010 = 0xaa.
>
> I hope this helps, if not I can look deeper in the code and see exactly.
>
Oh, right, so for half and quarter keys you need to not affect the
neighbour keys when modifying a row. That's exactly the information I
was looking for, thanks!
> > Is there any special meaning to a TCAM entry > with subword zero unused?
> >
[...]
>
> --
> /Horatiu
-Vladimir
next prev parent reply other threads:[~2020-04-23 9:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 7:16 [PATCH net-next v3 0/2] Add hw offload of TC flower on MSCC Ocelot Horatiu Vultur
2019-05-31 7:16 ` [PATCH net-next v3 1/2] net: mscc: ocelot: Add support for tcam Horatiu Vultur
2020-02-24 10:38 ` Vladimir Oltean
2020-02-24 11:03 ` Horatiu Vultur
2020-02-24 11:32 ` Vladimir Oltean
2020-04-22 21:26 ` Vladimir Oltean
2020-04-23 8:29 ` Horatiu Vultur
2020-04-23 9:18 ` Vladimir Oltean [this message]
2020-09-24 23:39 ` Vladimir Oltean
2020-09-26 11:20 ` Horatiu Vultur
2020-09-26 12:37 ` Vladimir Oltean
2020-09-26 18:55 ` Horatiu Vultur
2020-09-26 19:06 ` Vladimir Oltean
2019-05-31 7:16 ` [PATCH net-next v3 2/2] net: mscc: ocelot: Hardware ofload for tc flower filter Horatiu Vultur
2019-06-02 20:50 ` [PATCH net-next v3 0/2] Add hw offload of TC flower on MSCC Ocelot David Miller
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=CA+h21hod2kOJP3SApEczq3+hcJFMWZd0UzZPvfYwTAP1h-cMwQ@mail.gmail.com \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=allan.nielsen@microchip.com \
--cc=hongbo.wang@nxp.com \
--cc=horatiu.vultur@microchip.com \
--cc=jhogan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul.burton@mips.com \
--cc=ralf@linux-mips.org \
--cc=xiaoliang.yang_1@nxp.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).