* [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 14:48 ` Ferruh Yigit
2022-10-10 6:08 ` [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload Chaoyong He
` (22 subsequent siblings)
23 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the flow stats process logic in the ctrl VNIC service.
The flower firmware pass the flow stats to nfp driver through
control message, we store them in the flow_priv structure.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.h | 2 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 25 +++++++++++
drivers/net/nfp/flower/nfp_flower_ctrl.c | 73 ++++++++++++++++++++++++++++++--
drivers/net/nfp/nfp_flow.h | 20 +++++++++
4 files changed, 116 insertions(+), 4 deletions(-)
create mode 100644 drivers/net/nfp/nfp_flow.h
diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index 48f597a..b90391c 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -51,6 +51,8 @@ struct nfp_app_fw_flower {
/* PF representor */
struct nfp_flower_representor *pf_repr;
+
+ struct nfp_flow_priv *flow_priv;
};
int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev);
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 0bf8fc8..5c28363 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -129,6 +129,31 @@ struct nfp_flower_cmsg_port_mod {
rte_be16_t mtu;
};
+/*
+ * NFP_FLOWER_CMSG_TYPE_FLOW_STATS
+ * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+ * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * Word +---------------+-----------------------------------------------+
+ * 0 | Reserved | Host Context |
+ * +---------------+-----------------------------------------------+
+ * 1 | Packet Count |
+ * +---------------------------------------------------------------+
+ * 2 | Byte Count |
+ * +---------------------------------------------------------------+
+ * 2 | Byte Count |
+ * +---------------------------------------------------------------+
+ * 3 | Host Cookie |
+ * +---------------------------------------------------------------+
+ * 4 | Host Cookie |
+ * +---------------------------------------------------------------+
+ */
+struct nfp_flower_stats_frame {
+ rte_be32_t stats_con_id;
+ rte_be32_t pkt_count;
+ rte_be64_t byte_count;
+ rte_be64_t stats_cookie;
+};
+
enum nfp_flower_cmsg_port_type {
NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC,
NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT,
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index df908ef..bb9efe1 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -10,8 +10,10 @@
#include "../nfp_logs.h"
#include "../nfp_ctrl.h"
#include "../nfp_rxtx.h"
+#include "nfp_flow.h"
#include "nfp_flower.h"
#include "nfp_flower_ctrl.h"
+#include "nfp_flower_cmsg.h"
#define MAX_PKT_BURST 32
@@ -222,10 +224,74 @@
return cnt;
}
+static void
+nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
+ struct rte_mbuf *mbuf)
+{
+ char *msg;
+ uint16_t i;
+ uint16_t count;
+ uint16_t msg_len;
+ uint32_t ctx_id;
+ struct nfp_flower_stats_frame *stats;
+
+ msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+ msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
+ count = msg_len / sizeof(struct nfp_flower_stats_frame);
+
+ rte_spinlock_lock(&flow_priv->stats_lock);
+ for (i = 0; i < count; i++) {
+ stats = (struct nfp_flower_stats_frame *)msg + i;
+ ctx_id = rte_be_to_cpu_32(stats->stats_con_id);
+ flow_priv->stats[ctx_id].pkts += rte_be_to_cpu_32(stats->pkt_count);
+ flow_priv->stats[ctx_id].bytes += rte_be_to_cpu_64(stats->byte_count);
+ }
+ rte_spinlock_unlock(&flow_priv->stats_lock);
+}
+
+static void
+nfp_flower_cmsg_rx(struct nfp_flow_priv *flow_priv,
+ struct rte_mbuf **pkts_burst,
+ uint16_t count)
+{
+ uint16_t i;
+ char *meta;
+ uint32_t meta_type;
+ uint32_t meta_info;
+ struct nfp_flower_cmsg_hdr *cmsg_hdr;
+
+ for (i = 0; i < count; i++) {
+ meta = rte_pktmbuf_mtod(pkts_burst[i], char *);
+
+ /* Free the unsupported ctrl packet */
+ meta_type = rte_be_to_cpu_32(*(uint32_t *)(meta - 8));
+ meta_info = rte_be_to_cpu_32(*(uint32_t *)(meta - 4));
+ if (meta_type != NFP_NET_META_PORTID ||
+ meta_info != NFP_META_PORT_ID_CTRL) {
+ PMD_DRV_LOG(ERR, "Incorrect metadata for ctrl packet!");
+ rte_pktmbuf_free(pkts_burst[i]);
+ continue;
+ }
+
+ cmsg_hdr = (struct nfp_flower_cmsg_hdr *)meta;
+ if (unlikely(cmsg_hdr->version != NFP_FLOWER_CMSG_VER1)) {
+ PMD_DRV_LOG(ERR, "Incorrect repr control version!");
+ rte_pktmbuf_free(pkts_burst[i]);
+ continue;
+ }
+
+ if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_FLOW_STATS) {
+ /* We need to deal with stats updates from HW asap */
+ nfp_flower_cmsg_rx_stats(flow_priv, pkts_burst[i]);
+ }
+
+ rte_pktmbuf_free(pkts_burst[i]);
+ }
+}
+
void
nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower)
{
- uint16_t i;
uint16_t count;
struct nfp_net_rxq *rxq;
struct nfp_net_hw *ctrl_hw;
@@ -242,9 +308,8 @@
count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST);
if (count != 0) {
app_fw_flower->ctrl_vnic_rx_count += count;
- /* Process cmsgs here, only free for now */
- for (i = 0; i < count; i++)
- rte_pktmbuf_free(pkts_burst[i]);
+ /* Process cmsgs here */
+ nfp_flower_cmsg_rx(app_fw_flower->flow_priv, pkts_burst, count);
}
}
}
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
new file mode 100644
index 0000000..971ba69
--- /dev/null
+++ b/drivers/net/nfp/nfp_flow.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _NFP_FLOW_H_
+#define _NFP_FLOW_H_
+
+struct nfp_fl_stats {
+ uint64_t pkts;
+ uint64_t bytes;
+};
+
+struct nfp_flow_priv {
+ /* flow stats */
+ struct nfp_fl_stats *stats; /**< Store stats of flow. */
+ rte_spinlock_t stats_lock; /** < Lock the update of 'stats' field. */
+};
+
+#endif /* _NFP_FLOW_H_ */
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service
2022-10-10 6:08 ` [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service Chaoyong He
@ 2022-10-10 14:48 ` Ferruh Yigit
0 siblings, 0 replies; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-10 14:48 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund
On 10/10/2022 7:08 AM, Chaoyong He wrote:
> Add the flow stats process logic in the ctrl VNIC service.
> The flower firmware pass the flow stats to nfp driver through
> control message, we store them in the flow_priv structure.
>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
<...>
> +static void
> +nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
> + struct rte_mbuf *mbuf)
> +{
> + char *msg;
> + uint16_t i;
> + uint16_t count;
> + uint16_t msg_len;
> + uint32_t ctx_id;
> + struct nfp_flower_stats_frame *stats;
> +
> + msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
> + msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
> + count = msg_len / sizeof(struct nfp_flower_stats_frame);
> +
> + rte_spinlock_lock(&flow_priv->stats_lock);
> + for (i = 0; i < count; i++) {
> + stats = (struct nfp_flower_stats_frame *)msg + i;
> + ctx_id = rte_be_to_cpu_32(stats->stats_con_id);
> + flow_priv->stats[ctx_id].pkts += rte_be_to_cpu_32(stats->pkt_count);
> + flow_priv->stats[ctx_id].bytes += rte_be_to_cpu_64(stats->byte_count);
Like below comment, 'stats' is a pointer and I don't see any code that
allocates memory that this pointer points, at this stage it has invalid
value and above code will crash.
I assume that memory allocation is in next patch, in that case this
patch should come after it.
<...>
> void
> nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower)
> {
> - uint16_t i;
> uint16_t count;
> struct nfp_net_rxq *rxq;
> struct nfp_net_hw *ctrl_hw;
> @@ -242,9 +308,8 @@
> count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST);
> if (count != 0) {
> app_fw_flower->ctrl_vnic_rx_count += count;
> - /* Process cmsgs here, only free for now */
> - for (i = 0; i < count; i++)
> - rte_pktmbuf_free(pkts_burst[i]);
> + /* Process cmsgs here */
> + nfp_flower_cmsg_rx(app_fw_flower->flow_priv, pkts_burst, count);
At this point, as far as I can see, 'app_fw_flower->flow_priv' is not
pointing to any allocated memory, so it is an invalid pointer.
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
2022-10-10 6:08 ` [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 14:49 ` Ferruh Yigit
2022-10-10 6:08 ` [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD Chaoyong He
` (21 subsequent siblings)
23 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the structures and functions to process mask table, flow
table, and flow stats id, which are used in the rte_flow
offload logics.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 11 +-
drivers/net/nfp/meson.build | 3 +
drivers/net/nfp/nfp_flow.c | 507 ++++++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_flow.h | 81 ++++++
4 files changed, 601 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/nfp/nfp_flow.c
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 3e97f5c..3b16c12 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -15,6 +15,7 @@
#include "../nfp_ctrl.h"
#include "../nfp_cpp_bridge.h"
#include "../nfp_rxtx.h"
+#include "../nfp_flow.h"
#include "../nfpcore/nfp_mip.h"
#include "../nfpcore/nfp_rtsym.h"
#include "../nfpcore/nfp_nsp.h"
@@ -1089,13 +1090,19 @@
pf_dev->app_fw_priv = app_fw_flower;
+ ret = nfp_flow_priv_init(pf_dev);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "init flow priv failed");
+ goto app_cleanup;
+ }
+
/* Allocate memory for the PF AND ctrl vNIC here (hence the * 2) */
pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_adapter),
RTE_CACHE_LINE_SIZE, numa_node);
if (pf_hw == NULL) {
PMD_INIT_LOG(ERR, "Could not malloc nfp pf vnic");
ret = -ENOMEM;
- goto app_cleanup;
+ goto flow_priv_cleanup;
}
/* Map the PF ctrl bar */
@@ -1173,6 +1180,8 @@
nfp_cpp_area_free(pf_dev->ctrl_area);
vnic_cleanup:
rte_free(pf_hw);
+flow_priv_cleanup:
+ nfp_flow_priv_uninit(pf_dev);
app_cleanup:
rte_free(app_fw_flower);
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 8a63979..7416fd3 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -27,4 +27,7 @@ sources = files(
'nfp_cpp_bridge.c',
'nfp_ethdev_vf.c',
'nfp_ethdev.c',
+ 'nfp_flow.c',
)
+
+deps += ['hash']
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
new file mode 100644
index 0000000..97f5d1b
--- /dev/null
+++ b/drivers/net/nfp/nfp_flow.c
@@ -0,0 +1,507 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include <rte_flow_driver.h>
+#include <rte_hash.h>
+#include <rte_jhash.h>
+#include <bus_pci_driver.h>
+
+#include "nfp_common.h"
+#include "nfp_flow.h"
+#include "nfp_logs.h"
+#include "flower/nfp_flower.h"
+#include "nfpcore/nfp_mip.h"
+#include "nfpcore/nfp_rtsym.h"
+
+struct nfp_mask_id_entry {
+ uint32_t hash_key;
+ uint32_t ref_cnt;
+ uint8_t mask_id;
+};
+
+static int
+nfp_mask_id_alloc(struct nfp_flow_priv *priv, uint8_t *mask_id)
+{
+ uint8_t temp_id;
+ uint8_t freed_id;
+ struct circ_buf *ring;
+
+ /* Checking for unallocated entries first. */
+ if (priv->mask_ids.init_unallocated > 0) {
+ *mask_id = priv->mask_ids.init_unallocated;
+ priv->mask_ids.init_unallocated--;
+ return 0;
+ }
+
+ /* Checking if buffer is empty. */
+ freed_id = NFP_FLOWER_MASK_ENTRY_RS - 1;
+ ring = &priv->mask_ids.free_list;
+ if (ring->head == ring->tail) {
+ *mask_id = freed_id;
+ return -ENOENT;
+ }
+
+ rte_memcpy(&temp_id, &ring->buf[ring->tail], NFP_FLOWER_MASK_ELEMENT_RS);
+ *mask_id = temp_id;
+
+ rte_memcpy(&ring->buf[ring->tail], &freed_id, NFP_FLOWER_MASK_ELEMENT_RS);
+ ring->tail = (ring->tail + NFP_FLOWER_MASK_ELEMENT_RS) %
+ (NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS);
+
+ return 0;
+}
+
+static int
+nfp_mask_id_free(struct nfp_flow_priv *priv, uint8_t mask_id)
+{
+ struct circ_buf *ring;
+
+ ring = &priv->mask_ids.free_list;
+
+ /* Checking if buffer is full. */
+ if (CIRC_SPACE(ring->head, ring->tail, NFP_FLOWER_MASK_ENTRY_RS) == 0)
+ return -ENOBUFS;
+
+ rte_memcpy(&ring->buf[ring->head], &mask_id, NFP_FLOWER_MASK_ELEMENT_RS);
+ ring->head = (ring->head + NFP_FLOWER_MASK_ELEMENT_RS) %
+ (NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS);
+
+ return 0;
+}
+
+static int
+nfp_mask_table_add(struct nfp_flow_priv *priv,
+ char *mask_data,
+ uint32_t mask_len,
+ uint8_t *id)
+{
+ int ret;
+ uint8_t mask_id;
+ uint32_t hash_key;
+ struct nfp_mask_id_entry *mask_entry;
+
+ mask_entry = rte_zmalloc("mask_entry", sizeof(struct nfp_mask_id_entry), 0);
+ if (mask_entry == NULL) {
+ ret = -ENOMEM;
+ goto exit;
+ }
+
+ ret = nfp_mask_id_alloc(priv, &mask_id);
+ if (ret != 0)
+ goto mask_entry_free;
+
+ hash_key = rte_jhash(mask_data, mask_len, priv->hash_seed);
+ mask_entry->mask_id = mask_id;
+ mask_entry->hash_key = hash_key;
+ mask_entry->ref_cnt = 1;
+ PMD_DRV_LOG(DEBUG, "hash_key=%#x id=%u ref=%u", hash_key,
+ mask_id, mask_entry->ref_cnt);
+
+ ret = rte_hash_add_key_data(priv->mask_table, &hash_key, mask_entry);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Add to mask table failed.");
+ goto mask_id_free;
+ }
+
+ *id = mask_id;
+ return 0;
+
+mask_id_free:
+ nfp_mask_id_free(priv, mask_id);
+mask_entry_free:
+ rte_free(mask_entry);
+exit:
+ return ret;
+}
+
+static int
+nfp_mask_table_del(struct nfp_flow_priv *priv,
+ char *mask_data,
+ uint32_t mask_len,
+ uint8_t id)
+{
+ int ret;
+ uint32_t hash_key;
+
+ hash_key = rte_jhash(mask_data, mask_len, priv->hash_seed);
+ ret = rte_hash_del_key(priv->mask_table, &hash_key);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "Delete from mask table failed.");
+ return ret;
+ }
+
+ ret = nfp_mask_id_free(priv, id);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Free mask id failed.");
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct nfp_mask_id_entry *
+nfp_mask_table_search(struct nfp_flow_priv *priv,
+ char *mask_data,
+ uint32_t mask_len)
+{
+ int index;
+ uint32_t hash_key;
+ struct nfp_mask_id_entry *entry;
+
+ hash_key = rte_jhash(mask_data, mask_len, priv->hash_seed);
+ index = rte_hash_lookup_data(priv->mask_table, &hash_key, (void **)&entry);
+ if (index < 0) {
+ PMD_DRV_LOG(DEBUG, "Data NOT found in the mask table.");
+ return NULL;
+ }
+
+ return entry;
+}
+
+__rte_unused static bool
+nfp_check_mask_add(struct nfp_flow_priv *priv,
+ char *mask_data,
+ uint32_t mask_len,
+ uint8_t *meta_flags,
+ uint8_t *mask_id)
+{
+ int ret;
+ struct nfp_mask_id_entry *mask_entry;
+
+ mask_entry = nfp_mask_table_search(priv, mask_data, mask_len);
+ if (mask_entry == NULL) {
+ /* mask entry does not exist, let's create one */
+ ret = nfp_mask_table_add(priv, mask_data, mask_len, mask_id);
+ if (ret != 0)
+ return false;
+
+ *meta_flags |= NFP_FL_META_FLAG_MANAGE_MASK;
+ } else {
+ /* mask entry already exist */
+ mask_entry->ref_cnt++;
+ *mask_id = mask_entry->mask_id;
+ }
+
+ return true;
+}
+
+__rte_unused static bool
+nfp_check_mask_remove(struct nfp_flow_priv *priv,
+ char *mask_data,
+ uint32_t mask_len,
+ uint8_t *meta_flags)
+{
+ int ret;
+ struct nfp_mask_id_entry *mask_entry;
+
+ mask_entry = nfp_mask_table_search(priv, mask_data, mask_len);
+ if (mask_entry == NULL)
+ return false;
+
+ mask_entry->ref_cnt--;
+ if (mask_entry->ref_cnt == 0) {
+ ret = nfp_mask_table_del(priv, mask_data, mask_len,
+ mask_entry->mask_id);
+ if (ret != 0)
+ return false;
+
+ rte_free(mask_entry);
+ if (meta_flags)
+ *meta_flags &= ~NFP_FL_META_FLAG_MANAGE_MASK;
+ }
+
+ return true;
+}
+
+__rte_unused static int
+nfp_flow_table_add(struct nfp_flow_priv *priv,
+ struct rte_flow *nfp_flow)
+{
+ int ret;
+ char *hash_data;
+ uint32_t hash_key;
+
+ hash_data = (char *)(nfp_flow->payload.unmasked_data);
+ hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed);
+ ret = rte_hash_add_key_data(priv->flow_table, &hash_key, nfp_flow);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Add to flow table failed.");
+ return ret;
+ }
+
+ return 0;
+}
+
+__rte_unused static int
+nfp_flow_table_delete(struct nfp_flow_priv *priv,
+ struct rte_flow *nfp_flow)
+{
+ int ret;
+ char *hash_data;
+ uint32_t hash_key;
+
+ hash_data = (char *)(nfp_flow->payload.unmasked_data);
+ hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed);
+ ret = rte_hash_del_key(priv->flow_table, &hash_key);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "Delete from flow table failed.");
+ return ret;
+ }
+
+ return 0;
+}
+
+__rte_unused static struct rte_flow *
+nfp_flow_table_search(struct nfp_flow_priv *priv,
+ struct rte_flow *nfp_flow)
+{
+ int index;
+ char *hash_data;
+ uint32_t hash_key;
+ struct rte_flow *flow_find;
+
+ hash_data = (char *)(nfp_flow->payload.unmasked_data);
+ hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed);
+ index = rte_hash_lookup_data(priv->flow_table, &hash_key, (void **)&flow_find);
+ if (index < 0) {
+ PMD_DRV_LOG(DEBUG, "Data NOT found in the flow table.");
+ return NULL;
+ }
+
+ return flow_find;
+}
+
+__rte_unused static struct rte_flow *
+nfp_flow_alloc(struct nfp_fl_key_ls *key_layer)
+{
+ char *tmp;
+ size_t len;
+ struct rte_flow *nfp_flow;
+ struct nfp_fl_payload *payload;
+
+ nfp_flow = rte_zmalloc("nfp_flow", sizeof(struct rte_flow), 0);
+ if (nfp_flow == NULL)
+ goto exit;
+
+ len = key_layer->key_size + key_layer->key_size + key_layer->act_size;
+ tmp = rte_zmalloc("nfp_flow_payload", len + sizeof(struct nfp_fl_rule_metadata), 0);
+ if (tmp == NULL)
+ goto free_flow;
+
+ nfp_flow->length = len;
+
+ payload = &nfp_flow->payload;
+ payload->meta = (struct nfp_fl_rule_metadata *)tmp;
+ payload->unmasked_data = tmp + sizeof(struct nfp_fl_rule_metadata);
+ payload->mask_data = payload->unmasked_data + key_layer->key_size;
+ payload->action_data = payload->mask_data + key_layer->key_size;
+
+ return nfp_flow;
+
+free_flow:
+ rte_free(nfp_flow);
+exit:
+ return NULL;
+}
+
+__rte_unused static void
+nfp_flow_free(struct rte_flow *nfp_flow)
+{
+ rte_free(nfp_flow->payload.meta);
+ rte_free(nfp_flow);
+}
+
+__rte_unused static int
+nfp_stats_id_alloc(struct nfp_flow_priv *priv, uint32_t *ctx)
+{
+ struct circ_buf *ring;
+ uint32_t freed_stats_id;
+ uint32_t temp_stats_id;
+
+ /* Check for unallocated entries first. */
+ if (priv->stats_ids.init_unallocated > 0) {
+ *ctx = ((priv->stats_ids.init_unallocated - 1) & NFP_FL_STAT_ID_STAT) |
+ (priv->active_mem_unit & NFP_FL_STAT_ID_MU_NUM);
+ if (++priv->active_mem_unit == priv->total_mem_units) {
+ priv->stats_ids.init_unallocated--;
+ priv->active_mem_unit = 0;
+ }
+ return 0;
+ }
+
+ /* Check if buffer is empty */
+ ring = &priv->stats_ids.free_list;
+ freed_stats_id = priv->stats_ring_size;
+ if (ring->head == ring->tail) {
+ *ctx = freed_stats_id;
+ return -ENOENT;
+ }
+
+ memcpy(&temp_stats_id, &ring->buf[ring->tail], NFP_FL_STATS_ELEM_RS);
+ *ctx = temp_stats_id;
+ memcpy(&ring->buf[ring->tail], &freed_stats_id, NFP_FL_STATS_ELEM_RS);
+ ring->tail = (ring->tail + NFP_FL_STATS_ELEM_RS) %
+ (priv->stats_ring_size * NFP_FL_STATS_ELEM_RS);
+
+ return 0;
+}
+
+__rte_unused static int
+nfp_stats_id_free(struct nfp_flow_priv *priv, uint32_t ctx)
+{
+ struct circ_buf *ring;
+
+ /* Check if buffer is full */
+ ring = &priv->stats_ids.free_list;
+ if (!CIRC_SPACE(ring->head, ring->tail, priv->stats_ring_size *
+ NFP_FL_STATS_ELEM_RS - NFP_FL_STATS_ELEM_RS + 1))
+ return -ENOBUFS;
+
+ memcpy(&ring->buf[ring->head], &ctx, NFP_FL_STATS_ELEM_RS);
+ ring->head = (ring->head + NFP_FL_STATS_ELEM_RS) %
+ (priv->stats_ring_size * NFP_FL_STATS_ELEM_RS);
+
+ return 0;
+}
+
+int
+nfp_flow_priv_init(struct nfp_pf_dev *pf_dev)
+{
+ int ret = 0;
+ uint64_t ctx_count;
+ uint64_t ctx_split;
+ size_t stats_size;
+ struct nfp_flow_priv *priv;
+ struct nfp_app_fw_flower *app_fw_flower;
+
+ struct rte_hash_parameters mask_hash_params = {
+ .name = "mask_hash_table",
+ .entries = NFP_MASK_TABLE_ENTRIES,
+ .hash_func = rte_jhash,
+ .socket_id = rte_socket_id(),
+ .key_len = sizeof(uint32_t),
+ .extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY,
+ };
+
+ struct rte_hash_parameters flow_hash_params = {
+ .name = "flow_hash_table",
+ .hash_func = rte_jhash,
+ .socket_id = rte_socket_id(),
+ .key_len = sizeof(uint32_t),
+ .extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY,
+ };
+
+ ctx_count = nfp_rtsym_read_le(pf_dev->sym_tbl,
+ "CONFIG_FC_HOST_CTX_COUNT", &ret);
+ if (ret < 0) {
+ PMD_INIT_LOG(ERR, "Read CTX_COUNT from symbol table failed");
+ goto exit;
+ }
+
+ ctx_split = nfp_rtsym_read_le(pf_dev->sym_tbl,
+ "CONFIG_FC_HOST_CTX_SPLIT", &ret);
+ if (ret < 0) {
+ PMD_INIT_LOG(ERR, "Read CTX_SPLIT from symbol table failed");
+ goto exit;
+ }
+
+ priv = rte_zmalloc("nfp_app_flow_priv", sizeof(struct nfp_flow_priv), 0);
+ if (priv == NULL) {
+ PMD_INIT_LOG(ERR, "nfp app flow priv creation failed");
+ ret = -ENOMEM;
+ goto exit;
+ }
+
+ app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv);
+ app_fw_flower->flow_priv = priv;
+ priv->hash_seed = (uint32_t)rte_rand();
+ priv->stats_ring_size = ctx_count;
+ priv->total_mem_units = ctx_split;
+
+ /* Init ring buffer and unallocated mask_ids. */
+ priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1;
+ priv->mask_ids.free_list.buf = rte_zmalloc("nfp_app_mask_ids",
+ NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS, 0);
+ if (priv->mask_ids.free_list.buf == NULL) {
+ PMD_INIT_LOG(ERR, "mask id free list creation failed");
+ ret = -ENOMEM;
+ goto free_priv;
+ }
+
+ /* Init ring buffer and unallocated stats_ids. */
+ priv->stats_ids.init_unallocated = ctx_count / ctx_split;
+ priv->stats_ids.free_list.buf = rte_zmalloc("nfp_app_stats_ids",
+ priv->stats_ring_size * NFP_FL_STATS_ELEM_RS, 0);
+ if (priv->stats_ids.free_list.buf == NULL) {
+ PMD_INIT_LOG(ERR, "stats id free list creation failed");
+ ret = -ENOMEM;
+ goto free_mask_id;
+ }
+
+ /* flow stats */
+ rte_spinlock_init(&priv->stats_lock);
+ stats_size = (ctx_count & NFP_FL_STAT_ID_STAT) |
+ ((ctx_split - 1) & NFP_FL_STAT_ID_MU_NUM);
+ PMD_INIT_LOG(INFO, "ctx_count:%0lx, ctx_split:%0lx, stats_size:%0lx ",
+ ctx_count, ctx_split, stats_size);
+ priv->stats = rte_zmalloc("nfp_flow_stats",
+ stats_size * sizeof(struct nfp_fl_stats), 0);
+ if (priv->stats == NULL) {
+ PMD_INIT_LOG(ERR, "flow stats creation failed");
+ ret = -ENOMEM;
+ goto free_stats_id;
+ }
+
+ /* mask table */
+ mask_hash_params.hash_func_init_val = priv->hash_seed;
+ priv->mask_table = rte_hash_create(&mask_hash_params);
+ if (priv->mask_table == NULL) {
+ PMD_INIT_LOG(ERR, "mask hash table creation failed");
+ ret = -ENOMEM;
+ goto free_stats;
+ }
+
+ /* flow table */
+ flow_hash_params.hash_func_init_val = priv->hash_seed;
+ flow_hash_params.entries = ctx_count;
+ priv->flow_table = rte_hash_create(&flow_hash_params);
+ if (priv->flow_table == NULL) {
+ PMD_INIT_LOG(ERR, "flow hash table creation failed");
+ ret = -ENOMEM;
+ goto free_mask_table;
+ }
+
+ return 0;
+
+free_mask_table:
+ rte_free(priv->mask_table);
+free_stats:
+ rte_free(priv->stats);
+free_stats_id:
+ rte_free(priv->stats_ids.free_list.buf);
+free_mask_id:
+ rte_free(priv->mask_ids.free_list.buf);
+free_priv:
+ rte_free(priv);
+exit:
+ return ret;
+}
+
+void
+nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev)
+{
+ struct nfp_app_fw_flower *app_fw_flower;
+ struct nfp_flow_priv *priv;
+
+ app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv);
+ priv = app_fw_flower->flow_priv;
+
+ rte_hash_free(priv->flow_table);
+ rte_hash_free(priv->mask_table);
+ rte_free(priv->stats);
+ rte_free(priv->stats_ids.free_list.buf);
+ rte_free(priv->mask_ids.free_list.buf);
+ rte_free(priv);
+}
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index 971ba69..142d7d5 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,15 +6,96 @@
#ifndef _NFP_FLOW_H_
#define _NFP_FLOW_H_
+#define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7)
+
+#define NFP_MASK_TABLE_ENTRIES 1024
+
+enum nfp_flower_tun_type {
+ NFP_FL_TUN_NONE = 0,
+ NFP_FL_TUN_GRE = 1,
+ NFP_FL_TUN_VXLAN = 2,
+ NFP_FL_TUN_GENEVE = 4,
+};
+
+struct nfp_fl_key_ls {
+ uint32_t key_layer_two;
+ uint8_t key_layer;
+ int key_size;
+ int act_size;
+ uint32_t port;
+ uint16_t vlan;
+ enum nfp_flower_tun_type tun_type;
+};
+
+struct nfp_fl_rule_metadata {
+ uint8_t key_len;
+ uint8_t mask_len;
+ uint8_t act_len;
+ uint8_t flags;
+ rte_be32_t host_ctx_id;
+ rte_be64_t host_cookie __rte_packed;
+ rte_be64_t flow_version __rte_packed;
+ rte_be32_t shortcut;
+};
+
+struct nfp_fl_payload {
+ struct nfp_fl_rule_metadata *meta;
+ char *unmasked_data;
+ char *mask_data;
+ char *action_data;
+};
+
+#define CIRC_CNT(head, tail, size) (((head) - (tail)) & ((size) - 1))
+#define CIRC_SPACE(head, tail, size) CIRC_CNT((tail), ((head) + 1), (size))
+struct circ_buf {
+ uint32_t head;
+ uint32_t tail;
+ char *buf;
+};
+
+#define NFP_FLOWER_MASK_ENTRY_RS 256
+#define NFP_FLOWER_MASK_ELEMENT_RS sizeof(uint8_t)
+struct nfp_fl_mask_id {
+ struct circ_buf free_list;
+ uint8_t init_unallocated;
+};
+
+#define NFP_FL_STATS_ELEM_RS sizeof(uint32_t)
+struct nfp_fl_stats_id {
+ struct circ_buf free_list;
+ uint32_t init_unallocated;
+};
+
+#define NFP_FL_STAT_ID_MU_NUM 0xffc00000
+#define NFP_FL_STAT_ID_STAT 0x003fffff
struct nfp_fl_stats {
uint64_t pkts;
uint64_t bytes;
};
struct nfp_flow_priv {
+ uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */
+ /* mask hash table */
+ struct nfp_fl_mask_id mask_ids; /**< Entry for mask hash table */
+ struct rte_hash *mask_table; /**< Hash table to store mask ids. */
+ /* flow hash table */
+ struct rte_hash *flow_table; /**< Hash table to store flow rules. */
/* flow stats */
+ uint32_t active_mem_unit; /**< The size of active mem units. */
+ uint32_t total_mem_units; /**< The size of total mem units. */
+ uint32_t stats_ring_size; /**< The size of stats id ring. */
+ struct nfp_fl_stats_id stats_ids; /**< The stats id ring. */
struct nfp_fl_stats *stats; /**< Store stats of flow. */
rte_spinlock_t stats_lock; /** < Lock the update of 'stats' field. */
};
+struct rte_flow {
+ struct nfp_fl_payload payload;
+ size_t length;
+ bool install_flag;
+};
+
+int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev);
+void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev);
+
#endif /* _NFP_FLOW_H_ */
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload
2022-10-10 6:08 ` [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload Chaoyong He
@ 2022-10-10 14:49 ` Ferruh Yigit
2022-10-19 2:50 ` Chaoyong He
0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-10 14:49 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund
On 10/10/2022 7:08 AM, Chaoyong He wrote:
> Add the structures and functions to process mask table, flow
> table, and flow stats id, which are used in the rte_flow
> offload logics.
>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
<...>
> +__rte_unused static int
> +nfp_flow_table_delete(struct nfp_flow_priv *priv,
> + struct rte_flow *nfp_flow)
> +{
> + int ret;
> + char *hash_data;
> + uint32_t hash_key;
> +
> + hash_data = (char *)(nfp_flow->payload.unmasked_data);
> + hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed);
It can be an option to store hash information in 'struct rte_flow',
instead of keep calculating it.
<...>
> + /* flow stats */
> + rte_spinlock_init(&priv->stats_lock);
> + stats_size = (ctx_count & NFP_FL_STAT_ID_STAT) |
> + ((ctx_split - 1) & NFP_FL_STAT_ID_MU_NUM);
> + PMD_INIT_LOG(INFO, "ctx_count:%0lx, ctx_split:%0lx, stats_size:%0lx ",
> + ctx_count, ctx_split, stats_size);
> + priv->stats = rte_zmalloc("nfp_flow_stats",
> + stats_size * sizeof(struct nfp_fl_stats), 0);
Is this allocates 'stats' for max possible flow rule count? Isn't this a
too big number to allocate in advance?
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload
2022-10-10 14:49 ` Ferruh Yigit
@ 2022-10-19 2:50 ` Chaoyong He
2022-10-19 10:48 ` Ferruh Yigit
0 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-19 2:50 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: oss-drivers, Niklas Soderlund
> On 10/10/2022 7:08 AM, Chaoyong He wrote:
> > Add the structures and functions to process mask table, flow table,
> > and flow stats id, which are used in the rte_flow offload logics.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>
> <...>
>
> > +__rte_unused static int
> > +nfp_flow_table_delete(struct nfp_flow_priv *priv,
> > + struct rte_flow *nfp_flow) {
> > + int ret;
> > + char *hash_data;
> > + uint32_t hash_key;
> > +
> > + hash_data = (char *)(nfp_flow->payload.unmasked_data);
> > + hash_key = rte_jhash(hash_data, nfp_flow->length,
> > + priv->hash_seed);
>
> It can be an option to store hash information in 'struct rte_flow', instead of
> keep calculating it.
>
Okay, I will revise like this in the next version patch, thanks.
> <...>
>
> > + /* flow stats */
> > + rte_spinlock_init(&priv->stats_lock);
> > + stats_size = (ctx_count & NFP_FL_STAT_ID_STAT) |
> > + ((ctx_split - 1) & NFP_FL_STAT_ID_MU_NUM);
> > + PMD_INIT_LOG(INFO, "ctx_count:%0lx, ctx_split:%0lx, stats_size:%0lx
> ",
> > + ctx_count, ctx_split, stats_size);
> > + priv->stats = rte_zmalloc("nfp_flow_stats",
> > + stats_size * sizeof(struct nfp_fl_stats), 0);
>
> Is this allocates 'stats' for max possible flow rule count? Isn't this a too big
> number to allocate in advance?
For now, the 'stats_size' for our card is 500,000, and sizeof(structure nfp_fl_stats) is 16,
so the size of memory need alloc here is about 8MB. Maybe it's not a very big memory?
And we also calculate an index use these two macros(in function nfp_stats_id_alloc()),
and then send it to firmware, and the firmware will send the stats with this index to PMD.
If we alloc a small memory at start and then enlarge it at some point, we can't make sure
the index we calculated is unique anymore, and the stats will confusion, which is not good.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload
2022-10-19 2:50 ` Chaoyong He
@ 2022-10-19 10:48 ` Ferruh Yigit
0 siblings, 0 replies; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-19 10:48 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, Niklas Soderlund
On 10/19/2022 3:50 AM, Chaoyong He wrote:
>> On 10/10/2022 7:08 AM, Chaoyong He wrote:
>>> Add the structures and functions to process mask table, flow table,
>>> and flow stats id, which are used in the rte_flow offload logics.
>>>
>>> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
>>> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>>
>> <...>
>>
>>> +__rte_unused static int
>>> +nfp_flow_table_delete(struct nfp_flow_priv *priv,
>>> + struct rte_flow *nfp_flow) {
>>> + int ret;
>>> + char *hash_data;
>>> + uint32_t hash_key;
>>> +
>>> + hash_data = (char *)(nfp_flow->payload.unmasked_data);
>>> + hash_key = rte_jhash(hash_data, nfp_flow->length,
>>> + priv->hash_seed);
>>
>> It can be an option to store hash information in 'struct rte_flow', instead of
>> keep calculating it.
>>
>
> Okay, I will revise like this in the next version patch, thanks.
>
>> <...>
>>
>>> + /* flow stats */
>>> + rte_spinlock_init(&priv->stats_lock);
>>> + stats_size = (ctx_count & NFP_FL_STAT_ID_STAT) |
>>> + ((ctx_split - 1) & NFP_FL_STAT_ID_MU_NUM);
>>> + PMD_INIT_LOG(INFO, "ctx_count:%0lx, ctx_split:%0lx, stats_size:%0lx
>> ",
>>> + ctx_count, ctx_split, stats_size);
>>> + priv->stats = rte_zmalloc("nfp_flow_stats",
>>> + stats_size * sizeof(struct nfp_fl_stats), 0);
>>
>> Is this allocates 'stats' for max possible flow rule count? Isn't this a too big
>> number to allocate in advance?
>
> For now, the 'stats_size' for our card is 500,000, and sizeof(structure nfp_fl_stats) is 16,
> so the size of memory need alloc here is about 8MB. Maybe it's not a very big memory?
>
agree, 8MB doesn't look much.
> And we also calculate an index use these two macros(in function nfp_stats_id_alloc()),
> and then send it to firmware, and the firmware will send the stats with this index to PMD.
> If we alloc a small memory at start and then enlarge it at some point, we can't make sure
> the index we calculated is unique anymore, and the stats will confusion, which is not good.
>
ack
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
2022-10-10 6:08 ` [PATCH v2 01/24] net/nfp: add the stats process logic in ctrl VNIC service Chaoyong He
2022-10-10 6:08 ` [PATCH v2 02/24] net/nfp: add the structures and functions for flow offload Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 14:51 ` Ferruh Yigit
2022-10-10 6:08 ` [PATCH v2 04/24] net/nfp: add the offload support of basic items Chaoyong He
` (20 subsequent siblings)
23 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the flow validate/create/query/destroy/flush API of nfp PMD.
The flow create API construct a control cmsg and send it to
firmware, then add this flow to the hash table.
The flow query API get flow stats from the flow_priv structure.
Note there exist an rte_spin_lock to prevent the update and query
action occur at the same time.
The flow destroy API construct a control cmsg and send it to
firmware, then adelete this flow from the hash table.
The flow flush API just iterate the flows in hash table and
call the flow destroy API.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_cmsg.c | 69 +++
drivers/net/nfp/flower/nfp_flower_cmsg.h | 48 ++
drivers/net/nfp/flower/nfp_flower_representor.c | 3 +
drivers/net/nfp/nfp_flow.c | 573 +++++++++++++++++++++++-
drivers/net/nfp/nfp_flow.h | 28 ++
5 files changed, 712 insertions(+), 9 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 750a629..15d8381 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -6,6 +6,7 @@
#include "../nfpcore/nfp_nsp.h"
#include "../nfp_logs.h"
#include "../nfp_common.h"
+#include "../nfp_flow.h"
#include "nfp_flower.h"
#include "nfp_flower_cmsg.h"
#include "nfp_flower_ctrl.h"
@@ -177,3 +178,71 @@
return 0;
}
+
+int
+nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower,
+ struct rte_flow *flow)
+{
+ char *msg;
+ uint16_t cnt;
+ uint32_t msg_len;
+ struct rte_mbuf *mbuf;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+
+ mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
+ if (mbuf == NULL) {
+ PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow delete.");
+ return -ENOMEM;
+ }
+
+ /* Copy the flow to mbuf */
+ nfp_flow_meta = flow->payload.meta;
+ msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len +
+ nfp_flow_meta->act_len) << NFP_FL_LW_SIZ;
+ msg_len += sizeof(struct nfp_fl_rule_metadata);
+ msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_FLOW_DEL, msg_len);
+ rte_memcpy(msg, flow->payload.meta, msg_len);
+
+ cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
+ if (cnt == 0) {
+ PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
+ rte_pktmbuf_free(mbuf);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int
+nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower,
+ struct rte_flow *flow)
+{
+ char *msg;
+ uint16_t cnt;
+ uint32_t msg_len;
+ struct rte_mbuf *mbuf;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+
+ mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
+ if (mbuf == NULL) {
+ PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow add.");
+ return -ENOMEM;
+ }
+
+ /* copy the flow to mbuf */
+ nfp_flow_meta = flow->payload.meta;
+ msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len +
+ nfp_flow_meta->act_len) << NFP_FL_LW_SIZ;
+ msg_len += sizeof(struct nfp_fl_rule_metadata);
+ msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_FLOW_ADD, msg_len);
+ rte_memcpy(msg, flow->payload.meta, msg_len);
+
+ cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
+ if (cnt == 0) {
+ PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
+ rte_pktmbuf_free(mbuf);
+ return -EIO;
+ }
+
+ return 0;
+}
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 5c28363..6045bb0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -189,10 +189,58 @@ enum nfp_flower_cmsg_port_vnic_type {
return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
}
+/*
+ * Metadata with L2 (1W/4B)
+ * ----------------------------------------------------------------
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | key_type | mask_id | PCP |p| vlan outermost VID |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ^ ^
+ * NOTE: | TCI |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_meta_tci {
+ uint8_t nfp_flow_key_layer;
+ uint8_t mask_id;
+ rte_be16_t tci;
+};
+
+/*
+ * Extended metadata for additional key_layers (1W/4B)
+ * ----------------------------------------------------------------
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | nfp_flow_key_layer2 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_ext_meta {
+ rte_be32_t nfp_flow_key_layer2;
+};
+
+/*
+ * L1 Port details (1W/4B)
+ * ----------------------------------------------------------------
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | port_ingress |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_in_port {
+ rte_be32_t in_port;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
int nfp_flower_cmsg_port_mod(struct nfp_app_fw_flower *app_fw_flower,
uint32_t port_id, bool carrier_ok);
+int nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower,
+ struct rte_flow *flow);
+int nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower,
+ struct rte_flow *flow);
#endif /* _NFP_CMSG_H_ */
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 0e60f50..f1cd298 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -10,6 +10,7 @@
#include "../nfp_logs.h"
#include "../nfp_ctrl.h"
#include "../nfp_rxtx.h"
+#include "../nfp_flow.h"
#include "../nfpcore/nfp_mip.h"
#include "../nfpcore/nfp_rtsym.h"
#include "../nfpcore/nfp_nsp.h"
@@ -590,6 +591,8 @@
.promiscuous_disable = nfp_flower_repr_promiscuous_disable,
.mac_addr_set = nfp_flower_repr_mac_addr_set,
+
+ .flow_ops_get = nfp_net_flow_ops_get,
};
static uint32_t
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 97f5d1b..114686f 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -7,11 +7,15 @@
#include <rte_hash.h>
#include <rte_jhash.h>
#include <bus_pci_driver.h>
+#include <rte_malloc.h>
#include "nfp_common.h"
#include "nfp_flow.h"
#include "nfp_logs.h"
#include "flower/nfp_flower.h"
+#include "flower/nfp_flower_cmsg.h"
+#include "flower/nfp_flower_ctrl.h"
+#include "flower/nfp_flower_representor.h"
#include "nfpcore/nfp_mip.h"
#include "nfpcore/nfp_rtsym.h"
@@ -21,6 +25,15 @@ struct nfp_mask_id_entry {
uint8_t mask_id;
};
+static inline struct nfp_flow_priv *
+nfp_flow_dev_to_priv(struct rte_eth_dev *dev)
+{
+ struct nfp_flower_representor *repr;
+
+ repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ return repr->app_fw_flower->flow_priv;
+}
+
static int
nfp_mask_id_alloc(struct nfp_flow_priv *priv, uint8_t *mask_id)
{
@@ -160,7 +173,7 @@ struct nfp_mask_id_entry {
return entry;
}
-__rte_unused static bool
+static bool
nfp_check_mask_add(struct nfp_flow_priv *priv,
char *mask_data,
uint32_t mask_len,
@@ -187,7 +200,7 @@ struct nfp_mask_id_entry {
return true;
}
-__rte_unused static bool
+static bool
nfp_check_mask_remove(struct nfp_flow_priv *priv,
char *mask_data,
uint32_t mask_len,
@@ -215,7 +228,7 @@ struct nfp_mask_id_entry {
return true;
}
-__rte_unused static int
+static int
nfp_flow_table_add(struct nfp_flow_priv *priv,
struct rte_flow *nfp_flow)
{
@@ -234,7 +247,7 @@ struct nfp_mask_id_entry {
return 0;
}
-__rte_unused static int
+static int
nfp_flow_table_delete(struct nfp_flow_priv *priv,
struct rte_flow *nfp_flow)
{
@@ -253,7 +266,7 @@ struct nfp_mask_id_entry {
return 0;
}
-__rte_unused static struct rte_flow *
+static struct rte_flow *
nfp_flow_table_search(struct nfp_flow_priv *priv,
struct rte_flow *nfp_flow)
{
@@ -273,7 +286,7 @@ struct nfp_mask_id_entry {
return flow_find;
}
-__rte_unused static struct rte_flow *
+static struct rte_flow *
nfp_flow_alloc(struct nfp_fl_key_ls *key_layer)
{
char *tmp;
@@ -306,14 +319,14 @@ struct nfp_mask_id_entry {
return NULL;
}
-__rte_unused static void
+static void
nfp_flow_free(struct rte_flow *nfp_flow)
{
rte_free(nfp_flow->payload.meta);
rte_free(nfp_flow);
}
-__rte_unused static int
+static int
nfp_stats_id_alloc(struct nfp_flow_priv *priv, uint32_t *ctx)
{
struct circ_buf *ring;
@@ -348,7 +361,7 @@ struct nfp_mask_id_entry {
return 0;
}
-__rte_unused static int
+static int
nfp_stats_id_free(struct nfp_flow_priv *priv, uint32_t ctx)
{
struct circ_buf *ring;
@@ -366,6 +379,548 @@ struct nfp_mask_id_entry {
return 0;
}
+static void
+nfp_flower_compile_meta_tci(char *mbuf_off, struct nfp_fl_key_ls *key_layer)
+{
+ struct nfp_flower_meta_tci *tci_meta;
+
+ tci_meta = (struct nfp_flower_meta_tci *)mbuf_off;
+ tci_meta->nfp_flow_key_layer = key_layer->key_layer;
+ tci_meta->mask_id = ~0;
+ tci_meta->tci = rte_cpu_to_be_16(key_layer->vlan);
+}
+
+static void
+nfp_flower_update_meta_tci(char *exact, uint8_t mask_id)
+{
+ struct nfp_flower_meta_tci *meta_tci;
+
+ meta_tci = (struct nfp_flower_meta_tci *)exact;
+ meta_tci->mask_id = mask_id;
+}
+
+static void
+nfp_flower_compile_ext_meta(char *mbuf_off, struct nfp_fl_key_ls *key_layer)
+{
+ struct nfp_flower_ext_meta *ext_meta;
+
+ ext_meta = (struct nfp_flower_ext_meta *)mbuf_off;
+ ext_meta->nfp_flow_key_layer2 = rte_cpu_to_be_32(key_layer->key_layer_two);
+}
+
+static void
+nfp_compile_meta_port(char *mbuf_off,
+ struct nfp_fl_key_ls *key_layer,
+ bool is_mask)
+{
+ struct nfp_flower_in_port *port_meta;
+
+ port_meta = (struct nfp_flower_in_port *)mbuf_off;
+
+ if (is_mask)
+ port_meta->in_port = rte_cpu_to_be_32(~0);
+ else if (key_layer->tun_type)
+ port_meta->in_port = rte_cpu_to_be_32(NFP_FL_PORT_TYPE_TUN |
+ key_layer->tun_type);
+ else
+ port_meta->in_port = rte_cpu_to_be_32(key_layer->port);
+}
+
+static void
+nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
+ struct rte_flow *nfp_flow,
+ struct nfp_fl_key_ls *key_layer,
+ uint32_t stats_ctx)
+{
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+ char *mbuf_off_exact;
+ char *mbuf_off_mask;
+
+ /*
+ * Convert to long words as firmware expects
+ * lengths in units of NFP_FL_LW_SIZ.
+ */
+ nfp_flow_meta = nfp_flow->payload.meta;
+ nfp_flow_meta->key_len = key_layer->key_size >> NFP_FL_LW_SIZ;
+ nfp_flow_meta->mask_len = key_layer->key_size >> NFP_FL_LW_SIZ;
+ nfp_flow_meta->act_len = key_layer->act_size >> NFP_FL_LW_SIZ;
+ nfp_flow_meta->flags = 0;
+ nfp_flow_meta->host_ctx_id = rte_cpu_to_be_32(stats_ctx);
+ nfp_flow_meta->host_cookie = rte_rand();
+ nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version);
+ priv->flower_version++;
+
+ mbuf_off_exact = nfp_flow->payload.unmasked_data;
+ mbuf_off_mask = nfp_flow->payload.mask_data;
+
+ /* Populate Metadata */
+ nfp_flower_compile_meta_tci(mbuf_off_exact, key_layer);
+ nfp_flower_compile_meta_tci(mbuf_off_mask, key_layer);
+ mbuf_off_exact += sizeof(struct nfp_flower_meta_tci);
+ mbuf_off_mask += sizeof(struct nfp_flower_meta_tci);
+
+ /* Populate Extended Metadata if required */
+ if (key_layer->key_layer & NFP_FLOWER_LAYER_EXT_META) {
+ nfp_flower_compile_ext_meta(mbuf_off_exact, key_layer);
+ nfp_flower_compile_ext_meta(mbuf_off_mask, key_layer);
+ mbuf_off_exact += sizeof(struct nfp_flower_ext_meta);
+ mbuf_off_mask += sizeof(struct nfp_flower_ext_meta);
+ }
+
+ /* Populate Port Data */
+ nfp_compile_meta_port(mbuf_off_exact, key_layer, false);
+ nfp_compile_meta_port(mbuf_off_mask, key_layer, true);
+ mbuf_off_exact += sizeof(struct nfp_flower_in_port);
+ mbuf_off_mask += sizeof(struct nfp_flower_in_port);
+}
+
+static int
+nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
+ __rte_unused struct nfp_fl_key_ls *key_ls)
+{
+ const struct rte_flow_item *item;
+
+ for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
+ switch (item->type) {
+ default:
+ PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
+ return -ENOTSUP;
+ }
+ }
+
+ return 0;
+}
+
+static int
+nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
+ struct nfp_fl_key_ls *key_ls)
+{
+ int ret = 0;
+ const struct rte_flow_action *action;
+
+ for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
+ /* Make sure actions length no longer than NFP_FL_MAX_A_SIZ */
+ if (key_ls->act_size > NFP_FL_MAX_A_SIZ) {
+ PMD_DRV_LOG(ERR, "The action list is too long.");
+ ret = -ERANGE;
+ break;
+ }
+
+ switch (action->type) {
+ case RTE_FLOW_ACTION_TYPE_VOID:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VOID detected");
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
+ return -ENOTSUP;
+ }
+ }
+
+ return ret;
+}
+
+static int
+nfp_flow_key_layers_calculate(const struct rte_flow_item items[],
+ const struct rte_flow_action actions[],
+ struct nfp_fl_key_ls *key_ls)
+{
+ int ret = 0;
+
+ key_ls->key_layer_two = 0;
+ key_ls->key_layer = NFP_FLOWER_LAYER_PORT;
+ key_ls->key_size = sizeof(struct nfp_flower_meta_tci) +
+ sizeof(struct nfp_flower_in_port);
+ key_ls->act_size = 0;
+ key_ls->port = ~0;
+ key_ls->vlan = 0;
+ key_ls->tun_type = NFP_FL_TUN_NONE;
+
+ ret |= nfp_flow_key_layers_calculate_items(items, key_ls);
+ ret |= nfp_flow_key_layers_calculate_actions(actions, key_ls);
+
+ return ret;
+}
+
+static struct rte_flow *
+nfp_flow_process(struct nfp_flower_representor *representor,
+ const struct rte_flow_item items[],
+ const struct rte_flow_action actions[])
+{
+ int ret;
+ char *mask_data;
+ uint32_t mask_len;
+ uint32_t stats_ctx = 0;
+ uint8_t new_mask_id = 0;
+ struct rte_flow *nfp_flow;
+ struct rte_flow *flow_find;
+ struct nfp_flow_priv *priv;
+ struct nfp_fl_key_ls key_layer;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+
+ ret = nfp_flow_key_layers_calculate(items, actions, &key_layer);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Key layers calculate failed.");
+ return NULL;
+ }
+
+ if (key_layer.port == (uint32_t)~0)
+ key_layer.port = representor->port_id;
+
+ priv = representor->app_fw_flower->flow_priv;
+ ret = nfp_stats_id_alloc(priv, &stats_ctx);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp stats id alloc failed.");
+ return NULL;
+ }
+
+ nfp_flow = nfp_flow_alloc(&key_layer);
+ if (nfp_flow == NULL) {
+ PMD_DRV_LOG(ERR, "Alloc nfp flow failed.");
+ goto free_stats;
+ }
+
+ nfp_flow->install_flag = true;
+
+ nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx);
+
+ nfp_flow_meta = nfp_flow->payload.meta;
+ mask_data = nfp_flow->payload.mask_data;
+ mask_len = key_layer.key_size;
+ if (!nfp_check_mask_add(priv, mask_data, mask_len,
+ &nfp_flow_meta->flags, &new_mask_id)) {
+ PMD_DRV_LOG(ERR, "nfp mask add check failed.");
+ goto free_flow;
+ }
+
+ /* Once we have a mask_id, update the meta tci */
+ nfp_flower_update_meta_tci(nfp_flow->payload.unmasked_data, new_mask_id);
+
+ /* Find the flow in hash table */
+ flow_find = nfp_flow_table_search(priv, nfp_flow);
+ if (flow_find != NULL) {
+ PMD_DRV_LOG(ERR, "This flow is already exist.");
+ if (!nfp_check_mask_remove(priv, mask_data, mask_len,
+ &nfp_flow_meta->flags)) {
+ PMD_DRV_LOG(ERR, "nfp mask del check failed.");
+ }
+ goto free_flow;
+ }
+
+ return nfp_flow;
+
+free_flow:
+ nfp_flow_free(nfp_flow);
+free_stats:
+ nfp_stats_id_free(priv, stats_ctx);
+
+ return NULL;
+}
+
+static struct rte_flow *
+nfp_flow_setup(struct nfp_flower_representor *representor,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item items[],
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ if (attr->group != 0)
+ PMD_DRV_LOG(INFO, "Pretend we support group attribute.");
+
+ if (attr->priority != 0)
+ PMD_DRV_LOG(INFO, "Pretend we support priority attribute.");
+
+ if (attr->transfer != 0)
+ PMD_DRV_LOG(INFO, "Pretend we support transfer attribute.");
+
+ if (attr->egress != 0) {
+ rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
+ NULL, "Egress is not supported.");
+ return NULL;
+ }
+
+ if (attr->ingress == 0) {
+ rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
+ NULL, "Only ingress is supported.");
+ return NULL;
+ }
+
+ return nfp_flow_process(representor, items, actions);
+}
+
+static int
+nfp_flow_teardown(struct nfp_flow_priv *priv, struct rte_flow *nfp_flow)
+{
+ char *mask_data;
+ uint32_t mask_len;
+ uint32_t stats_ctx;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+
+ nfp_flow_meta = nfp_flow->payload.meta;
+ mask_data = nfp_flow->payload.mask_data;
+ mask_len = nfp_flow_meta->mask_len << NFP_FL_LW_SIZ;
+ if (!nfp_check_mask_remove(priv, mask_data, mask_len,
+ &nfp_flow_meta->flags)) {
+ PMD_DRV_LOG(ERR, "nfp mask del check failed.");
+ return -EINVAL;
+ }
+
+ nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version);
+ priv->flower_version++;
+
+ stats_ctx = rte_be_to_cpu_32(nfp_flow_meta->host_ctx_id);
+ return nfp_stats_id_free(priv, stats_ctx);
+}
+
+static int
+nfp_flow_validate(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item items[],
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ int ret;
+ struct rte_flow *nfp_flow;
+ struct nfp_flow_priv *priv;
+ struct nfp_flower_representor *representor;
+
+ representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ priv = representor->app_fw_flower->flow_priv;
+
+ nfp_flow = nfp_flow_setup(representor, attr, items, actions, error);
+ if (nfp_flow == NULL) {
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "This flow can not be offloaded.");
+ }
+
+ ret = nfp_flow_teardown(priv, nfp_flow);
+ if (ret != 0) {
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Flow resource free failed.");
+ }
+
+ nfp_flow_free(nfp_flow);
+
+ return 0;
+}
+
+static struct rte_flow *
+nfp_flow_create(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item items[],
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ int ret;
+ struct rte_flow *nfp_flow;
+ struct nfp_flow_priv *priv;
+ struct nfp_app_fw_flower *app_fw_flower;
+ struct nfp_flower_representor *representor;
+
+ representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ app_fw_flower = representor->app_fw_flower;
+ priv = app_fw_flower->flow_priv;
+
+ nfp_flow = nfp_flow_setup(representor, attr, items, actions, error);
+ if (nfp_flow == NULL) {
+ rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "This flow can not be offloaded.");
+ return NULL;
+ }
+
+ /* Add the flow to hardware */
+ if (nfp_flow->install_flag) {
+ ret = nfp_flower_cmsg_flow_add(app_fw_flower, nfp_flow);
+ if (ret != 0) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Add flow to firmware failed.");
+ goto flow_teardown;
+ }
+ }
+
+ /* Add the flow to flow hash table */
+ ret = nfp_flow_table_add(priv, nfp_flow);
+ if (ret != 0) {
+ rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Add flow to the flow table failed.");
+ goto flow_teardown;
+ }
+
+ return nfp_flow;
+
+flow_teardown:
+ nfp_flow_teardown(priv, nfp_flow);
+ nfp_flow_free(nfp_flow);
+
+ return NULL;
+}
+
+static int
+nfp_flow_destroy(struct rte_eth_dev *dev,
+ struct rte_flow *nfp_flow,
+ struct rte_flow_error *error)
+{
+ int ret;
+ struct rte_flow *flow_find;
+ struct nfp_flow_priv *priv;
+ struct nfp_app_fw_flower *app_fw_flower;
+ struct nfp_flower_representor *representor;
+
+ representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ app_fw_flower = representor->app_fw_flower;
+ priv = app_fw_flower->flow_priv;
+
+ /* Find the flow in flow hash table */
+ flow_find = nfp_flow_table_search(priv, nfp_flow);
+ if (flow_find == NULL) {
+ rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Flow does not exist.");
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ /* Update flow */
+ ret = nfp_flow_teardown(priv, nfp_flow);
+ if (ret != 0) {
+ rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Flow teardown failed.");
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ /* Delete the flow from hardware */
+ if (nfp_flow->install_flag) {
+ ret = nfp_flower_cmsg_flow_delete(app_fw_flower, nfp_flow);
+ if (ret != 0) {
+ rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Delete flow from firmware failed.");
+ ret = -EINVAL;
+ goto exit;
+ }
+ }
+
+ /* Delete the flow from flow hash table */
+ ret = nfp_flow_table_delete(priv, nfp_flow);
+ if (ret != 0) {
+ rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Delete flow from the flow table failed.");
+ ret = -EINVAL;
+ goto exit;
+ }
+
+exit:
+ nfp_flow_free(nfp_flow);
+
+ return ret;
+}
+
+static int
+nfp_flow_flush(struct rte_eth_dev *dev,
+ struct rte_flow_error *error)
+{
+ int ret = 0;
+ void *next_data;
+ uint32_t iter = 0;
+ const void *next_key;
+ struct nfp_flow_priv *priv;
+
+ priv = nfp_flow_dev_to_priv(dev);
+
+ while (rte_hash_iterate(priv->flow_table, &next_key, &next_data, &iter) >= 0) {
+ ret = nfp_flow_destroy(dev, (struct rte_flow *)next_data, error);
+ if (ret != 0)
+ break;
+ }
+
+ return ret;
+}
+
+static void
+nfp_flow_stats_get(struct rte_eth_dev *dev,
+ struct rte_flow *nfp_flow,
+ void *data)
+{
+ uint32_t ctx_id;
+ struct rte_flow *flow;
+ struct nfp_flow_priv *priv;
+ struct nfp_fl_stats *stats;
+ struct rte_flow_query_count *query;
+
+ priv = nfp_flow_dev_to_priv(dev);
+ flow = nfp_flow_table_search(priv, nfp_flow);
+ if (flow == NULL) {
+ PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
+ return;
+ }
+
+ query = (struct rte_flow_query_count *)data;
+ ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
+ stats = &priv->stats[ctx_id];
+
+ rte_spinlock_lock(&priv->stats_lock);
+ if (stats->pkts && stats->bytes) {
+ query->hits = stats->pkts;
+ query->bytes = stats->bytes;
+ query->hits_set = 1;
+ query->bytes_set = 1;
+ stats->pkts = 0;
+ stats->bytes = 0;
+ }
+ rte_spinlock_unlock(&priv->stats_lock);
+}
+
+static int
+nfp_flow_query(struct rte_eth_dev *dev,
+ struct rte_flow *nfp_flow,
+ const struct rte_flow_action *actions,
+ void *data,
+ struct rte_flow_error *error)
+{
+ const struct rte_flow_action *action;
+
+ for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
+ switch (action->type) {
+ case RTE_FLOW_ACTION_TYPE_VOID:
+ break;
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+ nfp_flow_stats_get(dev, nfp_flow, data);
+ break;
+ default:
+ rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Unsupported action type for flow query.");
+ return -ENOTSUP;
+ }
+ }
+
+ return 0;
+}
+
+static const struct rte_flow_ops nfp_flow_ops = {
+ .validate = nfp_flow_validate,
+ .create = nfp_flow_create,
+ .destroy = nfp_flow_destroy,
+ .flush = nfp_flow_flush,
+ .query = nfp_flow_query,
+};
+
+int
+nfp_net_flow_ops_get(struct rte_eth_dev *dev,
+ const struct rte_flow_ops **ops)
+{
+ if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+ *ops = NULL;
+ PMD_DRV_LOG(ERR, "Port is not a representor.");
+ return -EINVAL;
+ }
+
+ *ops = &nfp_flow_ops;
+
+ return 0;
+}
+
int
nfp_flow_priv_init(struct nfp_pf_dev *pf_dev)
{
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index 142d7d5..83f9f29 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,10 +6,36 @@
#ifndef _NFP_FLOW_H_
#define _NFP_FLOW_H_
+#include <ethdev_driver.h>
+
+#define NFP_FLOWER_LAYER_EXT_META (1 << 0)
+#define NFP_FLOWER_LAYER_PORT (1 << 1)
+#define NFP_FLOWER_LAYER_MAC (1 << 2)
+#define NFP_FLOWER_LAYER_TP (1 << 3)
+#define NFP_FLOWER_LAYER_IPV4 (1 << 4)
+#define NFP_FLOWER_LAYER_IPV6 (1 << 5)
+#define NFP_FLOWER_LAYER_CT (1 << 6)
+#define NFP_FLOWER_LAYER_VXLAN (1 << 7)
+
+#define NFP_FLOWER_LAYER2_GRE (1 << 0)
+#define NFP_FLOWER_LAYER2_QINQ (1 << 4)
+#define NFP_FLOWER_LAYER2_GENEVE (1 << 5)
+#define NFP_FLOWER_LAYER2_GENEVE_OP (1 << 6)
+#define NFP_FLOWER_LAYER2_TUN_IPV6 (1 << 7)
+
#define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7)
#define NFP_MASK_TABLE_ENTRIES 1024
+/* The maximum action list size (in bytes) supported by the NFP. */
+#define NFP_FL_MAX_A_SIZ 1216
+
+/* The firmware expects lengths in units of long words */
+#define NFP_FL_LW_SIZ 2
+
+/* Tunnel ports */
+#define NFP_FL_PORT_TYPE_TUN 0x50000000
+
enum nfp_flower_tun_type {
NFP_FL_TUN_NONE = 0,
NFP_FL_TUN_GRE = 1,
@@ -75,6 +101,7 @@ struct nfp_fl_stats {
struct nfp_flow_priv {
uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */
+ uint64_t flower_version; /**< Flow version, always increase. */
/* mask hash table */
struct nfp_fl_mask_id mask_ids; /**< Entry for mask hash table */
struct rte_hash *mask_table; /**< Hash table to store mask ids. */
@@ -97,5 +124,6 @@ struct rte_flow {
int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev);
void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev);
+int nfp_net_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);
#endif /* _NFP_FLOW_H_ */
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-10 6:08 ` [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD Chaoyong He
@ 2022-10-10 14:51 ` Ferruh Yigit
2022-10-19 3:00 ` Chaoyong He
0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-10 14:51 UTC (permalink / raw)
To: Chaoyong He; +Cc: oss-drivers, niklas.soderlund, dev
On 10/10/2022 7:08 AM, Chaoyong He wrote:
> Add the flow validate/create/query/destroy/flush API of nfp PMD.
>
> The flow create API construct a control cmsg and send it to
> firmware, then add this flow to the hash table.
>
> The flow query API get flow stats from the flow_priv structure.
> Note there exist an rte_spin_lock to prevent the update and query
> action occur at the same time.
>
> The flow destroy API construct a control cmsg and send it to
> firmware, then adelete this flow from the hash table.
>
> The flow flush API just iterate the flows in hash table and
> call the flow destroy API.
>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
<...>
> +static void
> +nfp_flow_stats_get(struct rte_eth_dev *dev,
> + struct rte_flow *nfp_flow,
> + void *data)
> +{
> + uint32_t ctx_id;
> + struct rte_flow *flow;
> + struct nfp_flow_priv *priv;
> + struct nfp_fl_stats *stats;
> + struct rte_flow_query_count *query;
> +
> + priv = nfp_flow_dev_to_priv(dev);
> + flow = nfp_flow_table_search(priv, nfp_flow);
> + if (flow == NULL) {
> + PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
> + return;
> + }
> +
> + query = (struct rte_flow_query_count *)data;
> + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
> + stats = &priv->stats[ctx_id];
> +
> + rte_spinlock_lock(&priv->stats_lock);
> + if (stats->pkts && stats->bytes) {
Is it guaranteed that 'query' ("void *data") is zeroed out when it is
provided by application?
> + query->hits = stats->pkts;
> + query->bytes = stats->bytes;
> + query->hits_set = 1;
> + query->bytes_set = 1;
> + stats->pkts = 0;
> + stats->bytes = 0;
need to check 'reset' field of action to decide reset or not.
<...>
> @@ -75,6 +101,7 @@ struct nfp_fl_stats {
>
> struct nfp_flow_priv {
> uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */
> + uint64_t flower_version; /**< Flow version, always increase. */
Is this version to keep unique value per flow configuration? If so as
far as I can see '.validate' is updating this value, is this expected?
Also who suppose to use this value?
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-10 14:51 ` Ferruh Yigit
@ 2022-10-19 3:00 ` Chaoyong He
2022-10-19 11:11 ` Ferruh Yigit
0 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-19 3:00 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: oss-drivers, Niklas Soderlund, dev
> On 10/10/2022 7:08 AM, Chaoyong He wrote:
> > Add the flow validate/create/query/destroy/flush API of nfp PMD.
> >
> > The flow create API construct a control cmsg and send it to firmware,
> > then add this flow to the hash table.
> >
> > The flow query API get flow stats from the flow_priv structure.
> > Note there exist an rte_spin_lock to prevent the update and query
> > action occur at the same time.
> >
> > The flow destroy API construct a control cmsg and send it to firmware,
> > then adelete this flow from the hash table.
> >
> > The flow flush API just iterate the flows in hash table and call the
> > flow destroy API.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>
> <...>
>
> > +static void
> > +nfp_flow_stats_get(struct rte_eth_dev *dev,
> > + struct rte_flow *nfp_flow,
> > + void *data)
> > +{
> > + uint32_t ctx_id;
> > + struct rte_flow *flow;
> > + struct nfp_flow_priv *priv;
> > + struct nfp_fl_stats *stats;
> > + struct rte_flow_query_count *query;
> > +
> > + priv = nfp_flow_dev_to_priv(dev);
> > + flow = nfp_flow_table_search(priv, nfp_flow);
> > + if (flow == NULL) {
> > + PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
> > + return;
> > + }
> > +
> > + query = (struct rte_flow_query_count *)data;
> > + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
> > + stats = &priv->stats[ctx_id];
> > +
> > + rte_spinlock_lock(&priv->stats_lock);
> > + if (stats->pkts && stats->bytes) {
>
> Is it guaranteed that 'query' ("void *data") is zeroed out when it is provided
> by application?
>
> > + query->hits = stats->pkts;
> > + query->bytes = stats->bytes;
> > + query->hits_set = 1;
> > + query->bytes_set = 1;
> > + stats->pkts = 0;
> > + stats->bytes = 0;
>
> need to check 'reset' field of action to decide reset or not.
>
> <...>
>
> > @@ -75,6 +101,7 @@ struct nfp_fl_stats {
> >
> > struct nfp_flow_priv {
> > uint32_t hash_seed; /**< Hash seed for hash tables in this
> > structure. */
> > + uint64_t flower_version; /**< Flow version, always increase. */
>
> Is this version to keep unique value per flow configuration? If so as far as I
> can see '.validate' is updating this value, is this expected?
>
> Also who suppose to use this value?
Yes, it is expected.
This value is part of the nfp_flow_meta, and which is part of the flow offloaded
to the firmware.
And the content of the flow offloaded to the firmware is the ABI of the firmware,
so it's can't easily change.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-19 3:00 ` Chaoyong He
@ 2022-10-19 11:11 ` Ferruh Yigit
2022-10-19 11:30 ` Chaoyong He
0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-19 11:11 UTC (permalink / raw)
To: Chaoyong He; +Cc: oss-drivers, Niklas Soderlund, dev
On 10/19/2022 4:00 AM, Chaoyong He wrote:
>> On 10/10/2022 7:08 AM, Chaoyong He wrote:
>>> Add the flow validate/create/query/destroy/flush API of nfp PMD.
>>>
>>> The flow create API construct a control cmsg and send it to firmware,
>>> then add this flow to the hash table.
>>>
>>> The flow query API get flow stats from the flow_priv structure.
>>> Note there exist an rte_spin_lock to prevent the update and query
>>> action occur at the same time.
>>>
>>> The flow destroy API construct a control cmsg and send it to firmware,
>>> then adelete this flow from the hash table.
>>>
>>> The flow flush API just iterate the flows in hash table and call the
>>> flow destroy API.
>>>
>>> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
>>> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>>
>> <...>
>>
>>> +static void
>>> +nfp_flow_stats_get(struct rte_eth_dev *dev,
>>> + struct rte_flow *nfp_flow,
>>> + void *data)
>>> +{
>>> + uint32_t ctx_id;
>>> + struct rte_flow *flow;
>>> + struct nfp_flow_priv *priv;
>>> + struct nfp_fl_stats *stats;
>>> + struct rte_flow_query_count *query;
>>> +
>>> + priv = nfp_flow_dev_to_priv(dev);
>>> + flow = nfp_flow_table_search(priv, nfp_flow);
>>> + if (flow == NULL) {
>>> + PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
>>> + return;
>>> + }
>>> +
>>> + query = (struct rte_flow_query_count *)data;
>>> + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
>>> + stats = &priv->stats[ctx_id];
>>> +
>>> + rte_spinlock_lock(&priv->stats_lock);
>>> + if (stats->pkts && stats->bytes) {
>>
>> Is it guaranteed that 'query' ("void *data") is zeroed out when it is provided
>> by application?
>>
Let me clarify this comment,
When "stats->pkts == 0", not taken this branch and 'query' fields are
not updated. How caller can know if 'query' has random values or
assigned values, won't it be good to memset query.
>>> + query->hits = stats->pkts;
>>> + query->bytes = stats->bytes;
>>> + query->hits_set = 1;
>>> + query->bytes_set = 1;
>>> + stats->pkts = 0;
>>> + stats->bytes = 0;
>>
>> need to check 'reset' field of action to decide reset or not.
>>
And this one also seems not answered, to there is an attribute of action
to request resetting stats, above code ignores it.
>> <...>
>>
>>> @@ -75,6 +101,7 @@ struct nfp_fl_stats {
>>>
>>> struct nfp_flow_priv {
>>> uint32_t hash_seed; /**< Hash seed for hash tables in this
>>> structure. */
>>> + uint64_t flower_version; /**< Flow version, always increase. */
>>
>> Is this version to keep unique value per flow configuration? If so as far as I
>> can see '.validate' is updating this value, is this expected?
>>
>> Also who suppose to use this value?
>
> Yes, it is expected.
>
> This value is part of the nfp_flow_meta, and which is part of the flow offloaded
> to the firmware.
> And the content of the flow offloaded to the firmware is the ABI of the firmware,
> so it's can't easily change.
I am not sure we are on same page. This variable is increased when a
flow rule is added or validated by application, how this is part of ABI?
Also whenever application validates a flow this 'flower_version' value
is increased. Application is just validating the flow, not adding a flow
so nothing changes in the HW config.
And this increase in the 'flower_version' variable may cause driver/hw
think that config is changed?
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-19 11:11 ` Ferruh Yigit
@ 2022-10-19 11:30 ` Chaoyong He
2022-10-19 11:38 ` Ferruh Yigit
0 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-19 11:30 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: oss-drivers, Niklas Soderlund, dev
> On 10/19/2022 4:00 AM, Chaoyong He wrote:
> >> On 10/10/2022 7:08 AM, Chaoyong He wrote:
> >>> Add the flow validate/create/query/destroy/flush API of nfp PMD.
> >>>
> >>> The flow create API construct a control cmsg and send it to
> >>> firmware, then add this flow to the hash table.
> >>>
> >>> The flow query API get flow stats from the flow_priv structure.
> >>> Note there exist an rte_spin_lock to prevent the update and query
> >>> action occur at the same time.
> >>>
> >>> The flow destroy API construct a control cmsg and send it to
> >>> firmware, then adelete this flow from the hash table.
> >>>
> >>> The flow flush API just iterate the flows in hash table and call the
> >>> flow destroy API.
> >>>
> >>> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> >>> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> >>
> >> <...>
> >>
> >>> +static void
> >>> +nfp_flow_stats_get(struct rte_eth_dev *dev,
> >>> + struct rte_flow *nfp_flow,
> >>> + void *data)
> >>> +{
> >>> + uint32_t ctx_id;
> >>> + struct rte_flow *flow;
> >>> + struct nfp_flow_priv *priv;
> >>> + struct nfp_fl_stats *stats;
> >>> + struct rte_flow_query_count *query;
> >>> +
> >>> + priv = nfp_flow_dev_to_priv(dev);
> >>> + flow = nfp_flow_table_search(priv, nfp_flow);
> >>> + if (flow == NULL) {
> >>> + PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
> >>> + return;
> >>> + }
> >>> +
> >>> + query = (struct rte_flow_query_count *)data;
> >>> + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
> >>> + stats = &priv->stats[ctx_id];
> >>> +
> >>> + rte_spinlock_lock(&priv->stats_lock);
> >>> + if (stats->pkts && stats->bytes) {
> >>
> >> Is it guaranteed that 'query' ("void *data") is zeroed out when it is
> >> provided by application?
> >>
>
> Let me clarify this comment,
>
> When "stats->pkts == 0", not taken this branch and 'query' fields are not
> updated. How caller can know if 'query' has random values or assigned values,
> won't it be good to memset query.
>
Okay, I understand it now. I'll revise like what you said in the next version patch, thanks.
> >>> + query->hits = stats->pkts;
> >>> + query->bytes = stats->bytes;
> >>> + query->hits_set = 1;
> >>> + query->bytes_set = 1;
> >>> + stats->pkts = 0;
> >>> + stats->bytes = 0;
> >>
> >> need to check 'reset' field of action to decide reset or not.
> >>
>
> And this one also seems not answered, to there is an attribute of action to
> request resetting stats, above code ignores it.
>
How about like this:
```
if (stats->pkts != 0 && stats->bytes != 0) {
query->hits = stats->pkts;
query->bytes = stats->bytes;
query->hits_set = 1;
query->bytes_set = 1;
if (query->reset != 0) {
rte_spinlock_lock(&priv->stats_lock);
stats->pkts = 0;
stats->bytes = 0;
rte_spinlock_unlock(&priv->stats_lock);
}
} else {
memset(query, 0, sizeof(*query));
}
```
And I'm not quite sure if I should add a check about the `reserved` field like this:
```
query = (struct rte_flow_query_count *)data;
if (query->reserved != 0) {
PMD_DRV_LOG(ERR, "The reserved field should always be 0!");
return;
}
```
> >> <...>
> >>
> >>> @@ -75,6 +101,7 @@ struct nfp_fl_stats {
> >>>
> >>> struct nfp_flow_priv {
> >>> uint32_t hash_seed; /**< Hash seed for hash tables in this
> >>> structure. */
> >>> + uint64_t flower_version; /**< Flow version, always increase.
> >>> + */
> >>
> >> Is this version to keep unique value per flow configuration? If so as
> >> far as I can see '.validate' is updating this value, is this expected?
> >>
> >> Also who suppose to use this value?
> >
> > Yes, it is expected.
> >
> > This value is part of the nfp_flow_meta, and which is part of the flow
> > offloaded to the firmware.
> > And the content of the flow offloaded to the firmware is the ABI of
> > the firmware, so it's can't easily change.
>
> I am not sure we are on same page. This variable is increased when a flow
> rule is added or validated by application, how this is part of ABI?
>
> Also whenever application validates a flow this 'flower_version' value is
> increased. Application is just validating the flow, not adding a flow so nothing
> changes in the HW config.
> And this increase in the 'flower_version' variable may cause driver/hw think
> that config is changed?
Okay, I will revise to make sure the '.validate' won't change this value anymore, thanks.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD
2022-10-19 11:30 ` Chaoyong He
@ 2022-10-19 11:38 ` Ferruh Yigit
0 siblings, 0 replies; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-19 11:38 UTC (permalink / raw)
To: Chaoyong He; +Cc: oss-drivers, Niklas Soderlund, dev
On 10/19/2022 12:30 PM, Chaoyong He wrote:
>> On 10/19/2022 4:00 AM, Chaoyong He wrote:
>>>> On 10/10/2022 7:08 AM, Chaoyong He wrote:
>>>>> Add the flow validate/create/query/destroy/flush API of nfp PMD.
>>>>>
>>>>> The flow create API construct a control cmsg and send it to
>>>>> firmware, then add this flow to the hash table.
>>>>>
>>>>> The flow query API get flow stats from the flow_priv structure.
>>>>> Note there exist an rte_spin_lock to prevent the update and query
>>>>> action occur at the same time.
>>>>>
>>>>> The flow destroy API construct a control cmsg and send it to
>>>>> firmware, then adelete this flow from the hash table.
>>>>>
>>>>> The flow flush API just iterate the flows in hash table and call the
>>>>> flow destroy API.
>>>>>
>>>>> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
>>>>> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
>>>>
>>>> <...>
>>>>
>>>>> +static void
>>>>> +nfp_flow_stats_get(struct rte_eth_dev *dev,
>>>>> + struct rte_flow *nfp_flow,
>>>>> + void *data)
>>>>> +{
>>>>> + uint32_t ctx_id;
>>>>> + struct rte_flow *flow;
>>>>> + struct nfp_flow_priv *priv;
>>>>> + struct nfp_fl_stats *stats;
>>>>> + struct rte_flow_query_count *query;
>>>>> +
>>>>> + priv = nfp_flow_dev_to_priv(dev);
>>>>> + flow = nfp_flow_table_search(priv, nfp_flow);
>>>>> + if (flow == NULL) {
>>>>> + PMD_DRV_LOG(ERR, "Can not find statistics for this flow.");
>>>>> + return;
>>>>> + }
>>>>> +
>>>>> + query = (struct rte_flow_query_count *)data;
>>>>> + ctx_id = rte_be_to_cpu_32(nfp_flow->payload.meta->host_ctx_id);
>>>>> + stats = &priv->stats[ctx_id];
>>>>> +
>>>>> + rte_spinlock_lock(&priv->stats_lock);
>>>>> + if (stats->pkts && stats->bytes) {
>>>>
>>>> Is it guaranteed that 'query' ("void *data") is zeroed out when it is
>>>> provided by application?
>>>>
>>
>> Let me clarify this comment,
>>
>> When "stats->pkts == 0", not taken this branch and 'query' fields are not
>> updated. How caller can know if 'query' has random values or assigned values,
>> won't it be good to memset query.
>>
>
> Okay, I understand it now. I'll revise like what you said in the next version patch, thanks.
>
>>>>> + query->hits = stats->pkts;
>>>>> + query->bytes = stats->bytes;
>>>>> + query->hits_set = 1;
>>>>> + query->bytes_set = 1;
>>>>> + stats->pkts = 0;
>>>>> + stats->bytes = 0;
>>>>
>>>> need to check 'reset' field of action to decide reset or not.
>>>>
>>
>> And this one also seems not answered, to there is an attribute of action to
>> request resetting stats, above code ignores it.
>>
>
> How about like this:
> ```
> if (stats->pkts != 0 && stats->bytes != 0) {
> query->hits = stats->pkts;
> query->bytes = stats->bytes;
> query->hits_set = 1;
> query->bytes_set = 1;
> if (query->reset != 0) {
> rte_spinlock_lock(&priv->stats_lock);
> stats->pkts = 0;
> stats->bytes = 0;
> rte_spinlock_unlock(&priv->stats_lock);
> }
ack
> } else {
> memset(query, 0, sizeof(*query));
> }
memset can go outside of the if block for simplicity, but both are OK,
up to you.
> ```
>
> And I'm not quite sure if I should add a check about the `reserved` field like this:
> ```
> query = (struct rte_flow_query_count *)data;
> if (query->reserved != 0) {
> PMD_DRV_LOG(ERR, "The reserved field should always be 0!");
> return;
> }
> ```
I don't think it is required to check reserved fields.
>
>>>> <...>
>>>>
>>>>> @@ -75,6 +101,7 @@ struct nfp_fl_stats {
>>>>>
>>>>> struct nfp_flow_priv {
>>>>> uint32_t hash_seed; /**< Hash seed for hash tables in this
>>>>> structure. */
>>>>> + uint64_t flower_version; /**< Flow version, always increase.
>>>>> + */
>>>>
>>>> Is this version to keep unique value per flow configuration? If so as
>>>> far as I can see '.validate' is updating this value, is this expected?
>>>>
>>>> Also who suppose to use this value?
>>>
>>> Yes, it is expected.
>>>
>>> This value is part of the nfp_flow_meta, and which is part of the flow
>>> offloaded to the firmware.
>>> And the content of the flow offloaded to the firmware is the ABI of
>>> the firmware, so it's can't easily change.
>>
>> I am not sure we are on same page. This variable is increased when a flow
>> rule is added or validated by application, how this is part of ABI?
>>
>> Also whenever application validates a flow this 'flower_version' value is
>> increased. Application is just validating the flow, not adding a flow so nothing
>> changes in the HW config.
>> And this increase in the 'flower_version' variable may cause driver/hw think
>> that config is changed?
>
> Okay, I will revise to make sure the '.validate' won't change this value anymore, thanks.
ack
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 04/24] net/nfp: add the offload support of basic items
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (2 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 03/24] net/nfp: add the flow APIs of nfp PMD Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 05/24] net/nfp: add the offload support of basic actions Chaoyong He
` (19 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the offload support of very basic items: ethernet and
port id.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 4 +
doc/guides/rel_notes/release_22_11.rst | 4 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 20 +++
drivers/net/nfp/nfp_flow.c | 252 ++++++++++++++++++++++++++++++-
4 files changed, 279 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index f7a0362..4460cf0 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -25,3 +25,7 @@ Linux = Y
Multiprocess aware = Y
x86-64 = Y
Usage doc = Y
+
+[rte_flow items]
+eth = Y
+port_id = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index fbb5752..cd22d95 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -151,6 +151,10 @@ New Features
* Added the control message interactive channels between PMD and firmware.
* Added the support of representor port.
+ Add the support of rte_flow pattern items as follow:
+
+ * Ethernet
+
* **Updated NXP dpaa2 driver.**
* Added support for flow action REPRESENTED_PORT.
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 6045bb0..75a3b91 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -233,6 +233,26 @@ struct nfp_flower_in_port {
rte_be32_t in_port;
};
+/*
+ * L2 details (4W/16B)
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | mac_addr_dst, 31 - 0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | mac_addr_dst, 47 - 32 | mac_addr_src, 15 - 0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | mac_addr_src, 47 - 16 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | mpls outermost label | TC |B| reserved |q|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_mac_mpls {
+ uint8_t mac_dst[6];
+ uint8_t mac_src[6];
+ rte_be32_t mpls_lse;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 114686f..a077423 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -19,6 +19,30 @@
#include "nfpcore/nfp_mip.h"
#include "nfpcore/nfp_rtsym.h"
+/* Static initializer for a list of subsequent item types */
+#define NEXT_ITEM(...) \
+ ((const enum rte_flow_item_type []){ \
+ __VA_ARGS__, RTE_FLOW_ITEM_TYPE_END, \
+ })
+
+/* Process structure associated with a flow item */
+struct nfp_flow_item_proc {
+ /* Bit-mask for fields supported by this PMD. */
+ const void *mask_support;
+ /* Bit-mask to use when @p item->mask is not provided. */
+ const void *mask_default;
+ /* Size in bytes for @p mask_support and @p mask_default. */
+ const unsigned int mask_sz;
+ /* Merge a pattern item into a flow rule handle. */
+ int (*merge)(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask);
+ /* List of possible subsequent items. */
+ const enum rte_flow_item_type *const next_item;
+};
+
struct nfp_mask_id_entry {
uint32_t hash_key;
uint32_t ref_cnt;
@@ -476,12 +500,36 @@ struct nfp_mask_id_entry {
static int
nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
- __rte_unused struct nfp_fl_key_ls *key_ls)
+ struct nfp_fl_key_ls *key_ls)
{
+ struct rte_eth_dev *ethdev;
const struct rte_flow_item *item;
+ struct nfp_flower_representor *representor;
+ const struct rte_flow_item_port_id *port_id;
for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
switch (item->type) {
+ case RTE_FLOW_ITEM_TYPE_ETH:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_ETH detected");
+ /*
+ * eth is set with no specific params.
+ * NFP does not need this.
+ */
+ if (item->spec == NULL)
+ continue;
+ key_ls->key_layer |= NFP_FLOWER_LAYER_MAC;
+ key_ls->key_size += sizeof(struct nfp_flower_mac_mpls);
+ break;
+ case RTE_FLOW_ITEM_TYPE_PORT_ID:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_PORT_ID detected");
+ port_id = item->spec;
+ if (port_id->id >= RTE_MAX_ETHPORTS)
+ return -ERANGE;
+ ethdev = &rte_eth_devices[port_id->id];
+ representor = (struct nfp_flower_representor *)
+ ethdev->data->dev_private;
+ key_ls->port = rte_cpu_to_be_32(representor->port_id);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -541,6 +589,202 @@ struct nfp_mask_id_entry {
return ret;
}
+static int
+nfp_flow_merge_eth(__rte_unused struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ struct nfp_flower_mac_mpls *eth;
+ const struct rte_flow_item_eth *spec;
+ const struct rte_flow_item_eth *mask;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge eth: no item->spec!");
+ goto eth_end;
+ }
+
+ mask = item->mask ? item->mask : proc->mask_default;
+ eth = (void *)*mbuf_off;
+
+ if (is_mask) {
+ memcpy(eth->mac_src, mask->src.addr_bytes, RTE_ETHER_ADDR_LEN);
+ memcpy(eth->mac_dst, mask->dst.addr_bytes, RTE_ETHER_ADDR_LEN);
+ } else {
+ memcpy(eth->mac_src, spec->src.addr_bytes, RTE_ETHER_ADDR_LEN);
+ memcpy(eth->mac_dst, spec->dst.addr_bytes, RTE_ETHER_ADDR_LEN);
+ }
+
+ eth->mpls_lse = 0;
+
+eth_end:
+ *mbuf_off += sizeof(struct nfp_flower_mac_mpls);
+
+ return 0;
+}
+
+/* Graph of supported items and associated process function */
+static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
+ [RTE_FLOW_ITEM_TYPE_END] = {
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH),
+ },
+ [RTE_FLOW_ITEM_TYPE_ETH] = {
+ .mask_support = &(const struct rte_flow_item_eth){
+ .hdr = {
+ .dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+ .src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+ .ether_type = RTE_BE16(0xffff),
+ },
+ .has_vlan = 1,
+ },
+ .mask_default = &rte_flow_item_eth_mask,
+ .mask_sz = sizeof(struct rte_flow_item_eth),
+ .merge = nfp_flow_merge_eth,
+ },
+};
+
+static int
+nfp_flow_item_check(const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc)
+{
+ int ret = 0;
+ unsigned int i;
+ const uint8_t *mask;
+
+ /* item->last and item->mask cannot exist without item->spec. */
+ if (item->spec == NULL) {
+ if (item->mask || item->last) {
+ PMD_DRV_LOG(ERR, "'mask' or 'last' field provided"
+ " without a corresponding 'spec'.");
+ return -EINVAL;
+ }
+ /* No spec, no mask, no problem. */
+ return 0;
+ }
+
+ mask = item->mask ?
+ (const uint8_t *)item->mask :
+ (const uint8_t *)proc->mask_default;
+
+ /*
+ * Single-pass check to make sure that:
+ * - Mask is supported, no bits are set outside proc->mask_support.
+ * - Both item->spec and item->last are included in mask.
+ */
+ for (i = 0; i != proc->mask_sz; ++i) {
+ if (mask[i] == 0)
+ continue;
+
+ if ((mask[i] | ((const uint8_t *)proc->mask_support)[i]) !=
+ ((const uint8_t *)proc->mask_support)[i]) {
+ PMD_DRV_LOG(ERR, "Unsupported field found in 'mask'.");
+ ret = -EINVAL;
+ break;
+ }
+
+ if (item->last && (((const uint8_t *)item->spec)[i] & mask[i]) !=
+ (((const uint8_t *)item->last)[i] & mask[i])) {
+ PMD_DRV_LOG(ERR, "Range between 'spec' and 'last'"
+ " is larger than 'mask'.");
+ ret = -ERANGE;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int
+nfp_flow_compile_item_proc(const struct rte_flow_item items[],
+ struct rte_flow *nfp_flow,
+ char **mbuf_off_exact,
+ char **mbuf_off_mask)
+{
+ int i;
+ int ret = 0;
+ const struct rte_flow_item *item;
+ const struct nfp_flow_item_proc *proc_list;
+
+ proc_list = nfp_flow_item_proc_list;
+ for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) {
+ const struct nfp_flow_item_proc *proc = NULL;
+
+ for (i = 0; proc_list->next_item && proc_list->next_item[i]; ++i) {
+ if (proc_list->next_item[i] == item->type) {
+ proc = &nfp_flow_item_proc_list[item->type];
+ break;
+ }
+ }
+
+ if (proc == NULL) {
+ PMD_DRV_LOG(ERR, "No next item provided for %d", item->type);
+ ret = -ENOTSUP;
+ break;
+ }
+
+ /* Perform basic sanity checks */
+ ret = nfp_flow_item_check(item, proc);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow item %d check failed", item->type);
+ ret = -EINVAL;
+ break;
+ }
+
+ if (proc->merge == NULL) {
+ PMD_DRV_LOG(ERR, "nfp flow item %d no proc function", item->type);
+ ret = -ENOTSUP;
+ break;
+ }
+
+ ret = proc->merge(nfp_flow, mbuf_off_exact, item,
+ proc, false);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow item %d exact merge failed", item->type);
+ break;
+ }
+
+ ret = proc->merge(nfp_flow, mbuf_off_mask, item,
+ proc, true);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow item %d mask merge failed", item->type);
+ break;
+ }
+
+ proc_list = proc;
+ }
+
+ return ret;
+}
+
+static int
+nfp_flow_compile_items(__rte_unused struct nfp_flower_representor *representor,
+ const struct rte_flow_item items[],
+ struct rte_flow *nfp_flow)
+{
+ int ret;
+ char *mbuf_off_mask;
+ char *mbuf_off_exact;
+
+ mbuf_off_exact = nfp_flow->payload.unmasked_data +
+ sizeof(struct nfp_flower_meta_tci) +
+ sizeof(struct nfp_flower_in_port);
+ mbuf_off_mask = nfp_flow->payload.mask_data +
+ sizeof(struct nfp_flower_meta_tci) +
+ sizeof(struct nfp_flower_in_port);
+
+ /* Go over items */
+ ret = nfp_flow_compile_item_proc(items, nfp_flow,
+ &mbuf_off_exact, &mbuf_off_mask);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow item compile failed.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static struct rte_flow *
nfp_flow_process(struct nfp_flower_representor *representor,
const struct rte_flow_item items[],
@@ -583,6 +827,12 @@ struct nfp_mask_id_entry {
nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx);
+ ret = nfp_flow_compile_items(representor, items, nfp_flow);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow item process failed.");
+ goto free_flow;
+ }
+
nfp_flow_meta = nfp_flow->payload.meta;
mask_data = nfp_flow->payload.mask_data;
mask_len = key_layer.key_size;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 05/24] net/nfp: add the offload support of basic actions
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (3 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 04/24] net/nfp: add the offload support of basic items Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 14:52 ` Ferruh Yigit
2022-10-10 6:08 ` [PATCH v2 06/24] net/nfp: add the offload support of VLAN item Chaoyong He
` (18 subsequent siblings)
23 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the offload support of very basic actions: mark, rss,
count, drop and output.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 6 ++
doc/guides/rel_notes/release_22_11.rst | 6 ++
drivers/net/nfp/flower/nfp_flower_cmsg.h | 11 +++
drivers/net/nfp/nfp_flow.c | 112 +++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_flow.h | 37 ++++++++++
5 files changed, 172 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 4460cf0..194fe64 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -29,3 +29,9 @@ Usage doc = Y
[rte_flow items]
eth = Y
port_id = Y
+
+[rte_flow actions]
+count = Y
+dec_ttl = Y
+drop = Y
+port_id = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index cd22d95..ac0223f 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -155,6 +155,12 @@ New Features
* Ethernet
+ Add the support of rte_flow actions as follow:
+
+ * Count
+ * Drop
+ * TTL decrement
+
* **Updated NXP dpaa2 driver.**
* Added support for flow action REPRESENTED_PORT.
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 75a3b91..d776e37 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -253,6 +253,17 @@ struct nfp_flower_mac_mpls {
rte_be32_t mpls_lse;
};
+struct nfp_fl_act_head {
+ uint8_t jump_id;
+ uint8_t len_lw;
+};
+
+struct nfp_fl_act_output {
+ struct nfp_fl_act_head head;
+ rte_be16_t flags;
+ rte_be32_t port;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index a077423..ec021f0 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -558,6 +558,22 @@ struct nfp_mask_id_entry {
case RTE_FLOW_ACTION_TYPE_VOID:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_VOID detected");
break;
+ case RTE_FLOW_ACTION_TYPE_MARK:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
+ break;
+ case RTE_FLOW_ACTION_TYPE_DROP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_DROP detected");
+ break;
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_COUNT detected");
+ break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected");
+ break;
+ case RTE_FLOW_ACTION_TYPE_PORT_ID:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_PORT_ID detected");
+ key_ls->act_size += sizeof(struct nfp_fl_act_output);
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -785,6 +801,96 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_action_output(char *act_data,
+ const struct rte_flow_action *action,
+ struct nfp_fl_rule_metadata *nfp_flow_meta)
+{
+ size_t act_size;
+ struct rte_eth_dev *ethdev;
+ struct nfp_fl_act_output *output;
+ struct nfp_flower_representor *representor;
+ const struct rte_flow_action_port_id *port_id;
+
+ port_id = action->conf;
+ if (port_id == NULL || port_id->id >= RTE_MAX_ETHPORTS)
+ return -ERANGE;
+
+ ethdev = &rte_eth_devices[port_id->id];
+ representor = (struct nfp_flower_representor *)ethdev->data->dev_private;
+ act_size = sizeof(struct nfp_fl_act_output);
+
+ output = (struct nfp_fl_act_output *)act_data;
+ output->head.jump_id = NFP_FL_ACTION_OPCODE_OUTPUT;
+ output->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ output->flags = rte_cpu_to_be_16(NFP_FL_OUT_FLAGS_LAST);
+ output->port = rte_cpu_to_be_32(representor->port_id);
+
+ nfp_flow_meta->shortcut = rte_cpu_to_be_32(representor->port_id);
+
+ return 0;
+}
+
+static int
+nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
+ const struct rte_flow_action actions[],
+ struct rte_flow *nfp_flow)
+{
+ int ret = 0;
+ char *position;
+ char *action_data;
+ bool drop_flag = false;
+ uint32_t total_actions = 0;
+ const struct rte_flow_action *action;
+ struct nfp_fl_rule_metadata *nfp_flow_meta;
+
+ nfp_flow_meta = nfp_flow->payload.meta;
+ action_data = nfp_flow->payload.action_data;
+ position = action_data;
+
+ for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
+ switch (action->type) {
+ case RTE_FLOW_ACTION_TYPE_VOID:
+ break;
+ case RTE_FLOW_ACTION_TYPE_MARK:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
+ break;
+ case RTE_FLOW_ACTION_TYPE_DROP:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_DROP");
+ drop_flag = true;
+ break;
+ case RTE_FLOW_ACTION_TYPE_COUNT:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_COUNT");
+ break;
+ case RTE_FLOW_ACTION_TYPE_RSS:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS");
+ break;
+ case RTE_FLOW_ACTION_TYPE_PORT_ID:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_PORT_ID");
+ ret = nfp_flow_action_output(position, action, nfp_flow_meta);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed when process"
+ " RTE_FLOW_ACTION_TYPE_PORT_ID");
+ return ret;
+ }
+
+ position += sizeof(struct nfp_fl_act_output);
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
+ return -ENOTSUP;
+ }
+ total_actions++;
+ }
+
+ if (drop_flag)
+ nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_DROP);
+ else if (total_actions > 1)
+ nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_NULL);
+
+ return 0;
+}
+
static struct rte_flow *
nfp_flow_process(struct nfp_flower_representor *representor,
const struct rte_flow_item items[],
@@ -833,6 +939,12 @@ struct nfp_mask_id_entry {
goto free_flow;
}
+ ret = nfp_flow_compile_action(representor, actions, nfp_flow);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "nfp flow action process failed.");
+ goto free_flow;
+ }
+
nfp_flow_meta = nfp_flow->payload.meta;
mask_data = nfp_flow->payload.mask_data;
mask_len = key_layer.key_size;
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index 83f9f29..f1fbada 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -33,6 +33,43 @@
/* The firmware expects lengths in units of long words */
#define NFP_FL_LW_SIZ 2
+#define NFP_FL_SC_ACT_DROP 0x80000000
+#define NFP_FL_SC_ACT_USER 0x7D000000
+#define NFP_FL_SC_ACT_POPV 0x6A000000
+#define NFP_FL_SC_ACT_NULL 0x00000000
+
+/* Action opcodes */
+#define NFP_FL_ACTION_OPCODE_OUTPUT 0
+#define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1
+#define NFP_FL_ACTION_OPCODE_POP_VLAN 2
+#define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3
+#define NFP_FL_ACTION_OPCODE_POP_MPLS 4
+#define NFP_FL_ACTION_OPCODE_USERSPACE 5
+#define NFP_FL_ACTION_OPCODE_SET_TUNNEL 6
+#define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7
+#define NFP_FL_ACTION_OPCODE_SET_MPLS 8
+#define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
+#define NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS 10
+#define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11
+#define NFP_FL_ACTION_OPCODE_SET_IPV6_DST 12
+#define NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL 13
+#define NFP_FL_ACTION_OPCODE_SET_UDP 14
+#define NFP_FL_ACTION_OPCODE_SET_TCP 15
+#define NFP_FL_ACTION_OPCODE_PRE_LAG 16
+#define NFP_FL_ACTION_OPCODE_PRE_TUNNEL 17
+#define NFP_FL_ACTION_OPCODE_PRE_GS 18
+#define NFP_FL_ACTION_OPCODE_GS 19
+#define NFP_FL_ACTION_OPCODE_PUSH_NSH 20
+#define NFP_FL_ACTION_OPCODE_POP_NSH 21
+#define NFP_FL_ACTION_OPCODE_SET_QUEUE 22
+#define NFP_FL_ACTION_OPCODE_CONNTRACK 23
+#define NFP_FL_ACTION_OPCODE_METER 24
+#define NFP_FL_ACTION_OPCODE_CT_NAT_EXT 25
+#define NFP_FL_ACTION_OPCODE_PUSH_GENEVE 26
+#define NFP_FL_ACTION_OPCODE_NUM 32
+
+#define NFP_FL_OUT_FLAGS_LAST (1 << 15)
+
/* Tunnel ports */
#define NFP_FL_PORT_TYPE_TUN 0x50000000
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 05/24] net/nfp: add the offload support of basic actions
2022-10-10 6:08 ` [PATCH v2 05/24] net/nfp: add the offload support of basic actions Chaoyong He
@ 2022-10-10 14:52 ` Ferruh Yigit
2022-10-19 11:32 ` Chaoyong He
0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-10 14:52 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund
On 10/10/2022 7:08 AM, Chaoyong He wrote:
> Add the offload support of very basic actions: mark, rss,
> count, drop and output.
>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> ---
> doc/guides/nics/features/nfp.ini | 6 ++
> doc/guides/rel_notes/release_22_11.rst | 6 ++
> drivers/net/nfp/flower/nfp_flower_cmsg.h | 11 +++
> drivers/net/nfp/nfp_flow.c | 112 +++++++++++++++++++++++++++++++
> drivers/net/nfp/nfp_flow.h | 37 ++++++++++
> 5 files changed, 172 insertions(+)
>
> diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
> index 4460cf0..194fe64 100644
> --- a/doc/guides/nics/features/nfp.ini
> +++ b/doc/guides/nics/features/nfp.ini
> @@ -29,3 +29,9 @@ Usage doc = Y
> [rte_flow items]
> eth = Y
> port_id = Y
> +
> +[rte_flow actions]
> +count = Y
> +dec_ttl = Y
> +drop = Y
> +port_id = Y
Are these actions supported? As far as I can see all done in the code is
print log when these actions detected.
For 'dec_ttl' even logging seems missing.
I think better to document them as supported when actual support is added.
> diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
> index cd22d95..ac0223f 100644
> --- a/doc/guides/rel_notes/release_22_11.rst
> +++ b/doc/guides/rel_notes/release_22_11.rst
> @@ -155,6 +155,12 @@ New Features
>
> * Ethernet
>
> + Add the support of rte_flow actions as follow:
> +
> + * Count
> + * Drop
> + * TTL decrement
Not sure if this level of details is required in release notes, it can
be sufficient that driver flow API support is added.
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH v2 05/24] net/nfp: add the offload support of basic actions
2022-10-10 14:52 ` Ferruh Yigit
@ 2022-10-19 11:32 ` Chaoyong He
0 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-19 11:32 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: oss-drivers, Niklas Soderlund
> On 10/10/2022 7:08 AM, Chaoyong He wrote:
> > Add the offload support of very basic actions: mark, rss, count, drop
> > and output.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> > ---
> > doc/guides/nics/features/nfp.ini | 6 ++
> > doc/guides/rel_notes/release_22_11.rst | 6 ++
> > drivers/net/nfp/flower/nfp_flower_cmsg.h | 11 +++
> > drivers/net/nfp/nfp_flow.c | 112
> +++++++++++++++++++++++++++++++
> > drivers/net/nfp/nfp_flow.h | 37 ++++++++++
> > 5 files changed, 172 insertions(+)
> >
> > diff --git a/doc/guides/nics/features/nfp.ini
> > b/doc/guides/nics/features/nfp.ini
> > index 4460cf0..194fe64 100644
> > --- a/doc/guides/nics/features/nfp.ini
> > +++ b/doc/guides/nics/features/nfp.ini
> > @@ -29,3 +29,9 @@ Usage doc = Y
> > [rte_flow items]
> > eth = Y
> > port_id = Y
> > +
> > +[rte_flow actions]
> > +count = Y
> > +dec_ttl = Y
> > +drop = Y
> > +port_id = Y
>
> Are these actions supported? As far as I can see all done in the code is print
> log when these actions detected.
>
> For 'dec_ttl' even logging seems missing.
>
> I think better to document them as supported when actual support is added.
>
I will delete the 'dec_ttl' here, and we does support the offload of other ones, thanks.
> > diff --git a/doc/guides/rel_notes/release_22_11.rst
> > b/doc/guides/rel_notes/release_22_11.rst
> > index cd22d95..ac0223f 100644
> > --- a/doc/guides/rel_notes/release_22_11.rst
> > +++ b/doc/guides/rel_notes/release_22_11.rst
> > @@ -155,6 +155,12 @@ New Features
> >
> > * Ethernet
> >
> > + Add the support of rte_flow actions as follow:
> > +
> > + * Count
> > + * Drop
> > + * TTL decrement
>
> Not sure if this level of details is required in release notes, it can be sufficient
> that driver flow API support is added.
Okay, I will revise them at next version patch, thanks.
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 06/24] net/nfp: add the offload support of VLAN item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (4 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 05/24] net/nfp: add the offload support of basic actions Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 07/24] net/nfp: add the offload support of IPv4 item Chaoyong He
` (17 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of VLAN item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 46 ++++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_flow.h | 2 ++
4 files changed, 50 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 194fe64..f0ecae2 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -29,6 +29,7 @@ Usage doc = Y
[rte_flow items]
eth = Y
port_id = Y
+vlan = Y
[rte_flow actions]
count = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index ac0223f..9160cc6 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -154,6 +154,7 @@ New Features
Add the support of rte_flow pattern items as follow:
* Ethernet
+ * Single VLAN
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index ec021f0..b063b96 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -530,6 +530,10 @@ struct nfp_mask_id_entry {
ethdev->data->dev_private;
key_ls->port = rte_cpu_to_be_32(representor->port_id);
break;
+ case RTE_FLOW_ITEM_TYPE_VLAN:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_VLAN detected");
+ key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI;
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -641,12 +645,42 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_vlan(struct rte_flow *nfp_flow,
+ __rte_unused char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ struct nfp_flower_meta_tci *meta_tci;
+ const struct rte_flow_item_vlan *spec;
+ const struct rte_flow_item_vlan *mask;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge vlan: no item->spec!");
+ return 0;
+ }
+
+ mask = item->mask ? item->mask : proc->mask_default;
+ if (is_mask) {
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.mask_data;
+ meta_tci->tci |= mask->tci;
+ } else {
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ meta_tci->tci |= spec->tci;
+ }
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH),
},
[RTE_FLOW_ITEM_TYPE_ETH] = {
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN),
.mask_support = &(const struct rte_flow_item_eth){
.hdr = {
.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
@@ -659,6 +693,18 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_eth),
.merge = nfp_flow_merge_eth,
},
+ [RTE_FLOW_ITEM_TYPE_VLAN] = {
+ .mask_support = &(const struct rte_flow_item_vlan){
+ .hdr = {
+ .vlan_tci = RTE_BE16(0xefff),
+ .eth_proto = RTE_BE16(0xffff),
+ },
+ .has_more_vlan = 1,
+ },
+ .mask_default = &rte_flow_item_vlan_mask,
+ .mask_sz = sizeof(struct rte_flow_item_vlan),
+ .merge = nfp_flow_merge_vlan,
+ },
};
static int
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index f1fbada..f6bd3e4 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -25,6 +25,8 @@
#define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7)
+#define NFP_FLOWER_MASK_VLAN_CFI (1 << 12)
+
#define NFP_MASK_TABLE_ENTRIES 1024
/* The maximum action list size (in bytes) supported by the NFP. */
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 07/24] net/nfp: add the offload support of IPv4 item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (5 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 06/24] net/nfp: add the offload support of VLAN item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item Chaoyong He
` (16 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of IPv4 item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 38 ++++++++++++++++++
drivers/net/nfp/nfp_flow.c | 68 +++++++++++++++++++++++++++++++-
4 files changed, 107 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index f0ecae2..d4ceae0 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -28,6 +28,7 @@ Usage doc = Y
[rte_flow items]
eth = Y
+ipv4 = Y
port_id = Y
vlan = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 9160cc6..8de49df 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -155,6 +155,7 @@ New Features
* Ethernet
* Single VLAN
+ * IPv4
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index d776e37..5964ecf 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -253,6 +253,44 @@ struct nfp_flower_mac_mpls {
rte_be32_t mpls_lse;
};
+/*
+ * L4 ports (for UDP, TCP, SCTP) (1W/4B)
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | port_src | port_dst |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_tp_ports {
+ rte_be16_t port_src;
+ rte_be16_t port_dst;
+};
+
+struct nfp_flower_ip_ext {
+ uint8_t tos;
+ uint8_t proto;
+ uint8_t ttl;
+ uint8_t flags;
+};
+
+/*
+ * L3 IPv4 details (3W/12B)
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | DSCP |ECN| protocol | ttl | flags |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_addr_src |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_addr_dst |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_ipv4 {
+ struct nfp_flower_ip_ext ip_ext;
+ rte_be32_t ipv4_src;
+ rte_be32_t ipv4_dst;
+};
+
struct nfp_fl_act_head {
uint8_t jump_id;
uint8_t len_lw;
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index b063b96..810f2d7 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -534,6 +534,11 @@ struct nfp_mask_id_entry {
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_VLAN detected");
key_ls->vlan = NFP_FLOWER_MASK_VLAN_CFI;
break;
+ case RTE_FLOW_ITEM_TYPE_IPV4:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
+ key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
+ key_ls->key_size += sizeof(struct nfp_flower_ipv4);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -674,13 +679,58 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_ipv4(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ struct nfp_flower_ipv4 *ipv4;
+ const struct rte_ipv4_hdr *hdr;
+ struct nfp_flower_meta_tci *meta_tci;
+ const struct rte_flow_item_ipv4 *spec;
+ const struct rte_flow_item_ipv4 *mask;
+
+ spec = item->spec;
+ mask = item->mask ? item->mask : proc->mask_default;
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge ipv4: no item->spec!");
+ goto ipv4_end;
+ }
+
+ /*
+ * reserve space for L4 info.
+ * rte_flow has ipv4 before L4 but NFP flower fw requires L4 before ipv4
+ */
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP)
+ *mbuf_off += sizeof(struct nfp_flower_tp_ports);
+
+ hdr = is_mask ? &mask->hdr : &spec->hdr;
+ ipv4 = (struct nfp_flower_ipv4 *)*mbuf_off;
+
+ ipv4->ip_ext.tos = hdr->type_of_service;
+ ipv4->ip_ext.proto = hdr->next_proto_id;
+ ipv4->ip_ext.ttl = hdr->time_to_live;
+ ipv4->ipv4_src = hdr->src_addr;
+ ipv4->ipv4_dst = hdr->dst_addr;
+
+ipv4_end:
+ *mbuf_off += sizeof(struct nfp_flower_ipv4);
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH),
},
[RTE_FLOW_ITEM_TYPE_ETH] = {
- .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN),
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN,
+ RTE_FLOW_ITEM_TYPE_IPV4),
.mask_support = &(const struct rte_flow_item_eth){
.hdr = {
.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
@@ -694,6 +744,7 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_eth,
},
[RTE_FLOW_ITEM_TYPE_VLAN] = {
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_IPV4),
.mask_support = &(const struct rte_flow_item_vlan){
.hdr = {
.vlan_tci = RTE_BE16(0xefff),
@@ -705,6 +756,21 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_vlan),
.merge = nfp_flow_merge_vlan,
},
+ [RTE_FLOW_ITEM_TYPE_IPV4] = {
+ .mask_support = &(const struct rte_flow_item_ipv4){
+ .hdr = {
+ .type_of_service = 0xff,
+ .fragment_offset = RTE_BE16(0xffff),
+ .time_to_live = 0xff,
+ .next_proto_id = 0xff,
+ .src_addr = RTE_BE32(0xffffffff),
+ .dst_addr = RTE_BE32(0xffffffff),
+ },
+ },
+ .mask_default = &rte_flow_item_ipv4_mask,
+ .mask_sz = sizeof(struct rte_flow_item_ipv4),
+ .merge = nfp_flow_merge_ipv4,
+ },
};
static int
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (6 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 07/24] net/nfp: add the offload support of IPv4 item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 14:53 ` Ferruh Yigit
2022-10-10 6:08 ` [PATCH v2 09/24] net/nfp: add the offload support of TCP item Chaoyong He
` (15 subsequent siblings)
23 siblings, 1 reply; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of IPv6 item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 2 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 33 +++++++++++++++
drivers/net/nfp/nfp_flow.c | 73 +++++++++++++++++++++++++++++++-
4 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index d4ceae0..9dff34b 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -29,6 +29,8 @@ Usage doc = Y
[rte_flow items]
eth = Y
ipv4 = Y
+ipv6 = Y
+ipv6_frag_ext = Y
port_id = Y
vlan = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 8de49df..5039a6f 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -156,6 +156,7 @@ New Features
* Ethernet
* Single VLAN
* IPv4
+ * IPv6
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 5964ecf..36d406f 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -291,6 +291,39 @@ struct nfp_flower_ipv4 {
rte_be32_t ipv4_dst;
};
+/*
+ * L3 IPv6 details (10W/40B)
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | DSCP |ECN| protocol | ttl | flags |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_exthdr | res | ipv6_flow_label |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_src, 31 - 0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_src, 63 - 32 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_src, 95 - 64 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_src, 127 - 96 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_dst, 31 - 0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_dst, 63 - 32 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_dst, 95 - 64 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_dst, 127 - 96 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_ipv6 {
+ struct nfp_flower_ip_ext ip_ext;
+ rte_be32_t ipv6_flow_label_exthdr;
+ uint8_t ipv6_src[16];
+ uint8_t ipv6_dst[16];
+};
+
struct nfp_fl_act_head {
uint8_t jump_id;
uint8_t len_lw;
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 810f2d7..5b78110 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -539,6 +539,11 @@ struct nfp_mask_id_entry {
key_ls->key_layer |= NFP_FLOWER_LAYER_IPV4;
key_ls->key_size += sizeof(struct nfp_flower_ipv4);
break;
+ case RTE_FLOW_ITEM_TYPE_IPV6:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected");
+ key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
+ key_ls->key_size += sizeof(struct nfp_flower_ipv6);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -723,6 +728,51 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_ipv6(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ struct nfp_flower_ipv6 *ipv6;
+ const struct rte_ipv6_hdr *hdr;
+ struct nfp_flower_meta_tci *meta_tci;
+ const struct rte_flow_item_ipv6 *spec;
+ const struct rte_flow_item_ipv6 *mask;
+
+ spec = item->spec;
+ mask = item->mask ? item->mask : proc->mask_default;
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge ipv6: no item->spec!");
+ goto ipv6_end;
+ }
+
+ /*
+ * reserve space for L4 info.
+ * rte_flow has ipv4 before L4 but NFP flower fw requires L4 before ipv4
+ */
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_TP)
+ *mbuf_off += sizeof(struct nfp_flower_tp_ports);
+
+ hdr = is_mask ? &mask->hdr : &spec->hdr;
+ ipv6 = (struct nfp_flower_ipv6 *)*mbuf_off;
+
+ ipv6->ip_ext.tos = (hdr->vtc_flow & RTE_IPV6_HDR_TC_MASK) >>
+ RTE_IPV6_HDR_TC_SHIFT;
+ ipv6->ip_ext.proto = hdr->proto;
+ ipv6->ip_ext.ttl = hdr->hop_limits;
+ memcpy(ipv6->ipv6_src, hdr->src_addr, sizeof(ipv6->ipv6_src));
+ memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
+
+ipv6_end:
+ *mbuf_off += sizeof(struct nfp_flower_ipv6);
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
@@ -730,7 +780,8 @@ struct nfp_mask_id_entry {
},
[RTE_FLOW_ITEM_TYPE_ETH] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_VLAN,
- RTE_FLOW_ITEM_TYPE_IPV4),
+ RTE_FLOW_ITEM_TYPE_IPV4,
+ RTE_FLOW_ITEM_TYPE_IPV6),
.mask_support = &(const struct rte_flow_item_eth){
.hdr = {
.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
@@ -744,7 +795,8 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_eth,
},
[RTE_FLOW_ITEM_TYPE_VLAN] = {
- .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_IPV4),
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_IPV4,
+ RTE_FLOW_ITEM_TYPE_IPV6),
.mask_support = &(const struct rte_flow_item_vlan){
.hdr = {
.vlan_tci = RTE_BE16(0xefff),
@@ -771,6 +823,23 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_ipv4),
.merge = nfp_flow_merge_ipv4,
},
+ [RTE_FLOW_ITEM_TYPE_IPV6] = {
+ .mask_support = &(const struct rte_flow_item_ipv6){
+ .hdr = {
+ .vtc_flow = RTE_BE32(0x0ff00000),
+ .proto = 0xff,
+ .hop_limits = 0xff,
+ .src_addr = "\xff\xff\xff\xff\xff\xff\xff\xff"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ .dst_addr = "\xff\xff\xff\xff\xff\xff\xff\xff"
+ "\xff\xff\xff\xff\xff\xff\xff\xff",
+ },
+ .has_frag_ext = 1,
+ },
+ .mask_default = &rte_flow_item_ipv6_mask,
+ .mask_sz = sizeof(struct rte_flow_item_ipv6),
+ .merge = nfp_flow_merge_ipv6,
+ },
};
static int
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item
2022-10-10 6:08 ` [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item Chaoyong He
@ 2022-10-10 14:53 ` Ferruh Yigit
2022-10-19 11:33 ` Chaoyong He
0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-10-10 14:53 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund
On 10/10/2022 7:08 AM, Chaoyong He wrote:
> Add the corresponding data structure and logics, to support
> the offload of IPv6 item.
>
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> ---
> doc/guides/nics/features/nfp.ini | 2 +
> doc/guides/rel_notes/release_22_11.rst | 1 +
> drivers/net/nfp/flower/nfp_flower_cmsg.h | 33 +++++++++++++++
> drivers/net/nfp/nfp_flow.c | 73 +++++++++++++++++++++++++++++++-
> 4 files changed, 107 insertions(+), 2 deletions(-)
>
> diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
> index d4ceae0..9dff34b 100644
> --- a/doc/guides/nics/features/nfp.ini
> +++ b/doc/guides/nics/features/nfp.ini
> @@ -29,6 +29,8 @@ Usage doc = Y
> [rte_flow items]
> eth = Y
> ipv4 = Y
> +ipv6 = Y
> +ipv6_frag_ext = Y
There are 'RTE_FLOW_ITEM_TYPE_IPV6_EXT' &
'RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT' flow item types, shouldn't code check
them before claiming the support?
Please use './devtools/check-doc-vs-code.sh' script to double check if
code and .ini file matches.
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item
2022-10-10 14:53 ` Ferruh Yigit
@ 2022-10-19 11:33 ` Chaoyong He
0 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-19 11:33 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: oss-drivers, Niklas Soderlund
> On 10/10/2022 7:08 AM, Chaoyong He wrote:
> > Add the corresponding data structure and logics, to support the
> > offload of IPv6 item.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> > ---
> > doc/guides/nics/features/nfp.ini | 2 +
> > doc/guides/rel_notes/release_22_11.rst | 1 +
> > drivers/net/nfp/flower/nfp_flower_cmsg.h | 33 +++++++++++++++
> > drivers/net/nfp/nfp_flow.c | 73
> +++++++++++++++++++++++++++++++-
> > 4 files changed, 107 insertions(+), 2 deletions(-)
> >
> > diff --git a/doc/guides/nics/features/nfp.ini
> > b/doc/guides/nics/features/nfp.ini
> > index d4ceae0..9dff34b 100644
> > --- a/doc/guides/nics/features/nfp.ini
> > +++ b/doc/guides/nics/features/nfp.ini
> > @@ -29,6 +29,8 @@ Usage doc = Y
> > [rte_flow items]
> > eth = Y
> > ipv4 = Y
> > +ipv6 = Y
> > +ipv6_frag_ext = Y
>
> There are 'RTE_FLOW_ITEM_TYPE_IPV6_EXT' &
> 'RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT' flow item types, shouldn't code
> check them before claiming the support?
>
> Please use './devtools/check-doc-vs-code.sh' script to double check if code
> and .ini file matches.
I will delete 'ipv6_frag_ext' here, sorry for the confusion.
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 09/24] net/nfp: add the offload support of TCP item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (7 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 08/24] net/nfp: add the offload support of IPv6 item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 10/24] net/nfp: add the offload support of UDP item Chaoyong He
` (14 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of TCP item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 91 ++++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_flow.h | 7 +++
4 files changed, 100 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 9dff34b..66ee03c 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -32,6 +32,7 @@ ipv4 = Y
ipv6 = Y
ipv6_frag_ext = Y
port_id = Y
+tcp = Y
vlan = Y
[rte_flow actions]
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 5039a6f..95e5ed2 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -157,6 +157,7 @@ New Features
* Single VLAN
* IPv4
* IPv6
+ * TCP
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 5b78110..f1d1bba 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -544,6 +544,11 @@ struct nfp_mask_id_entry {
key_ls->key_layer |= NFP_FLOWER_LAYER_IPV6;
key_ls->key_size += sizeof(struct nfp_flower_ipv6);
break;
+ case RTE_FLOW_ITEM_TYPE_TCP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_TCP detected");
+ key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
+ key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -773,6 +778,78 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_tcp(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ uint8_t tcp_flags;
+ struct nfp_flower_tp_ports *ports;
+ struct nfp_flower_ipv4 *ipv4 = NULL;
+ struct nfp_flower_ipv6 *ipv6 = NULL;
+ const struct rte_flow_item_tcp *spec;
+ const struct rte_flow_item_tcp *mask;
+ struct nfp_flower_meta_tci *meta_tci;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge tcp: no item->spec!");
+ return 0;
+ }
+
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
+ ipv4 = (struct nfp_flower_ipv4 *)
+ (*mbuf_off - sizeof(struct nfp_flower_ipv4));
+ ports = (struct nfp_flower_tp_ports *)
+ ((char *)ipv4 - sizeof(struct nfp_flower_tp_ports));
+ } else { /* IPv6 */
+ ipv6 = (struct nfp_flower_ipv6 *)
+ (*mbuf_off - sizeof(struct nfp_flower_ipv6));
+ ports = (struct nfp_flower_tp_ports *)
+ ((char *)ipv6 - sizeof(struct nfp_flower_tp_ports));
+ }
+
+ mask = item->mask ? item->mask : proc->mask_default;
+ if (is_mask) {
+ ports->port_src = mask->hdr.src_port;
+ ports->port_dst = mask->hdr.dst_port;
+ tcp_flags = mask->hdr.tcp_flags;
+ } else {
+ ports->port_src = spec->hdr.src_port;
+ ports->port_dst = spec->hdr.dst_port;
+ tcp_flags = spec->hdr.tcp_flags;
+ }
+
+ if (ipv4) {
+ if (tcp_flags & RTE_TCP_FIN_FLAG)
+ ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_FIN;
+ if (tcp_flags & RTE_TCP_SYN_FLAG)
+ ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_SYN;
+ if (tcp_flags & RTE_TCP_RST_FLAG)
+ ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_RST;
+ if (tcp_flags & RTE_TCP_PSH_FLAG)
+ ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_PSH;
+ if (tcp_flags & RTE_TCP_URG_FLAG)
+ ipv4->ip_ext.flags |= NFP_FL_TCP_FLAG_URG;
+ } else { /* IPv6 */
+ if (tcp_flags & RTE_TCP_FIN_FLAG)
+ ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_FIN;
+ if (tcp_flags & RTE_TCP_SYN_FLAG)
+ ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_SYN;
+ if (tcp_flags & RTE_TCP_RST_FLAG)
+ ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_RST;
+ if (tcp_flags & RTE_TCP_PSH_FLAG)
+ ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_PSH;
+ if (tcp_flags & RTE_TCP_URG_FLAG)
+ ipv6->ip_ext.flags |= NFP_FL_TCP_FLAG_URG;
+ }
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
@@ -809,6 +886,7 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_vlan,
},
[RTE_FLOW_ITEM_TYPE_IPV4] = {
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP),
.mask_support = &(const struct rte_flow_item_ipv4){
.hdr = {
.type_of_service = 0xff,
@@ -824,6 +902,7 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_ipv4,
},
[RTE_FLOW_ITEM_TYPE_IPV6] = {
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP),
.mask_support = &(const struct rte_flow_item_ipv6){
.hdr = {
.vtc_flow = RTE_BE32(0x0ff00000),
@@ -840,6 +919,18 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_ipv6),
.merge = nfp_flow_merge_ipv6,
},
+ [RTE_FLOW_ITEM_TYPE_TCP] = {
+ .mask_support = &(const struct rte_flow_item_tcp){
+ .hdr = {
+ .tcp_flags = 0xff,
+ .src_port = RTE_BE16(0xffff),
+ .dst_port = RTE_BE16(0xffff),
+ },
+ },
+ .mask_default = &rte_flow_item_tcp_mask,
+ .mask_sz = sizeof(struct rte_flow_item_tcp),
+ .merge = nfp_flow_merge_tcp,
+ },
};
static int
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index f6bd3e4..b3bd949 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -23,6 +23,13 @@
#define NFP_FLOWER_LAYER2_GENEVE_OP (1 << 6)
#define NFP_FLOWER_LAYER2_TUN_IPV6 (1 << 7)
+/* Compressed HW representation of TCP Flags */
+#define NFP_FL_TCP_FLAG_FIN (1 << 0)
+#define NFP_FL_TCP_FLAG_SYN (1 << 1)
+#define NFP_FL_TCP_FLAG_RST (1 << 2)
+#define NFP_FL_TCP_FLAG_PSH (1 << 3)
+#define NFP_FL_TCP_FLAG_URG (1 << 4)
+
#define NFP_FL_META_FLAG_MANAGE_MASK (1 << 7)
#define NFP_FLOWER_MASK_VLAN_CFI (1 << 12)
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 10/24] net/nfp: add the offload support of UDP item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (8 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 09/24] net/nfp: add the offload support of TCP item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 11/24] net/nfp: add the offload support of SCTP item Chaoyong He
` (13 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload
of UDP item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 63 ++++++++++++++++++++++++++++++++--
3 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 66ee03c..f6ba2eb 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -33,6 +33,7 @@ ipv6 = Y
ipv6_frag_ext = Y
port_id = Y
tcp = Y
+udp = Y
vlan = Y
[rte_flow actions]
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 95e5ed2..2c4afa8 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -158,6 +158,7 @@ New Features
* IPv4
* IPv6
* TCP
+ * UDP
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index f1d1bba..b20a341 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -549,6 +549,11 @@ struct nfp_mask_id_entry {
key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
break;
+ case RTE_FLOW_ITEM_TYPE_UDP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_UDP detected");
+ key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
+ key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -850,6 +855,47 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_udp(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ char *ports_off;
+ struct nfp_flower_tp_ports *ports;
+ const struct rte_flow_item_udp *spec;
+ const struct rte_flow_item_udp *mask;
+ struct nfp_flower_meta_tci *meta_tci;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge udp: no item->spec!");
+ return 0;
+ }
+
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
+ ports_off = *mbuf_off - sizeof(struct nfp_flower_ipv4) -
+ sizeof(struct nfp_flower_tp_ports);
+ } else {/* IPv6 */
+ ports_off = *mbuf_off - sizeof(struct nfp_flower_ipv6) -
+ sizeof(struct nfp_flower_tp_ports);
+ }
+ ports = (struct nfp_flower_tp_ports *)ports_off;
+
+ mask = item->mask ? item->mask : proc->mask_default;
+ if (is_mask) {
+ ports->port_src = mask->hdr.src_port;
+ ports->port_dst = mask->hdr.dst_port;
+ } else {
+ ports->port_src = spec->hdr.src_port;
+ ports->port_dst = spec->hdr.dst_port;
+ }
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
@@ -886,7 +932,8 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_vlan,
},
[RTE_FLOW_ITEM_TYPE_IPV4] = {
- .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP),
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP,
+ RTE_FLOW_ITEM_TYPE_UDP),
.mask_support = &(const struct rte_flow_item_ipv4){
.hdr = {
.type_of_service = 0xff,
@@ -902,7 +949,8 @@ struct nfp_mask_id_entry {
.merge = nfp_flow_merge_ipv4,
},
[RTE_FLOW_ITEM_TYPE_IPV6] = {
- .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP),
+ .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP,
+ RTE_FLOW_ITEM_TYPE_UDP),
.mask_support = &(const struct rte_flow_item_ipv6){
.hdr = {
.vtc_flow = RTE_BE32(0x0ff00000),
@@ -931,6 +979,17 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_tcp),
.merge = nfp_flow_merge_tcp,
},
+ [RTE_FLOW_ITEM_TYPE_UDP] = {
+ .mask_support = &(const struct rte_flow_item_udp){
+ .hdr = {
+ .src_port = RTE_BE16(0xffff),
+ .dst_port = RTE_BE16(0xffff),
+ },
+ },
+ .mask_default = &rte_flow_item_udp_mask,
+ .mask_sz = sizeof(struct rte_flow_item_udp),
+ .merge = nfp_flow_merge_udp,
+ },
};
static int
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 11/24] net/nfp: add the offload support of SCTP item
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (9 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 10/24] net/nfp: add the offload support of UDP item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 12/24] net/nfp: add the offload support of set SRC MAC action Chaoyong He
` (12 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload
of SCTP item.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 63 ++++++++++++++++++++++++++++++++--
3 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index f6ba2eb..f8f2577 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -32,6 +32,7 @@ ipv4 = Y
ipv6 = Y
ipv6_frag_ext = Y
port_id = Y
+sctp = Y
tcp = Y
udp = Y
vlan = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 2c4afa8..f51fb1f 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -159,6 +159,7 @@ New Features
* IPv6
* TCP
* UDP
+ * SCTP
Add the support of rte_flow actions as follow:
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index b20a341..bb445ef 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -554,6 +554,11 @@ struct nfp_mask_id_entry {
key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
break;
+ case RTE_FLOW_ITEM_TYPE_SCTP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_SCTP detected");
+ key_ls->key_layer |= NFP_FLOWER_LAYER_TP;
+ key_ls->key_size += sizeof(struct nfp_flower_tp_ports);
+ break;
default:
PMD_DRV_LOG(ERR, "Item type %d not supported.", item->type);
return -ENOTSUP;
@@ -896,6 +901,47 @@ struct nfp_mask_id_entry {
return 0;
}
+static int
+nfp_flow_merge_sctp(struct rte_flow *nfp_flow,
+ char **mbuf_off,
+ const struct rte_flow_item *item,
+ const struct nfp_flow_item_proc *proc,
+ bool is_mask)
+{
+ char *ports_off;
+ struct nfp_flower_tp_ports *ports;
+ struct nfp_flower_meta_tci *meta_tci;
+ const struct rte_flow_item_sctp *spec;
+ const struct rte_flow_item_sctp *mask;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "nfp flow merge sctp: no item->spec!");
+ return 0;
+ }
+
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
+ ports_off = *mbuf_off - sizeof(struct nfp_flower_ipv4) -
+ sizeof(struct nfp_flower_tp_ports);
+ } else { /* IPv6 */
+ ports_off = *mbuf_off - sizeof(struct nfp_flower_ipv6) -
+ sizeof(struct nfp_flower_tp_ports);
+ }
+ ports = (struct nfp_flower_tp_ports *)ports_off;
+
+ mask = item->mask ? item->mask : proc->mask_default;
+ if (is_mask) {
+ ports->port_src = mask->hdr.src_port;
+ ports->port_dst = mask->hdr.dst_port;
+ } else {
+ ports->port_src = spec->hdr.src_port;
+ ports->port_dst = spec->hdr.dst_port;
+ }
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
@@ -933,7 +979,8 @@ struct nfp_mask_id_entry {
},
[RTE_FLOW_ITEM_TYPE_IPV4] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP,
- RTE_FLOW_ITEM_TYPE_UDP),
+ RTE_FLOW_ITEM_TYPE_UDP,
+ RTE_FLOW_ITEM_TYPE_SCTP),
.mask_support = &(const struct rte_flow_item_ipv4){
.hdr = {
.type_of_service = 0xff,
@@ -950,7 +997,8 @@ struct nfp_mask_id_entry {
},
[RTE_FLOW_ITEM_TYPE_IPV6] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_TCP,
- RTE_FLOW_ITEM_TYPE_UDP),
+ RTE_FLOW_ITEM_TYPE_UDP,
+ RTE_FLOW_ITEM_TYPE_SCTP),
.mask_support = &(const struct rte_flow_item_ipv6){
.hdr = {
.vtc_flow = RTE_BE32(0x0ff00000),
@@ -990,6 +1038,17 @@ struct nfp_mask_id_entry {
.mask_sz = sizeof(struct rte_flow_item_udp),
.merge = nfp_flow_merge_udp,
},
+ [RTE_FLOW_ITEM_TYPE_SCTP] = {
+ .mask_support = &(const struct rte_flow_item_sctp){
+ .hdr = {
+ .src_port = RTE_BE16(0xffff),
+ .dst_port = RTE_BE16(0xffff),
+ },
+ },
+ .mask_default = &rte_flow_item_sctp_mask,
+ .mask_sz = sizeof(struct rte_flow_item_sctp),
+ .merge = nfp_flow_merge_sctp,
+ },
};
static int
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 12/24] net/nfp: add the offload support of set SRC MAC action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (10 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 11/24] net/nfp: add the offload support of SCTP item Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 13/24] net/nfp: add the offload support of set DST " Chaoyong He
` (11 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of set source MAC action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 27 ++++++++++++++++++
drivers/net/nfp/nfp_flow.c | 47 ++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index f8f2577..ab6ddab 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -42,3 +42,4 @@ count = Y
dec_ttl = Y
drop = Y
port_id = Y
+set_mac_src = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 36d406f..b61342e 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -335,6 +335,33 @@ struct nfp_fl_act_output {
rte_be32_t port;
};
+/*
+ * ETH
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | - |jump_id| - |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_dst_47_16_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_dst_15_0_mask | eth_src_47_32_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_src_31_0_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_dst_47_16 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_dst_15_0 | eth_src_47_32 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | eth_src_31_0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_eth {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+ uint8_t eth_addr_mask[RTE_ETHER_ADDR_LEN * 2];
+ uint8_t eth_addr[RTE_ETHER_ADDR_LEN * 2];
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index bb445ef..431c212 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -573,6 +573,7 @@ struct nfp_mask_id_entry {
struct nfp_fl_key_ls *key_ls)
{
int ret = 0;
+ bool mac_set_flag = false;
const struct rte_flow_action *action;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
@@ -603,6 +604,13 @@ struct nfp_mask_id_entry {
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_PORT_ID detected");
key_ls->act_size += sizeof(struct nfp_fl_act_output);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_MAC_SRC detected");
+ if (!mac_set_flag) {
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
+ mac_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1221,6 +1229,36 @@ struct nfp_mask_id_entry {
return 0;
}
+static void
+nfp_flow_action_set_mac(char *act_data,
+ const struct rte_flow_action *action,
+ bool mac_src_flag,
+ bool mac_set_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_eth *set_eth;
+ const struct rte_flow_action_set_mac *set_mac;
+
+ if (mac_set_flag)
+ set_eth = (struct nfp_fl_act_set_eth *)act_data - 1;
+ else
+ set_eth = (struct nfp_fl_act_set_eth *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_eth);
+ set_eth->head.jump_id = NFP_FL_ACTION_OPCODE_SET_ETHERNET;
+ set_eth->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ set_eth->reserved = 0;
+
+ set_mac = (const struct rte_flow_action_set_mac *)action->conf;
+ if (mac_src_flag) {
+ rte_memcpy(&set_eth->eth_addr[RTE_ETHER_ADDR_LEN],
+ set_mac->mac_addr, RTE_ETHER_ADDR_LEN);
+ } else {
+ rte_memcpy(&set_eth->eth_addr[0],
+ set_mac->mac_addr, RTE_ETHER_ADDR_LEN);
+ }
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
@@ -1230,6 +1268,7 @@ struct nfp_mask_id_entry {
char *position;
char *action_data;
bool drop_flag = false;
+ bool mac_set_flag = false;
uint32_t total_actions = 0;
const struct rte_flow_action *action;
struct nfp_fl_rule_metadata *nfp_flow_meta;
@@ -1266,6 +1305,14 @@ struct nfp_mask_id_entry {
position += sizeof(struct nfp_fl_act_output);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_MAC_SRC");
+ nfp_flow_action_set_mac(position, action, true, mac_set_flag);
+ if (!mac_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_eth);
+ mac_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 13/24] net/nfp: add the offload support of set DST MAC action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (11 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 12/24] net/nfp: add the offload support of set SRC MAC action Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 14/24] net/nfp: add the offload support of pop VLAN action Chaoyong He
` (10 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of
set dest MAC action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 15 +++++++++++++++
3 files changed, 17 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index ab6ddab..578c35e 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -42,4 +42,5 @@ count = Y
dec_ttl = Y
drop = Y
port_id = Y
+set_mac_dst = Y
set_mac_src = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index f51fb1f..1a2caf4 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -166,6 +166,7 @@ New Features
* Count
* Drop
* TTL decrement
+ * Set the MAC address
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 431c212..68032b5 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -611,6 +611,13 @@ struct nfp_mask_id_entry {
mac_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_MAC_DST detected");
+ if (!mac_set_flag) {
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_eth);
+ mac_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1313,6 +1320,14 @@ struct nfp_mask_id_entry {
mac_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_MAC_DST");
+ nfp_flow_action_set_mac(position, action, false, mac_set_flag);
+ if (!mac_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_eth);
+ mac_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 14/24] net/nfp: add the offload support of pop VLAN action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (12 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 13/24] net/nfp: add the offload support of set DST " Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 15/24] net/nfp: add the offload support of push " Chaoyong He
` (9 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of pop_vlan action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 5 +++++
drivers/net/nfp/nfp_flow.c | 25 +++++++++++++++++++++++++
3 files changed, 31 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 578c35e..95d1779 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -41,6 +41,7 @@ vlan = Y
count = Y
dec_ttl = Y
drop = Y
+of_pop_vlan = Y
port_id = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index b61342e..4ce03da 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -362,6 +362,11 @@ struct nfp_fl_act_set_eth {
uint8_t eth_addr[RTE_ETHER_ADDR_LEN * 2];
};
+struct nfp_fl_act_pop_vlan {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 68032b5..fb06085 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -618,6 +618,10 @@ struct nfp_mask_id_entry {
mac_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_POP_VLAN detected");
+ key_ls->act_size += sizeof(struct nfp_fl_act_pop_vlan);
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1266,6 +1270,22 @@ struct nfp_mask_id_entry {
}
}
+static void
+nfp_flow_action_pop_vlan(char *act_data,
+ struct nfp_fl_rule_metadata *nfp_flow_meta)
+{
+ size_t act_size;
+ struct nfp_fl_act_pop_vlan *pop_vlan;
+
+ act_size = sizeof(struct nfp_fl_act_pop_vlan);
+ pop_vlan = (struct nfp_fl_act_pop_vlan *)act_data;
+ pop_vlan->head.jump_id = NFP_FL_ACTION_OPCODE_POP_VLAN;
+ pop_vlan->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ pop_vlan->reserved = 0;
+
+ nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_POPV);
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
@@ -1328,6 +1348,11 @@ struct nfp_mask_id_entry {
mac_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_OF_POP_VLAN");
+ nfp_flow_action_pop_vlan(position, nfp_flow_meta);
+ position += sizeof(struct nfp_fl_act_pop_vlan);
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 15/24] net/nfp: add the offload support of push VLAN action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (13 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 14/24] net/nfp: add the offload support of pop VLAN action Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 16/24] net/nfp: add the offload support of set SRC IPv4 action Chaoyong He
` (8 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of push_vlan action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 3 ++
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 7 ++++
drivers/net/nfp/nfp_flow.c | 60 ++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 95d1779..514e0ba 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -42,6 +42,9 @@ count = Y
dec_ttl = Y
drop = Y
of_pop_vlan = Y
+of_push_vlan = Y
+of_set_vlan_pcp = Y
+of_set_vlan_vid = Y
port_id = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 1a2caf4..5128c0d 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -167,6 +167,7 @@ New Features
* Drop
* TTL decrement
* Set the MAC address
+ * POP and PUSH VLAN
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 4ce03da..30a9ff5 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -367,6 +367,13 @@ struct nfp_fl_act_pop_vlan {
rte_be16_t reserved;
};
+struct nfp_fl_act_push_vlan {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+ rte_be16_t vlan_tpid;
+ rte_be16_t vlan_tci;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index fb06085..d66bcca 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -622,6 +622,16 @@ struct nfp_mask_id_entry {
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_POP_VLAN detected");
key_ls->act_size += sizeof(struct nfp_fl_act_pop_vlan);
break;
+ case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN detected");
+ key_ls->act_size += sizeof(struct nfp_fl_act_push_vlan);
+ break;
+ case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID detected");
+ break;
+ case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP detected");
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1287,6 +1297,39 @@ struct nfp_mask_id_entry {
}
static int
+nfp_flow_action_push_vlan(char *act_data,
+ const struct rte_flow_action *action)
+{
+ size_t act_size;
+ struct nfp_fl_act_push_vlan *push_vlan;
+ const struct rte_flow_action_of_push_vlan *push_vlan_conf;
+ const struct rte_flow_action_of_set_vlan_pcp *vlan_pcp_conf;
+ const struct rte_flow_action_of_set_vlan_vid *vlan_vid_conf;
+
+ if (((action + 1)->type != RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) ||
+ ((action + 2)->type != RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID))
+ return -EINVAL;
+
+ act_size = sizeof(struct nfp_fl_act_push_vlan);
+ push_vlan = (struct nfp_fl_act_push_vlan *)act_data;
+ push_vlan->head.jump_id = NFP_FL_ACTION_OPCODE_PUSH_VLAN;
+ push_vlan->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ push_vlan->reserved = 0;
+
+ push_vlan_conf = (const struct rte_flow_action_of_push_vlan *)
+ action->conf;
+ vlan_pcp_conf = (const struct rte_flow_action_of_set_vlan_pcp *)
+ (action + 1)->conf;
+ vlan_vid_conf = (const struct rte_flow_action_of_set_vlan_vid *)
+ (action + 2)->conf;
+ push_vlan->vlan_tpid = push_vlan_conf->ethertype;
+ push_vlan->vlan_tci = ((vlan_pcp_conf->vlan_pcp & 0x07) << 13) |
+ (vlan_vid_conf->vlan_vid & 0x0fff);
+
+ return 0;
+}
+
+static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
struct rte_flow *nfp_flow)
@@ -1353,6 +1396,23 @@ struct nfp_mask_id_entry {
nfp_flow_action_pop_vlan(position, nfp_flow_meta);
position += sizeof(struct nfp_fl_act_pop_vlan);
break;
+ case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN");
+ ret = nfp_flow_action_push_vlan(position, action);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed when process"
+ " RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN");
+ return ret;
+ }
+
+ /*
+ * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP and
+ * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
+ * have also been processed.
+ */
+ action += 2;
+ position += sizeof(struct nfp_fl_act_push_vlan);
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 16/24] net/nfp: add the offload support of set SRC IPv4 action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (14 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 15/24] net/nfp: add the offload support of push " Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 17/24] net/nfp: add the offload support of set DST " Chaoyong He
` (7 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of set source IPv4 address action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 25 ++++++++++++++++++
drivers/net/nfp/nfp_flow.c | 45 ++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 514e0ba..8f7120b 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -46,5 +46,6 @@ of_push_vlan = Y
of_set_vlan_pcp = Y
of_set_vlan_vid = Y
port_id = Y
+set_ipv4_src = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 30a9ff5..77cb51d 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -374,6 +374,31 @@ struct nfp_fl_act_push_vlan {
rte_be16_t vlan_tci;
};
+/*
+ * IPv4 addrs
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | |jump_id| - |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_saddr_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_saddr |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_daddr_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv4_daddr |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_ip4_addrs {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+ rte_be32_t ipv4_src_mask;
+ rte_be32_t ipv4_src;
+ rte_be32_t ipv4_dst_mask;
+ rte_be32_t ipv4_dst;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index d66bcca..54f94e5 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -574,6 +574,7 @@ struct nfp_mask_id_entry {
{
int ret = 0;
bool mac_set_flag = false;
+ bool ip_set_flag = false;
const struct rte_flow_action *action;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
@@ -632,6 +633,14 @@ struct nfp_mask_id_entry {
case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP detected");
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC detected");
+ if (!ip_set_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ip4_addrs);
+ ip_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1296,6 +1305,33 @@ struct nfp_mask_id_entry {
nfp_flow_meta->shortcut = rte_cpu_to_be_32(NFP_FL_SC_ACT_POPV);
}
+static void
+nfp_flow_action_set_ip(char *act_data,
+ const struct rte_flow_action *action,
+ bool ip_src_flag,
+ bool ip_set_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_ip4_addrs *set_ip;
+ const struct rte_flow_action_set_ipv4 *set_ipv4;
+
+ if (ip_set_flag)
+ set_ip = (struct nfp_fl_act_set_ip4_addrs *)act_data - 1;
+ else
+ set_ip = (struct nfp_fl_act_set_ip4_addrs *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_ip4_addrs);
+ set_ip->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS;
+ set_ip->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ set_ip->reserved = 0;
+
+ set_ipv4 = (const struct rte_flow_action_set_ipv4 *)action->conf;
+ if (ip_src_flag)
+ set_ip->ipv4_src = set_ipv4->ipv4_addr;
+ else
+ set_ip->ipv4_dst = set_ipv4->ipv4_addr;
+}
+
static int
nfp_flow_action_push_vlan(char *act_data,
const struct rte_flow_action *action)
@@ -1338,6 +1374,7 @@ struct nfp_mask_id_entry {
char *position;
char *action_data;
bool drop_flag = false;
+ bool ip_set_flag = false;
bool mac_set_flag = false;
uint32_t total_actions = 0;
const struct rte_flow_action *action;
@@ -1413,6 +1450,14 @@ struct nfp_mask_id_entry {
action += 2;
position += sizeof(struct nfp_fl_act_push_vlan);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC");
+ nfp_flow_action_set_ip(position, action, true, ip_set_flag);
+ if (!ip_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_ip4_addrs);
+ ip_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 17/24] net/nfp: add the offload support of set DST IPv4 action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (15 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 16/24] net/nfp: add the offload support of set SRC IPv4 action Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 18/24] net/nfp: add the offload support of set SRC IPv6 action Chaoyong He
` (6 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of
set dest IPv4 address action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 16 ++++++++++++++++
3 files changed, 18 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 8f7120b..14a9c18 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -46,6 +46,7 @@ of_push_vlan = Y
of_set_vlan_pcp = Y
of_set_vlan_vid = Y
port_id = Y
+set_ipv4_dst = Y
set_ipv4_src = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 5128c0d..cdc4ef6 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -168,6 +168,7 @@ New Features
* TTL decrement
* Set the MAC address
* POP and PUSH VLAN
+ * Set the IP address of IPv4
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 54f94e5..aeaf1f4 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -641,6 +641,14 @@ struct nfp_mask_id_entry {
ip_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_DST detected");
+ if (!ip_set_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ip4_addrs);
+ ip_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1458,6 +1466,14 @@ struct nfp_mask_id_entry {
ip_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_DST");
+ nfp_flow_action_set_ip(position, action, false, ip_set_flag);
+ if (!ip_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_ip4_addrs);
+ ip_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 18/24] net/nfp: add the offload support of set SRC IPv6 action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (16 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 17/24] net/nfp: add the offload support of set DST " Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 19/24] net/nfp: add the offload support of set DST " Chaoyong He
` (5 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of set source IPv6 address action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 33 ++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_flow.c | 35 ++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 14a9c18..0c04458 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -48,5 +48,6 @@ of_set_vlan_vid = Y
port_id = Y
set_ipv4_dst = Y
set_ipv4_src = Y
+set_ipv6_src = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 77cb51d..45e50dd 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -399,6 +399,39 @@ struct nfp_fl_act_set_ip4_addrs {
rte_be32_t ipv4_dst;
};
+/*
+ * IPv6 addr
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | |jump_id| - |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_127_96_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_127_96 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_95_64_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_95_64 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_63_32_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_63_32 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_31_0_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ipv6_addr_31_0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_ipv6_addr {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+ struct {
+ rte_be32_t mask;
+ rte_be32_t exact;
+ } ipv6[4];
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index aeaf1f4..1adc3dd 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -649,6 +649,10 @@ struct nfp_mask_id_entry {
ip_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC detected");
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1340,6 +1344,32 @@ struct nfp_mask_id_entry {
set_ip->ipv4_dst = set_ipv4->ipv4_addr;
}
+static void
+nfp_flow_action_set_ipv6(char *act_data,
+ const struct rte_flow_action *action,
+ bool ip_src_flag)
+{
+ int i;
+ size_t act_size;
+ struct nfp_fl_act_set_ipv6_addr *set_ip;
+ const struct rte_flow_action_set_ipv6 *set_ipv6;
+
+ set_ip = (struct nfp_fl_act_set_ipv6_addr *)act_data;
+ set_ipv6 = (const struct rte_flow_action_set_ipv6 *)action->conf;
+
+ if (ip_src_flag)
+ set_ip->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_SRC;
+ else
+ set_ip->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_DST;
+
+ act_size = sizeof(struct nfp_fl_act_set_ipv6_addr);
+ set_ip->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ set_ip->reserved = 0;
+
+ for (i = 0; i < 4; i++)
+ set_ip->ipv6[i].exact = set_ipv6->ipv6_addr[i];
+}
+
static int
nfp_flow_action_push_vlan(char *act_data,
const struct rte_flow_action *action)
@@ -1474,6 +1504,11 @@ struct nfp_mask_id_entry {
ip_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC");
+ nfp_flow_action_set_ipv6(position, action, true);
+ position += sizeof(struct nfp_fl_act_set_ipv6_addr);
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 19/24] net/nfp: add the offload support of set DST IPv6 action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (17 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 18/24] net/nfp: add the offload support of set SRC IPv6 action Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 20/24] net/nfp: add the offload support of set TP SRC port action Chaoyong He
` (4 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of
set dest IPv6 address action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 2 +-
drivers/net/nfp/nfp_flow.c | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 0c04458..16fdf87 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -48,6 +48,7 @@ of_set_vlan_vid = Y
port_id = Y
set_ipv4_dst = Y
set_ipv4_src = Y
+set_ipv6_dst = Y
set_ipv6_src = Y
set_mac_dst = Y
set_mac_src = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index cdc4ef6..6f0c9e9 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -168,7 +168,7 @@ New Features
* TTL decrement
* Set the MAC address
* POP and PUSH VLAN
- * Set the IP address of IPv4
+ * Set the IP address of IPv4 and IPv6
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 1adc3dd..6c53fba 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -653,6 +653,10 @@ struct nfp_mask_id_entry {
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC detected");
key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_DST detected");
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1509,6 +1513,11 @@ struct nfp_mask_id_entry {
nfp_flow_action_set_ipv6(position, action, true);
position += sizeof(struct nfp_fl_act_set_ipv6_addr);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_DST");
+ nfp_flow_action_set_ipv6(position, action, false);
+ position += sizeof(struct nfp_fl_act_set_ipv6_addr);
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 20/24] net/nfp: add the offload support of set TP SRC port action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (18 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 19/24] net/nfp: add the offload support of set DST " Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:08 ` [PATCH v2 21/24] net/nfp: add the offload support of set TP DST " Chaoyong He
` (3 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of set TP source port action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 21 +++++++++++++++
drivers/net/nfp/nfp_flow.c | 44 ++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 16fdf87..68f5b89 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -52,3 +52,4 @@ set_ipv6_dst = Y
set_ipv6_src = Y
set_mac_dst = Y
set_mac_src = Y
+set_tp_src = Y
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 45e50dd..26de8b1 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -432,6 +432,27 @@ struct nfp_fl_act_set_ipv6_addr {
} ipv6[4];
};
+/*
+ * TCP/UDP/SCTP
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | |jump_id| - |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | src_mask | dst_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | src | dst |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_tport {
+ struct nfp_fl_act_head head;
+ rte_be16_t reserved;
+ rte_be16_t src_port_mask;
+ rte_be16_t dst_port_mask;
+ rte_be16_t src_port;
+ rte_be16_t dst_port;
+};
+
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 6c53fba..96bb69d 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -575,6 +575,7 @@ struct nfp_mask_id_entry {
int ret = 0;
bool mac_set_flag = false;
bool ip_set_flag = false;
+ bool tp_set_flag = false;
const struct rte_flow_action *action;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
@@ -657,6 +658,13 @@ struct nfp_mask_id_entry {
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_DST detected");
key_ls->act_size += sizeof(struct nfp_fl_act_set_ipv6_addr);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TP_SRC detected");
+ if (!tp_set_flag) {
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
+ tp_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1374,6 +1382,33 @@ struct nfp_mask_id_entry {
set_ip->ipv6[i].exact = set_ipv6->ipv6_addr[i];
}
+static void
+nfp_flow_action_set_tp(char *act_data,
+ const struct rte_flow_action *action,
+ bool tp_src_flag,
+ bool tp_set_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_tport *set_tp;
+ const struct rte_flow_action_set_tp *set_tp_conf;
+
+ if (tp_set_flag)
+ set_tp = (struct nfp_fl_act_set_tport *)act_data - 1;
+ else
+ set_tp = (struct nfp_fl_act_set_tport *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_tport);
+ set_tp->head.jump_id = NFP_FL_ACTION_OPCODE_SET_TCP;
+ set_tp->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+ set_tp->reserved = 0;
+
+ set_tp_conf = (const struct rte_flow_action_set_tp *)action->conf;
+ if (tp_src_flag)
+ set_tp->src_port = set_tp_conf->port;
+ else
+ set_tp->dst_port = set_tp_conf->port;
+}
+
static int
nfp_flow_action_push_vlan(char *act_data,
const struct rte_flow_action *action)
@@ -1417,6 +1452,7 @@ struct nfp_mask_id_entry {
char *action_data;
bool drop_flag = false;
bool ip_set_flag = false;
+ bool tp_set_flag = false;
bool mac_set_flag = false;
uint32_t total_actions = 0;
const struct rte_flow_action *action;
@@ -1518,6 +1554,14 @@ struct nfp_mask_id_entry {
nfp_flow_action_set_ipv6(position, action, false);
position += sizeof(struct nfp_fl_act_set_ipv6_addr);
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_SRC");
+ nfp_flow_action_set_tp(position, action, true, tp_set_flag);
+ if (!tp_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_tport);
+ tp_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 21/24] net/nfp: add the offload support of set TP DST port action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (19 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 20/24] net/nfp: add the offload support of set TP SRC port action Chaoyong He
@ 2022-10-10 6:08 ` Chaoyong He
2022-10-10 6:09 ` [PATCH v2 22/24] net/nfp: add the offload support of set TTL action Chaoyong He
` (2 subsequent siblings)
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:08 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of set
TP dest port action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 15 +++++++++++++++
3 files changed, 17 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 68f5b89..c7b560b 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -52,4 +52,5 @@ set_ipv6_dst = Y
set_ipv6_src = Y
set_mac_dst = Y
set_mac_src = Y
+set_tp_dst = Y
set_tp_src = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 6f0c9e9..f0416e5 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -169,6 +169,7 @@ New Features
* Set the MAC address
* POP and PUSH VLAN
* Set the IP address of IPv4 and IPv6
+ * Set the port number
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 96bb69d..cbdd357 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -665,6 +665,13 @@ struct nfp_mask_id_entry {
tp_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TP_DST detected");
+ if (!tp_set_flag) {
+ key_ls->act_size += sizeof(struct nfp_fl_act_set_tport);
+ tp_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1562,6 +1569,14 @@ struct nfp_mask_id_entry {
tp_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TP_DST");
+ nfp_flow_action_set_tp(position, action, false, tp_set_flag);
+ if (!tp_set_flag) {
+ position += sizeof(struct nfp_fl_act_set_tport);
+ tp_set_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 22/24] net/nfp: add the offload support of set TTL action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (20 preceding siblings ...)
2022-10-10 6:08 ` [PATCH v2 21/24] net/nfp: add the offload support of set TP DST " Chaoyong He
@ 2022-10-10 6:09 ` Chaoyong He
2022-10-10 6:09 ` [PATCH v2 23/24] net/nfp: add the offload support of set IPv4 DSCP action Chaoyong He
2022-10-10 6:09 ` [PATCH v2 24/24] net/nfp: add the offload support of set IPv6 " Chaoyong He
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:09 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding data structure and logics, to support
the offload of set TTL action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.h | 44 +++++++++++++++++
drivers/net/nfp/nfp_flow.c | 84 ++++++++++++++++++++++++++++++++
4 files changed, 130 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index c7b560b..2706fd2 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -54,3 +54,4 @@ set_mac_dst = Y
set_mac_src = Y
set_tp_dst = Y
set_tp_src = Y
+set_ttl = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index f0416e5..121094e 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -170,6 +170,7 @@ New Features
* POP and PUSH VLAN
* Set the IP address of IPv4 and IPv6
* Set the port number
+ * Set the TTL
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 26de8b1..6bf8ff7 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -400,6 +400,25 @@ struct nfp_fl_act_set_ip4_addrs {
};
/*
+ * IPv4 ttl tos
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | |jump_id| ttl_mask | tos_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ttl | tos | 0 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_ip4_ttl_tos {
+ struct nfp_fl_act_head head;
+ uint8_t ipv4_ttl_mask;
+ uint8_t ipv4_tos_mask;
+ uint8_t ipv4_ttl;
+ uint8_t ipv4_tos;
+ rte_be16_t reserved;
+};
+
+/*
* IPv6 addr
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
@@ -433,6 +452,31 @@ struct nfp_fl_act_set_ipv6_addr {
};
/*
+ * ipv6 tc hl fl
+ * 3 2 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | - |opcode | |jump_id| tclass_mask | hlimit_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | 0 | tclass | hlimit |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | 0 | flabel_mask |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | 0 | flabel |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_set_ipv6_tc_hl_fl {
+ struct nfp_fl_act_head head;
+ uint8_t ipv6_tc_mask;
+ uint8_t ipv6_hop_limit_mask;
+ rte_be16_t reserved;
+ uint8_t ipv6_tc;
+ uint8_t ipv6_hop_limit;
+ rte_be32_t ipv6_label_mask;
+ rte_be32_t ipv6_label;
+};
+
+/*
* TCP/UDP/SCTP
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index cbdd357..928f909 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -573,9 +573,11 @@ struct nfp_mask_id_entry {
struct nfp_fl_key_ls *key_ls)
{
int ret = 0;
+ bool tc_hl_flag = false;
bool mac_set_flag = false;
bool ip_set_flag = false;
bool tp_set_flag = false;
+ bool ttl_tos_flag = false;
const struct rte_flow_action *action;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
@@ -672,6 +674,22 @@ struct nfp_mask_id_entry {
tp_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TTL:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_TTL detected");
+ if (key_ls->key_layer & NFP_FLOWER_LAYER_IPV4) {
+ if (!ttl_tos_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos_flag = true;
+ }
+ } else {
+ if (!tc_hl_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl_flag = true;
+ }
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1449,6 +1467,52 @@ struct nfp_mask_id_entry {
return 0;
}
+static void
+nfp_flow_action_set_ttl(char *act_data,
+ const struct rte_flow_action *action,
+ bool ttl_tos_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_ip4_ttl_tos *ttl_tos;
+ const struct rte_flow_action_set_ttl *ttl_conf;
+
+ if (ttl_tos_flag)
+ ttl_tos = (struct nfp_fl_act_set_ip4_ttl_tos *)act_data - 1;
+ else
+ ttl_tos = (struct nfp_fl_act_set_ip4_ttl_tos *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS;
+ ttl_tos->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+
+ ttl_conf = (const struct rte_flow_action_set_ttl *)action->conf;
+ ttl_tos->ipv4_ttl = ttl_conf->ttl_value;
+ ttl_tos->reserved = 0;
+}
+
+static void
+nfp_flow_action_set_hl(char *act_data,
+ const struct rte_flow_action *action,
+ bool tc_hl_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_ipv6_tc_hl_fl *tc_hl;
+ const struct rte_flow_action_set_ttl *ttl_conf;
+
+ if (tc_hl_flag)
+ tc_hl = (struct nfp_fl_act_set_ipv6_tc_hl_fl *)act_data - 1;
+ else
+ tc_hl = (struct nfp_fl_act_set_ipv6_tc_hl_fl *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL;
+ tc_hl->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+
+ ttl_conf = (const struct rte_flow_action_set_ttl *)action->conf;
+ tc_hl->ipv6_hop_limit = ttl_conf->ttl_value;
+ tc_hl->reserved = 0;
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
@@ -1457,17 +1521,21 @@ struct nfp_mask_id_entry {
int ret = 0;
char *position;
char *action_data;
+ bool ttl_tos_flag = false;
+ bool tc_hl_flag = false;
bool drop_flag = false;
bool ip_set_flag = false;
bool tp_set_flag = false;
bool mac_set_flag = false;
uint32_t total_actions = 0;
const struct rte_flow_action *action;
+ struct nfp_flower_meta_tci *meta_tci;
struct nfp_fl_rule_metadata *nfp_flow_meta;
nfp_flow_meta = nfp_flow->payload.meta;
action_data = nfp_flow->payload.action_data;
position = action_data;
+ meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
for (action = actions; action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
switch (action->type) {
@@ -1577,6 +1645,22 @@ struct nfp_mask_id_entry {
tp_set_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_TTL:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_TTL");
+ if (meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) {
+ nfp_flow_action_set_ttl(position, action, ttl_tos_flag);
+ if (!ttl_tos_flag) {
+ position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos_flag = true;
+ }
+ } else {
+ nfp_flow_action_set_hl(position, action, ttl_tos_flag);
+ if (!tc_hl_flag) {
+ position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl_flag = true;
+ }
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 23/24] net/nfp: add the offload support of set IPv4 DSCP action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (21 preceding siblings ...)
2022-10-10 6:09 ` [PATCH v2 22/24] net/nfp: add the offload support of set TTL action Chaoyong He
@ 2022-10-10 6:09 ` Chaoyong He
2022-10-10 6:09 ` [PATCH v2 24/24] net/nfp: add the offload support of set IPv6 " Chaoyong He
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:09 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of
set IPv4 DSCP action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 1 +
drivers/net/nfp/nfp_flow.c | 39 ++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 2706fd2..7cb68b5 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -46,6 +46,7 @@ of_push_vlan = Y
of_set_vlan_pcp = Y
of_set_vlan_vid = Y
port_id = Y
+set_ipv4_dscp = Y
set_ipv4_dst = Y
set_ipv4_src = Y
set_ipv6_dst = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 121094e..8e19f18 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -171,6 +171,7 @@ New Features
* Set the IP address of IPv4 and IPv6
* Set the port number
* Set the TTL
+ * Set the DSCP of IPv4
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 928f909..283b4b1 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -690,6 +690,14 @@ struct nfp_mask_id_entry {
}
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP detected");
+ if (!ttl_tos_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1513,6 +1521,29 @@ struct nfp_mask_id_entry {
tc_hl->reserved = 0;
}
+static void
+nfp_flow_action_set_tos(char *act_data,
+ const struct rte_flow_action *action,
+ bool ttl_tos_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_ip4_ttl_tos *ttl_tos;
+ const struct rte_flow_action_set_dscp *tos_conf;
+
+ if (ttl_tos_flag)
+ ttl_tos = (struct nfp_fl_act_set_ip4_ttl_tos *)act_data - 1;
+ else
+ ttl_tos = (struct nfp_fl_act_set_ip4_ttl_tos *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS;
+ ttl_tos->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+
+ tos_conf = (const struct rte_flow_action_set_dscp *)action->conf;
+ ttl_tos->ipv4_tos = tos_conf->dscp;
+ ttl_tos->reserved = 0;
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
@@ -1661,6 +1692,14 @@ struct nfp_mask_id_entry {
}
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP");
+ nfp_flow_action_set_tos(position, action, ttl_tos_flag);
+ if (!ttl_tos_flag) {
+ position += sizeof(struct nfp_fl_act_set_ip4_ttl_tos);
+ ttl_tos_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH v2 24/24] net/nfp: add the offload support of set IPv6 DSCP action
2022-10-10 6:08 [PATCH v2 00/24] add the basic rte_flow offload support of nfp PMD Chaoyong He
` (22 preceding siblings ...)
2022-10-10 6:09 ` [PATCH v2 23/24] net/nfp: add the offload support of set IPv4 DSCP action Chaoyong He
@ 2022-10-10 6:09 ` Chaoyong He
23 siblings, 0 replies; 38+ messages in thread
From: Chaoyong He @ 2022-10-10 6:09 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Add the corresponding logics to support the offload of
set IPv6 DSCP action.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
doc/guides/rel_notes/release_22_11.rst | 2 +-
drivers/net/nfp/nfp_flow.c | 39 ++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 7cb68b5..1ad6c2c 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -49,6 +49,7 @@ port_id = Y
set_ipv4_dscp = Y
set_ipv4_dst = Y
set_ipv4_src = Y
+set_ipv6_dscp = Y
set_ipv6_dst = Y
set_ipv6_src = Y
set_mac_dst = Y
diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 8e19f18..b79cffa 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -171,7 +171,7 @@ New Features
* Set the IP address of IPv4 and IPv6
* Set the port number
* Set the TTL
- * Set the DSCP of IPv4
+ * Set the DSCP of IPv4 and IPv6
* **Updated NXP dpaa2 driver.**
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 283b4b1..3f3ac4c 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -698,6 +698,14 @@ struct nfp_mask_id_entry {
ttl_tos_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP detected");
+ if (!tc_hl_flag) {
+ key_ls->act_size +=
+ sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
return -ENOTSUP;
@@ -1544,6 +1552,29 @@ struct nfp_mask_id_entry {
ttl_tos->reserved = 0;
}
+static void
+nfp_flow_action_set_tc(char *act_data,
+ const struct rte_flow_action *action,
+ bool tc_hl_flag)
+{
+ size_t act_size;
+ struct nfp_fl_act_set_ipv6_tc_hl_fl *tc_hl;
+ const struct rte_flow_action_set_dscp *tos_conf;
+
+ if (tc_hl_flag)
+ tc_hl = (struct nfp_fl_act_set_ipv6_tc_hl_fl *)act_data - 1;
+ else
+ tc_hl = (struct nfp_fl_act_set_ipv6_tc_hl_fl *)act_data;
+
+ act_size = sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL;
+ tc_hl->head.len_lw = act_size >> NFP_FL_LW_SIZ;
+
+ tos_conf = (const struct rte_flow_action_set_dscp *)action->conf;
+ tc_hl->ipv6_tc = tos_conf->dscp;
+ tc_hl->reserved = 0;
+}
+
static int
nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor,
const struct rte_flow_action actions[],
@@ -1700,6 +1731,14 @@ struct nfp_mask_id_entry {
ttl_tos_flag = true;
}
break;
+ case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP:
+ PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP");
+ nfp_flow_action_set_tc(position, action, ttl_tos_flag);
+ if (!tc_hl_flag) {
+ position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
+ tc_hl_flag = true;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
return -ENOTSUP;
--
1.8.3.1
^ permalink raw reply [flat|nested] 38+ messages in thread