[4/4] net/nfp: support generic SCTP flow item

Message ID 20240528015504.2376070-5-chaoyong.he@corigine.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series support generic flow item |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Chaoyong He May 28, 2024, 1:55 a.m. UTC
  Add support of SCTP flow item with a NULL 'item->spec' value.

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/flower/nfp_flower_flow.c | 37 +++++++++++++++++-------
 1 file changed, 26 insertions(+), 11 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 4cbdfd02b8..bd77807db0 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -1586,28 +1586,43 @@  nfp_flow_merge_sctp(__rte_unused struct nfp_app_fw_flower *app_fw_flower,
 		bool is_mask,
 		__rte_unused bool is_outer_layer)
 {
-	char *ports_off;
 	struct nfp_flower_tp_ports *ports;
+	struct nfp_flower_ipv4 *ipv4 = NULL;
+	struct nfp_flower_ipv6 *ipv6 = NULL;
 	struct nfp_flower_meta_tci *meta_tci;
 	const struct rte_flow_item_sctp *spec;
 	const struct rte_flow_item_sctp *mask;
 
+	meta_tci = (struct nfp_flower_meta_tci *)nfp_flow->payload.unmasked_data;
+	if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
+		ipv4 = (struct nfp_flower_ipv4 *)
+				(*mbuf_off - sizeof(struct nfp_flower_ipv4));
+		if (is_mask)
+			ipv4->ip_ext.proto = 0xFF;
+		else
+			ipv4->ip_ext.proto = IPPROTO_SCTP;
+		ports = (struct nfp_flower_tp_ports *)
+				((char *)ipv4 - sizeof(struct nfp_flower_tp_ports));
+	} else if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6) != 0) {
+		ipv6 = (struct nfp_flower_ipv6 *)
+				(*mbuf_off - sizeof(struct nfp_flower_ipv6));
+		if (is_mask)
+			ipv6->ip_ext.proto = 0xFF;
+		else
+			ipv6->ip_ext.proto = IPPROTO_SCTP;
+		ports = (struct nfp_flower_tp_ports *)
+				((char *)ipv6 - sizeof(struct nfp_flower_tp_ports));
+	} else {
+		PMD_DRV_LOG(ERR, "nfp flow merge sctp: no L3 layer!");
+		return -EINVAL;
+	}
+
 	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) != 0) {
-		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;