X-Git-Url: https://gerrit.fd.io/r/gitweb?p=deb_dpdk.git;a=blobdiff_plain;f=drivers%2Fnet%2Fsoftnic%2Frte_eth_softnic_cli.c;h=c6640d6588aa781524a51bc4d673d47f25b07d2e;hp=0c7448cc4bdf0993cdb15e69433c93db8a5c6e4f;hb=8d01b9cd70a67cdafd5b965a70420c3bd7fb3f82;hpb=b63264c8342e6a1b6971c79550d2af2024b6a4de diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 0c7448cc..c6640d65 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -9,6 +9,8 @@ #include #include +#include +#include #include "rte_eth_softnic_internals.h" #include "parser.h" @@ -1088,6 +1090,67 @@ cmd_tap(struct pmd_internals *softnic, } } +/** + * cryptodev dev | dev_id + * queue + **/ + +static void +cmd_cryptodev(struct pmd_internals *softnic, + char **tokens, + uint32_t n_tokens, + char *out, + size_t out_size) +{ + struct softnic_cryptodev_params params; + char *name; + + memset(¶ms, 0, sizeof(params)); + if (n_tokens != 7) { + snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); + return; + } + + name = tokens[1]; + + if (strcmp(tokens[2], "dev") == 0) + params.dev_name = tokens[3]; + else if (strcmp(tokens[2], "dev_id") == 0) { + if (softnic_parser_read_uint32(¶ms.dev_id, tokens[3]) < 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "dev_id"); + return; + } + } else { + snprintf(out, out_size, MSG_ARG_INVALID, + "cryptodev"); + return; + } + + if (strcmp(tokens[4], "queue")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, + "4"); + return; + } + + if (softnic_parser_read_uint32(¶ms.n_queues, tokens[5]) < 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "q"); + return; + } + + if (softnic_parser_read_uint32(¶ms.queue_size, tokens[6]) < 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "queue_size"); + return; + } + + if (softnic_cryptodev_create(softnic, name, ¶ms) == NULL) { + snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); + return; + } +} + /** * port in action profile * [filter match | mismatch offset mask key port ] @@ -1272,13 +1335,17 @@ cmd_port_in_action_profile(struct pmd_internals *softnic, * tc * stats none | pkts | bytes | both] * [tm spp pps ] - * [encap ether | vlan | qinq | mpls | pppoe] + * [encap ether | vlan | qinq | mpls | pppoe | + * vxlan offset ipv4 | ipv6 vlan on | off] * [nat src | dst * proto udp | tcp] * [ttl drop | fwd * stats none | pkts] * [stats pkts | bytes | both] * [time] + * [tag] + * [decap] + * */ static void cmd_table_action_profile(struct pmd_internals *softnic, @@ -1478,6 +1545,8 @@ cmd_table_action_profile(struct pmd_internals *softnic, if (t0 < n_tokens && (strcmp(tokens[t0], "encap") == 0)) { + uint32_t n_extra_tokens = 0; + if (n_tokens < t0 + 2) { snprintf(out, out_size, MSG_ARG_MISMATCH, "action profile encap"); @@ -1494,13 +1563,61 @@ cmd_table_action_profile(struct pmd_internals *softnic, p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS; } else if (strcmp(tokens[t0 + 1], "pppoe") == 0) { p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE; + } else if (strcmp(tokens[t0 + 1], "vxlan") == 0) { + if (n_tokens < t0 + 2 + 5) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "action profile encap vxlan"); + return; + } + + if (strcmp(tokens[t0 + 2], "offset") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, + "vxlan: offset"); + return; + } + + if (softnic_parser_read_uint32(&p.encap.vxlan.data_offset, + tokens[t0 + 2 + 1]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "vxlan: ether_offset"); + return; + } + + if (strcmp(tokens[t0 + 2 + 2], "ipv4") == 0) + p.encap.vxlan.ip_version = 1; + else if (strcmp(tokens[t0 + 2 + 2], "ipv6") == 0) + p.encap.vxlan.ip_version = 0; + else { + snprintf(out, out_size, MSG_ARG_INVALID, + "vxlan: ipv4 or ipv6"); + return; + } + + if (strcmp(tokens[t0 + 2 + 3], "vlan") != 0) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, + "vxlan: vlan"); + return; + } + + if (strcmp(tokens[t0 + 2 + 4], "on") == 0) + p.encap.vxlan.vlan = 1; + else if (strcmp(tokens[t0 + 2 + 4], "off") == 0) + p.encap.vxlan.vlan = 0; + else { + snprintf(out, out_size, MSG_ARG_INVALID, + "vxlan: on or off"); + return; + } + + p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VXLAN; + n_extra_tokens = 5; + } else { snprintf(out, out_size, MSG_ARG_MISMATCH, "encap"); return; } - p.action_mask |= 1LLU << RTE_TABLE_ACTION_ENCAP; - t0 += 2; + t0 += 2 + n_extra_tokens; } /* encap */ if (t0 < n_tokens && @@ -1610,6 +1727,18 @@ cmd_table_action_profile(struct pmd_internals *softnic, t0 += 1; } /* time */ + if (t0 < n_tokens && + (strcmp(tokens[t0], "tag") == 0)) { + p.action_mask |= 1LLU << RTE_TABLE_ACTION_TAG; + t0 += 1; + } /* tag */ + + if (t0 < n_tokens && + (strcmp(tokens[t0], "decap") == 0)) { + p.action_mask |= 1LLU << RTE_TABLE_ACTION_DECAP; + t0 += 1; + } /* decap */ + if (t0 < n_tokens) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -1682,6 +1811,7 @@ cmd_pipeline(struct pmd_internals *softnic, * | tmgr * | tap mempool mtu * | source mempool file bpp + * | cryptodev rxq * [action ] * [disabled] */ @@ -1697,6 +1827,8 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, uint32_t t0; int enabled, status; + memset(&p, 0, sizeof(p)); + if (n_tokens < 7) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -1735,7 +1867,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_RXQ; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); if (strcmp(tokens[t0 + 2], "rxq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); @@ -1758,7 +1890,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_SWQ; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); t0 += 2; } else if (strcmp(tokens[t0], "tmgr") == 0) { @@ -1770,7 +1902,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TMGR; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); t0 += 2; } else if (strcmp(tokens[t0], "tap") == 0) { @@ -1782,7 +1914,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TAP; - p.dev_name = tokens[t0 + 1]; + strcpy(p.dev_name, tokens[t0 + 1]); if (strcmp(tokens[t0 + 2], "mempool") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, @@ -1814,8 +1946,6 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_SOURCE; - p.dev_name = NULL; - if (strcmp(tokens[t0 + 1], "mempool") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool"); @@ -1846,12 +1976,32 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, } t0 += 7; + } else if (strcmp(tokens[t0], "cryptodev") == 0) { + if (n_tokens < t0 + 3) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "pipeline port in cryptodev"); + return; + } + + p.type = PORT_IN_CRYPTODEV; + + strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name)); + if (softnic_parser_read_uint16(&p.rxq.queue_id, + tokens[t0 + 3]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "rxq"); + return; + } + + p.cryptodev.arg_callback = NULL; + p.cryptodev.f_callback = NULL; + + t0 += 4; } else { snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); return; } - p.action_profile_name = NULL; if (n_tokens > t0 && (strcmp(tokens[t0], "action") == 0)) { if (n_tokens < t0 + 2) { @@ -1859,7 +2009,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, return; } - p.action_profile_name = tokens[t0 + 1]; + strcpy(p.action_profile_name, tokens[t0 + 1]); t0 += 2; } @@ -1895,6 +2045,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, * | tmgr * | tap * | sink [file pkts ] + * | cryptodev txq offset */ static void cmd_pipeline_port_out(struct pmd_internals *softnic, @@ -1945,7 +2096,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TXQ; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); if (strcmp(tokens[8], "txq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "txq"); @@ -1966,7 +2117,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_SWQ; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "tmgr") == 0) { if (n_tokens != 8) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1976,7 +2127,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TMGR; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "tap") == 0) { if (n_tokens != 8) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1986,7 +2137,7 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_TAP; - p.dev_name = tokens[7]; + strcpy(p.dev_name, tokens[7]); } else if (strcmp(tokens[6], "sink") == 0) { if ((n_tokens != 7) && (n_tokens != 11)) { snprintf(out, out_size, MSG_ARG_MISMATCH, @@ -1996,8 +2147,6 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, p.type = PORT_OUT_SINK; - p.dev_name = NULL; - if (n_tokens == 7) { p.sink.file_name = NULL; p.sink.max_n_pkts = 0; @@ -2021,6 +2170,40 @@ cmd_pipeline_port_out(struct pmd_internals *softnic, return; } } + } else if (strcmp(tokens[6], "cryptodev") == 0) { + if (n_tokens != 12) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "pipeline port out cryptodev"); + return; + } + + p.type = PORT_OUT_CRYPTODEV; + + strlcpy(p.dev_name, tokens[7], sizeof(p.dev_name)); + + if (strcmp(tokens[8], "txq")) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "pipeline port out cryptodev"); + return; + } + + if (softnic_parser_read_uint16(&p.cryptodev.queue_id, tokens[9]) + != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "queue_id"); + return; + } + + if (strcmp(tokens[10], "offset")) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "pipeline port out cryptodev"); + return; + } + + if (softnic_parser_read_uint32(&p.cryptodev.op_offset, + tokens[11]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, "queue_id"); + return; + } } else { snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]); return; @@ -2064,12 +2247,13 @@ cmd_pipeline_table(struct pmd_internals *softnic, char *out, size_t out_size) { - uint8_t key_mask[TABLE_RULE_MATCH_SIZE_MAX]; struct softnic_table_params p; char *pipeline_name; uint32_t t0; int status; + memset(&p, 0, sizeof(p)); + if (n_tokens < 5) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; @@ -2203,12 +2387,11 @@ cmd_pipeline_table(struct pmd_internals *softnic, } if ((softnic_parse_hex_string(tokens[t0 + 5], - key_mask, &key_mask_size) != 0) || + p.match.hash.key_mask, &key_mask_size) != 0) || key_mask_size != p.match.hash.key_size) { snprintf(out, out_size, MSG_ARG_INVALID, "key_mask"); return; } - p.match.hash.key_mask = key_mask; if (strcmp(tokens[t0 + 6], "offset") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "offset"); @@ -2295,7 +2478,6 @@ cmd_pipeline_table(struct pmd_internals *softnic, return; } - p.action_profile_name = NULL; if (n_tokens > t0 && (strcmp(tokens[t0], "action") == 0)) { if (n_tokens < t0 + 2) { @@ -2303,7 +2485,7 @@ cmd_pipeline_table(struct pmd_internals *softnic, return; } - p.action_profile_name = tokens[t0 + 1]; + strcpy(p.action_profile_name, tokens[t0 + 1]); t0 += 2; } @@ -3176,10 +3358,30 @@ parse_match(char **tokens, * [label2