[v1,25/38] net/mvpp2: support udf configuration
diff mbox series

Message ID 20201202101212.4717-26-lironh@marvell.com
State Changes Requested
Delegated to: Jerin Jacob
Headers show
Series
  • net/mvpp2: misc updates
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Liron Himi Dec. 2, 2020, 10:11 a.m. UTC
From: Liron Himi <lironh@marvell.com>

extend the config file with 'udf' (user-defined) settings

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c |   4 +-
 drivers/net/mvpp2/mrvl_qos.c    | 212 ++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_qos.h    |   3 +
 3 files changed, 218 insertions(+), 1 deletion(-)

Comments

Michael Shamis Dec. 23, 2020, 9:35 a.m. UTC | #1
Reviewed-by: Michael Shamis <michaelsh@marvell.com>

-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of lironh@marvell.com
Sent: Wednesday, December 2, 2020 12:12 PM
To: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Cc: dev@dpdk.org; Liron Himi <lironh@marvell.com>
Subject: [dpdk-dev] [PATCH v1 25/38] net/mvpp2: support udf configuration

From: Liron Himi <lironh@marvell.com>

extend the config file with 'udf' (user-defined) settings

Signed-off-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c |   4 +-
 drivers/net/mvpp2/mrvl_qos.c    | 212 ++++++++++++++++++++++++++++++++
 drivers/net/mvpp2/mrvl_qos.h    |   3 +
 3 files changed, 218 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 6bd3b0430..5ff11e2c9 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -3027,7 +3027,9 @@ mrvl_init_pp2(void)
 	init_params.hif_reserved_map = MRVL_MUSDK_HIFS_RESERVED;
 	init_params.bm_pool_reserved_map = MRVL_MUSDK_BPOOLS_RESERVED;
 	init_params.rss_tbl_reserved_map = MRVL_MUSDK_RSS_RESERVED;
-
+	if (mrvl_cfg && mrvl_cfg->pp2_cfg.prs_udfs.num_udfs)
+		memcpy(&init_params.prs_udfs, &mrvl_cfg->pp2_cfg.prs_udfs,
+		       sizeof(struct pp2_parse_udfs));
 	return pp2_init(&init_params);
 }
 
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index 1c65b5276..f5275efc7 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -35,6 +35,7 @@
 #define MRVL_TOK_TXQ "txq"
 #define MRVL_TOK_VLAN "vlan"
 #define MRVL_TOK_VLAN_IP "vlan/ip"
+#define MRVL_TOK_PARSER_UDF "parser udf"
 
 /* egress specific configuration tokens */  #define MRVL_TOK_BURST_SIZE "burst_size"
@@ -62,6 +63,18 @@
 #define MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW "yellow"
 #define MRVL_TOK_PLCR_DEFAULT_COLOR_RED "red"
 
+/* paser udf specific configuration tokens */ #define 
+MRVL_TOK_PARSER_UDF_PROTO "proto"
+#define MRVL_TOK_PARSER_UDF_FIELD "field"
+#define MRVL_TOK_PARSER_UDF_KEY "key"
+#define MRVL_TOK_PARSER_UDF_MASK "mask"
+#define MRVL_TOK_PARSER_UDF_OFFSET "offset"
+#define MRVL_TOK_PARSER_UDF_PROTO_ETH "eth"
+#define MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE "type"
+#define MRVL_TOK_PARSER_UDF_PROTO_UDP "udp"
+#define MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT "dport"
+
+
 /** Number of tokens in range a-b = 2. */  #define MAX_RNG_TOKENS 2
 
@@ -453,6 +466,175 @@ parse_policer(struct rte_cfgfile *file, int port, const char *sec_name,
 	return 0;
 }
 
+/**
+ * Parse parser udf.
+ *
+ * @param file Config file handle.
+ * @param sec_name section name
+ * @param udf udf index
+ * @param cfg[out] Parsing results.
+ * @returns 0 in case of success, negative value otherwise.
+ */
+static int
+parse_udf(struct rte_cfgfile *file, const char *sec_name, int udf,
+	  struct mrvl_cfg *cfg)
+{
+	struct pp2_parse_udf_params *udf_params;
+	const char *entry, *entry_field;
+	uint32_t val, i;
+	uint8_t field_size;
+	char malloc_name[32], tmp_arr[3];
+	/* field len in chars equal to '0x' + rest of data */
+#define FIELD_LEN_IN_CHARS(field_size)	(uint32_t)(2 + (field_size) * 2)
+
+	udf_params = &cfg->pp2_cfg.prs_udfs.udfs[udf];
+
+	/* Read 'proto' field */
+	entry = rte_cfgfile_get_entry(file, sec_name,
+				      MRVL_TOK_PARSER_UDF_PROTO);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_PROTO);
+		return -1;
+	}
+
+	/* Read 'field' field */
+	entry_field = rte_cfgfile_get_entry(file, sec_name,
+				       MRVL_TOK_PARSER_UDF_FIELD);
+	if (!entry_field) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_FIELD);
+		return -1;
+	}
+
+	if (!strncmp(entry, MRVL_TOK_PARSER_UDF_PROTO_ETH,
+				sizeof(MRVL_TOK_PARSER_UDF_PROTO_ETH))) {
+		udf_params->match_proto = MV_NET_PROTO_ETH;
+		if (!strncmp(entry_field, MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE,
+			     sizeof(MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE))) {
+			udf_params->match_field.eth = MV_NET_ETH_F_TYPE;
+			field_size = 2;
+		} else {
+			MRVL_LOG(ERR, "UDF[%d]: mismatch between '%s' proto "
+				 "and '%s' field\n", udf,
+				 MRVL_TOK_PARSER_UDF_PROTO_ETH,
+				 entry_field);
+			return -1;
+		}
+	} else if (!strncmp(entry, MRVL_TOK_PARSER_UDF_PROTO_UDP,
+				sizeof(MRVL_TOK_PARSER_UDF_PROTO_UDP))) {
+		udf_params->match_proto = MV_NET_PROTO_UDP;
+		if (!strncmp(entry_field, MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT,
+			     sizeof(MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT))) {
+			udf_params->match_field.udp = MV_NET_UDP_F_DP;
+			field_size = 2;
+		} else {
+			MRVL_LOG(ERR, "UDF[%d]: mismatch between '%s' proto "
+				 "and '%s' field\n", udf,
+				 MRVL_TOK_PARSER_UDF_PROTO_UDP,
+				 entry_field);
+			return -1;
+		}
+	} else {
+		MRVL_LOG(ERR, "UDF[%d]: Unsupported '%s' proto\n", udf, entry);
+		return -1;
+	}
+
+	snprintf(malloc_name, sizeof(malloc_name), "mrvl_udf_%d_key", udf);
+	udf_params->match_key = rte_zmalloc(malloc_name, field_size, 0);
+	if (udf_params->match_key == NULL) {
+		MRVL_LOG(ERR, "Cannot allocate udf %d key\n", udf);
+		return -1;
+	}
+	snprintf(malloc_name, sizeof(malloc_name), "mrvl_udf_%d_mask", udf);
+	udf_params->match_mask = rte_zmalloc(malloc_name, field_size, 0);
+	if (udf_params->match_mask == NULL) {
+		MRVL_LOG(ERR, "Cannot allocate udf %d mask\n", udf);
+		return -1;
+	}
+
+	/* Read 'key' field */
+	entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PARSER_UDF_KEY);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_KEY);
+		return -1;
+	}
+
+	if (strncmp(entry, "0x", 2) != 0)  {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must start with '0x'\n",
+			 udf, MRVL_TOK_PARSER_UDF_KEY);
+		return -EINVAL;
+	}
+
+	if (strlen(entry) != FIELD_LEN_IN_CHARS(field_size)) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field's len must be %d\n", udf,
+			 MRVL_TOK_PARSER_UDF_KEY,
+			 FIELD_LEN_IN_CHARS(field_size));
+		return -EINVAL;
+	}
+
+	entry += 2; /* skip the '0x' */
+	for (i = 0; i < field_size; i++) {
+		strncpy(tmp_arr, entry, 2);
+		tmp_arr[2] = '\0';
+		if (get_val_securely8(tmp_arr, 16,
+				      &udf_params->match_key[i]) < 0) {
+			MRVL_LOG(ERR, "UDF[%d]: '%s' field's value is not in "
+				"hex format\n", udf, MRVL_TOK_PARSER_UDF_KEY);
+			return -EINVAL;
+		}
+		entry += 2;
+	}
+
+	/* Read 'mask' field */
+	entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PARSER_UDF_MASK);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_MASK);
+		return -1;
+	}
+	if (strncmp(entry, "0x", 2) != 0) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must start with '0x'\n",
+			 udf, MRVL_TOK_PARSER_UDF_MASK);
+		return -EINVAL;
+	}
+
+	if (strlen(entry) != FIELD_LEN_IN_CHARS(field_size)) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field's len must be %d\n", udf,
+			 MRVL_TOK_PARSER_UDF_MASK,
+			 FIELD_LEN_IN_CHARS(field_size));
+		return -EINVAL;
+	}
+
+	entry += 2; /* skip the '0x' */
+	for (i = 0; i < field_size; i++) {
+		strncpy(tmp_arr, entry, 2);
+		tmp_arr[2] = '\0';
+		if (get_val_securely8(tmp_arr, 16,
+				      &udf_params->match_mask[i]) < 0) {
+			MRVL_LOG(ERR, "UDF[%d]: '%s' field's value is not in "
+				"hex format\n", udf, MRVL_TOK_PARSER_UDF_MASK);
+			return -EINVAL;
+		}
+		entry += 2;
+	}
+
+	/* Read offset */
+	entry = rte_cfgfile_get_entry(file, sec_name,
+				      MRVL_TOK_PARSER_UDF_OFFSET);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_OFFSET);
+		return -1;
+	}
+	if (get_val_securely(entry, &val) < 0)
+		return -1;
+	udf_params->offset = val;
+
+	return 0;
+}
+
 /**
  * Parse configuration - rte_kvargs_process handler.
  *
@@ -487,6 +669,36 @@ mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
 		return -1;
 	}
 
+	/* PP2 configuration */
+	n = rte_cfgfile_num_sections(file, MRVL_TOK_PARSER_UDF,
+		sizeof(MRVL_TOK_PARSER_UDF) - 1);
+
+	if (n && n > PP2_MAX_UDFS_SUPPORTED) {
+		MRVL_LOG(ERR, "found %d udf sections, but only %d are supported\n",
+			 n, PP2_MAX_UDFS_SUPPORTED);
+		return -1;
+	}
+	(*cfg)->pp2_cfg.prs_udfs.num_udfs = n;
+	for (i = 0; i < n; i++) {
+		snprintf(sec_name, sizeof(sec_name), "%s %d",
+				MRVL_TOK_PARSER_UDF, i);
+
+		/* udf sections must be sequential. */
+		if (rte_cfgfile_num_sections(file, sec_name,
+				strlen(sec_name)) <= 0) {
+			MRVL_LOG(ERR, "udf sections must be sequential (0 - %d)\n",
+				 PP2_MAX_UDFS_SUPPORTED - 1);
+			return -1;
+		}
+
+		ret = parse_udf(file, sec_name, i, *cfg);
+		if (ret) {
+			MRVL_LOG(ERR, "Error in parsing %s!\n", sec_name);
+			return -1;
+		}
+	}
+
+	/* PP2 Ports configuration */
 	n = rte_cfgfile_num_sections(file, MRVL_TOK_PORT,
 		sizeof(MRVL_TOK_PORT) - 1);
 
diff --git a/drivers/net/mvpp2/mrvl_qos.h b/drivers/net/mvpp2/mrvl_qos.h index 928cfe366..daf4776ec 100644
--- a/drivers/net/mvpp2/mrvl_qos.h
+++ b/drivers/net/mvpp2/mrvl_qos.h
@@ -19,6 +19,9 @@
 
 /* config. */
 struct mrvl_cfg {
+	struct  {
+		struct pp2_parse_udfs	prs_udfs;
+	} pp2_cfg;
 	struct port_cfg {
 		enum pp2_ppio_eth_start_hdr eth_start_hdr;
 		int rate_limit_enable;
--
2.28.0

Patch
diff mbox series

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 6bd3b0430..5ff11e2c9 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -3027,7 +3027,9 @@  mrvl_init_pp2(void)
 	init_params.hif_reserved_map = MRVL_MUSDK_HIFS_RESERVED;
 	init_params.bm_pool_reserved_map = MRVL_MUSDK_BPOOLS_RESERVED;
 	init_params.rss_tbl_reserved_map = MRVL_MUSDK_RSS_RESERVED;
-
+	if (mrvl_cfg && mrvl_cfg->pp2_cfg.prs_udfs.num_udfs)
+		memcpy(&init_params.prs_udfs, &mrvl_cfg->pp2_cfg.prs_udfs,
+		       sizeof(struct pp2_parse_udfs));
 	return pp2_init(&init_params);
 }
 
diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c
index 1c65b5276..f5275efc7 100644
--- a/drivers/net/mvpp2/mrvl_qos.c
+++ b/drivers/net/mvpp2/mrvl_qos.c
@@ -35,6 +35,7 @@ 
 #define MRVL_TOK_TXQ "txq"
 #define MRVL_TOK_VLAN "vlan"
 #define MRVL_TOK_VLAN_IP "vlan/ip"
+#define MRVL_TOK_PARSER_UDF "parser udf"
 
 /* egress specific configuration tokens */
 #define MRVL_TOK_BURST_SIZE "burst_size"
@@ -62,6 +63,18 @@ 
 #define MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW "yellow"
 #define MRVL_TOK_PLCR_DEFAULT_COLOR_RED "red"
 
+/* paser udf specific configuration tokens */
+#define MRVL_TOK_PARSER_UDF_PROTO "proto"
+#define MRVL_TOK_PARSER_UDF_FIELD "field"
+#define MRVL_TOK_PARSER_UDF_KEY "key"
+#define MRVL_TOK_PARSER_UDF_MASK "mask"
+#define MRVL_TOK_PARSER_UDF_OFFSET "offset"
+#define MRVL_TOK_PARSER_UDF_PROTO_ETH "eth"
+#define MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE "type"
+#define MRVL_TOK_PARSER_UDF_PROTO_UDP "udp"
+#define MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT "dport"
+
+
 /** Number of tokens in range a-b = 2. */
 #define MAX_RNG_TOKENS 2
 
@@ -453,6 +466,175 @@  parse_policer(struct rte_cfgfile *file, int port, const char *sec_name,
 	return 0;
 }
 
+/**
+ * Parse parser udf.
+ *
+ * @param file Config file handle.
+ * @param sec_name section name
+ * @param udf udf index
+ * @param cfg[out] Parsing results.
+ * @returns 0 in case of success, negative value otherwise.
+ */
+static int
+parse_udf(struct rte_cfgfile *file, const char *sec_name, int udf,
+	  struct mrvl_cfg *cfg)
+{
+	struct pp2_parse_udf_params *udf_params;
+	const char *entry, *entry_field;
+	uint32_t val, i;
+	uint8_t field_size;
+	char malloc_name[32], tmp_arr[3];
+	/* field len in chars equal to '0x' + rest of data */
+#define FIELD_LEN_IN_CHARS(field_size)	(uint32_t)(2 + (field_size) * 2)
+
+	udf_params = &cfg->pp2_cfg.prs_udfs.udfs[udf];
+
+	/* Read 'proto' field */
+	entry = rte_cfgfile_get_entry(file, sec_name,
+				      MRVL_TOK_PARSER_UDF_PROTO);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_PROTO);
+		return -1;
+	}
+
+	/* Read 'field' field */
+	entry_field = rte_cfgfile_get_entry(file, sec_name,
+				       MRVL_TOK_PARSER_UDF_FIELD);
+	if (!entry_field) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_FIELD);
+		return -1;
+	}
+
+	if (!strncmp(entry, MRVL_TOK_PARSER_UDF_PROTO_ETH,
+				sizeof(MRVL_TOK_PARSER_UDF_PROTO_ETH))) {
+		udf_params->match_proto = MV_NET_PROTO_ETH;
+		if (!strncmp(entry_field, MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE,
+			     sizeof(MRVL_TOK_PARSER_UDF_FIELD_ETH_TYPE))) {
+			udf_params->match_field.eth = MV_NET_ETH_F_TYPE;
+			field_size = 2;
+		} else {
+			MRVL_LOG(ERR, "UDF[%d]: mismatch between '%s' proto "
+				 "and '%s' field\n", udf,
+				 MRVL_TOK_PARSER_UDF_PROTO_ETH,
+				 entry_field);
+			return -1;
+		}
+	} else if (!strncmp(entry, MRVL_TOK_PARSER_UDF_PROTO_UDP,
+				sizeof(MRVL_TOK_PARSER_UDF_PROTO_UDP))) {
+		udf_params->match_proto = MV_NET_PROTO_UDP;
+		if (!strncmp(entry_field, MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT,
+			     sizeof(MRVL_TOK_PARSER_UDF_FIELD_UDP_DPORT))) {
+			udf_params->match_field.udp = MV_NET_UDP_F_DP;
+			field_size = 2;
+		} else {
+			MRVL_LOG(ERR, "UDF[%d]: mismatch between '%s' proto "
+				 "and '%s' field\n", udf,
+				 MRVL_TOK_PARSER_UDF_PROTO_UDP,
+				 entry_field);
+			return -1;
+		}
+	} else {
+		MRVL_LOG(ERR, "UDF[%d]: Unsupported '%s' proto\n", udf, entry);
+		return -1;
+	}
+
+	snprintf(malloc_name, sizeof(malloc_name), "mrvl_udf_%d_key", udf);
+	udf_params->match_key = rte_zmalloc(malloc_name, field_size, 0);
+	if (udf_params->match_key == NULL) {
+		MRVL_LOG(ERR, "Cannot allocate udf %d key\n", udf);
+		return -1;
+	}
+	snprintf(malloc_name, sizeof(malloc_name), "mrvl_udf_%d_mask", udf);
+	udf_params->match_mask = rte_zmalloc(malloc_name, field_size, 0);
+	if (udf_params->match_mask == NULL) {
+		MRVL_LOG(ERR, "Cannot allocate udf %d mask\n", udf);
+		return -1;
+	}
+
+	/* Read 'key' field */
+	entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PARSER_UDF_KEY);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_KEY);
+		return -1;
+	}
+
+	if (strncmp(entry, "0x", 2) != 0)  {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must start with '0x'\n",
+			 udf, MRVL_TOK_PARSER_UDF_KEY);
+		return -EINVAL;
+	}
+
+	if (strlen(entry) != FIELD_LEN_IN_CHARS(field_size)) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field's len must be %d\n", udf,
+			 MRVL_TOK_PARSER_UDF_KEY,
+			 FIELD_LEN_IN_CHARS(field_size));
+		return -EINVAL;
+	}
+
+	entry += 2; /* skip the '0x' */
+	for (i = 0; i < field_size; i++) {
+		strncpy(tmp_arr, entry, 2);
+		tmp_arr[2] = '\0';
+		if (get_val_securely8(tmp_arr, 16,
+				      &udf_params->match_key[i]) < 0) {
+			MRVL_LOG(ERR, "UDF[%d]: '%s' field's value is not in "
+				"hex format\n", udf, MRVL_TOK_PARSER_UDF_KEY);
+			return -EINVAL;
+		}
+		entry += 2;
+	}
+
+	/* Read 'mask' field */
+	entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PARSER_UDF_MASK);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_MASK);
+		return -1;
+	}
+	if (strncmp(entry, "0x", 2) != 0) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must start with '0x'\n",
+			 udf, MRVL_TOK_PARSER_UDF_MASK);
+		return -EINVAL;
+	}
+
+	if (strlen(entry) != FIELD_LEN_IN_CHARS(field_size)) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field's len must be %d\n", udf,
+			 MRVL_TOK_PARSER_UDF_MASK,
+			 FIELD_LEN_IN_CHARS(field_size));
+		return -EINVAL;
+	}
+
+	entry += 2; /* skip the '0x' */
+	for (i = 0; i < field_size; i++) {
+		strncpy(tmp_arr, entry, 2);
+		tmp_arr[2] = '\0';
+		if (get_val_securely8(tmp_arr, 16,
+				      &udf_params->match_mask[i]) < 0) {
+			MRVL_LOG(ERR, "UDF[%d]: '%s' field's value is not in "
+				"hex format\n", udf, MRVL_TOK_PARSER_UDF_MASK);
+			return -EINVAL;
+		}
+		entry += 2;
+	}
+
+	/* Read offset */
+	entry = rte_cfgfile_get_entry(file, sec_name,
+				      MRVL_TOK_PARSER_UDF_OFFSET);
+	if (!entry) {
+		MRVL_LOG(ERR, "UDF[%d]: '%s' field must be set\n", udf,
+			 MRVL_TOK_PARSER_UDF_OFFSET);
+		return -1;
+	}
+	if (get_val_securely(entry, &val) < 0)
+		return -1;
+	udf_params->offset = val;
+
+	return 0;
+}
+
 /**
  * Parse configuration - rte_kvargs_process handler.
  *
@@ -487,6 +669,36 @@  mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
 		return -1;
 	}
 
+	/* PP2 configuration */
+	n = rte_cfgfile_num_sections(file, MRVL_TOK_PARSER_UDF,
+		sizeof(MRVL_TOK_PARSER_UDF) - 1);
+
+	if (n && n > PP2_MAX_UDFS_SUPPORTED) {
+		MRVL_LOG(ERR, "found %d udf sections, but only %d are supported\n",
+			 n, PP2_MAX_UDFS_SUPPORTED);
+		return -1;
+	}
+	(*cfg)->pp2_cfg.prs_udfs.num_udfs = n;
+	for (i = 0; i < n; i++) {
+		snprintf(sec_name, sizeof(sec_name), "%s %d",
+				MRVL_TOK_PARSER_UDF, i);
+
+		/* udf sections must be sequential. */
+		if (rte_cfgfile_num_sections(file, sec_name,
+				strlen(sec_name)) <= 0) {
+			MRVL_LOG(ERR, "udf sections must be sequential (0 - %d)\n",
+				 PP2_MAX_UDFS_SUPPORTED - 1);
+			return -1;
+		}
+
+		ret = parse_udf(file, sec_name, i, *cfg);
+		if (ret) {
+			MRVL_LOG(ERR, "Error in parsing %s!\n", sec_name);
+			return -1;
+		}
+	}
+
+	/* PP2 Ports configuration */
 	n = rte_cfgfile_num_sections(file, MRVL_TOK_PORT,
 		sizeof(MRVL_TOK_PORT) - 1);
 
diff --git a/drivers/net/mvpp2/mrvl_qos.h b/drivers/net/mvpp2/mrvl_qos.h
index 928cfe366..daf4776ec 100644
--- a/drivers/net/mvpp2/mrvl_qos.h
+++ b/drivers/net/mvpp2/mrvl_qos.h
@@ -19,6 +19,9 @@ 
 
 /* config. */
 struct mrvl_cfg {
+	struct  {
+		struct pp2_parse_udfs	prs_udfs;
+	} pp2_cfg;
 	struct port_cfg {
 		enum pp2_ppio_eth_start_hdr eth_start_hdr;
 		int rate_limit_enable;