From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: Daniel Machon <daniel.machon@microchip.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
UNGLinuxDriver@microchip.com
Cc: robert.marko@sartura.hr, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 4/5] net: sparx5: Add hardware programming for the port policer
Date: Thu, 5 Nov 2026 09:09:03 -0800 [thread overview]
Message-ID: <619a4027-0709-4b13-9367-866a06d2cd02@gmail.com> (raw)
In-Reply-To: <20261105-b4-lan966x-pci-fdma-sparx5-lan969x-port-policers-v3-4-b45a3a26bed5@microchip.com>
> +int sparx5_add_port_policer(struct sparx5_mall_entry *entry,
> + struct netlink_ext_ack *extack)
> +{
> + struct flow_action_police *police = &entry->port_policer.police;
> + struct sparx5_port *port = entry->port;
> + struct sparx5 *sparx5 = port->sparx5;
> + struct sparx5_policer pol = { 0 };
> + int idx, err;
> +
> + if (!entry->ingress) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer is not supported on egress");
> + return -EOPNOTSUPP;
> + }
> +
> + if (entry->port->tc.ingress_block_shared) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer is not supported on shared ingress blocks");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->exceed.act_id != FLOW_ACTION_DROP) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->notexceed.act_id != FLOW_ACTION_PIPE &&
> + police->notexceed.act_id != FLOW_ACTION_ACCEPT) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->peakrate_bytes_ps || police->avrate ||
> + police->overhead) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->rate_pkt_ps) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
Curious if we can have distinct messages for several unrelated checks
sharing the extack "Policer parameters are not supported";
> +
> + if (!police->rate_bytes_ps) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer requires a rate");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->burst > ANA_AC_POL_PORT_THRES_CFG_0_PORT_THRES0 *
> + SPX5_POLICER_BYTE_BURST_UNIT) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
> +
> + if (police->rate_bytes_ps >
> + div_u64((u64)ANA_AC_POL_PORT_RATE_CFG_PORT_RATE *
> + SPX5_POLICER_RATE_UNIT, BITS_PER_BYTE)) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Policer parameters are not supported");
> + return -EOPNOTSUPP;
> + }
> +
> + idx = sparx5_alloc_port_policer_idx(port, entry->cookie);
> + if (idx < 0) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Only one port policer per port is supported");
> + return idx;
> + }
> +
Any reason why police->mtu isn't checked? In software, frames longer
than the police MTU always take the exceed action. Is this intentionally
skipped here?
> + pol.type = SPX5_POL_PORT;
> + pol.rate = police->rate_bytes_ps * BITS_PER_BYTE;
> + pol.burst = police->burst;
> + pol.idx = port->portno * SPX5_POLICERS_PER_PORT + idx;
> +
> + sparx5_init_port_policer_stats(port, idx);
> +
> + err = sparx5_policer_conf_set(sparx5, &pol);
> + if (err)
> + return err;
> +
> + port->tc.port_policer[idx].policer = entry->cookie;
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2026-11-05 17:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 13:19 [PATCH net-next v3 0/5] net: sparx5: add tc matchall port policer offload Daniel Machon
2026-11-05 13:19 ` [PATCH net-next v3 1/5] net: sparx5: Drop redundant POL_ prefix from POL_UPD_INT_CFG Daniel Machon
2026-11-05 17:16 ` Mohsin Bashir
2026-11-05 13:19 ` [PATCH net-next v3 2/5] net: sparx5: Add registers used by the port policer Daniel Machon
2026-11-05 13:19 ` [PATCH net-next v3 3/5] net: sparx5: Track shared tc blocks and per-port policer state Daniel Machon
2026-11-05 13:19 ` [PATCH net-next v3 4/5] net: sparx5: Add hardware programming for the port policer Daniel Machon
2026-11-05 17:09 ` Mohsin Bashir [this message]
2026-11-06 7:45 ` Daniel Machon
2026-11-05 13:19 ` [PATCH net-next v3 5/5] net: sparx5: Offload tc port policers via matchall Daniel Machon
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=619a4027-0709-4b13-9367-866a06d2cd02@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robert.marko@sartura.hr \
/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