Example #1
0
static void
check_sinks(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pktq_sink; i++) {
		struct app_pktq_sink_params *p = &app->sink_params[i];
		uint32_t n_writers = app_sink_get_writers(app, p);

		APP_CHECK((n_writers != 0),
			"%s has no writer\n", p->name);

		APP_CHECK((n_writers == 1),
			"%s has more than one writer\n", p->name);
	}
}
Example #2
0
static void
check_sources(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pktq_source; i++) {
		struct app_pktq_source_params *p = &app->source_params[i];
		uint32_t n_readers = app_source_get_readers(app, p);

		APP_CHECK((n_readers != 0),
			"%s has no reader\n", p->name);

		APP_CHECK((n_readers == 1),
			"%s has more than one reader\n", p->name);
	}
}
Example #3
0
static void
check_mempools(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_mempools; i++) {
		struct app_mempool_params *p = &app->mempool_params[i];

		APP_CHECK((p->pool_size > 0),
			"Mempool %s size is 0\n", p->name);

		APP_CHECK((p->cache_size > 0),
			"Mempool %s cache size is 0\n", p->name);

		APP_CHECK(rte_is_power_of_2(p->cache_size),
			"Mempool %s cache size not a power of 2\n", p->name);
	}
}
Example #4
0
static void
check_swqs(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pktq_swq; i++) {
		struct app_pktq_swq_params *p = &app->swq_params[i];
		uint32_t n_readers = app_swq_get_readers(app, p);
		uint32_t n_writers = app_swq_get_writers(app, p);

		APP_CHECK((p->size > 0),
			"%s size is 0\n", p->name);

		APP_CHECK((rte_is_power_of_2(p->size)),
			"%s size is not a power of 2\n", p->name);

		APP_CHECK((p->burst_read > 0),
			"%s read burst size is 0\n", p->name);

		APP_CHECK((p->burst_read <= p->size),
			"%s read burst size is bigger than its size\n",
			p->name);

		APP_CHECK((p->burst_write > 0),
			"%s write burst size is 0\n", p->name);

		APP_CHECK((p->burst_write <= p->size),
			"%s write burst size is bigger than its size\n",
			p->name);

		APP_CHECK((n_readers != 0),
			"%s has no reader\n", p->name);

		APP_CHECK((n_readers == 1),
			"%s has more than one reader\n", p->name);

		APP_CHECK((n_writers != 0),
			"%s has no writer\n", p->name);

		APP_CHECK((n_writers == 1),
			"%s has more than one writer\n", p->name);
	}
}
Example #5
0
static void
check_txqs(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pktq_hwq_out; i++) {
		struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
		uint32_t n_writers = app_txq_get_writers(app, p);

		APP_CHECK((p->size > 0),
			"%s size is 0\n", p->name);

		APP_CHECK((rte_is_power_of_2(p->size)),
			"%s size is not a power of 2\n", p->name);

		APP_CHECK((p->burst > 0),
			"%s burst size is 0\n", p->name);

		APP_CHECK((p->burst <= p->size),
			"%s burst size is bigger than its size\n", p->name);

		APP_CHECK((n_writers != 0),
			"%s has no writer\n", p->name);

		APP_CHECK((n_writers == 1),
			"%s has more than one writer\n", p->name);
	}
}
Example #6
0
static void
check_pipelines(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pipelines; i++) {
		struct app_pipeline_params *p = &app->pipeline_params[i];

		APP_CHECK((p->n_msgq_in == p->n_msgq_out),
			"%s number of input MSGQs does not match "
			"the number of output MSGQs\n", p->name);
	}
}
Example #7
0
void
parse_sp6_tokens(char **tokens, uint32_t n_tokens,
	struct parse_status *status)
{
	struct acl6_rules *rule_ipv6 = NULL;

	uint32_t *ri = NULL; /* rule index */
	uint32_t ti = 0; /* token index */

	uint32_t esp_p = 0;
	uint32_t protect_p = 0;
	uint32_t bypass_p = 0;
	uint32_t discard_p = 0;
	uint32_t pri_p = 0;
	uint32_t src_p = 0;
	uint32_t dst_p = 0;
	uint32_t proto_p = 0;
	uint32_t sport_p = 0;
	uint32_t dport_p = 0;

	if (strcmp(tokens[1], "in") == 0) {
		ri = &nb_acl6_rules_in;

		APP_CHECK(*ri <= MAX_ACL_RULE_NUM - 1, status, "too "
			"many sp rules, abort insertion\n");
		if (status->status < 0)
			return;

		rule_ipv6 = &acl6_rules_in[*ri];

	} else if (strcmp(tokens[1], "out") == 0) {
		ri = &nb_acl6_rules_out;

		APP_CHECK(*ri <= MAX_ACL_RULE_NUM - 1, status, "too "
			"many sp rules, abort insertion\n");
		if (status->status < 0)
			return;

		rule_ipv6 = &acl6_rules_out[*ri];

	} else {
		APP_CHECK(0, status, "unrecognized input \"%s\", expect"
			" \"in\" or \"out\"\n", tokens[ti]);
		return;
	}

	rule_ipv6->data.category_mask = 1;


	for (ti = 2; ti < n_tokens; ti++) {
		if (strcmp(tokens[ti], "esp") == 0) {
			/* currently do nothing */
			APP_CHECK_PRESENCE(esp_p, tokens[ti], status);
			if (status->status < 0)
				return;
			esp_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "protect") == 0) {
			APP_CHECK_PRESENCE(protect_p, tokens[ti], status);
			if (status->status < 0)
				return;
			APP_CHECK(bypass_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"bypass");
			if (status->status < 0)
				return;
			APP_CHECK(discard_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"discard");
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;
			APP_CHECK_TOKEN_IS_NUM(tokens, ti, status);
			if (status->status < 0)
				return;

			rule_ipv6->data.userdata =
				PROTECT(atoi(tokens[ti]));

			protect_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "bypass") == 0) {
			APP_CHECK_PRESENCE(bypass_p, tokens[ti], status);
			if (status->status < 0)
				return;
			APP_CHECK(protect_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"protect");
			if (status->status < 0)
				return;
			APP_CHECK(discard_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"discard");
			if (status->status < 0)
				return;

			rule_ipv6->data.userdata = BYPASS;

			bypass_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "discard") == 0) {
			APP_CHECK_PRESENCE(discard_p, tokens[ti], status);
			if (status->status < 0)
				return;
			APP_CHECK(protect_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"protect");
			if (status->status < 0)
				return;
			APP_CHECK(bypass_p == 0, status, "conflict item "
				"between \"%s\" and \"%s\"", tokens[ti],
				"discard");
			if (status->status < 0)
				return;

			rule_ipv6->data.userdata = DISCARD;

			discard_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "pri") == 0) {
			APP_CHECK_PRESENCE(pri_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;
			APP_CHECK_TOKEN_IS_NUM(tokens, ti, status);
			if (status->status < 0)
				return;

			rule_ipv6->data.priority = atoi(tokens[ti]);

			pri_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "src") == 0) {
			struct in6_addr ip;
			uint32_t depth;

			APP_CHECK_PRESENCE(src_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;

			APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
				&depth) == 0, status, "unrecognized "
				"input \"%s\", expect valid ipv6 "
				"addr", tokens[ti]);
			if (status->status < 0)
				return;

			rule_ipv6->field[1].value.u32 =
				(uint32_t)ip.s6_addr[0] << 24 |
				(uint32_t)ip.s6_addr[1] << 16 |
				(uint32_t)ip.s6_addr[2] << 8 |
				(uint32_t)ip.s6_addr[3];
			rule_ipv6->field[1].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[2].value.u32 =
				(uint32_t)ip.s6_addr[4] << 24 |
				(uint32_t)ip.s6_addr[5] << 16 |
				(uint32_t)ip.s6_addr[6] << 8 |
				(uint32_t)ip.s6_addr[7];
			rule_ipv6->field[2].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[3].value.u32 =
				(uint32_t)ip.s6_addr[8] << 24 |
				(uint32_t)ip.s6_addr[9] << 16 |
				(uint32_t)ip.s6_addr[10] << 8 |
				(uint32_t)ip.s6_addr[11];
			rule_ipv6->field[3].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[4].value.u32 =
				(uint32_t)ip.s6_addr[12] << 24 |
				(uint32_t)ip.s6_addr[13] << 16 |
				(uint32_t)ip.s6_addr[14] << 8 |
				(uint32_t)ip.s6_addr[15];
			rule_ipv6->field[4].mask_range.u32 =
				(depth > 32) ? 32 : depth;

			src_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "dst") == 0) {
			struct in6_addr ip;
			uint32_t depth;

			APP_CHECK_PRESENCE(dst_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;

			APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
				&depth) == 0, status, "unrecognized "
				"input \"%s\", expect valid ipv6 "
				"addr", tokens[ti]);
			if (status->status < 0)
				return;

			rule_ipv6->field[5].value.u32 =
				(uint32_t)ip.s6_addr[0] << 24 |
				(uint32_t)ip.s6_addr[1] << 16 |
				(uint32_t)ip.s6_addr[2] << 8 |
				(uint32_t)ip.s6_addr[3];
			rule_ipv6->field[5].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[6].value.u32 =
				(uint32_t)ip.s6_addr[4] << 24 |
				(uint32_t)ip.s6_addr[5] << 16 |
				(uint32_t)ip.s6_addr[6] << 8 |
				(uint32_t)ip.s6_addr[7];
			rule_ipv6->field[6].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[7].value.u32 =
				(uint32_t)ip.s6_addr[8] << 24 |
				(uint32_t)ip.s6_addr[9] << 16 |
				(uint32_t)ip.s6_addr[10] << 8 |
				(uint32_t)ip.s6_addr[11];
			rule_ipv6->field[7].mask_range.u32 =
				(depth > 32) ? 32 : depth;
			depth = (depth > 32) ? (depth - 32) : 0;
			rule_ipv6->field[8].value.u32 =
				(uint32_t)ip.s6_addr[12] << 24 |
				(uint32_t)ip.s6_addr[13] << 16 |
				(uint32_t)ip.s6_addr[14] << 8 |
				(uint32_t)ip.s6_addr[15];
			rule_ipv6->field[8].mask_range.u32 =
				(depth > 32) ? 32 : depth;

			dst_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "proto") == 0) {
			uint16_t low, high;

			APP_CHECK_PRESENCE(proto_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;

			APP_CHECK(parse_range(tokens[ti], &low, &high)
				== 0, status, "unrecognized input \"%s\""
				", expect \"from:to\"", tokens[ti]);
			if (status->status < 0)
				return;
			APP_CHECK(low <= 0xff, status, "proto low "
				"over-limit");
			if (status->status < 0)
				return;
			APP_CHECK(high <= 0xff, status, "proto high "
				"over-limit");
			if (status->status < 0)
				return;

			rule_ipv6->field[0].value.u8 = (uint8_t)low;
			rule_ipv6->field[0].mask_range.u8 = (uint8_t)high;

			proto_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "sport") == 0) {
			uint16_t port_low, port_high;

			APP_CHECK_PRESENCE(sport_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;

			APP_CHECK(parse_range(tokens[ti], &port_low,
				&port_high) == 0, status, "unrecognized "
				"input \"%s\", expect \"port_from:"
				"port_to\"", tokens[ti]);
			if (status->status < 0)
				return;

			rule_ipv6->field[9].value.u16 = port_low;
			rule_ipv6->field[9].mask_range.u16 = port_high;

			sport_p = 1;
			continue;
		}

		if (strcmp(tokens[ti], "dport") == 0) {
			uint16_t port_low, port_high;

			APP_CHECK_PRESENCE(dport_p, tokens[ti], status);
			if (status->status < 0)
				return;
			INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
			if (status->status < 0)
				return;

			APP_CHECK(parse_range(tokens[ti], &port_low,
				&port_high) == 0, status, "unrecognized "
				"input \"%s\", expect \"port_from:"
				"port_to\"", tokens[ti]);
			if (status->status < 0)
				return;

			rule_ipv6->field[10].value.u16 = port_low;
			rule_ipv6->field[10].mask_range.u16 = port_high;

			dport_p = 1;
			continue;
		}

		/* unrecognizeable input */
		APP_CHECK(0, status, "unrecognized input \"%s\"",
			tokens[ti]);
		return;
	}

	/* check if argument(s) are missing */
	APP_CHECK(esp_p == 1, status, "missing argument \"esp\"");
	if (status->status < 0)
		return;

	APP_CHECK(protect_p | bypass_p | discard_p, status, "missing "
		"argument \"protect\", \"bypass\", or \"discard\"");
	if (status->status < 0)
		return;

	*ri = *ri + 1;
}
Example #8
0
static void
check_links(struct app_params *app)
{
	uint32_t i;

	/* Check that number of links matches the port mask */
	if (app->port_mask) {
		uint32_t n_links_port_mask =
			__builtin_popcountll(app->port_mask);

		APP_CHECK((app->n_links == n_links_port_mask),
			"Not enough links provided in the PORT_MASK\n");
	}

	for (i = 0; i < app->n_links; i++) {
		struct app_link_params *link = &app->link_params[i];
		uint32_t rxq_max, n_rxq, n_txq, link_id, i;

		APP_PARAM_GET_ID(link, "LINK", link_id);

		/* Check that link RXQs are contiguous */
		rxq_max = 0;
		if (link->arp_q > rxq_max)
			rxq_max = link->arp_q;
		if (link->tcp_syn_q > rxq_max)
			rxq_max = link->tcp_syn_q;
		if (link->ip_local_q > rxq_max)
			rxq_max = link->ip_local_q;
		if (link->tcp_local_q > rxq_max)
			rxq_max = link->tcp_local_q;
		if (link->udp_local_q > rxq_max)
			rxq_max = link->udp_local_q;
		if (link->sctp_local_q > rxq_max)
			rxq_max = link->sctp_local_q;

		for (i = 1; i <= rxq_max; i++)
			APP_CHECK(((link->arp_q == i) ||
				(link->tcp_syn_q == i) ||
				(link->ip_local_q == i) ||
				(link->tcp_local_q == i) ||
				(link->udp_local_q == i) ||
				(link->sctp_local_q == i)),
				"%s RXQs are not contiguous (A)\n", link->name);

		n_rxq = app_link_get_n_rxq(app, link);

		APP_CHECK((n_rxq), "%s does not have any RXQ\n", link->name);

		APP_CHECK((n_rxq == rxq_max + 1),
			"%s RXQs are not contiguous (B)\n", link->name);

		for (i = 0; i < n_rxq; i++) {
			char name[APP_PARAM_NAME_SIZE];
			int pos;

			sprintf(name, "RXQ%" PRIu32 ".%" PRIu32,
				link_id, i);
			pos = APP_PARAM_FIND(app->hwq_in_params, name);
			APP_CHECK((pos >= 0),
				"%s RXQs are not contiguous (C)\n", link->name);
		}

		/* Check that link RXQs are contiguous */
		n_txq = app_link_get_n_txq(app, link);

		APP_CHECK((n_txq),  "%s does not have any TXQ\n", link->name);

		for (i = 0; i < n_txq; i++) {
			char name[APP_PARAM_NAME_SIZE];
			int pos;

			sprintf(name, "TXQ%" PRIu32 ".%" PRIu32,
				link_id, i);
			pos = APP_PARAM_FIND(app->hwq_out_params, name);
			APP_CHECK((pos >= 0),
				"%s TXQs are not contiguous\n", link->name);
		}
	}
}
Example #9
0
static void
check_msgqs(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_msgq; i++) {
		struct app_msgq_params *p = &app->msgq_params[i];
		uint32_t n_readers = app_msgq_get_readers(app, p);
		uint32_t n_writers = app_msgq_get_writers(app, p);
		uint32_t msgq_req_pipeline, msgq_rsp_pipeline;
		uint32_t msgq_req_core, msgq_rsp_core;

		APP_CHECK((p->size > 0),
			"%s size is 0\n", p->name);

		APP_CHECK((rte_is_power_of_2(p->size)),
			"%s size is not a power of 2\n", p->name);

		msgq_req_pipeline = (strncmp(p->name, "MSGQ-REQ-PIPELINE",
			strlen("MSGQ-REQ-PIPELINE")) == 0);

		msgq_rsp_pipeline = (strncmp(p->name, "MSGQ-RSP-PIPELINE",
			strlen("MSGQ-RSP-PIPELINE")) == 0);

		msgq_req_core = (strncmp(p->name, "MSGQ-REQ-CORE",
			strlen("MSGQ-REQ-CORE")) == 0);

		msgq_rsp_core = (strncmp(p->name, "MSGQ-RSP-CORE",
			strlen("MSGQ-RSP-CORE")) == 0);

		if ((msgq_req_pipeline == 0) &&
			(msgq_rsp_pipeline == 0) &&
			(msgq_req_core == 0) &&
			(msgq_rsp_core == 0)) {
			APP_CHECK((n_readers != 0),
				"%s has no reader\n", p->name);

			APP_CHECK((n_readers == 1),
				"%s has more than one reader\n", p->name);

			APP_CHECK((n_writers != 0),
				"%s has no writer\n", p->name);

			APP_CHECK((n_writers == 1),
				"%s has more than one writer\n", p->name);
		}

		if (msgq_req_pipeline) {
			struct app_pipeline_params *pipeline;
			uint32_t pipeline_id;

			APP_PARAM_GET_ID(p, "MSGQ-REQ-PIPELINE", pipeline_id);

			APP_PARAM_FIND_BY_ID(app->pipeline_params,
				"PIPELINE",
				pipeline_id,
				pipeline);

			APP_CHECK((pipeline != NULL),
				"%s is not associated with a valid pipeline\n",
				p->name);
		}

		if (msgq_rsp_pipeline) {
			struct app_pipeline_params *pipeline;
			uint32_t pipeline_id;

			APP_PARAM_GET_ID(p, "MSGQ-RSP-PIPELINE", pipeline_id);

			APP_PARAM_FIND_BY_ID(app->pipeline_params,
				"PIPELINE",
				pipeline_id,
				pipeline);

			APP_CHECK((pipeline != NULL),
				"%s is not associated with a valid pipeline\n",
				p->name);
		}
	}
}
Example #10
0
static void
check_swqs(struct app_params *app)
{
	uint32_t i;

	for (i = 0; i < app->n_pktq_swq; i++) {
		struct app_pktq_swq_params *p = &app->swq_params[i];
		uint32_t n_readers = app_swq_get_readers(app, p);
		uint32_t n_writers = app_swq_get_writers(app, p);
		uint32_t n_flags;

		APP_CHECK((p->size > 0),
			"%s size is 0\n", p->name);

		APP_CHECK((rte_is_power_of_2(p->size)),
			"%s size is not a power of 2\n", p->name);

		APP_CHECK((p->burst_read > 0),
			"%s read burst size is 0\n", p->name);

		APP_CHECK((p->burst_read <= p->size),
			"%s read burst size is bigger than its size\n",
			p->name);

		APP_CHECK((p->burst_write > 0),
			"%s write burst size is 0\n", p->name);

		APP_CHECK((p->burst_write <= p->size),
			"%s write burst size is bigger than its size\n",
			p->name);

		APP_CHECK((n_readers != 0),
			"%s has no reader\n", p->name);

		if (n_readers > 1)
			APP_LOG(app, LOW, "%s has more than one reader", p->name);

		APP_CHECK((n_writers != 0),
			"%s has no writer\n", p->name);

		if (n_writers > 1)
			APP_LOG(app, LOW, "%s has more than one writer", p->name);

		n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras;

		APP_CHECK((n_flags < 2),
			"%s has more than one fragmentation or reassembly mode enabled\n",
			p->name);

		APP_CHECK((!((n_readers > 1) && (n_flags == 1))),
			"%s has more than one reader when fragmentation or reassembly"
			" mode enabled\n",
			p->name);

		APP_CHECK((!((n_writers > 1) && (n_flags == 1))),
			"%s has more than one writer when fragmentation or reassembly"
			" mode enabled\n",
			p->name);

		n_flags = p->ipv4_ras + p->ipv6_ras;

		APP_CHECK((!((p->dropless == 1) && (n_flags == 1))),
			"%s has dropless when reassembly mode enabled\n", p->name);

		n_flags = p->ipv4_frag + p->ipv6_frag;

		if (n_flags == 1) {
			uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) :
				sizeof(struct ipv6_hdr);

			APP_CHECK((p->mtu > ip_hdr_size),
				"%s mtu size is smaller than ip header\n", p->name);

			APP_CHECK((!((p->mtu - ip_hdr_size) % 8)),
				"%s mtu size is incorrect\n", p->name);
		}
	}
}