DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Boyer <aboyer@pensando.io>
To: dev@dpdk.org
Cc: Alfredo Cardigliano <cardigliano@ntop.org>,
	Andrew Boyer <aboyer@pensando.io>
Subject: [dpdk-dev] [PATCH 03/13] net/ionic: observe endianness in Rx filter code
Date: Mon, 18 Jan 2021 12:34:58 -0800	[thread overview]
Message-ID: <20210118203508.1332-4-aboyer@pensando.io> (raw)
In-Reply-To: <20210118203508.1332-1-aboyer@pensando.io>

The IONIC firmware is little-endian.
Add a new field to struct ionic_rx_filter to store the CPU-endian
match type.
Use a local variable for the VLAN when searching the hash table.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic_rx_filter.c | 22 +++++++++++-----------
 drivers/net/ionic/ionic_rx_filter.h |  1 +
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ionic/ionic_rx_filter.c b/drivers/net/ionic/ionic_rx_filter.c
index fe624538df..320b9019b3 100644
--- a/drivers/net/ionic/ionic_rx_filter.c
+++ b/drivers/net/ionic/ionic_rx_filter.c
@@ -25,7 +25,7 @@ ionic_rx_filter_del(struct ionic_lif *lif, struct ionic_rx_filter *f)
 		.pending_work = true,
 		.cmd.rx_filter_del = {
 			.opcode = IONIC_CMD_RX_FILTER_DEL,
-			.filter_id = f->filter_id,
+			.filter_id = rte_cpu_to_le_32(f->filter_id),
 		},
 	};
 
@@ -74,25 +74,24 @@ ionic_rx_filter_save(struct ionic_lif *lif, uint32_t flow_id,
 		return -ENOMEM;
 
 	f->flow_id = flow_id;
-	f->filter_id = ctx->comp.rx_filter_add.filter_id;
+	f->filter_id = rte_le_to_cpu_32(ctx->comp.rx_filter_add.filter_id);
 	f->rxq_index = rxq_index;
+	f->match = rte_le_to_cpu_16(f->cmd.match);
 	memcpy(&f->cmd, &ctx->cmd, sizeof(f->cmd));
 
-	switch (f->cmd.match) {
+	switch (f->match) {
 	case IONIC_RX_FILTER_MATCH_VLAN:
-		key = f->cmd.vlan.vlan & IONIC_RX_FILTER_HLISTS_MASK;
+		key = rte_le_to_cpu_16(f->cmd.vlan.vlan);
 		break;
 	case IONIC_RX_FILTER_MATCH_MAC:
 		memcpy(&key, f->cmd.mac.addr, sizeof(key));
-		key &= IONIC_RX_FILTER_HLISTS_MASK;
-		break;
-	case IONIC_RX_FILTER_MATCH_MAC_VLAN:
-		key = f->cmd.mac_vlan.vlan & IONIC_RX_FILTER_HLISTS_MASK;
 		break;
 	default:
 		return -EINVAL;
 	}
 
+	key &= IONIC_RX_FILTER_HLISTS_MASK;
+
 	rte_spinlock_lock(&lif->rx_filters.lock);
 
 	LIST_INSERT_HEAD(&lif->rx_filters.by_hash[key], f, by_hash);
@@ -111,11 +110,12 @@ ionic_rx_filter_by_vlan(struct ionic_lif *lif, uint16_t vid)
 {
 	uint32_t key = vid & IONIC_RX_FILTER_HLISTS_MASK;
 	struct ionic_rx_filter *f;
+	__le16 vid_le = rte_cpu_to_le_16(vid);
 
 	LIST_FOREACH(f, &lif->rx_filters.by_hash[key], by_hash) {
-		if (f->cmd.match != IONIC_RX_FILTER_MATCH_VLAN)
+		if (f->match != IONIC_RX_FILTER_MATCH_VLAN)
 			continue;
-		if (f->cmd.vlan.vlan == vid)
+		if (f->cmd.vlan.vlan == vid_le)
 			return f;
 	}
 
@@ -130,7 +130,7 @@ ionic_rx_filter_by_addr(struct ionic_lif *lif, const uint8_t *addr)
 	struct ionic_rx_filter *f;
 
 	LIST_FOREACH(f, &lif->rx_filters.by_hash[key], by_hash) {
-		if (f->cmd.match != IONIC_RX_FILTER_MATCH_MAC)
+		if (f->match != IONIC_RX_FILTER_MATCH_MAC)
 			continue;
 		if (memcmp(addr, f->cmd.mac.addr, RTE_ETHER_ADDR_LEN) == 0)
 			return f;
diff --git a/drivers/net/ionic/ionic_rx_filter.h b/drivers/net/ionic/ionic_rx_filter.h
index 6204a7b535..e1dd5f910c 100644
--- a/drivers/net/ionic/ionic_rx_filter.h
+++ b/drivers/net/ionic/ionic_rx_filter.h
@@ -15,6 +15,7 @@ struct ionic_rx_filter {
 	uint32_t flow_id;
 	uint32_t filter_id;
 	uint16_t rxq_index;
+	uint16_t match;
 	struct ionic_rx_filter_add_cmd cmd;
 	LIST_ENTRY(ionic_rx_filter) by_hash;
 	LIST_ENTRY(ionic_rx_filter) by_id;
-- 
2.17.1


  parent reply	other threads:[~2021-01-18 20:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 20:34 [dpdk-dev] [PATCH 00/13] net/ionic: fixes and optimizations Andrew Boyer
2021-01-18 20:34 ` [dpdk-dev] [PATCH 01/13] net/ionic: strip out unneeded interrupt code Andrew Boyer
2021-01-18 20:34 ` [dpdk-dev] [PATCH 02/13] net/ionic: observe endianness in firmware commands Andrew Boyer
2021-01-18 20:34 ` Andrew Boyer [this message]
2021-01-18 20:34 ` [dpdk-dev] [PATCH 04/13] net/ionic: add an array-size macro Andrew Boyer
2021-01-27 17:22   ` Ferruh Yigit
2021-01-27 17:40     ` Andrew Boyer
2021-01-29 22:44   ` [dpdk-dev] [PATCH v2 4/13] net/ionic: use the existing " Andrew Boyer
2021-02-02 12:45     ` Ferruh Yigit
2021-01-18 20:35 ` [dpdk-dev] [PATCH 05/13] net/ionic: query firmware for supported queue versions Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 06/13] net/ionic: clean up Tx queue version support Andrew Boyer
2021-01-27 17:30   ` Ferruh Yigit
2021-01-27 17:46     ` Andrew Boyer
2021-01-29 22:44   ` [dpdk-dev] [PATCH v2 6/13] " Andrew Boyer
2021-02-02 12:46     ` Ferruh Yigit
2021-02-05 20:20     ` Thomas Monjalon
2021-02-05 20:26       ` Andrew Boyer
2021-02-05 20:34         ` Thomas Monjalon
2021-01-18 20:35 ` [dpdk-dev] [PATCH 07/13] net/ionic: inline queue flush function Andrew Boyer
2021-01-27 17:36   ` Ferruh Yigit
2021-01-27 17:43     ` Andrew Boyer
2021-01-27 17:50       ` Ferruh Yigit
2021-01-18 20:35 ` [dpdk-dev] [PATCH 08/13] net/ionic: inline queue space function Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 09/13] net/ionic: observe endiannness in ioread/iowrite Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 10/13] net/ionic: fix to allow separate L3 and L4 csum offload Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 11/13] net/ionic: convert per-queue offloads into queue flags Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 12/13] net/ionic: fix up function attribute tags Andrew Boyer
2021-01-18 20:35 ` [dpdk-dev] [PATCH 13/13] net/ionic: fix address handling in transmit code Andrew Boyer
2021-01-27 18:02 ` [dpdk-dev] [PATCH 00/13] net/ionic: fixes and optimizations Ferruh Yigit
2021-01-27 18:10   ` Andrew Boyer
2021-01-27 22:23     ` Ferruh Yigit
2021-01-27 22:25       ` Ferruh Yigit
2021-01-29 22:44 [dpdk-dev] [PATCH] net: redefine array size macros Andrew Boyer
2021-02-01 22:28 ` Thomas Monjalon
2021-02-01 22:32   ` Andrew Boyer
2021-02-02 12:30     ` Ferruh Yigit
2021-02-22 17:09       ` Ferruh Yigit

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=20210118203508.1332-4-aboyer@pensando.io \
    --to=aboyer@pensando.io \
    --cc=cardigliano@ntop.org \
    --cc=dev@dpdk.org \
    /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).