From: Steen Hegelund <steen.hegelund@microchip.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Steen Hegelund <steen.hegelund@microchip.com>,
<UNGLinuxDriver@microchip.com>,
Randy Dunlap <rdunlap@infradead.org>,
"Casper Andersson" <casper.casan@gmail.com>,
Russell King <rmk+kernel@armlinux.org.uk>,
Wan Jiabing <wanjiabing@vivo.com>,
"Nathan Huckleberry" <nhuck@google.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
Daniel Machon <daniel.machon@microchip.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
Dan Carpenter <error27@gmail.com>,
Michael Walle <michael@walle.cc>
Subject: [PATCH net-next 7/8] net: microchip: sparx5: Add support for IS0 VCAP ethernet protocol types
Date: Fri, 20 Jan 2023 10:08:30 +0100 [thread overview]
Message-ID: <20230120090831.20032-8-steen.hegelund@microchip.com> (raw)
In-Reply-To: <20230120090831.20032-1-steen.hegelund@microchip.com>
This allows the IS0 VCAP to have its own list of supported ethernet
protocol types matching what is supported by the VCAPs port lookup
classification.
Signed-off-by: Steen Hegelund <steen.hegelund@microchip.com>
---
.../microchip/sparx5/sparx5_tc_flower.c | 24 +---------
.../microchip/sparx5/sparx5_vcap_impl.c | 46 ++++++++++++++++---
.../microchip/sparx5/sparx5_vcap_impl.h | 3 ++
3 files changed, 43 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
index 3875b5bc984f..9e613dc5b868 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
@@ -36,16 +36,6 @@ struct sparx5_tc_flower_parse_usage {
unsigned int used_keys;
};
-/* These protocols have dedicated keysets in IS2 and a TC dissector
- * ETH_P_ARP does not have a TC dissector
- */
-static u16 sparx5_tc_known_etypes[] = {
- ETH_P_ALL,
- ETH_P_ARP,
- ETH_P_IP,
- ETH_P_IPV6,
-};
-
enum sparx5_is2_arp_opcode {
SPX5_IS2_ARP_REQUEST,
SPX5_IS2_ARP_REPLY,
@@ -59,18 +49,6 @@ enum tc_arp_opcode {
TC_ARP_OP_REPLY,
};
-static bool sparx5_tc_is_known_etype(u16 etype)
-{
- int idx;
-
- /* For now this only knows about IS2 traffic classification */
- for (idx = 0; idx < ARRAY_SIZE(sparx5_tc_known_etypes); ++idx)
- if (sparx5_tc_known_etypes[idx] == etype)
- return true;
-
- return false;
-}
-
static int sparx5_tc_flower_handler_ethaddr_usage(struct sparx5_tc_flower_parse_usage *st)
{
enum vcap_key_field smac_key = VCAP_KF_L2_SMAC;
@@ -273,7 +251,7 @@ sparx5_tc_flower_handler_basic_usage(struct sparx5_tc_flower_parse_usage *st)
if (mt.mask->n_proto) {
st->l3_proto = be16_to_cpu(mt.key->n_proto);
- if (!sparx5_tc_is_known_etype(st->l3_proto)) {
+ if (!sparx5_vcap_is_known_etype(st->admin, st->l3_proto)) {
err = vcap_rule_add_key_u32(st->vrule, VCAP_KF_ETYPE,
st->l3_proto, ~0);
if (err)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c
index cceb4301103b..6165518ed0f2 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c
@@ -106,6 +106,21 @@ static struct sparx5_vcap_inst {
},
};
+/* These protocols have dedicated keysets in IS0 and a TC dissector */
+static u16 sparx5_vcap_is0_known_etypes[] = {
+ ETH_P_ALL,
+ ETH_P_IP,
+ ETH_P_IPV6,
+};
+
+/* These protocols have dedicated keysets in IS2 and a TC dissector */
+static u16 sparx5_vcap_is2_known_etypes[] = {
+ ETH_P_ALL,
+ ETH_P_ARP,
+ ETH_P_IP,
+ ETH_P_IPV6,
+};
+
static void sparx5_vcap_type_err(struct sparx5 *sparx5,
struct vcap_admin *admin,
const char *fname)
@@ -277,10 +292,6 @@ static int sparx5_vcap_is0_get_port_keysets(struct net_device *ndev,
value = spx5_rd(sparx5, ANA_CL_ADV_CL_CFG(portno, lookup));
- /* Check if the port keyset selection is enabled */
- if (!ANA_CL_ADV_CL_CFG_LOOKUP_ENA_GET(value))
- return -ENOENT;
-
/* Collect all keysets for the port in a list */
if (l3_proto == ETH_P_ALL)
sparx5_vcap_is0_get_port_etype_keysets(keysetlist, value);
@@ -333,10 +344,7 @@ static int sparx5_vcap_is2_get_port_keysets(struct net_device *ndev,
int portno = port->portno;
u32 value;
- /* Check if the port keyset selection is enabled */
value = spx5_rd(sparx5, ANA_ACL_VCAP_S2_KEY_SEL(portno, lookup));
- if (!ANA_ACL_VCAP_S2_KEY_SEL_KEY_SEL_ENA_GET(value))
- return -ENOENT;
/* Collect all keysets for the port in a list */
if (l3_proto == ETH_P_ALL || l3_proto == ETH_P_ARP) {
@@ -456,6 +464,30 @@ int sparx5_vcap_get_port_keyset(struct net_device *ndev,
return err;
}
+/* Check if the ethertype is supported by the vcap port classification */
+bool sparx5_vcap_is_known_etype(struct vcap_admin *admin, u16 etype)
+{
+ const u16 *known_etypes;
+ int size, idx;
+
+ switch (admin->vtype) {
+ case VCAP_TYPE_IS0:
+ known_etypes = sparx5_vcap_is0_known_etypes;
+ size = ARRAY_SIZE(sparx5_vcap_is0_known_etypes);
+ break;
+ case VCAP_TYPE_IS2:
+ known_etypes = sparx5_vcap_is2_known_etypes;
+ size = ARRAY_SIZE(sparx5_vcap_is2_known_etypes);
+ break;
+ default:
+ break;
+ }
+ for (idx = 0; idx < size; ++idx)
+ if (known_etypes[idx] == etype)
+ return true;
+ return false;
+}
+
/* API callback used for validating a field keyset (check the port keysets) */
static enum vcap_keyfield_set
sparx5_vcap_validate_keyset(struct net_device *ndev,
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.h b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.h
index 80c99b0d50e7..aabdf4355103 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.h
@@ -136,4 +136,7 @@ int sparx5_vcap_get_port_keyset(struct net_device *ndev,
u16 l3_proto,
struct vcap_keyset_list *kslist);
+/* Check if the ethertype is supported by the vcap port classification */
+bool sparx5_vcap_is_known_etype(struct vcap_admin *admin, u16 etype);
+
#endif /* __SPARX5_VCAP_IMPL_H__ */
--
2.39.1
next prev parent reply other threads:[~2023-01-20 9:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 9:08 [PATCH net-next 0/8] Adding Sparx5 IS0 VCAP support Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 1/8] net: microchip: sparx5: Add IS0 VCAP model and updated KUNIT VCAP model Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 2/8] net: microchip: sparx5: Add IS0 VCAP keyset configuration for Sparx5 Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 3/8] net: microchip: sparx5: Add actionset type id information to rule Steen Hegelund
2023-01-20 9:11 ` Dan Carpenter
2023-01-20 9:35 ` Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 4/8] net: microchip: sparx5: Add TC support for IS0 VCAP Steen Hegelund
2023-01-20 9:13 ` Dan Carpenter
2023-01-20 9:36 ` Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 5/8] net: microchip: sparx5: Add TC filter chaining support for IS0 and IS2 VCAPs Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 6/8] net: microchip: sparx5: Add automatic selection of VCAP rule actionset Steen Hegelund
2023-01-20 9:08 ` Steen Hegelund [this message]
2023-01-20 9:20 ` [PATCH net-next 7/8] net: microchip: sparx5: Add support for IS0 VCAP ethernet protocol types Dan Carpenter
2023-01-20 9:38 ` Steen Hegelund
2023-01-20 9:08 ` [PATCH net-next 8/8] net: microchip: sparx5: Add support for IS0 VCAP CVLAN TC keys Steen Hegelund
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=20230120090831.20032-8-steen.hegelund@microchip.com \
--to=steen.hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=casper.casan@gmail.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
--cc=nhuck@google.com \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=wanjiabing@vivo.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).