2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <cmdline_parse.h>
18 #include <cmdline_parse_num.h>
19 #include <cmdline_parse_string.h>
20 #include <cmdline_parse_ipaddr.h>
21 #include <cmdline_parse_etheraddr.h>
24 #include "pipeline_common_fe.h"
25 #include "pipeline_cgnapt.h"
26 #include "pipeline_cgnapt_common.h"
27 #include "cgnapt_pcp_fe.h"
28 #include "cgnapt_pcp_be.h"
34 * Pipeline CG-NAPT PCP FE Implementation.
36 * Implementation of Pipeline CG-NAPT PCP Front End (FE).
37 * Provides CLI support.
38 * Runs on master core.
44 __rte_unused struct cmdline *cl,
47 * A structure defining PCP cmd parse arguments.
49 struct cmd_pcp_result {
50 cmdline_fixed_string_t p_string;
52 cmdline_fixed_string_t pcp_string;
57 static cmdline_parse_token_string_t cmd_pcp_p_string =
58 TOKEN_STRING_INITIALIZER(struct cmd_pcp_result, p_string, "p");
60 static cmdline_parse_token_num_t cmd_pcp_p =
61 TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, p, UINT32);
63 static cmdline_parse_token_string_t cmd_pcp_string =
64 TOKEN_STRING_INITIALIZER(struct cmd_pcp_result,
67 static cmdline_parse_token_num_t cmd_pcp_cmd =
68 TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, cmd, UINT8);
70 static cmdline_parse_token_num_t cmd_pcp_lifetime =
71 TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, lifetime, UINT32);
73 cmdline_parse_inst_t cmd_pcp = {
76 .help_str = "NAPT PCP cmd",
78 (void *) &cmd_pcp_p_string,
80 (void *) &cmd_pcp_string,
81 (void *) &cmd_pcp_cmd,
82 (void *) &cmd_pcp_lifetime,
88 * Function to send a PCP cmd message to BE
91 * A pointer to pipeline app
95 * PCP specific command whether to show stats,set to get lifetime
99 * 0 on success, negative on error.
103 app_pipeline_cgnapt_pcp(struct app_params *app,
104 uint32_t pipeline_id, uint8_t cmd, uint32_t lifetime){
106 struct pipeline_cgnapt *p;
107 struct pipeline_cgnapt_pcp_msg_req *req;
108 struct pipeline_cgnapt_pcp_msg_rsp *rsp;
110 /* Check input arguments */
114 p = app_pipeline_data_fe(app, pipeline_id,
115 (struct pipeline_type *)&pipeline_cgnapt);
119 /* Allocate and write request */
120 req = app_msg_alloc(app);
124 req->type = PIPELINE_MSG_REQ_CUSTOM;
125 req->subtype = PIPELINE_CGNAPT_MSG_REQ_PCP;
127 req->lifetime = lifetime;
129 rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
135 app_msg_free(app, rsp);
136 printf("Error rsp->status %d\n", rsp->status);
141 app_msg_free(app, rsp);
147 * Helping function for PCP cmd
149 * @param parsed_result
150 * A pointer parsed add arguments
152 * unused pointer to struct cmdline
157 cmd_pcp_parsed(void *parsed_result,
158 __rte_unused struct cmdline *cl,
161 struct cmd_pcp_result *params = parsed_result;
162 struct app_params *app = data;
165 status = app_pipeline_cgnapt_pcp(app, params->p, params->cmd,
169 printf("PCP Command failed\n");