From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"allan.nielsen@microchip.com" <allan.nielsen@microchip.com>,
"joergen.andreasen@microchip.com"
<joergen.andreasen@microchip.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
"vinicius.gomes@intel.com" <vinicius.gomes@intel.com>,
"michael.chan@broadcom.com" <michael.chan@broadcom.com>,
"vishal@chelsio.com" <vishal@chelsio.com>,
"saeedm@mellanox.com" <saeedm@mellanox.com>,
"jiri@mellanox.com" <jiri@mellanox.com>,
"idosch@mellanox.com" <idosch@mellanox.com>,
"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
"kuba@kernel.org" <kuba@kernel.org>, Po Liu <po.liu@nxp.com>,
Leo Li <leoyang.li@nxp.com>
Subject: Re: [PATCH v3 net-next 5/8] net: dsa: felix: support psfp filter on vsc9959
Date: Tue, 31 Aug 2021 07:54:51 +0000 [thread overview]
Message-ID: <20210831075450.u7smg5bibz3vvw4q@skbuf> (raw)
In-Reply-To: <20210831034536.17497-6-xiaoliang.yang_1@nxp.com>
On Tue, Aug 31, 2021 at 11:45:33AM +0800, Xiaoliang Yang wrote:
> +static int vsc9959_mact_stream_set(struct ocelot *ocelot,
> + struct felix_stream *stream,
> + struct netlink_ext_ack *extack)
> +{
> + struct ocelot_mact_entry entry;
> + u32 row, col, reg, dst_idx;
> + int ret;
> +
> + /* Stream identification desn't support to add a stream with non
> + * existent MAC (The MAC entry has not been learned in MAC table).
> + */
Who will add the MAC entry to the MAC table in this design? The user?
> + ret = ocelot_mact_lookup(ocelot, stream->dmac, stream->vid, &row, &col);
> + if (ret) {
> + if (extack)
> + NL_SET_ERR_MSG_MOD(extack, "Stream is not learned in MAC table");
> + return -EOPNOTSUPP;
> + }
> +
> + ocelot_rmw(ocelot,
> + (stream->sfid_valid ? ANA_TABLES_STREAMDATA_SFID_VALID : 0) |
> + ANA_TABLES_STREAMDATA_SFID(stream->sfid),
> + ANA_TABLES_STREAMDATA_SFID_VALID |
> + ANA_TABLES_STREAMDATA_SFID_M,
> + ANA_TABLES_STREAMDATA);
> +
> + reg = ocelot_read(ocelot, ANA_TABLES_STREAMDATA);
> + reg &= (ANA_TABLES_STREAMDATA_SFID_VALID | ANA_TABLES_STREAMDATA_SSID_VALID);
> + entry.type = (reg ? ENTRYTYPE_LOCKED : ENTRYTYPE_NORMAL);
So if the STREAMDATA entry for this SFID was valid, you mark the MAC
table entry as static, otherwise you mark it as ageable? Why?
> + ether_addr_copy(entry.mac, stream->dmac);
> + entry.vid = stream->vid;
> +
> + reg = ocelot_read(ocelot, ANA_TABLES_MACACCESS);
> + dst_idx = (reg & ANA_TABLES_MACACCESS_DEST_IDX_M) >> 3;
> +
> + ocelot_mact_write(ocelot, dst_idx, &entry, row, col);
> +
> + return 0;
> +}
> +
> +static int vsc9959_stream_table_add(struct ocelot *ocelot,
> + struct list_head *stream_list,
> + struct felix_stream *stream,
> + struct netlink_ext_ack *extack)
> +{
> + struct felix_stream *stream_entry;
> + int ret;
> +
> + stream_entry = kzalloc(sizeof(*stream_entry), GFP_KERNEL);
> + if (!stream_entry)
> + return -ENOMEM;
> +
> + memcpy(stream_entry, stream, sizeof(*stream_entry));
> +
> + ret = vsc9959_mact_stream_set(ocelot, stream, extack);
> + if (ret) {
> + kfree(stream_entry);
> + return ret;
> + }
> +
> + list_add_tail(&stream_entry->list, stream_list);
> +
> + return 0;
> +}
> +
> +static bool vsc9959_stream_table_lookup(struct list_head *stream_list,
> + struct felix_stream *stream)
> +{
> + struct felix_stream *tmp;
> +
> + list_for_each_entry(tmp, stream_list, list)
> + if (ether_addr_equal(tmp->dmac, stream->dmac) &&
> + tmp->vid == stream->vid)
> + return true;
> +
> + return false;
> +}
> +
> +static struct felix_stream *
> +vsc9959_stream_table_get(struct list_head *stream_list, unsigned long id)
> +{
> + struct felix_stream *tmp;
> +
> + list_for_each_entry(tmp, stream_list, list)
> + if (tmp->id == id)
> + return tmp;
> +
> + return NULL;
> +}
> +
> +static void vsc9959_stream_table_del(struct ocelot *ocelot,
> + struct felix_stream *stream)
> +{
> + vsc9959_mact_stream_set(ocelot, stream, NULL);
> +
> + list_del(&stream->list);
> + kfree(stream);
> +}
> +
> +static u32 vsc9959_sfi_access_status(struct ocelot *ocelot)
> +{
> + return ocelot_read(ocelot, ANA_TABLES_SFIDACCESS);
> +}
> +
> +static int vsc9959_psfp_sfi_set(struct ocelot *ocelot,
> + struct felix_stream_filter *sfi)
> +{
> + u32 val;
> +
> + if (sfi->index > VSC9959_PSFP_SFID_MAX)
> + return -EINVAL;
> +
> + if (!sfi->enable) {
> + ocelot_write(ocelot, ANA_TABLES_SFIDTIDX_SFID_INDEX(sfi->index),
> + ANA_TABLES_SFIDTIDX);
> +
> + val = ANA_TABLES_SFIDACCESS_SFID_TBL_CMD(SFIDACCESS_CMD_WRITE);
> + ocelot_write(ocelot, val, ANA_TABLES_SFIDACCESS);
> +
> + return readx_poll_timeout(vsc9959_sfi_access_status, ocelot, val,
> + (!ANA_TABLES_SFIDACCESS_SFID_TBL_CMD(val)),
> + 10, 100000);
> + }
> +
> + if (sfi->sgid > VSC9959_PSFP_GATE_ID_MAX ||
> + sfi->fmid > VSC9959_PSFP_POLICER_MAX)
> + return -EINVAL;
> +
> + ocelot_write(ocelot,
> + (sfi->sg_valid ? ANA_TABLES_SFIDTIDX_SGID_VALID : 0) |
> + ANA_TABLES_SFIDTIDX_SGID(sfi->sgid) |
> + (sfi->fm_valid ? ANA_TABLES_SFIDTIDX_POL_ENA : 0) |
> + ANA_TABLES_SFIDTIDX_POL_IDX(sfi->fmid) |
> + ANA_TABLES_SFIDTIDX_SFID_INDEX(sfi->index),
> + ANA_TABLES_SFIDTIDX);
> +
> + ocelot_write(ocelot,
> + (sfi->prio_valid ? ANA_TABLES_SFIDACCESS_IGR_PRIO_MATCH_ENA : 0) |
> + ANA_TABLES_SFIDACCESS_IGR_PRIO(sfi->prio) |
> + ANA_TABLES_SFIDACCESS_MAX_SDU_LEN(sfi->maxsdu) |
> + ANA_TABLES_SFIDACCESS_SFID_TBL_CMD(SFIDACCESS_CMD_WRITE),
> + ANA_TABLES_SFIDACCESS);
> +
> + return readx_poll_timeout(vsc9959_sfi_access_status, ocelot, val,
> + (!ANA_TABLES_SFIDACCESS_SFID_TBL_CMD(val)),
> + 10, 100000);
> +}
> +
> +static int vsc9959_psfp_sfi_table_add(struct ocelot *ocelot,
> + struct felix_stream_filter *sfi)
> +{
> + struct felix_stream_filter *sfi_entry, *tmp;
> + struct list_head *pos, *q, *last;
> + struct ocelot_psfp_list *psfp;
> + u32 insert = 0;
> + int ret;
> +
> + psfp = &ocelot->psfp;
> + last = &psfp->sfi_list;
> +
> + list_for_each_safe(pos, q, &psfp->sfi_list) {
> + tmp = list_entry(pos, struct felix_stream_filter, list);
> + if (sfi->sg_valid == tmp->sg_valid &&
> + sfi->fm_valid == tmp->fm_valid &&
> + tmp->sgid == sfi->sgid &&
> + tmp->fmid == sfi->fmid) {
> + sfi->index = tmp->index;
> + refcount_inc(&tmp->refcount);
> + return 0;
> + }
> + /* Make sure that the index is increasing in order. */
> + if (tmp->index == insert) {
> + last = pos;
> + insert++;
> + }
> + }
> + sfi->index = insert;
> +
> + sfi_entry = kzalloc(sizeof(*sfi_entry), GFP_KERNEL);
> + if (!sfi_entry)
> + return -ENOMEM;
> +
> + memcpy(sfi_entry, sfi, sizeof(*sfi_entry));
> + refcount_set(&sfi_entry->refcount, 1);
> +
> + ret = vsc9959_psfp_sfi_set(ocelot, sfi_entry);
> + if (ret) {
> + kfree(sfi_entry);
> + return ret;
> + }
> +
> + list_add(&sfi_entry->list, last);
> +
> + return 0;
> +}
> +
> +static struct felix_stream_filter *
> +vsc9959_psfp_sfi_table_get(struct list_head *sfi_list, u32 index)
This function needs to be introduced in the patch where it is used,
otherwise:
https://patchwork.hopto.org/static/nipa/539543/12466413/build_32bit/stderr
> +{
> + struct felix_stream_filter *tmp;
> +
> + list_for_each_entry(tmp, sfi_list, list)
> + if (tmp->index == index)
> + return tmp;
> +
> + return NULL;
> +}
next prev parent reply other threads:[~2021-08-31 7:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-31 3:45 [PATCH v3 net-next 0/8] net: dsa: felix: psfp support on vsc9959 Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 1/8] net: mscc: ocelot: export struct ocelot_mact_entry Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 2/8] net: mscc: ocelot: add MAC table write and lookup operations Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 3/8] net: mscc: ocelot: set vcap IS2 chain to goto PSFP chain Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 4/8] net: mscc: ocelot: add gate and police action offload to PSFP Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 5/8] net: dsa: felix: support psfp filter on vsc9959 Xiaoliang Yang
2021-08-31 7:54 ` Vladimir Oltean [this message]
2021-08-31 8:41 ` Xiaoliang Yang
2021-08-31 8:46 ` Vladimir Oltean
2021-08-31 8:55 ` Vladimir Oltean
2021-08-31 8:59 ` Xiaoliang Yang
2021-08-31 9:07 ` Vladimir Oltean
2021-08-31 9:18 ` Vladimir Oltean
2021-08-31 9:59 ` Xiaoliang Yang
2021-08-31 10:49 ` Vladimir Oltean
2021-09-02 3:14 ` Xiaoliang Yang
2021-09-09 11:33 ` Joergen Andreasen
2021-09-09 12:01 ` Vladimir Oltean
2021-08-31 3:45 ` [PATCH v3 net-next 6/8] net: dsa: felix: add stream gate settings for psfp Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 7/8] net: mscc: ocelot: use index to set vcap policer Xiaoliang Yang
2021-08-31 3:45 ` [PATCH v3 net-next 8/8] net: dsa: felix: use vcap policer to set flow meter for psfp Xiaoliang Yang
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=20210831075450.u7smg5bibz3vvw4q@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=joergen.andreasen@microchip.com \
--cc=kuba@kernel.org \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=po.liu@nxp.com \
--cc=saeedm@mellanox.com \
--cc=vinicius.gomes@intel.com \
--cc=vishal@chelsio.com \
--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