linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jose Abreu <Jose.Abreu@synopsys.com>
To: netdev@vger.kernel.org
Cc: Joao Pinto <Joao.Pinto@synopsys.com>,
	Jose Abreu <Jose.Abreu@synopsys.com>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	"David S. Miller" <davem@davemloft.net>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 13/26] net: stmmac: selftests: Add a selftest for Flexible RX Parser
Date: Mon,  5 Aug 2019 18:44:40 +0200	[thread overview]
Message-ID: <1bd693a85a15c5b57a759cc4b798dd958e5bf525.1565022597.git.joabreu@synopsys.com> (raw)
In-Reply-To: <cover.1565022597.git.joabreu@synopsys.com>
In-Reply-To: <cover.1565022597.git.joabreu@synopsys.com>

Add a selftest for the Flexible RX Parser feature.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 .../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 98 +++++++++++++++++++++-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
index 6b08bb15af15..abab84f2ef8b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
@@ -11,8 +11,10 @@
 #include <linux/ip.h>
 #include <linux/phy.h>
 #include <linux/udp.h>
+#include <net/pkt_cls.h>
 #include <net/tcp.h>
 #include <net/udp.h>
+#include <net/tc_act/tc_gact.h>
 #include "stmmac.h"
 
 struct stmmachdr {
@@ -229,7 +231,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb,
 			goto out;
 	}
 	if (tpriv->packet->src) {
-		if (!ether_addr_equal(ehdr->h_source, orig_ndev->dev_addr))
+		if (!ether_addr_equal(ehdr->h_source, tpriv->packet->src))
 			goto out;
 	}
 
@@ -912,6 +914,96 @@ static int stmmac_test_dvlanfilt(struct stmmac_priv *priv)
 	return ret;
 }
 
+#ifdef CONFIG_NET_CLS_ACT
+static int stmmac_test_rxp(struct stmmac_priv *priv)
+{
+	unsigned char addr[ETH_ALEN] = {0xde, 0xad, 0xbe, 0xef, 0x00, 0x00};
+	struct tc_cls_u32_offload cls_u32 = { };
+	struct stmmac_packet_attrs attr = { };
+	struct tc_action **actions, *act;
+	struct tc_u32_sel *sel;
+	struct tcf_exts *exts;
+	int ret, i, nk = 1;
+
+	if (!tc_can_offload(priv->dev))
+		return -EOPNOTSUPP;
+	if (!priv->dma_cap.frpsel)
+		return -EOPNOTSUPP;
+
+	sel = kzalloc(sizeof(*sel) + nk * sizeof(struct tc_u32_key), GFP_KERNEL);
+	if (!sel)
+		return -ENOMEM;
+
+	exts = kzalloc(sizeof(*exts), GFP_KERNEL);
+	if (!exts) {
+		ret = -ENOMEM;
+		goto cleanup_sel;
+	}
+
+	actions = kzalloc(nk * sizeof(*actions), GFP_KERNEL);
+	if (!actions) {
+		ret = -ENOMEM;
+		goto cleanup_exts;
+	}
+
+	act = kzalloc(nk * sizeof(*act), GFP_KERNEL);
+	if (!act) {
+		ret = -ENOMEM;
+		goto cleanup_actions;
+	}
+
+	cls_u32.command = TC_CLSU32_NEW_KNODE;
+	cls_u32.common.chain_index = 0;
+	cls_u32.common.protocol = htons(ETH_P_ALL);
+	cls_u32.knode.exts = exts;
+	cls_u32.knode.sel = sel;
+	cls_u32.knode.handle = 0x123;
+
+	exts->nr_actions = nk;
+	exts->actions = actions;
+	for (i = 0; i < nk; i++) {
+		struct tcf_gact *gact = to_gact(&act[i]);
+
+		actions[i] = &act[i];
+		gact->tcf_action = TC_ACT_SHOT;
+	}
+
+	sel->nkeys = nk;
+	sel->offshift = 0;
+	sel->keys[0].off = 6;
+	sel->keys[0].val = htonl(0xdeadbeef);
+	sel->keys[0].mask = ~0x0;
+
+	ret = stmmac_tc_setup_cls_u32(priv, priv, &cls_u32);
+	if (ret)
+		goto cleanup_act;
+
+	attr.dst = priv->dev->dev_addr;
+	attr.src = addr;
+
+	ret = __stmmac_test_loopback(priv, &attr);
+	ret = !ret; /* Shall NOT receive packet */
+
+	cls_u32.command = TC_CLSU32_DELETE_KNODE;
+	stmmac_tc_setup_cls_u32(priv, priv, &cls_u32);
+
+cleanup_act:
+	kfree(act);
+cleanup_actions:
+	kfree(actions);
+cleanup_exts:
+	kfree(exts);
+cleanup_sel:
+	kfree(sel);
+	return ret;
+}
+#else
+static int stmmac_test_rxp(struct stmmac_priv *priv)
+{
+	return -EOPNOTSUPP;
+}
+#endif
+
 #define STMMAC_LOOPBACK_NONE	0
 #define STMMAC_LOOPBACK_MAC	1
 #define STMMAC_LOOPBACK_PHY	2
@@ -969,6 +1061,10 @@ static const struct stmmac_test {
 		.name = "Double VLAN Filtering",
 		.lb = STMMAC_LOOPBACK_PHY,
 		.fn = stmmac_test_dvlanfilt,
+	}, {
+		.name = "Flexible RX Parser   ",
+		.lb = STMMAC_LOOPBACK_PHY,
+		.fn = stmmac_test_rxp,
 	},
 };
 
-- 
2.7.4


  parent reply	other threads:[~2019-08-05 16:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 16:44 [PATCH net-next 00/26] net: stmmac: Misc improvements for XGMAC Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 01/26] net: stmmac: xgmac: Fix XGMAC selftests Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 02/26] net: stmmac: xgmac: Implement MMC counters Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 03/26] net: stmmac: Fix issues when number of Queues >= 4 Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 04/26] net: stmmac: xgmac: Implement set_mtl_tx_queue_weight() Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 05/26] net: stmmac: xgmac: Implement tx_queue_prio() Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 06/26] net: stmmac: Implement RSS and enable it in XGMAC core Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 07/26] net: stmmac: selftests: Add RSS test Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 08/26] net: stmmac: Implement VLAN Hash Filtering in XGMAC Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 09/26] net: stmmac: selftests: Add test for VLAN and Double VLAN Filtering Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 10/26] net: stmmac: Implement Safety Features in XGMAC core Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 11/26] net: stmmac: Add Flexible RX Parser support in XGMAC Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 12/26] net: stmmac: tc: Do not return a fragment entry Jose Abreu
2019-08-05 16:44 ` Jose Abreu [this message]
2019-08-05 16:44 ` [PATCH net-next 14/26] net: stmmac: Get correct timestamp values from XGMAC Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 15/26] net: stmmac: Prepare to add Split Header support Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 16/26] net: stmmac: xgmac: Correctly return that RX descriptor is not last one Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 17/26] net: stmmac: Add Split Header support and enable it in XGMAC cores Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 18/26] net: stmmac: dwxgmac: Add Flexible PPS support Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 19/26] net: stmmac: Add ethtool register dump for XGMAC cores Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 20/26] net: stmmac: Add a counter for Split Header packets Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 21/26] net: stmmac: Add support for SA Insertion/Replacement in XGMAC cores Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 22/26] net: stmmac: selftests: Add tests for SA Insertion/Replacement Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 23/26] net: stmmac: xgmac: Add EEE support Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 24/26] net: stmmac: Add support for VLAN Insertion Offload Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 25/26] net: stmmac: selftests: Add selftest for VLAN TX Offload Jose Abreu
2019-08-05 16:44 ` [PATCH net-next 26/26] net: stmmac: selftests: Return proper error code to userspace Jose Abreu
2019-08-05 17:47 ` [PATCH net-next 00/26] net: stmmac: Misc improvements for XGMAC 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=1bd693a85a15c5b57a759cc4b798dd958e5bf525.1565022597.git.joabreu@synopsys.com \
    --to=jose.abreu@synopsys.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.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).