Skip to contentSkip to conversation

ip_pipeline: modify action handler in passthrough pipeline

PATCH Applied Jasvinder Singh 3 participants 3 messages Oct 3, 2015 – Dec 7, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip_pipeline: modify action handler in passthrough pipeline

This patch implements a generic approach to extract fields from the packet's header and copying them to packet metadata. The fields are selected at the desired offset on the basis of the mask specified in application configuration file. The extracted fields, for instance, can be used to compute hash for the lookup table. This feature exposes more flexibility to the users as they will be able to employ new protocol headers and specify the required fields to be extracted.

The above feature has been implemented as port_in action handler of the passthrough pipeline. The example of the configuration file for passthrough pipeline is as below;

[PIPELINE1]
type = PASS-THROUGH
core = 1
pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 dma_size = 16
dma_dst_offset = 64
dma_src_offset = 150
dma_src_mask = 00FF0000FFFFFFFFFFFFFFFFFFFFFFFF dma_hash_offset = 80

---
 examples/ip_pipeline/config_parse.c                |  52 ++
 .../ip_pipeline/pipeline/pipeline_passthrough_be.c | 660 ++++++++-------------
 .../ip_pipeline/pipeline/pipeline_passthrough_be.h |  17 +
 examples/ip_pipeline/pipeline_be.h                 |   3 +
 4 files changed, 319 insertions(+), 413 deletions(-)
examples/ip_pipeline/config_parse.c +52 -0
index c9b78f9..f4e2b1d 100644
@@ -362,6 +362,58 @@ parser_read_uint32(uint32_t *value, const char *p)
 	return 0;
 }
 
+static uint32_t
+get_hex_val(char c)
+{
+	switch (c) {
+	case '0': case '1': case '2': case '3': case '4': case '5':
+	case '6': case '7': case '8': case '9':
+		return c - '0';
+	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+		return c - 'A' + 10;
+	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+		return c - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
+{
+	char *c;
+	uint32_t len, i;
+
+	/* Check input parameters */
+	if ((src == NULL) ||
+		(dst == NULL) ||
+		(size == NULL) ||
+		(*size == 0))
+		return -1;
+
+	len = strlen(src);
+	if (((len & 3) != 0) ||
+		(len > (*size) * 2))
+		return -1;
+	*size = len / 2;
+
+	for (c = src; *c != 0; c++) {
+		if ((((*c) >= '0') && ((*c) <= '9')) ||
+			(((*c) >= 'A') && ((*c) <= 'F')) ||
+			(((*c) >= 'a') && ((*c) <= 'f')))
+			continue;
+
+		return -1;
+	}
+
+	/* Convert chars to bytes */
+	for (i = 0; i < *size; i++)
+		dst[i] = get_hex_val(src[2 * i]) * 16 +
+			get_hex_val(src[2 * i + 1]);
+
+	return 0;
+}
+
 static int
 parse_pipeline_core(uint32_t *socket,
 	uint32_t *core,
examples/ip_pipeline/pipeline/pipeline_passthrough_be.c +247 -413

746 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_passthrough_be.h +17 -0
index 9d5e3db..03756a1 100644
@@ -36,6 +36,23 @@
 
 #include "pipeline_common_be.h"
 
+#define PIPELINE_PASSTHROUGH_DMA_SIZE_MAX                             64
+
+struct pipeline_passthrough_params {
+	uint32_t dma_enabled;
+	uint32_t dma_dst_offset;
+	uint32_t dma_src_offset;
+	uint8_t dma_src_mask[PIPELINE_PASSTHROUGH_DMA_SIZE_MAX];
+	uint32_t dma_size;
+
+	uint32_t dma_hash_enabled;
+	uint32_t dma_hash_offset;
+};
+
+int
+pipeline_passthrough_parse_args(struct pipeline_passthrough_params *p,
+	struct pipeline_params *params);
+
 extern struct pipeline_be_ops pipeline_passthrough_be_ops;
 
 #endif
examples/ip_pipeline/pipeline_be.h +3 -0
index 51f1e4f..25869fb 100644
@@ -253,4 +253,7 @@ struct pipeline_be_ops {
 	pipeline_be_op_track f_track;
 };
 
+int
+parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
+
 #endif
Signature · 1 line
2.1.0