Skip to content
Snippets Groups Projects
Commit 8bb6911a authored by Maxim Menshikov's avatar Maxim Menshikov
Browse files

Support rule output value 0x00-0x07

parent 18a18607
No related branches found
No related tags found
No related merge requests found
...@@ -298,6 +298,30 @@ dscp_pcp_conv_result dscp_pcp2qosmap(uint8_t dscp_pcp[64], ...@@ -298,6 +298,30 @@ dscp_pcp_conv_result dscp_pcp2qosmap(uint8_t dscp_pcp[64],
return rc; return rc;
} }
dscp_pcp_conv_result dscp_pcp2qosmap_simple(int pcp, char *str, size_t len)
{
size_t i;
for (i = 0; i <= 0x7; ++i)
{
char s[50];
/*
* Map DSCP [0, 63] to PCP passed as argument,
* all other PCP->DSCP ranges are mapped to [255, 255] (unused)
*/
sprintf(s, "%s%d,%d", (i != 0) ? ",",
(pcp == i) ? 0 : 255,
(pcp == i) ? 63 : 255);
if ((strlen(str) + strlen(s)) >= len)
return DSCP_PCP_CONV_RESULT_TOO_LONG;
strcat(str, s);
}
return DSCP_PCP_CONV_RESULT_OK;
}
int qos_apply_dscp_rules(void *agent) int qos_apply_dscp_rules(void *agent)
{ {
dscp_pcp_conv_result rc; dscp_pcp_conv_result rc;
...@@ -309,10 +333,15 @@ int qos_apply_dscp_rules(void *agent) ...@@ -309,10 +333,15 @@ int qos_apply_dscp_rules(void *agent)
list_for_each_entry(r, &a->qos_rules, list) { list_for_each_entry(r, &a->qos_rules, list) {
char str[512] = { '\0' }; char str[512] = { '\0' };
if (r->spr.output != 0x08) if (r->spr.output < 0x08) {
continue; rc = dscp_pcp2qosmap_simple(r->spr.output, str, sizeof(str) - 1);
} else if (r->spr.output == 0x08) {
rc = dscp_pcp2qosmap(r->dscp.dscp_pcp, str, sizeof(str) - 1); rc = dscp_pcp2qosmap(r->dscp.dscp_pcp, str, sizeof(str) - 1);
} else {
err("%s: unsupported SPR output value\n", __func__);
rc = DSCP_PCP_CONV_RESULT_FAIL;
}
if (rc != DSCP_PCP_CONV_RESULT_OK && if (rc != DSCP_PCP_CONV_RESULT_OK &&
rc != DSCP_PCP_CONV_RESULT_OK_TOO_MANY_EXC) { rc != DSCP_PCP_CONV_RESULT_OK_TOO_MANY_EXC) {
err("%s: wrong QoS map\n", __func__); err("%s: wrong QoS map\n", __func__);
......
...@@ -80,6 +80,7 @@ typedef enum dscp_pcp_conv_result { ...@@ -80,6 +80,7 @@ typedef enum dscp_pcp_conv_result {
but too many exceptions */ but too many exceptions */
DSCP_PCP_CONV_RESULT_TOO_LONG, /**< Too long result that didn't DSCP_PCP_CONV_RESULT_TOO_LONG, /**< Too long result that didn't
fit the output buffer */ fit the output buffer */
DSCP_PCP_CONV_RESULT_FAIL, /**< Failure producing QoS map */
} dscp_pcp_conv_result; } dscp_pcp_conv_result;
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment