From: Simon Horman <horms@kernel.org>
To: edward.cree@amd.com
Cc: linux-net-drivers@amd.com, davem@davemloft.net, kuba@kernel.org,
edumazet@google.com, pabeni@redhat.com,
Edward Cree <ecree.xilinx@gmail.com>,
netdev@vger.kernel.org, habetsm.xilinx@gmail.com,
pieter.jansen-van-vuuren@amd.com
Subject: Re: [PATCH net-next 1/4] sfc: support TC left-hand-side rules on foreign netdevs
Date: Tue, 3 Oct 2023 14:20:35 +0200 [thread overview]
Message-ID: <ZRwHE0WiPCYle20r@kernel.org> (raw)
In-Reply-To: <890f07cf815ae31e7cd5b37cafb72801791f1c75.1696261222.git.ecree.xilinx@gmail.com>
On Mon, Oct 02, 2023 at 04:44:41PM +0100, edward.cree@amd.com wrote:
> From: Edward Cree <ecree.xilinx@gmail.com>
>
> Allow a tunnel netdevice (such as a vxlan) to offload conntrack lookups,
> in much the same way as efx netdevs.
> To ensure this rule does not overlap with other tunnel rules on the same
> sip,dip,dport tuple, register a pseudo encap match of a new type
> (EFX_TC_EM_PSEUDO_OR), which unlike PSEUDO_MASK may only be referenced
> once (because an actual Outer Rule in hardware exists, although its
> fw_id is not recorded in the encap match entry).
>
> Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
> Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
...
> @@ -1354,6 +1450,119 @@ static int efx_tc_incomplete_mangle(struct efx_tc_mangler_state *mung,
> return 0;
> }
>
> +static int efx_tc_flower_replace_foreign_lhs(struct efx_nic *efx,
> + struct flow_cls_offload *tc,
> + struct flow_rule *fr,
> + struct efx_tc_match *match,
> + struct net_device *net_dev)
> +{
> + struct netlink_ext_ack *extack = tc->common.extack;
> + struct efx_tc_lhs_rule *rule, *old;
> + enum efx_encap_type type;
> + int rc;
> +
> + if (tc->common.chain_index) {
> + NL_SET_ERR_MSG_MOD(extack, "LHS rule only allowed in chain 0");
> + return -EOPNOTSUPP;
> + }
> +
> + if (!efx_tc_match_is_encap(&match->mask)) {
> + /* This is not a tunnel decap rule, ignore it */
> + netif_dbg(efx, drv, efx->net_dev, "Ignoring foreign LHS filter without encap match\n");
Hi Edward,
is NL_SET_ERR_MSG_MOD() appropriate here?
> + return -EOPNOTSUPP;
> + }
> +
> + if (efx_tc_flower_flhs_needs_ar(match)) {
> + NL_SET_ERR_MSG_MOD(extack, "Match keys not available in Outer Rule");
> + return -EOPNOTSUPP;
> + }
> +
> + type = efx_tc_indr_netdev_type(net_dev);
> + if (type == EFX_ENCAP_TYPE_NONE) {
> + NL_SET_ERR_MSG_MOD(extack, "Egress encap match on unsupported tunnel device\n");
> + return -EOPNOTSUPP;
> + }
> +
> + rc = efx_mae_check_encap_type_supported(efx, type);
> + if (rc) {
> + NL_SET_ERR_MSG_FMT_MOD(extack,
> + "Firmware reports no support for %s encap match",
> + efx_tc_encap_type_name(type));
> + return rc;
> + }
> + /* Reserve the outer tuple with a pseudo Encap Match */
> + rc = efx_tc_flower_record_encap_match(efx, match, type,
> + EFX_TC_EM_PSEUDO_OR, 0, 0,
> + extack);
> + if (rc)
> + return rc;
> +
> + if (match->mask.ct_state_trk && match->value.ct_state_trk) {
> + NL_SET_ERR_MSG_MOD(extack, "LHS rule can never match +trk");
> + rc = -EOPNOTSUPP;
> + goto release_encap_match;
> + }
> + /* LHS rules are always -trk, so we don't need to match on that */
> + match->mask.ct_state_trk = 0;
> + match->value.ct_state_trk = 0;
> +
> + rc = efx_tc_flower_translate_flhs_match(match);
> + if (rc) {
> + NL_SET_ERR_MSG_MOD(extack, "LHS rule cannot match on inner fields");
> + goto release_encap_match;
> + }
> +
> + rc = efx_mae_match_check_caps_lhs(efx, &match->mask, extack);
> + if (rc)
> + goto release_encap_match;
> +
> + rule = kzalloc(sizeof(*rule), GFP_USER);
> + if (!rule) {
> + rc = -ENOMEM;
> + goto release_encap_match;
> + }
> + rule->cookie = tc->cookie;
> + old = rhashtable_lookup_get_insert_fast(&efx->tc->lhs_rule_ht,
> + &rule->linkage,
> + efx_tc_lhs_rule_ht_params);
> + if (old) {
> + netif_dbg(efx, drv, efx->net_dev,
> + "Already offloaded rule (cookie %lx)\n", tc->cookie);
> + rc = -EEXIST;
> + NL_SET_ERR_MSG_MOD(extack, "Rule already offloaded");
> + goto release;
> + }
> +
> + /* Parse actions */
> + rc = efx_tc_flower_handle_lhs_actions(efx, tc, fr, net_dev, rule);
> + if (rc)
> + goto release;
> +
> + rule->match = *match;
> + rule->lhs_act.tun_type = type;
> +
> + rc = efx_mae_insert_lhs_rule(efx, rule, EFX_TC_PRIO_TC);
> + if (rc) {
> + NL_SET_ERR_MSG_MOD(extack, "Failed to insert rule in hw");
> + goto release;
> + }
> + netif_dbg(efx, drv, efx->net_dev,
> + "Successfully parsed lhs rule (cookie %lx)\n",
> + tc->cookie);
> + return 0;
> +
> +release:
> + efx_tc_flower_release_lhs_actions(efx, &rule->lhs_act);
> + if (!old)
> + rhashtable_remove_fast(&efx->tc->lhs_rule_ht, &rule->linkage,
> + efx_tc_lhs_rule_ht_params);
> + kfree(rule);
> +release_encap_match:
> + if (match->encap)
> + efx_tc_flower_release_encap_match(efx, match->encap);
> + return rc;
> +}
...
next prev parent reply other threads:[~2023-10-03 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 15:44 [PATCH net-next 0/4] sfc: conntrack offload for tunnels edward.cree
2023-10-02 15:44 ` [PATCH net-next 1/4] sfc: support TC left-hand-side rules on foreign netdevs edward.cree
2023-10-03 12:20 ` Simon Horman [this message]
2023-10-02 15:44 ` [PATCH net-next 2/4] sfc: offload foreign RHS rules without an encap match edward.cree
2023-10-02 15:44 ` [PATCH net-next 3/4] sfc: ensure an extack msg from efx_tc_flower_replace_foreign EOPNOTSUPPs edward.cree
2023-10-02 15:44 ` [PATCH net-next 4/4] sfc: support TC rules which require OR-AR-CT-AR flow edward.cree
2023-10-06 10:10 ` [PATCH net-next 0/4] sfc: conntrack offload for tunnels patchwork-bot+netdevbpf
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=ZRwHE0WiPCYle20r@kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=edward.cree@amd.com \
--cc=habetsm.xilinx@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-net-drivers@amd.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pieter.jansen-van-vuuren@amd.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).