summaryrefslogtreecommitdiffstats
path: root/VNFs/vCGNAPT/pipeline/cgnapt_pcp_fe.c
blob: 51b94b0b3811fd73c4b940731b2239e0f818a13d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
// Copyright (c) 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>
#include <cmdline_parse_ipaddr.h>
#include <cmdline_parse_etheraddr.h>

#include "app.h"
#include "pipeline_common_fe.h"
#include "pipeline_cgnapt.h"
#include "pipeline_cgnapt_common.h"
#include "cgnapt_pcp_fe.h"
#include "cgnapt_pcp_be.h"

#ifdef PCP_ENABLE

/**
 * @file
 * Pipeline CG-NAPT PCP FE Implementation.
 *
 * Implementation of Pipeline CG-NAPT PCP Front End (FE).
 * Provides CLI support.
 * Runs on master core.
 *
 */

void cmd_pcp_parsed(
	void *parsed_result,
	 __rte_unused struct cmdline *cl,
	void *data);
/**
 * A structure defining PCP cmd parse arguments.
 */
struct cmd_pcp_result {
	cmdline_fixed_string_t p_string;
	uint32_t p;
	cmdline_fixed_string_t pcp_string;
	uint8_t cmd;
	uint32_t lifetime;
};

static cmdline_parse_token_string_t cmd_pcp_p_string =
TOKEN_STRING_INITIALIZER(struct cmd_pcp_result, p_string, "p");

static cmdline_parse_token_num_t cmd_pcp_p =
TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, p, UINT32);

static cmdline_parse_token_string_t cmd_pcp_string =
TOKEN_STRING_INITIALIZER(struct cmd_pcp_result,
			 pcp_string, "pcp");

static cmdline_parse_token_num_t cmd_pcp_cmd =
TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, cmd, UINT8);

static cmdline_parse_token_num_t cmd_pcp_lifetime =
TOKEN_NUM_INITIALIZER(struct cmd_pcp_result, lifetime, UINT32);

cmdline_parse_inst_t cmd_pcp = {
	.f = cmd_pcp_parsed,
	.data = NULL,
	.help_str = "NAPT PCP cmd",
	.tokens = {
			 (void *) &cmd_pcp_p_string,
			 (void *) &cmd_pcp_p,
			 (void *) &cmd_pcp_string,
			 (void *) &cmd_pcp_cmd,
			 (void *) &cmd_pcp_lifetime,
			 NULL,
			 },
};

 /**
 * Function to send a PCP cmd message to BE
 *
 * @param app
 *  A pointer to pipeline app
 * @param pipeline_id
 *  Pipeline id
 * @param cmd
 *  PCP specific command whether to show stats,set to get lifetime
 * @param lifetime
 *      PCP entry lifetime
 * @return
 *  0 on success, negative on error.
 */
//#ifdef PCP_ENABLE
static int
app_pipeline_cgnapt_pcp(struct app_params *app,
			uint32_t pipeline_id, uint8_t cmd, uint32_t lifetime){

	struct pipeline_cgnapt *p;
	struct pipeline_cgnapt_pcp_msg_req *req;
	struct pipeline_cgnapt_pcp_msg_rsp *rsp;

	/* Check input arguments */
	if (app == NULL)
		return -1;

	p = app_pipeline_data_fe(app, pipeline_id,
			(struct pipeline_type *)&pipeline_cgnapt);
	if (p == NULL)
		return -1;

	/* Allocate and write request */
	req = app_msg_alloc(app);
	if (req == NULL)
		return -1;

	req->type = PIPELINE_MSG_REQ_CUSTOM;
	req->subtype = PIPELINE_CGNAPT_MSG_REQ_PCP;
	req->cmd = cmd;
	req->lifetime = lifetime;

	rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
	if (rsp == NULL)
		return -1;

	/* Read response */
	if (rsp->status) {
		app_msg_free(app, rsp);
		printf("Error rsp->status %d\n", rsp->status);
		return -1;
	}

	/* Free response */
	app_msg_free(app, rsp);

	return 0;
}

/**
 * Helping function for PCP cmd
 *
 * @param parsed_result
 *  A pointer parsed add arguments
 * @param cl
 *  unused pointer to struct cmdline
 * @param data
 *  void pointer data
 */
void
cmd_pcp_parsed(void *parsed_result,
	__rte_unused struct cmdline *cl,
	void *data)
{
	struct cmd_pcp_result *params = parsed_result;
	struct app_params *app = data;
	int status;

	status = app_pipeline_cgnapt_pcp(app, params->p, params->cmd,
			params->lifetime);

	if (status != 0) {
		printf("PCP Command failed\n");
		return;
	}
}

#endif
ddr.bmdma_addr = base; ata_sff_std_ports(&ap->ioaddr); ap->pflags = ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; ninja32_program(base); /* FIXME: Should we disable them at remove ? */ return ata_host_activate(host, dev->irq, ata_bmdma_interrupt, IRQF_SHARED, &ninja32_sht); } #ifdef CONFIG_PM_SLEEP static int ninja32_reinit_one(struct pci_dev *pdev) { struct ata_host *host = pci_get_drvdata(pdev); int rc; rc = ata_pci_device_do_resume(pdev); if (rc) return rc; ninja32_program(host->iomap[0]); ata_host_resume(host); return 0; } #endif static const struct pci_device_id ninja32[] = { { 0x10FC, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0x8008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0xf008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1145, 0xf02C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { }, }; static struct pci_driver ninja32_pci_driver = { .name = DRV_NAME, .id_table = ninja32, .probe = ninja32_init_one, .remove = ata_pci_remove_one, #ifdef CONFIG_PM_SLEEP .suspend = ata_pci_device_suspend, .resume = ninja32_reinit_one, #endif }; module_pci_driver(ninja32_pci_driver); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("low-level driver for Ninja32 ATA"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, ninja32); MODULE_VERSION(DRV_VERSION);