From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH v2 08/11] net/nfp: support IPv6 flow item
Date: Tue, 5 Dec 2023 10:54:54 +0800 [thread overview]
Message-ID: <20231205025457.1067372-9-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231205025457.1067372-1-chaoyong.he@corigine.com>
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: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
drivers/net/nfp/nfp_net_cmsg.h | 61 +++++++++++++++++++++++++++
drivers/net/nfp/nfp_net_flow.c | 76 +++++++++++++++++++++++++++++++++-
2 files changed, 136 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/nfp_net_cmsg.h b/drivers/net/nfp/nfp_net_cmsg.h
index 9bc064d9d7..e177ac7cd6 100644
--- a/drivers/net/nfp/nfp_net_cmsg.h
+++ b/drivers/net/nfp/nfp_net_cmsg.h
@@ -58,6 +58,67 @@ struct nfp_net_cmsg_match_v4 {
uint16_t dst_port_mask;
};
+/**
+ * Match IPv6 data
+ * 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 | | Position | L4 Proto | L4 Proto Mask |
+ * +-----+-------------------------+---------------+---------------+
+ * 1 | SIP6 (0-3B) |
+ * +---------------------------------------------------------------+
+ * 2 | SIP6 (4-7B) |
+ * +---------------------------------------------------------------+
+ * 3 | SIP6 (8-11B) |
+ * +---------------------------------------------------------------+
+ * 4 | SIP6 (12-15B) |
+ * +---------------------------------------------------------------+
+ * 5 | SIP6 Mask (0-3B) |
+ * +---------------------------------------------------------------+
+ * 6 | SIP6 Mask (4-7B) |
+ * +---------------------------------------------------------------+
+ * 7 | SIP6 Mask (8-11B) |
+ * +---------------------------------------------------------------+
+ * 8 | SIP6 Mask (12-15B) |
+ * +---------------------------------------------------------------+
+ * 9 | DIP6 (0-3B) |
+ * +---------------------------------------------------------------+
+ * 10 | DIP6 (4-7B) |
+ * +---------------------------------------------------------------+
+ * 11 | DIP6 (8-11B) |
+ * +---------------------------------------------------------------+
+ * 12 | DIP6 (12-15B) |
+ * +---------------------------------------------------------------+
+ * 13 | DIP6 Mask (0-3B) |
+ * +---------------------------------------------------------------+
+ * 14 | DIP6 Mask (4-7B) |
+ * +---------------------------------------------------------------+
+ * 15 | DIP6 Mask (8-11B) |
+ * +---------------------------------------------------------------+
+ * 16 | DIP6 Mask (12-15B) |
+ * +-------------------------------+-------------------------------+
+ * 17 | SPort | SPort Mask |
+ * +-------------------------------+-------------------------------+
+ * 18 | DPort | DPort Mask |
+ * +-----------------+-------------+-------------------------------+
+ *
+ * Position – Position index of the rule, 13bits.
+ * As priority, smaller value indicates higher priority.
+ */
+struct nfp_net_cmsg_match_v6 {
+ uint8_t l4_protocol_mask;
+ uint8_t l4_protocol;
+ uint16_t position;
+ uint8_t src_ipv6[16];
+ uint8_t src_ipv6_mask[16];
+ uint8_t dst_ipv6[16];
+ uint8_t dst_ipv6_mask[16];
+ uint16_t src_port_mask;
+ uint16_t src_port;
+ uint16_t dst_port_mask;
+ uint16_t dst_port;
+};
+
#define NFP_NET_CMSG_ACTION_DROP (0x1 << 0) /* Drop action */
#define NFP_NET_CMSG_ACTION_QUEUE (0x1 << 1) /* Queue action */
#define NFP_NET_CMSG_ACTION_MARK (0x1 << 2) /* Mark action */
diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c
index 6edb96c17a..56846e3935 100644
--- a/drivers/net/nfp/nfp_net_flow.c
+++ b/drivers/net/nfp/nfp_net_flow.c
@@ -192,6 +192,10 @@ nfp_net_flow_calculate_items(const struct rte_flow_item items[],
PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV4 detected");
*match_len = sizeof(struct nfp_net_cmsg_match_v4);
return 0;
+ case RTE_FLOW_ITEM_TYPE_IPV6:
+ PMD_DRV_LOG(DEBUG, "RTE_FLOW_ITEM_TYPE_IPV6 detected");
+ *match_len = sizeof(struct nfp_net_cmsg_match_v6);
+ return 0;
default:
PMD_DRV_LOG(ERR, "Can't calculate match length");
*match_len = 0;
@@ -255,11 +259,62 @@ nfp_net_flow_merge_ipv4(struct rte_flow *nfp_flow,
return 0;
}
+static int
+nfp_net_flow_merge_ipv6(struct rte_flow *nfp_flow,
+ const struct rte_flow_item *item,
+ const struct nfp_net_flow_item_proc *proc)
+{
+ uint32_t i;
+ struct nfp_net_cmsg_match_v6 *ipv6;
+ const struct rte_flow_item_ipv6 *mask;
+ const struct rte_flow_item_ipv6 *spec;
+
+ spec = item->spec;
+ if (spec == NULL) {
+ PMD_DRV_LOG(DEBUG, "NFP flow merge ipv6: no item->spec!");
+ return 0;
+ }
+
+ mask = (item->mask != NULL) ? item->mask : proc->mask_default;
+
+ nfp_flow->payload.cmsg_type = NFP_NET_CFG_MBOX_CMD_FS_ADD_V6;
+ ipv6 = (struct nfp_net_cmsg_match_v6 *)nfp_flow->payload.match_data;
+
+ ipv6->l4_protocol_mask = mask->hdr.proto;
+ for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
+ ipv6->src_ipv6_mask[i] = mask->hdr.src_addr[i + 3];
+ ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr[i + 2];
+ ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr[i + 1];
+ ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr[i];
+
+ ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr[i + 3];
+ ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr[i + 2];
+ ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr[i + 1];
+ ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr[i];
+ }
+
+ ipv6->l4_protocol = spec->hdr.proto;
+ for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
+ ipv6->src_ipv6[i] = spec->hdr.src_addr[i + 3];
+ ipv6->src_ipv6[i + 1] = spec->hdr.src_addr[i + 2];
+ ipv6->src_ipv6[i + 2] = spec->hdr.src_addr[i + 1];
+ ipv6->src_ipv6[i + 3] = spec->hdr.src_addr[i];
+
+ ipv6->dst_ipv6[i] = spec->hdr.dst_addr[i + 3];
+ ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr[i + 2];
+ ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr[i + 1];
+ ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr[i];
+ }
+
+ return 0;
+}
+
/* Graph of supported items and associated process function */
static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = {
[RTE_FLOW_ITEM_TYPE_END] = {
.next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_ETH,
- RTE_FLOW_ITEM_TYPE_IPV4),
+ RTE_FLOW_ITEM_TYPE_IPV4,
+ RTE_FLOW_ITEM_TYPE_IPV6),
},
[RTE_FLOW_ITEM_TYPE_ETH] = {
.merge = nfp_net_flow_merge_eth,
@@ -276,6 +331,20 @@ static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = {
.mask_sz = sizeof(struct rte_flow_item_ipv4),
.merge = nfp_net_flow_merge_ipv4,
},
+ [RTE_FLOW_ITEM_TYPE_IPV6] = {
+ .mask_support = &(const struct rte_flow_item_ipv6){
+ .hdr = {
+ .proto = 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",
+ },
+ },
+ .mask_default = &rte_flow_item_ipv6_mask,
+ .mask_sz = sizeof(struct rte_flow_item_ipv6),
+ .merge = nfp_net_flow_merge_ipv6,
+ },
};
static int
@@ -419,12 +488,17 @@ nfp_net_flow_process_priority(struct rte_flow *nfp_flow,
uint32_t match_len)
{
struct nfp_net_cmsg_match_v4 *ipv4;
+ struct nfp_net_cmsg_match_v6 *ipv6;
switch (match_len) {
case sizeof(struct nfp_net_cmsg_match_v4):
ipv4 = (struct nfp_net_cmsg_match_v4 *)nfp_flow->payload.match_data;
ipv4->position = nfp_flow->position;
break;
+ case sizeof(struct nfp_net_cmsg_match_v6):
+ ipv6 = (struct nfp_net_cmsg_match_v6 *)nfp_flow->payload.match_data;
+ ipv6->position = nfp_flow->position;
+ break;
default:
break;
}
--
2.39.1
next prev parent reply other threads:[~2023-12-05 2:56 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 6:25 [PATCH 00/11] Add basic flow support for corenic firmware Chaoyong He
2023-11-03 6:25 ` [PATCH 01/11] net/nfp: move some source files Chaoyong He
2023-11-03 6:25 ` [PATCH 02/11] drivers: add the structures and functions for flow offload Chaoyong He
2023-11-03 6:25 ` [PATCH 03/11] net/nfp: add the control message channel Chaoyong He
2023-11-03 6:25 ` [PATCH 04/11] net/nfp: support flow API for CoreNIC firmware Chaoyong He
2023-11-03 6:26 ` [PATCH 05/11] net/nfp: support Ethernet flow item Chaoyong He
2023-11-03 6:26 ` [PATCH 06/11] net/nfp: support drop flow action Chaoyong He
2023-11-03 6:26 ` [PATCH 07/11] net/nfp: support IPv4 flow item Chaoyong He
2023-11-03 6:26 ` [PATCH 08/11] net/nfp: support IPv6 " Chaoyong He
2023-11-03 6:26 ` [PATCH 09/11] net/nfp: support TCP/UDP/SCTP flow items Chaoyong He
2023-11-03 6:26 ` [PATCH 10/11] drivers: support MARK flow action Chaoyong He
2023-11-03 6:26 ` [PATCH 11/11] net/nfp: support QUEUE " Chaoyong He
2023-11-03 16:12 ` [PATCH 00/11] Add basic flow support for corenic firmware Ferruh Yigit
2023-11-07 1:42 ` Chaoyong He
2023-11-07 9:18 ` Ferruh Yigit
2023-11-07 9:23 ` Chaoyong He
2023-11-07 16:50 ` Patrick Robb
2023-11-07 17:04 ` Patrick Robb
2023-11-07 20:19 ` Ferruh Yigit
2023-11-07 21:59 ` Patrick Robb
2023-11-03 17:01 ` Ferruh Yigit
2023-12-05 2:54 ` [PATCH v2 " Chaoyong He
2023-12-05 2:54 ` [PATCH v2 01/11] net/nfp: move some source files Chaoyong He
2023-12-05 2:54 ` [PATCH v2 02/11] net/nfp: add the structures and functions for flow offload Chaoyong He
2023-12-05 2:54 ` [PATCH v2 03/11] net/nfp: add the control message channel Chaoyong He
2023-12-08 19:15 ` Ferruh Yigit
2023-12-05 2:54 ` [PATCH v2 04/11] net/nfp: support flow API for CoreNIC firmware Chaoyong He
2023-12-05 2:54 ` [PATCH v2 05/11] net/nfp: support Ethernet flow item Chaoyong He
2023-12-05 2:54 ` [PATCH v2 06/11] net/nfp: support drop flow action Chaoyong He
2023-12-05 2:54 ` [PATCH v2 07/11] net/nfp: support IPv4 flow item Chaoyong He
2023-12-05 2:54 ` Chaoyong He [this message]
2023-12-05 2:54 ` [PATCH v2 09/11] net/nfp: support TCP/UDP/SCTP flow items Chaoyong He
2023-12-05 2:54 ` [PATCH v2 10/11] net/nfp: support MARK flow action Chaoyong He
2023-12-05 2:54 ` [PATCH v2 11/11] net/nfp: support QUEUE " Chaoyong He
2023-12-08 16:39 ` [PATCH v2 00/11] Add basic flow support for corenic firmware Ferruh Yigit
2023-12-11 1:42 ` Chaoyong He
2023-12-11 14:06 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231205025457.1067372-9-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).