blob: 1b119baa4c3ece32a775882ac014278d4027380a [file] [log] [blame]
/*******************************************************************************
Copyright (C) Marvell International Ltd. and its affiliates
This software file (the "File") is owned and distributed by Marvell
International Ltd. and/or its affiliates ("Marvell") under the following
alternative licensing terms. Once you have made an election to distribute the
File under one of the following license alternatives, please (i) delete this
introductory statement regarding license alternatives, (ii) delete the two
license alternatives that you have not elected to use and (iii) preserve the
Marvell copyright notice above.
********************************************************************************
Marvell Commercial License Option
If you received this File from Marvell and you have entered into a commercial
license agreement (a "Commercial License") with Marvell, the File is licensed
to you under the terms of the applicable Commercial License.
********************************************************************************
Marvell GPL License Option
If you received this File from Marvell, you may opt to use, redistribute and/or
modify this File in accordance with the terms and conditions of the General
Public License Version 2, June 1991 (the "GPL License"), a copy of which is
available along with the File in the license.txt file or by writing to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
DISCLAIMED. The GPL License provides additional details about this warranty
disclaimer.
********************************************************************************
Marvell BSD License Option
If you received this File from Marvell, you may opt to use, redistribute and/or
modify this File under the following licensing terms.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Marvell nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include <linux/ctype.h>
#include "tpm_common.h"
#include "tpm_header.h"
#include "tpm_sysfs_utils.h"
#include "tpm_sysfs_help.h"
#include "tpm_sysfs_hwcall.h"
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
extern struct semaphore tpm_sfs_2_ioctl_sem;
extern tpm_ioctl_mng_t tpm_sfs_2_ioctl_command;
#define PR_RULE_IDX(rule_idx) {}
#define PR_HIT_COUNT(hit_count){}
#define PR_RESULT {}
#define PR_MAC_COUNT {}
#else
#define PR_RULE_IDX(rule_idx) {printk(KERN_INFO "OK. rule_idx = %d\n", rule_idx);}
#define PR_HIT_COUNT(hit_count){printk(KERN_INFO "OK. hit_count = %d\n", hit_count);}
#define PR_RESULT {printk(KERN_INFO "OK.\n");}
#define PR_MAC_COUNT(count) {printk(KERN_INFO "OK. mac_learn_entry_count = %d\n", count);}
#endif
static char *l2_key_empty_name = "l2_key_empty";
static char *l3_key_empty_name = "l3_key_empty";
static char *ipv4_key_empty_name = "ipv4_key_empty";
static char *ipv6_key_empty_name = "ipv6_key_empty";
static char *frwd_empty_name = "frwd_empty";
static char *mod_empty_name = "mod_empty";
char *ipv6_gen_key_empty_name = "ipv6_gen_key_empty";
char *ipv6_dip_key_empty_name = "ipv6_dip_key_empty";
char *ipv6_l4_key_empty_name = "ipv6_l4_key_empty";
extern int32_t module_tpmSetup(tpm_setup_t *tpm_initp);
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_l2_rule_bounce(uint32_t owner_id,
tpm_src_port_type_t src_port,
uint32_t rule_num,
uint32_t *rule_idx,
tpm_parse_fields_t parse_rule_bm,
tpm_parse_flags_t parse_flags_bm,
tpm_l2_acl_key_t *l2_key,
tpm_pkt_frwd_t *pkt_frwd,
tpm_pkt_mod_t *pkt_mod,
tpm_pkt_mod_bm_t pkt_mod_bm,
tpm_rule_action_t *rule_action)
{
tpm_ioctl_add_acl_rule_t *tpm_add_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_add_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_ADD_ACL_SECTION;
tpm_add_acl_rule->add_acl_cmd = MV_TPM_IOCTL_ADD_L2_ACL_RULE;
tpm_add_acl_rule->owner_id = owner_id;
tpm_add_acl_rule->src_port = src_port;
tpm_add_acl_rule->rule_num = rule_num;
tpm_add_acl_rule->parse_rule_bm = parse_rule_bm;
tpm_add_acl_rule->l2_acl_rule.parse_flags_bm = parse_flags_bm;
tpm_add_acl_rule->l2_acl_rule.pkt_mod_bm = pkt_mod_bm;
memcpy(&(tpm_add_acl_rule->l2_acl_rule.l2_key), (void*)l2_key, sizeof(tpm_l2_acl_key_t));
memcpy(&(tpm_add_acl_rule->l2_acl_rule.pkt_frwd), (void*)pkt_frwd, sizeof(tpm_pkt_frwd_t));
memcpy(&(tpm_add_acl_rule->l2_acl_rule.pkt_mod), (void*)pkt_mod, sizeof(tpm_pkt_mod_t));
memcpy(&(tpm_add_acl_rule->l2_acl_rule.rule_action), (void*)rule_action, sizeof(tpm_rule_action_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_l2_rule tpm_add_l2_rule_bounce
#else
#define _tpm_add_l2_rule tpm_add_l2_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_l2_rule_add
*
* DESCRIPTION:
* This function creates a L2 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_l2_rule_add (const char *buf, size_t len)
{
typedef enum
{
l2ruleadd_owner=0, l2ruleadd_srcport, l2ruleadd_rulenum, l2ruleadd_parserulebm, l2ruleadd_parseflagbm, l2ruleadd_action, l2ruleadd_nextphase,
l2ruleadd_l2keyname, l2ruleadd_frwdname, l2ruleadd_modname, l2ruleadd_pktmodbm, l2ruleadd_max
} l2ruleadd_parm_indx_t;
// shell line parsing
uint32_t ownerid;
char srcport_str[20];
char uc_srcport_str[20];
int indx;
uint32_t src_port;
uint32_t rulenum;
uint32_t parserulebm;
uint32_t parseflagbm;
uint32_t pkt_mod_bm;
uint32_t action;
char nextphase_str[20];
uint32_t nextphase;
char l2keyname[20];
char frwdname[20];
char modname[20];
int parsedargs;
int numparms;
// DB
tpmcfg_frwd_entry_t *pdbfrwdentry = 0;
tpmcfg_l2_key_entry_t *pdbl2keyentry = 0;
tpmcfg_mod_entry_t *pdbmodentry = 0;
//Used in API call
tpm_rule_action_t rule_action;
tpm_pkt_frwd_t pkt_frwd;
tpm_l2_acl_key_t l2_acl;
tpm_pkt_mod_t pkt_mod;
uint32_t rule_idx;
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != l2ruleadd_max)
{
parm_error_completion(numparms, l2ruleadd_max, buf, sfs_help_l2_rule_add);
// if (numparms == 1 && buf[0] == '?')
// {
// char helpbuf[3000];
// int helpbuf_len;
//
// helpbuf_len = sfs_help_l2_rule_add(helpbuf);
// print_help_buffer(helpbuf, helpbuf_len);
// }
// else
// {
// printk(KERN_INFO "Parse problem: expected %d parameters, found %d\n", l2ruleadd_max, numparms);
// }
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %s %d 0x%x 0x%x 0x%x %s %s %s %s 0x%x", &ownerid, srcport_str, &rulenum, &parserulebm,
&parseflagbm, &action, nextphase_str, l2keyname, frwdname, modname, &pkt_mod_bm);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rulenum[%d], parserulebm[0x%x], action[0x%x], nextphase_str[%s], l2keyname[%s], frwdname[%s], modname[%s], pkt_mod_bm[0x%x]\n",
len, parsedargs, ownerid, srcport_str, rulenum, parserulebm, action, nextphase_str, l2keyname, frwdname, modname, pkt_mod_bm);
// Minimal help for src_port upper/lower case support
for (indx = 0; indx < strlen(srcport_str); indx++) uc_srcport_str[indx] = (char)toupper(srcport_str[indx]);
uc_srcport_str[strlen(srcport_str)] = 0;
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_srcport_value(uc_srcport_str, &src_port) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_port[%s]\n", srcport_str);
}
else if (get_phase_value(nextphase_str, &nextphase) == GT_FALSE)
{
printk(KERN_INFO "Invalid next_phase[%s]\n", nextphase_str);
}
else if (((pdbl2keyentry = find_tpm_l2_key_entry_by_name(l2keyname)) == 0) && strcmp(l2keyname, l2_key_empty_name) != 0)
{
printk(KERN_INFO "L2 key entry [%s] not found\n", l2keyname);
}
else if (((pdbfrwdentry = find_tpm_pkt_frwd_entry_by_name(frwdname)) == 0) && strcmp(frwdname, frwd_empty_name) != 0)
{
printk(KERN_INFO "frwd entry [%s] not found\n", frwdname);
}
else if (((pdbmodentry = find_tpm_mod_entry_by_name(modname)) == 0) && strcmp(modname, mod_empty_name) != 0)
{
printk(KERN_INFO "mod entry [%s] not found\n", modname);
}
else
{
rule_action.next_phase = nextphase;
rule_action.pkt_act = action;
if (pdbl2keyentry != 0) memcpy(&l2_acl, &pdbl2keyentry->l2_acl, sizeof(tpm_l2_acl_key_t));
else memset(&l2_acl, 0, sizeof(tpm_l2_acl_key_t));
if (pdbfrwdentry != 0) memcpy(&pkt_frwd, &pdbfrwdentry->frwd, sizeof(tpm_pkt_frwd_t));
else memset(&pkt_frwd, 0, sizeof(tpm_pkt_frwd_t));
if (pdbmodentry != 0) memcpy(&pkt_mod, &pdbmodentry->mod, sizeof(tpm_pkt_mod_t));
else memset(&pkt_mod, 0, sizeof(tpm_pkt_mod_t));
if ((rc = _tpm_add_l2_rule(ownerid,
src_port,
rulenum,
&rule_idx,
parserulebm,
parseflagbm,
&l2_acl,
&pkt_frwd,
&pkt_mod,
pkt_mod_bm,
&rule_action)) == TPM_RC_OK)
PR_RULE_IDX(rule_idx)
else
{
printk(KERN_INFO "%s: tpm_add_l2_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_l3_type_rule_bounce(uint32_t owner_id,
tpm_src_port_type_t src_port,
uint32_t rule_num,
uint32_t *rule_idx,
tpm_parse_fields_t parse_rule_bm,
tpm_parse_flags_t parse_flags_bm,
tpm_l3_type_key_t *l3_key,
tpm_pkt_frwd_t *pkt_frwd,
tpm_rule_action_t *rule_action)
{
tpm_ioctl_add_acl_rule_t *tpm_add_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_add_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_ADD_ACL_SECTION;
tpm_add_acl_rule->add_acl_cmd = MV_TPM_IOCTL_ADD_L3_ACL_RULE;
tpm_add_acl_rule->owner_id = owner_id;
tpm_add_acl_rule->src_port = src_port;
tpm_add_acl_rule->rule_num = rule_num;
tpm_add_acl_rule->parse_rule_bm = parse_rule_bm;
tpm_add_acl_rule->l3_acl_rule.parse_flags_bm = parse_flags_bm;
memcpy(&(tpm_add_acl_rule->l3_acl_rule.l3_key), (void*)l3_key, sizeof(tpm_l3_type_key_t));
memcpy(&(tpm_add_acl_rule->l3_acl_rule.pkt_frwd), (void*)pkt_frwd, sizeof(tpm_pkt_frwd_t));
memcpy(&(tpm_add_acl_rule->l3_acl_rule.rule_action), (void*)rule_action, sizeof(tpm_rule_action_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_l3_type_rule tpm_add_l3_type_rule_bounce
#else
#define _tpm_add_l3_type_rule tpm_add_l3_type_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_l3_rule_add
*
* DESCRIPTION:
* This function creates a L3 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_l3_rule_add (const char *buf, size_t len)
{
typedef enum
{
l3ruleadd_owner=0, l3ruleadd_srcport, l3ruleadd_rulenum, l3ruleadd_parserulebm, l3ruleadd_parseflagsbm, l3ruleadd_action, l3ruleadd_nextphase,
l2ruleadd_frwdname, l3ruleadd_l3keyname, l3ruleadd_max
} l3ruleadd_parm_indx_t;
// shell line parsing
uint32_t ownerid;
char srcport_str[20];
char uc_srcport_str[20];
int indx;
uint32_t src_port;
uint32_t rulenum;
uint32_t parserulebm;
uint32_t parseflagbm;
uint32_t action;
char nextphase_str[20];
uint32_t nextphase;
char frwdname[20];
char l3keyname[20];
int parsedargs;
int numparms;
// DB
tpmcfg_l3_key_entry_t *pdbl3keyentry = 0;
tpmcfg_frwd_entry_t *pdbfrwdentry = 0;
// Used in API call
tpm_rule_action_t rule_action;
tpm_pkt_frwd_t pkt_frwd;
tpm_l3_type_key_t l3_acl;
uint32_t rule_idx;
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != l3ruleadd_max)
{
parm_error_completion(numparms, l3ruleadd_max, buf, sfs_help_l3_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %s %d 0x%x 0x%x 0x%x %s %s %s",
&ownerid, srcport_str, &rulenum, &parserulebm, &parseflagbm, &action, nextphase_str, l3keyname, frwdname);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rulenum[%d], parserulebm[0x%x], parseflagbm[0x%x], action[0x%x], nextphase_str[%s], l3keyname[%s], frwdname[%s]\n",
len, parsedargs, ownerid, srcport_str, rulenum, parserulebm, parseflagbm, action, nextphase_str, l3keyname, frwdname);
// Minimal help for src_port upper/lower case support
for (indx = 0; indx < strlen(srcport_str); indx++) uc_srcport_str[indx] = (char)toupper(srcport_str[indx]);
uc_srcport_str[strlen(srcport_str)] = 0;
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_srcport_value(uc_srcport_str, &src_port) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_port[%s]\n", uc_srcport_str);
}
else if (get_phase_value(nextphase_str, &nextphase) == GT_FALSE)
{
printk(KERN_INFO "Invalid next_phase[%s]\n", nextphase_str);
}
else if (((pdbfrwdentry = find_tpm_pkt_frwd_entry_by_name(frwdname)) == 0) && strcmp(frwdname, frwd_empty_name) != 0)
{
printk(KERN_INFO "frwd entry [%s] not found\n", frwdname);
}
else if (((pdbl3keyentry = find_tpm_l3_key_entry_by_name(l3keyname)) == 0) && strcmp(l3keyname, l3_key_empty_name) != 0)
{
printk(KERN_INFO "L3 key entry [%s] not found\n", l3keyname);
}
else
{
rule_action.next_phase = nextphase;
rule_action.pkt_act = action;
if (pdbl3keyentry != 0) memcpy(&l3_acl, &pdbl3keyentry->l3_acl, sizeof(tpm_l3_type_key_t));
else memset(&l3_acl, 0, sizeof(tpm_l3_type_key_t));
if (pdbfrwdentry != 0) memcpy(&pkt_frwd, &pdbfrwdentry->frwd, sizeof(tpm_pkt_frwd_t));
else memset(&pkt_frwd, 0, sizeof(tpm_pkt_frwd_t));
if ((rc = _tpm_add_l3_type_rule(ownerid,
src_port,
rulenum,
&rule_idx,
parserulebm,
parseflagbm,
&l3_acl,
&pkt_frwd,
&rule_action)) == TPM_RC_OK)
PR_RULE_IDX(rule_idx)
else
{
printk(KERN_INFO "%s: tpm_add_l3_type_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv4_rule_bounce(uint32_t owner_id,
tpm_src_port_type_t src_port,
uint32_t rule_num,
uint32_t *rule_idx,
tpm_parse_fields_t parse_rule_bm,
tpm_parse_flags_t parse_flags_bm,
tpm_ipv4_acl_key_t *ipv4_key,
tpm_pkt_frwd_t *pkt_frwd,
tpm_pkt_mod_t *pkt_mod,
tpm_pkt_mod_bm_t pkt_mod_bm,
tpm_rule_action_t *rule_action)
{
tpm_ioctl_add_acl_rule_t *tpm_add_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_add_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_ADD_ACL_SECTION;
tpm_add_acl_rule->add_acl_cmd = MV_TPM_IOCTL_ADD_IPv4_ACL_RULE;
tpm_add_acl_rule->owner_id = owner_id;
tpm_add_acl_rule->src_port = src_port;
tpm_add_acl_rule->rule_num = rule_num;
tpm_add_acl_rule->parse_rule_bm = parse_rule_bm;
tpm_add_acl_rule->ipv4_acl_rule.parse_flags_bm = parse_flags_bm;
tpm_add_acl_rule->ipv4_acl_rule.pkt_mod_bm = pkt_mod_bm;
memcpy(&(tpm_add_acl_rule->ipv4_acl_rule.ipv4_key), (void*)ipv4_key, sizeof(tpm_ipv4_acl_key_t));
memcpy(&(tpm_add_acl_rule->ipv4_acl_rule.pkt_frwd), (void*)pkt_frwd, sizeof(tpm_pkt_frwd_t));
memcpy(&(tpm_add_acl_rule->ipv4_acl_rule.pkt_mod), (void*)pkt_mod, sizeof(tpm_pkt_mod_t));
memcpy(&(tpm_add_acl_rule->ipv4_acl_rule.rule_action), (void*)rule_action, sizeof(tpm_rule_action_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv4_rule tpm_add_ipv4_rule_bounce
#else
#define _tpm_add_ipv4_rule tpm_add_ipv4_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_ipv4_rule_add
*
* DESCRIPTION:
* This function creates a IPV4 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_ipv4_rule_add (const char *buf, size_t len)
{
typedef enum
{
ipv4ruleadd_owner=0, ipv4ruleadd_srcport, ipv4ruleadd_rulenum, ipv4ruleadd_parserulebm, ipv4ruleadd_parseflagsbm,
ipv4ruleadd_action, ipv4ruleadd_nextphase, ipv4ruleadd_frwdname, ipv4ruleadd_ipv4keyname, ipv4ruleadd_modbm,
ipv4ruleadd_modname, ipv4ruleadd_max
} ipv4ruleadd_parm_indx_t;
// shell line parsing
unsigned int ownerid;
char srcport_str[20];
char uc_srcport_str[20];
int indx;
uint32_t src_port;
uint32_t rulenum;
uint32_t parserulebm;
uint32_t parseflagsbm;
uint32_t action;
uint32_t nextphase;
char nextphase_str[20];
uint32_t modbm;
char ipv4keyname[20];
char frwdname[20];
char modname[20];
int parsedargs;
int numparms;
// DB
tpmcfg_ipv4_key_entry_t *pdbipv4keyentry = 0;
tpmcfg_frwd_entry_t *pdbfrwdentry = 0;
tpmcfg_mod_entry_t *pdbmodentry = 0;
// Used in API call
tpm_rule_action_t rule_action;
tpm_pkt_frwd_t pkt_frwd;
tpm_pkt_mod_t pkt_mod;
tpm_ipv4_acl_key_t ipv4_acl;
uint32_t rule_idx;
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != ipv4ruleadd_max)
{
parm_error_completion(numparms, ipv4ruleadd_max, buf, sfs_help_ipv4_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %s %d 0x%x 0x%x 0x%x %s 0x%x %s %s %s", &ownerid, srcport_str, &rulenum, &parserulebm, &parseflagsbm,
&action, nextphase_str, &modbm, ipv4keyname, frwdname, modname);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rulenum[%d], parserulebm[0x%x], parseflagsbm[0x%x], action[0x%x], nextphase_str[%s], modbm[0x%x], ipv4keyname[%s], frwdname[%s], modname[%s]\n",
// len, parsedargs, ownerid, srcport_str, rulenum, parserulebm, parseflagsbm, action, nextphase_str, modbm, ipv4keyname, frwdname, modname);
// Minimal help for src_port upper/lower case support
for (indx = 0; indx < strlen(srcport_str); indx++) uc_srcport_str[indx] = (char)toupper(srcport_str[indx]);
uc_srcport_str[strlen(srcport_str)] = 0;
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_srcport_value(uc_srcport_str, &src_port) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_port[%s]\n", srcport_str);
}
else if (get_phase_value(nextphase_str, &nextphase) == GT_FALSE)
{
printk(KERN_INFO "Invalid next_phase[%s]\n", nextphase_str);
}
else if (((pdbipv4keyentry = find_tpm_ipv4_key_entry_by_name(ipv4keyname)) == 0) && strcmp(ipv4keyname, ipv4_key_empty_name) != 0)
{
printk(KERN_INFO "IPV4 key entry [%s] not found\n", ipv4keyname);
}
else if (((pdbfrwdentry = find_tpm_pkt_frwd_entry_by_name(frwdname)) == 0) && strcmp(frwdname, frwd_empty_name) != 0)
{
printk(KERN_INFO "frwd entry [%s] not found\n", frwdname);
}
else if (((pdbmodentry = find_tpm_mod_entry_by_name(modname)) == 0) && strcmp(modname, mod_empty_name) != 0)
{
printk(KERN_INFO "mod entry [%s] not found\n", modname);
}
else
{
rule_action.next_phase = nextphase;
rule_action.pkt_act = action;
if (pdbipv4keyentry != 0) memcpy(&ipv4_acl, &pdbipv4keyentry->ipv4_acl, sizeof(tpm_ipv4_acl_key_t));
else memset(&ipv4_acl, 0, sizeof(tpm_ipv4_acl_key_t));
if (pdbfrwdentry != 0) memcpy(&pkt_frwd, &pdbfrwdentry->frwd, sizeof(tpm_pkt_frwd_t));
else memset(&pkt_frwd, 0, sizeof(tpm_pkt_frwd_t));
if (pdbmodentry != 0) memcpy(&pkt_mod, &pdbmodentry->mod, sizeof(tpm_pkt_mod_t));
else memset(&pkt_mod, 0, sizeof(tpm_pkt_mod_t));
if ((rc = _tpm_add_ipv4_rule(ownerid,
src_port,
rulenum,
&rule_idx,
parserulebm,
parseflagsbm,
&ipv4_acl,
&pkt_frwd,
&pkt_mod,
modbm,
&rule_action)) == TPM_RC_OK)
PR_RULE_IDX(rule_idx)
else
{
printk(KERN_INFO "%s: tpm_add_ipv4_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv4_mc_stream_bounce(uint32_t owner_id,
uint32_t stream_num,
tpm_mc_igmp_mode_t igmp_mode,
uint8_t mc_stream_pppoe,
uint16_t vid,
uint8_t ipv4_src_add[4],
uint8_t ipv4_dst_add[4],
uint8_t ignore_ipv4_src,
tpm_trg_port_type_t dest_port_bm)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_ADD_IPv4_MC_STREAM;
tpm_mc_rule->stream_num = stream_num;
tpm_mc_rule->igmp_mode = igmp_mode;
tpm_mc_rule->mc_stream_pppoe = mc_stream_pppoe;
tpm_mc_rule->vid = vid;
tpm_mc_rule->ipv4_mc.ignore_ipv4_src = ignore_ipv4_src;
tpm_mc_rule->dest_port_bm = dest_port_bm;
memcpy(&(tpm_mc_rule->ipv4_mc.ipv4_src_add[0]), ipv4_src_add, sizeof(uint8_t)*4);
memcpy(&(tpm_mc_rule->ipv4_mc.ipv4_dst_add[0]), ipv4_dst_add, sizeof(uint8_t)*4);
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv4_mc_stream tpm_add_ipv4_mc_stream_bounce
#else
#define _tpm_add_ipv4_mc_stream tpm_add_ipv4_mc_stream
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_mc_ipv4_stream_add
*
* DESCRIPTION:
* This function creates a multicast IPV4 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_mc_ipv4_stream_add (const char *buf, size_t len)
{
typedef enum
{
mcipv4add_owner=0, mcipv4add_stream, mcipv4add_mode, mcipv4add_pppoe, mcipv4add_vid,
mcipv4add_src_ip, mcipv4add_dst_ip, mcipv4add_ignore, mcipv4add_target_ports, mcipv4add_max
} mcipv4add_parm_indx_t;
// shell line parsing
unsigned int ownerid;
uint32_t stream;
uint32_t mode;
char mc_pppoe_str[20];
uint32_t mc_stream_pppoe;
uint32_t vid;
char srcip_str[30];
char dstip_str[30];
uint32_t temp_srcip[4];
uint32_t temp_dstip[4];
uint8_t srcip[4];
uint8_t dstip[4];
char ignore_str[20];
uint32_t ignore;
uint32_t target_ports;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mcipv4add_max)
{
parm_error_completion(numparms, mcipv4add_max, buf, sfs_help_mc_ipvx_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %s %d %s %s %s 0x%x",
&ownerid, &stream, &mode, mc_pppoe_str, &vid, srcip_str, dstip_str, ignore_str, &target_ports);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d], vid[%d], srcip_str[%s], dstip_str[%s], ignore_str[%s], target_ports[0x%x]\n",
// len, parsedargs, ownerid, stream, vid, srcip_str, dstip_str, ignore_str, target_ports);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_bool_value(mc_pppoe_str, &mc_stream_pppoe) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else if (parse_ipv4_address(srcip_str, temp_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_ip [%s]\n", srcip_str);
}
else if (parse_ipv4_address(dstip_str, temp_dstip) == GT_FALSE)
{
printk(KERN_INFO "Invalid dst_ip [%s]\n", dstip_str);
}
else if (get_bool_value(ignore_str, &ignore) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else
{
int indx;
for (indx = 0; indx < sizeof(srcip); indx++)
{
srcip[indx] = (uint8_t)temp_srcip[indx];
dstip[indx] = (uint8_t)temp_dstip[indx];
}
if ((rc = _tpm_add_ipv4_mc_stream(ownerid,
stream,
mode,
(uint8_t)mc_stream_pppoe,
vid,
srcip,
dstip,
(uint8_t)ignore,
target_ports)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_add_ipv4_mc_stream failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv4_mc_stream_set_queue_bounce(
uint32_t owner_id,
uint32_t stream_num,
tpm_mc_igmp_mode_t igmp_mode,
uint8_t mc_stream_pppoe,
uint16_t vid,
uint8_t ipv4_src_add[4],
uint8_t ipv4_dst_add[4],
uint8_t ignore_ipv4_src,
uint16_t dest_queue,
tpm_trg_port_type_t dest_port_bm)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_ADD_IPv4_MC_STREAM_SET_QUEUE;
tpm_mc_rule->stream_num = stream_num;
tpm_mc_rule->igmp_mode = igmp_mode;
tpm_mc_rule->mc_stream_pppoe = mc_stream_pppoe;
tpm_mc_rule->vid = vid;
tpm_mc_rule->ipv4_mc.ignore_ipv4_src = ignore_ipv4_src;
tpm_mc_rule->dest_queue = dest_queue;
tpm_mc_rule->dest_port_bm = dest_port_bm;
memcpy(&(tpm_mc_rule->ipv4_mc.ipv4_src_add[0]), ipv4_src_add, sizeof(uint8_t)*4);
memcpy(&(tpm_mc_rule->ipv4_mc.ipv4_dst_add[0]), ipv4_dst_add, sizeof(uint8_t)*4);
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv4_mc_stream_set_queue tpm_add_ipv4_mc_stream_set_queue_bounce
#else
#define _tpm_add_ipv4_mc_stream_set_queue tpm_add_ipv4_mc_stream_set_queue
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_mc_ipv4_stream_set_queue_add
*
* DESCRIPTION:
* This function creates a multicast IPV4 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_mc_ipv4_stream_set_queue_add (const char *buf, size_t len)
{
typedef enum
{
mcipv4add_owner=0, mcipv4add_stream, mcipv4add_mode, mcipv4add_pppoe, mcipv4add_vid,
mcipv4add_src_ip, mcipv4add_dst_ip, mcipv4add_ignore, mcipv4add_target_ports, mcipv4add_target_queue,
mcipv4add_max
} mcipv4add_parm_indx_t;
// shell line parsing
unsigned int ownerid;
uint32_t stream;
uint32_t mode;
char mc_pppoe_str[20];
uint32_t mc_stream_pppoe;
uint32_t vid;
char srcip_str[30];
char dstip_str[30];
uint32_t temp_srcip[4];
uint32_t temp_dstip[4];
uint8_t srcip[4];
uint8_t dstip[4];
char ignore_str[20];
uint32_t ignore;
uint32_t target_queue;
uint32_t target_ports;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mcipv4add_max)
{
parm_error_completion(numparms, mcipv4add_max, buf, sfs_help_mc_ipvx_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %s %d %s %s %s %d 0x%x",
&ownerid, &stream, &mode, mc_pppoe_str, &vid, srcip_str, dstip_str, ignore_str, &target_queue, &target_ports);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d], vid[%d], srcip_str[%s], dstip_str[%s], ignore_str[%s], target_ports[0x%x]\n",
// len, parsedargs, ownerid, stream, vid, srcip_str, dstip_str, ignore_str, target_ports);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_bool_value(mc_pppoe_str, &mc_stream_pppoe) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else if (parse_ipv4_address(srcip_str, temp_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_ip [%s]\n", srcip_str);
}
else if (parse_ipv4_address(dstip_str, temp_dstip) == GT_FALSE)
{
printk(KERN_INFO "Invalid dst_ip [%s]\n", dstip_str);
}
else if (get_bool_value(ignore_str, &ignore) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else
{
int indx;
for (indx = 0; indx < sizeof(srcip); indx++)
{
srcip[indx] = (uint8_t)temp_srcip[indx];
dstip[indx] = (uint8_t)temp_dstip[indx];
}
if ((rc = _tpm_add_ipv4_mc_stream_set_queue(ownerid,
stream,
mode,
(uint8_t)mc_stream_pppoe,
vid,
srcip,
dstip,
(uint8_t)ignore,
target_queue,
target_ports)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_add_ipv4_mc_stream_set_queue failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv6_mc_stream_set_queue_bounce(uint32_t owner_id,
uint32_t stream_num,
tpm_mc_igmp_mode_t igmp_mode,
uint8_t mc_stream_pppoe,
uint16_t vid,
uint8_t ipv6_src_add[16],
uint8_t ipv6_dst_add[16],
uint8_t ignore_ipv6_src,
uint16_t dest_queue,
tpm_trg_port_type_t dest_port_bm)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_ADD_IPv6_MC_STREAM_SET_QUEUE;
tpm_mc_rule->stream_num = stream_num;
tpm_mc_rule->igmp_mode = igmp_mode;
tpm_mc_rule->mc_stream_pppoe = mc_stream_pppoe;
tpm_mc_rule->vid = vid;
tpm_mc_rule->dest_port_bm = dest_port_bm;
tpm_mc_rule->dest_queue = dest_queue;
memcpy(&(tpm_mc_rule->ipv6_mc.ipv6_dst_add[0]), ipv6_dst_add, sizeof(uint8_t) * 16);
memcpy(&(tpm_mc_rule->ipv6_mc.ipv6_src_add[0]), ipv6_src_add, sizeof(uint8_t) * 16);
tpm_mc_rule->ipv6_mc.ignore_ipv6_src = ignore_ipv6_src;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv6_mc_stream_set_queue tpm_add_ipv6_mc_stream_set_queue_bounce
#else
#define _tpm_add_ipv6_mc_stream_set_queue tpm_add_ipv6_mc_stream_set_queue
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_mc_ipv6_stream_add_set_queue
*
* DESCRIPTION:
* This function creates a multicast ipv6 rule with destination queue
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_mc_ipv6_stream_set_queue_add (const char *buf, size_t len)
{
typedef enum
{
mcipv6add_owner=0, mcipv6add_stream, mcipv6add_mode, mcipv6add_pppoe, mcipv6add_vid,
mcipv6add_src_ip, mcipv6add_dst_ip, mcipv6add_ignor_src_ip, mcipv6add_target_queue, mcipv6add_target_ports, mcipv6add_max
} mcipv6add_parm_indx_t;
// shell line parsing
unsigned int ownerid;
uint32_t stream;
uint32_t mode;
char mc_pppoe_str[20];
uint32_t mc_stream_pppoe;
uint32_t vid;
char dstip_str[60];
uint32_t temp_dstip[16];
char srcip_str[60];
uint32_t temp_srcip[16];
uint8_t dstip[16];
uint8_t srcip[16];
uint32_t ignor_srcip;
char ignore_str[20];
uint32_t target_ports;
uint32_t target_queue;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mcipv6add_max)
{
parm_error_completion(numparms, mcipv6add_max, buf, sfs_help_mc_ipvx_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %s %d %s %s %s %d 0x%x",
&ownerid, &stream, &mode, mc_pppoe_str, &vid, srcip_str, dstip_str, ignore_str, &target_queue, &target_ports);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d], vid[%d], srcip_str[%s], "
"dstip_str[%s], ignor_srcip[%s], target_queue[%d], target_ports[0x%x]\n",
len, parsedargs, ownerid, stream, vid, srcip_str, dstip_str, ignore_str, target_queue, target_ports);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_bool_value(mc_pppoe_str, &mc_stream_pppoe) == GT_FALSE)
{
printk(KERN_INFO "Invalid mc_pppoe_str[%s]\n", mc_pppoe_str);
}
else if (parse_ipv6_address(dstip_str, temp_dstip) == GT_FALSE)
{
printk(KERN_INFO "Invalid dst_ip [%s]\n", dstip_str);
}
else if (parse_ipv6_address(srcip_str, temp_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid srcip_str [%s]\n", srcip_str);
}
else if (get_bool_value(ignore_str, &ignor_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else
{
int indx;
for (indx = 0; indx < sizeof(dstip); indx++)
{
dstip[indx] = (uint8_t)temp_dstip[indx];
srcip[indx] = (uint8_t)temp_srcip[indx];
}
if ((rc = _tpm_add_ipv6_mc_stream_set_queue(ownerid,
stream,
mode,
(uint8_t)mc_stream_pppoe,
vid,
srcip,
dstip,
ignor_srcip,
target_queue,
target_ports)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_add_ipv6_mc_stream_set_queue failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv6_mc_stream_bounce(uint32_t owner_id,
uint32_t stream_num,
tpm_mc_igmp_mode_t igmp_mode,
uint8_t mc_stream_pppoe,
uint16_t vid,
uint8_t ipv6_src_add[16],
uint8_t ipv6_dst_add[16],
uint8_t ignore_ipv6_src,
tpm_trg_port_type_t dest_port_bm)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_ADD_IPv6_MC_STREAM;
tpm_mc_rule->stream_num = stream_num;
tpm_mc_rule->igmp_mode = igmp_mode;
tpm_mc_rule->mc_stream_pppoe = mc_stream_pppoe;
tpm_mc_rule->vid = vid;
tpm_mc_rule->dest_port_bm = dest_port_bm;
memcpy(&(tpm_mc_rule->ipv6_mc.ipv6_dst_add[0]), ipv6_dst_add, sizeof(uint8_t) * 16);
memcpy(&(tpm_mc_rule->ipv6_mc.ipv6_src_add[0]), ipv6_src_add, sizeof(uint8_t) * 16);
tpm_mc_rule->ipv6_mc.ignore_ipv6_src = ignore_ipv6_src;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv6_mc_stream tpm_add_ipv6_mc_stream_bounce
#else
#define _tpm_add_ipv6_mc_stream tpm_add_ipv6_mc_stream
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_mc_ipv6_stream_add
*
* DESCRIPTION:
* This function creates a multicast ipv6 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_mc_ipv6_stream_add (const char *buf, size_t len)
{
typedef enum
{
mcipv6add_owner=0, mcipv6add_stream, mcipv6add_mode, mcipv6add_pppoe, mcipv6add_vid,
mcipv6add_src_ip, mcipv6add_dst_ip, mcipv6add_ignor_src_ip, mcipv6add_target_ports, mcipv6add_max
} mcipv6add_parm_indx_t;
// shell line parsing
unsigned int ownerid;
uint32_t stream;
uint32_t mode;
char mc_pppoe_str[20];
uint32_t mc_stream_pppoe;
uint32_t vid;
char dstip_str[60];
uint32_t temp_dstip[16];
char srcip_str[60];
uint32_t temp_srcip[16];
uint8_t dstip[16];
uint8_t srcip[16];
uint32_t ignor_srcip;
char ignore_str[20];
uint32_t target_ports;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mcipv6add_max)
{
parm_error_completion(numparms, mcipv6add_max, buf, sfs_help_mc_ipvx_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %s %d %s %s %s 0x%x",
&ownerid, &stream, &mode, mc_pppoe_str, &vid, srcip_str, dstip_str, ignore_str, &target_ports);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d], vid[%d], srcip_str[%s], "
"dstip_str[%s], ignor_srcip[%s], target_ports[0x%x]\n",
len, parsedargs, ownerid, stream, vid, srcip_str, dstip_str, ignore_str, target_ports);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_bool_value(mc_pppoe_str, &mc_stream_pppoe) == GT_FALSE)
{
printk(KERN_INFO "Invalid mc_pppoe_str[%s]\n", mc_pppoe_str);
}
else if (parse_ipv6_address(dstip_str, temp_dstip) == GT_FALSE)
{
printk(KERN_INFO "Invalid dst_ip [%s]\n", dstip_str);
}
else if (parse_ipv6_address(srcip_str, temp_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid srcip_str [%s]\n", srcip_str);
}
else if (get_bool_value(ignore_str, &ignor_srcip) == GT_FALSE)
{
printk(KERN_INFO "Invalid ignore[%s]\n", ignore_str);
}
else
{
int indx;
for (indx = 0; indx < sizeof(dstip); indx++)
{
dstip[indx] = (uint8_t)temp_dstip[indx];
srcip[indx] = (uint8_t)temp_srcip[indx];
}
if ((rc = _tpm_add_ipv6_mc_stream(ownerid,
stream,
mode,
(uint8_t)mc_stream_pppoe,
vid,
srcip,
dstip,
ignor_srcip,
target_ports)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_add_ipv6_mc_stream failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_set_port_igmp_frwd_mode_bounce(tpm_src_port_type_t src_port,
tpm_igmp_frwd_mode_t mode)
{
tpm_ioctl_igmp_t *tpm_igmp = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_igmp;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_IGMP_SECTION;
tpm_igmp->igmp_cmd = MV_TPM_IOCTL_IGMP_SET_PORT_FRWD_MODE;
tpm_igmp->src_port = src_port;
tpm_igmp->frwd_mode = mode;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_set_port_igmp_frwd_mode tpm_set_port_igmp_frwd_mode_bounce
#else
#define _tpm_set_port_igmp_frwd_mode tpm_set_port_igmp_frwd_mode
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_igmp_port_forward_mode_cfg
*
* DESCRIPTION:
* This function creates a multicast IPV4 rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_igmp_port_forward_mode_cfg (const char *buf, size_t len)
{
typedef enum
{
igmpfrwd_owner=0, igmpfrwd_src_port, igmpfrwd_mode, igmpfrwd_max
} igmpfrwd_parm_indx_t;
// shell line parsing
unsigned int ownerid; // NOTE: not used in API!!
char srcport_str[30];
char uc_srcport_str[30];
int indx;
uint32_t src_port;
char mode_str[30];
uint32_t mode;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != igmpfrwd_max)
{
parm_error_completion(numparms, igmpfrwd_max, buf, sfs_help_igmp_cfg);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %s %s", &ownerid, srcport_str, mode_str);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], mode_str[%s]\n",
// len, parsedargs, ownerid, srcport_str, mode_str);
// Minimal help for src_port upper/lower case support
for (indx = 0; indx < strlen(srcport_str); indx++) uc_srcport_str[indx] = (char)toupper(srcport_str[indx]);
uc_srcport_str[strlen(srcport_str)] = 0;
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_igmp_srcport_value(uc_srcport_str, &src_port) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_port [%s]\n", srcport_str);
}
else if (get_igmp_mode_value(mode_str, &mode) == GT_FALSE)
{
printk(KERN_INFO "Invalid mode [%s]\n", mode_str);
}
else
{
if ((rc = _tpm_set_port_igmp_frwd_mode(src_port,
mode)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_set_port_igmp_frwd_mode failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_set_igmp_cpu_rx_queue_bounce(uint32_t queue)
{
tpm_ioctl_igmp_t *tpm_igmp = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_igmp;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_IGMP_SECTION;
tpm_igmp->igmp_cmd = MV_TPM_IOCTL_IGMP_SET_CPU_RX_Q;
tpm_igmp->cpu_queue = queue;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_set_igmp_cpu_rx_queue tpm_set_igmp_cpu_rx_queue_bounce
#else
#define _tpm_set_igmp_cpu_rx_queue tpm_set_igmp_cpu_rx_queue
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_igmp_cpu_queue_cfg
*
* DESCRIPTION:
* This function configres the CPU queue for IGMP
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_igmp_cpu_queue_cfg (const char *buf, size_t len)
{
typedef enum
{
igmpcpuq_owner=0, igmpcpuq_queue, igmpcpuq_max
} igmpcpuq_parm_indx_t;
// shell line parsing
unsigned int ownerid; // NOTE: not used in API!!
uint32_t que;
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != igmpcpuq_max)
{
parm_error_completion(numparms, igmpcpuq_max, buf, sfs_help_igmp_cfg);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &que);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], que[%d]\n",
// len, parsedargs, ownerid, que);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (que >= TPM_MAX_NUM_RX_QUEUE) // Hope this a good choice
{
printk(KERN_INFO "Invalid queue [%d]\n", que);
}
else
{
if ((rc = _tpm_set_igmp_cpu_rx_queue(que)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_set_igmp_cpu_rx_queue failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_set_igmp_proxy_sa_mac_bounce(uint8_t *sa_mac)
{
tpm_ioctl_igmp_t *tpm_igmp_set_sa_mac = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_igmp;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_IGMP_SECTION;
tpm_igmp_set_sa_mac->igmp_cmd = MV_TPM_IOCTL_SET_IGMP_PROXY_SA_MAC;
memcpy(tpm_igmp_set_sa_mac->sa_mac, (void *)sa_mac, 6);
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_set_igmp_proxy_sa_mac tpm_set_igmp_proxy_sa_mac_bounce
#else
#define _tpm_set_igmp_proxy_sa_mac tpm_set_igmp_proxy_sa_mac
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_igmp_proxy_sa_mac
*
* DESCRIPTION:
* This function configures the sa_mac for IGMP proxy
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_igmp_proxy_sa_mac (const char *buf, size_t len)
{
typedef enum
{
igmpproxysa_owner=0, igmpproxysa_mac, igmpproxysa_max
} igmpproxysa_parm_indx_t;
// shell line parsing
unsigned int ownerid, i;
uint8_t mac[6];
uint32_t temp_mac[6];
int parsedargs;
int numparms;
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != igmpproxysa_max)
{
parm_error_completion(numparms, igmpproxysa_max, buf, sfs_help_igmp_cfg);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %02x:%02x:%02x:%02x:%02x:%02x",
&ownerid, &temp_mac[0], &temp_mac[1], &temp_mac[2], &temp_mac[3], &temp_mac[4], &temp_mac[5]);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], sa_mac[%02x:%02x:%02x:%02x:%02x:%02x]\n",
// len, parsedargs, ownerid, temp_mac[0], temp_mac[1], temp_mac[2], temp_mac[3], temp_mac[4], temp_mac[5]);
if (parsedargs != 7)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, 7);
}
else
{
for (i=0;i<6;i++)
{
mac[i] = temp_mac[i];
}
if ((rc = _tpm_set_igmp_proxy_sa_mac (mac)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_set_igmp_proxy_sa_mac failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_l2_rule_bounce(uint32_t owner_id,
uint32_t rule_idx)
{
tpm_ioctl_del_acl_rule_t *tpm_del_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_del_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_DEL_ACL_SECTION;
tpm_del_acl_rule->del_acl_cmd = MV_TPM_IOCTL_DEL_L2_ACL_RULE;
tpm_del_acl_rule->owner_id = owner_id;
tpm_del_acl_rule->rule_idx = rule_idx;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_l2_rule tpm_del_l2_rule_bounce
#else
#define _tpm_del_l2_rule tpm_del_l2_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_rule_add_l2
*
* DESCRIPTION:
* This function deletes a L2 HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_rule_add_l2 (const char *buf, size_t len)
{
typedef enum
{
noruleaddl2_owner=0, noruleaddl2_ruleidx, noruleaddl2_max
} noruleaddl2_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t rule_idx;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != noruleaddl2_max)
{
parm_error_completion(numparms, noruleaddl2_max, buf, sfs_help_no_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &rule_idx);
//printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], rule_idx[%d]\n",
// len, parsedargs, ownerid, rule_idx);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_del_l2_rule(ownerid,
rule_idx)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_del_l2_prim_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_l3_type_rule_bounce(uint32_t owner_id,
uint32_t rule_idx)
{
tpm_ioctl_del_acl_rule_t *tpm_del_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_del_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_DEL_ACL_SECTION;
tpm_del_acl_rule->del_acl_cmd = MV_TPM_IOCTL_DEL_L3_ACL_RULE;
tpm_del_acl_rule->owner_id = owner_id;
tpm_del_acl_rule->rule_idx = rule_idx;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_l3_type_rule tpm_del_l3_type_rule_bounce
#else
#define _tpm_del_l3_type_rule tpm_del_l3_type_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_rule_add_l3
*
* DESCRIPTION:
* This function deletes a L3 HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_rule_add_l3 (const char *buf, size_t len)
{
typedef enum
{
noruleaddl3_owner=0, noruleaddl3_ruleidx, noruleaddl3_max
} noruleaddl3_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t rule_idx;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != noruleaddl3_max)
{
parm_error_completion(numparms, noruleaddl3_max, buf, sfs_help_no_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &rule_idx);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rule_idx[%d], parserulebm[0x%x], keyname[%s]\n",
// len, parsedargs, ownerid, srcport_str, rule_idx, parserulebm, keyname);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_del_l3_type_rule(ownerid,
rule_idx)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_del_l3_type_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_ipv4_rule_bounce(uint32_t owner_id,
uint32_t rule_idx)
{
tpm_ioctl_del_acl_rule_t *tpm_del_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_del_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_DEL_ACL_SECTION;
tpm_del_acl_rule->del_acl_cmd = MV_TPM_IOCTL_DEL_IPv4_ACL_RULE;
tpm_del_acl_rule->owner_id = owner_id;
tpm_del_acl_rule->rule_idx = rule_idx;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_ipv4_rule tpm_del_ipv4_rule_bounce
#else
#define _tpm_del_ipv4_rule tpm_del_ipv4_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_rule_add_ipv4
*
* DESCRIPTION:
* This function deletes a IPV4 HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_rule_add_ipv4 (const char *buf, size_t len)
{
typedef enum
{
noruleaddipv4_owner=0, noruleaddipv4_ruleidx, noruleaddipv4_max
} noruleaddipv4_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t rule_idx;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != noruleaddipv4_max)
{
parm_error_completion(numparms, noruleaddipv4_max, buf, sfs_help_no_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d",
&ownerid, &rule_idx);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rule_idx[%d], parserulebm[0x%x], keyname[%s]\n",
// len, parsedargs, ownerid, srcport_str, rule_idx, parserulebm, keyname);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_del_ipv4_rule(ownerid,
rule_idx)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_del_ipv4_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_ipv4_mc_stream_bounce(uint32_t owner_id,
uint32_t stream_num)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_DEL_IPv4_MC_STREAM;
tpm_mc_rule->owner_id = owner_id;
tpm_mc_rule->stream_num = stream_num;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_ipv4_mc_stream tpm_del_ipv4_mc_stream_bounce
#else
#define _tpm_del_ipv4_mc_stream tpm_del_ipv4_mc_stream
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_mc_stream_add_ipv4
*
* DESCRIPTION:
* This function deletes a DSCP IPV6 HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_mc_stream_add_ipv4 (const char *buf, size_t len)
{
typedef enum
{
nostreamaddipv4_owner=0, nostreamaddipv4_ruleidx, nostreamaddipv4_max
} nostreamaddipv4_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t stream;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != nostreamaddipv4_max)
{
parm_error_completion(numparms, nostreamaddipv4_max, buf, sfs_help_no_mc_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &stream);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d]\n", len, parsedargs, ownerid, stream);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if ((rc = _tpm_del_ipv4_mc_stream(ownerid,
stream)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_del_ipv4_mc_stream failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_ipv6_mc_stream_bounce(uint32_t owner_id,
uint32_t stream_num)
{
tpm_ioctl_mc_rule_t *tpm_mc_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mc_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MC_STREAM_SECTION;
tpm_mc_rule->mc_cmd = MV_TPM_IOCTL_DEL_IPv6_MC_STREAM;
tpm_mc_rule->owner_id = owner_id;
tpm_mc_rule->stream_num = stream_num;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_ipv6_mc_stream tpm_del_ipv6_mc_stream_bounce
#else
#define _tpm_del_ipv6_mc_stream tpm_del_ipv6_mc_stream
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_mc_stream_add_ipv6
*
* DESCRIPTION:
* This function deletes a DSCP IPV6 HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_mc_stream_add_ipv6 (const char *buf, size_t len)
{
typedef enum
{
nostreamaddipv6_owner=0, nostreamaddipv6_ruleidx, nostreamaddipv6_max
} nostreamaddipv6_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t stream;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != nostreamaddipv6_max)
{
parm_error_completion(numparms, nostreamaddipv6_max, buf, sfs_help_no_mc_stream_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &stream);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], stream[%d]\n", len, parsedargs, ownerid, stream);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if ((rc = _tpm_del_ipv6_mc_stream(ownerid,
stream)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_del_ipv6_mc_stream failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_proc_set_enable_mtu_bounce(tpm_init_mtu_setting_enable_t enable)
{
tpm_ioctl_mtu_t *tpm_mtu_set = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_ioctl_mtu_set;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MTU_SECTION;
tpm_mtu_set->mtu_setting_cmd = MV_TPM_IOCTL_SET_MTU_ADMIN;
tpm_mtu_set->enable = enable;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_proc_set_enable_mtu tpm_proc_set_enable_mtu_bounce
#else
#define _tpm_proc_set_enable_mtu tpm_db_set_mtu_enable
#endif
void sfs_tpm_cfg_set_mtu_enable (const char *buf, size_t len)
{
typedef enum
{
mtu_enable=0, mtu_enable_max
} mtu_enable_indx_t;
/*shell line parsing*/
int enable;
int parsedargs;
int numparms;
/*used in API call*/
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mtu_enable_max)
parm_error_completion(numparms, mtu_enable_max, buf, sfs_help_setup);
else {
/*get parameters*/
parsedargs = sscanf(buf, "%d", &enable);
if (parsedargs != numparms)
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
else if ((enable != 1) && (enable != 0))
printk(KERN_INFO "Invalid enable[%d]\n", enable);
else {
if ((rc = _tpm_proc_set_enable_mtu(enable)) == TPM_RC_OK)
printk(KERN_INFO "OK\n");
else
printk(KERN_INFO "%s: tpm_proc_set_enable_mtu failed, rc[%d] - %s\n",
__FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_proc_set_mtu_bounce(uint32_t ipv4_or_ipv6,
uint32_t direction,
uint32_t mtu)
{
tpm_ioctl_mtu_t *tpm_mtu_set = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_ioctl_mtu_set;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MTU_SECTION;
tpm_mtu_set->mtu_setting_cmd = MV_TPM_IOCTL_SET_MTU;
tpm_mtu_set->ethertype = ipv4_or_ipv6;
tpm_mtu_set->direction = direction;
tpm_mtu_set->mtu = mtu;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_proc_set_mtu tpm_proc_set_mtu_bounce
#else
#define _tpm_proc_set_mtu tpm_proc_set_mtu
#endif
void sfs_tpm_cfg_set_mtu (const char *buf, size_t len)
{
typedef enum
{
mtu_ipv4_or_ipv6=0, mtu_direction, mtu_value, mtu_max
} mtu_indx_t;
// shell line parsing
uint32_t ipv4_or_ipv6;
uint32_t direction;
uint32_t mtu;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
tpm_setup_t setup;
memset(&setup, 0, sizeof(tpm_setup_t));
numparms = count_parameters(buf);
if (numparms != mtu_max)
{
parm_error_completion(numparms, mtu_max, buf, sfs_help_setup);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d", &ipv4_or_ipv6, &direction, &mtu);
printk(KERN_INFO "ipv4_or_ipv6=%d, direction=%d. mtu[%d],\n", ipv4_or_ipv6, direction, mtu);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (ipv4_or_ipv6 >= 2)
{
printk(KERN_INFO "Invalid ipv4_or_ipv6[%d]\n", ipv4_or_ipv6);
}
else if (direction >= 2)
{
printk(KERN_INFO "Invalid direction[%d]\n", direction);
}
else
{
if ((rc = _tpm_proc_set_mtu(ipv4_or_ipv6, direction, mtu)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_proc_set_mtu failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_proc_set_pppoe_mtu_bounce(uint32_t ipv4_or_ipv6,
uint32_t direction,
uint32_t pppoe_mtu)
{
tpm_ioctl_mtu_t *tpm_mtu_set = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_ioctl_mtu_set;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MTU_SECTION;
tpm_mtu_set->mtu_setting_cmd = MV_TPM_IOCTL_SET_PPPOE_MTU;
tpm_mtu_set->ethertype = ipv4_or_ipv6;
tpm_mtu_set->direction = direction;
tpm_mtu_set->pppoe_mtu= pppoe_mtu;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_proc_set_pppoe_mtu tpm_proc_set_pppoe_mtu_bounce
#else
#define _tpm_proc_set_pppoe_mtu tpm_proc_set_pppoe_mtu
#endif
void sfs_tpm_cfg_set_pppoe_mtu (const char *buf, size_t len)
{
typedef enum
{
pppoe_mtu_ipv4_or_ipv6=0, pppoe_mtu_direction, pppoe_mtu_value, pppoe_mtu_max
} pppoe_mtu_indx_t;
// shell line parsing
uint32_t ipv4_or_ipv6;
uint32_t direction;
uint32_t pppoe_mtu;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
tpm_setup_t setup;
memset(&setup, 0, sizeof(tpm_setup_t));
numparms = count_parameters(buf);
if (numparms != pppoe_mtu_max)
{
parm_error_completion(numparms, pppoe_mtu_max, buf, sfs_help_setup);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d", &ipv4_or_ipv6, &direction, &pppoe_mtu);
printk(KERN_INFO "ipv4_or_ipv6=%d, direction=%d. pppoe_mtu[%d],\n", ipv4_or_ipv6, direction, pppoe_mtu);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (ipv4_or_ipv6 >= 2)
{
printk(KERN_INFO "Invalid ipv4_or_ipv6[%d]\n", ipv4_or_ipv6);
}
else if (direction >= 2)
{
printk(KERN_INFO "Invalid direction[%d]\n", direction);
}
else
{
if ((rc = _tpm_proc_set_pppoe_mtu(ipv4_or_ipv6, direction, pppoe_mtu)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_proc_set_pppoe_mtu failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_ipv6_gen_rule_bounce(uint32_t owner_id,
uint32_t rule_idx)
{
tpm_ioctl_del_acl_rule_t *tpm_del_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_del_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_DEL_ACL_SECTION;
tpm_del_acl_rule->del_acl_cmd = MV_TPM_IOCTL_DEL_IPV6_GEN_ACL_RULE;
tpm_del_acl_rule->owner_id = owner_id;
tpm_del_acl_rule->rule_idx = rule_idx;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_ipv6_gen_rule tpm_del_ipv6_gen_rule_bounce
#else
#define _tpm_del_ipv6_gen_rule tpm_del_ipv6_gen_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_rule_add_ipv6_gen_acl
*
* DESCRIPTION:
* This function deletes a IPV6 HW gen ACL rule
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_rule_add_ipv6_gen_acl (const char *buf, size_t len)
{
typedef enum
{
noipv6gen_owner=0, noipv6gen_ruleidx, noipv6gen_max
} noipv6genruleadd_parm_indx_t;
// shell line parsing
unsigned int ownerid;
uint32_t rule_idx;
int parsedargs;
int numparms;
// DB
// Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != noipv6gen_max)
{
parm_error_completion(numparms, noipv6gen_max, buf, sfs_help_no_rule_add);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &rule_idx);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], rule_idx[%d]\n",
len, parsedargs, ownerid, rule_idx);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_del_ipv6_gen_rule(ownerid,
rule_idx)) == TPM_RC_OK)
PR_RESULT
else
{
printk(KERN_INFO "%s: tpm_del_ipv6_gen_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_ipv6_gen_rule_bounce(uint32_t owner_id,
tpm_src_port_type_t src_port,
uint32_t rule_num,
uint32_t *rule_idx,
tpm_parse_fields_t parse_rule_bm,
tpm_parse_flags_t parse_flags_bm,
tpm_ipv6_gen_acl_key_t *ipv6_gen_key,
tpm_pkt_frwd_t *pkt_frwd,
tpm_pkt_mod_t *pkt_mod,
tpm_pkt_mod_bm_t pkt_mod_bm,
tpm_rule_action_t *rule_action)
{
tpm_ioctl_add_acl_rule_t *tpm_add_acl_rule = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_add_acl_rule;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_ADD_ACL_SECTION;
tpm_add_acl_rule->add_acl_cmd = MV_TPM_IOCTL_ADD_IPV6_GEN_ACL_RULE;
tpm_add_acl_rule->owner_id = owner_id;
tpm_add_acl_rule->src_port = src_port;
tpm_add_acl_rule->rule_num = rule_num;
tpm_add_acl_rule->parse_rule_bm = parse_rule_bm;
tpm_add_acl_rule->ipv6_gen_acl_rule.parse_flags_bm = parse_flags_bm;
tpm_add_acl_rule->ipv6_gen_acl_rule.pkt_mod_bm = pkt_mod_bm;
memcpy(&(tpm_add_acl_rule->ipv6_gen_acl_rule.ipv6_gen_key), ipv6_gen_key, sizeof(tpm_ipv6_gen_acl_key_t));
memcpy(&(tpm_add_acl_rule->ipv6_gen_acl_rule.pkt_frwd), pkt_frwd, sizeof(tpm_pkt_frwd_t));
memcpy(&(tpm_add_acl_rule->ipv6_gen_acl_rule.pkt_mod), pkt_mod, sizeof(tpm_pkt_mod_t));
memcpy(&(tpm_add_acl_rule->ipv6_gen_acl_rule.rule_action), rule_action, sizeof(tpm_rule_action_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_ipv6_gen_rule tpm_add_ipv6_gen_rule_bounce
#else
#define _tpm_add_ipv6_gen_rule tpm_add_ipv6_gen_rule
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_ipv6_gen_rule_add
*
* DESCRIPTION:
* This function create IPv6 general rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_ipv6_gen_rule_add (const char *buf, size_t len)
{
typedef enum
{
ipv6ruleadd_owner=0, ipv6ruleadd_srcport, ipv6ruleadd_rulenum, ipv6ruleadd_parserulebm, ipv6ruleadd_parseflagsbm,
ipv6ruleadd_action, ipv6ruleadd_nextphase, ipv6ruleadd_modbm, ipv6ruleadd_ipv6genkeyname, ipv6ruleadd_frwdname,
ipv6ruleadd_modname, ipv6ruleadd_max
} ipv4ruleadd_parm_indx_t;
uint32_t owner_id;
tpm_src_port_type_t src_port;
uint32_t rule_num;
uint32_t rule_idx;
tpm_parse_fields_t parse_rule_bm;
tpm_parse_flags_t parse_flags_bm;
tpm_ipv6_gen_acl_key_t ipv6_gen_key;
tpm_pkt_frwd_t pkt_frwd;
tpm_pkt_mod_t pkt_mod;
tpm_pkt_mod_bm_t pkt_mod_bm;
tpm_rule_action_t rule_action;
tpmcfg_ipv6_gen_key_entry_t *pdbipv6genkeyentry = 0;
tpmcfg_frwd_entry_t *pdbfrwdentry = 0;
tpmcfg_mod_entry_t *pdbmodentry = 0;
tpm_error_code_t rc;
int indx;
int parsedargs;
int numparms;
uint32_t action;
uint32_t nextphase;
char srcport_str[20];
char uc_srcport_str[20];
char nextphase_str[20];
char ipv6genkeyname[30];
char frwdname[20];
char modname[20];
numparms = count_parameters(buf);
if (numparms != ipv6ruleadd_max)
{
parm_error_completion(numparms, ipv6ruleadd_max, buf, sfs_help_ipv6_gen_rule_add);
}
else
{
parsedargs = sscanf(buf, "%d %s %d 0x%x 0x%x 0x%x %s 0x%x %s %s %s",
&owner_id, srcport_str, &rule_num, &parse_rule_bm, &parse_flags_bm,
&action, nextphase_str, &pkt_mod_bm, ipv6genkeyname, frwdname, modname);
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], srcport_str[%s], rulenum[%d], parserulebm[0x%x], parseflagsbm[0x%x], action[0x%x], nextphase_str[%s], modbm[0x%x], ipv6keyname[%s], frwdname[%s], modname[%s]\n",
len, parsedargs, owner_id, srcport_str, rule_num, parse_rule_bm, parse_flags_bm, action, nextphase_str, pkt_mod_bm, ipv6genkeyname, frwdname, modname);
for (indx = 0; indx < strlen(srcport_str); indx++)
{
uc_srcport_str[indx] = (char)toupper(srcport_str[indx]);
}
uc_srcport_str[strlen(srcport_str)] = 0;
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (get_srcport_value(uc_srcport_str, &src_port) == GT_FALSE)
{
printk(KERN_INFO "Invalid src_port[%s]\n", srcport_str);
}
else if (get_phase_value(nextphase_str, &nextphase) == GT_FALSE)
{
printk(KERN_INFO "Invalid next_phase[%s]\n", nextphase_str);
}
else if (((pdbipv6genkeyentry = find_tpm_ipv6_gen_key_entry_by_name(ipv6genkeyname)) == 0) && \
strcmp(ipv6genkeyname, ipv6_gen_key_empty_name) != 0)
{
printk(KERN_INFO "IPV4 key entry [%s] not found\n", ipv6genkeyname);
}
else if (((pdbfrwdentry = find_tpm_pkt_frwd_entry_by_name(frwdname)) == 0) && \
strcmp(frwdname, frwd_empty_name) != 0)
{
printk(KERN_INFO "frwd entry [%s] not found\n", frwdname);
}
else if (((pdbmodentry = find_tpm_mod_entry_by_name(modname)) == 0) && \
strcmp(modname, mod_empty_name) != 0)
{
printk(KERN_INFO "mod entry [%s] not found\n", modname);
}
else
{
rule_action.next_phase = nextphase;
rule_action.pkt_act = action;
if (pdbipv6genkeyentry != 0)
memcpy(&ipv6_gen_key, &pdbipv6genkeyentry->ipv6gen_acl, sizeof(tpm_ipv6_gen_acl_key_t));
else
memset(&ipv6_gen_key, 0, sizeof(tpm_ipv6_gen_acl_key_t));
if (pdbfrwdentry != 0)
memcpy(&pkt_frwd, &pdbfrwdentry->frwd, sizeof(tpm_pkt_frwd_t));
else
memset(&pkt_frwd, 0, sizeof(tpm_pkt_frwd_t));
if (pdbmodentry != 0)
memcpy(&pkt_mod, &pdbmodentry->mod, sizeof(tpm_pkt_mod_t));
else
memset(&pkt_mod, 0, sizeof(tpm_pkt_mod_t));
if (TPM_RC_OK == (rc = _tpm_add_ipv6_gen_rule(owner_id,
src_port,
rule_num,
&rule_idx,
parse_rule_bm,
parse_flags_bm,
&ipv6_gen_key,
&pkt_frwd,
&pkt_mod,
pkt_mod_bm,
&rule_action)) )
PR_RULE_IDX(rule_idx)
else
{
printk(KERN_INFO "%s: tpm_add_ipv6_gen_rule failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_oam_epon_add_channel_bounce(uint32_t owner_id,
uint32_t cpu_rx_queue,
tpm_trg_port_type_t llid_num)
{
tpm_ioctl_mng_ch_t *tpm_oam_epon_chan = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mng_channel;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MNG_SECTION;
tpm_oam_epon_chan->mng_cmd = MV_TPM_IOCTL_ADD_OAM_CHNL;
tpm_oam_epon_chan->tpm_ioctl_oam_ch.owner_id = owner_id;
tpm_oam_epon_chan->tpm_ioctl_oam_ch.cpu_rx_queue = cpu_rx_queue;
tpm_oam_epon_chan->tpm_ioctl_oam_ch.llid_num = llid_num;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_oam_epon_add_channel tpm_oam_epon_add_channel_bounce
#else
#define _tpm_oam_epon_add_channel tpm_oam_epon_add_channel
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_oam_channel
*
* DESCRIPTION:
* This function creates OAM channel HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_oam_channel (const char *buf, size_t len)
{
typedef enum
{
oam_owner=0, oam_rxq, oam_llid, oam_max
} oam_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t rx_q;
uint32_t llid;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != oam_max)
{
parm_error_completion(numparms, oam_max, buf, sfs_help_oam_omci_channel);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d 0x%x", &ownerid, &rx_q, &llid);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], rxq[%d], llid[0x%x]\n", len, parsedargs, ownerid, rx_q, llid);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if ((rc = _tpm_oam_epon_add_channel (ownerid,
rx_q,
llid)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_oam_epon_add_channel failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_omci_add_channel_bounce(uint32_t owner_id,
tpm_gem_port_key_t gem_port,
uint32_t cpu_rx_queue,
tpm_trg_port_type_t tcont_num,
uint32_t cpu_tx_queue)
{
tpm_ioctl_mng_ch_t *tpm_omci_gpon_chan = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mng_channel;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MNG_SECTION;
tpm_omci_gpon_chan->mng_cmd = MV_TPM_IOCTL_ADD_OMCI_CHNL;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.owner_id = owner_id;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.gem_port = gem_port;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.cpu_rx_queue = cpu_rx_queue;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.tcont_num = tcont_num;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.cpu_tx_queue = cpu_tx_queue;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_omci_add_channel tpm_omci_add_channel_bounce
#else
#define _tpm_omci_add_channel tpm_omci_add_channel
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_omci_channel
*
* DESCRIPTION:
* This function creates creates an OMCI channel HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_omci_channel (const char *buf, size_t len)
{
typedef enum
{
omci_owner=0, omci_gemport, omci_rxq, omci_txq, omci_tcont, omci_max
} omci_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t gemport;
uint32_t rx_q;
uint32_t tx_q;
uint32_t tcont;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != omci_max)
{
parm_error_completion(numparms, omci_max, buf, sfs_help_oam_omci_channel);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %d 0x%x", &ownerid, &gemport, &rx_q, &tx_q, &tcont);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], gemport[%d], rx_q[%d], tx_q[%d], tcont[0x%x]\n",
// len, parsedargs, ownerid, gemport, rx_q, tx_q, tcont);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (gemport >= 255)
{
printk(KERN_INFO "invalid gemport[%d]\n", gemport);
}
else
{
if ((rc = _tpm_omci_add_channel (ownerid,
(uint16_t)gemport,
rx_q,
tcont,
tx_q)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_omci_add_channel failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_oam_epon_del_channel_bounce(uint32_t owner_id)
{
tpm_ioctl_mng_ch_t *tpm_oam_epon_chan = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mng_channel;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MNG_SECTION;
tpm_oam_epon_chan->mng_cmd = MV_TPM_IOCTL_DEL_OAM_CHNL;
tpm_oam_epon_chan->tpm_ioctl_oam_ch.owner_id = owner_id;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_oam_epon_del_channel tpm_oam_epon_del_channel_bounce
#else
#define _tpm_oam_epon_del_channel tpm_oam_epon_del_channel
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_oam_channel
*
* DESCRIPTION:
* This function deletes OAM channel HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_oam_channel (const char *buf, size_t len)
{
typedef enum
{
nooam_owner=0, nooam_max
} oam_parm_indx_t;
// shell line parsing
uint32_t ownerid;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms == 1 && buf[0] == '?')
{
#ifdef CONFIG_MV_TPM_SYSFS_HELP
char helpbuf[1000];
int helpbuf_len;
helpbuf_len = sfs_help_no_oam_omci_channel(helpbuf);
print_help_buffer(helpbuf, helpbuf_len);
#else
printk(KERN_INFO "Parse problem: parameters expected/found %d/%d\n", nooam_max, numparms);
#endif
}
else if (numparms != 1)
{
printk(KERN_INFO "Parse problem: parameters expected/found %d/%d\n", nooam_max, numparms);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d", &ownerid);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d]\n", len, parsedargs, ownerid);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if ((rc = _tpm_oam_epon_del_channel (ownerid)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_oam_epon_del_channel failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
/*Evan*/
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_omci_del_channel_bounce(uint32_t owner_id)
{
tpm_ioctl_mng_ch_t *tpm_omci_gpon_chan = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mng_channel;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_MNG_SECTION;
tpm_omci_gpon_chan->mng_cmd = MV_TPM_IOCTL_DEL_OMCI_CHNL;
tpm_omci_gpon_chan->tpm_ioctl_omci_ch.owner_id = owner_id;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_omci_del_channel tpm_omci_del_channel_bounce
#else
#define _tpm_omci_del_channel tpm_omci_del_channel
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_no_omci_channel
*
* DESCRIPTION:
* This function creates creates an OMCI channel HW rule (PNC)
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_no_omci_channel (const char *buf, size_t len)
{
typedef enum
{
noomci_owner=0, noomci_max
} noomci__parm_indx_t;
// shell line parsing
uint32_t ownerid;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms == 1 && buf[0] == '?')
{
#ifdef CONFIG_MV_TPM_SYSFS_HELP
char helpbuf[1000];
int helpbuf_len;
helpbuf_len = sfs_help_no_oam_omci_channel(helpbuf);
print_help_buffer(helpbuf, helpbuf_len);
#else
printk(KERN_INFO "Parse problem: parameters expected/found %d/%d\n", noomci_max, numparms);
#endif
}
else if (numparms != 1)
{
printk(KERN_INFO "Parse problem: parameters expected/found %d/%d\n", noomci_max, numparms);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d ", &ownerid);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d]\n", len, parsedargs, ownerid);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if ((rc = _tpm_omci_del_channel (ownerid)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_omci_del_channel failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
/*******************************************************************************
* sfs_tpm_cfg_setup
*
* DESCRIPTION:
* This function initializes tpm module
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_setup (const char *buf, size_t len)
{
typedef enum
{
/*setup_ponype=0, */setup_filename=0, setup_max
} setup_parm_indx_t;
// shell line parsing
/*uint32_t pon_type;*/
char filename[XML_FILE_PATH_LENGTH];
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
tpm_setup_t setup;
memset(&setup, 0, sizeof(tpm_setup_t));
numparms = count_parameters(buf);
if (numparms != setup_max)
{
parm_error_completion(numparms, setup_max, buf, sfs_help_setup);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%s", filename);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], level[%d]\n", len, parsedargs, ownerid, level);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
/*else if (pon_type >= TPM_NONE)
{
printk(KERN_INFO "Invalid pon_type[%d]\n", pon_type);
}*/
else
{
/*setup.pon_type = pon_type;*/
if (strcmp(filename, "default"))
{
strcpy(setup.xml_file_path, filename);
}
if ((rc = module_tpmSetup(&setup)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: module_tpmSetup failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_mib_reset_bounce(uint32_t owner_id,
uint32_t level)
{
tpm_ioctl_mib_reset_t *tpm_mib_reset_param = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_mib_reset_param;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_RESET_SECTION;
tpm_mib_reset_param->owner_id = owner_id;
tpm_mib_reset_param->reset_level = level;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_mib_reset tpm_mib_reset_bounce
#else
#define _tpm_mib_reset tpm_mib_reset
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_mib_reset
*
* DESCRIPTION:
* This function creates does a MIB reset
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_mib_reset (const char *buf, size_t len)
{
typedef enum
{
mibreset_owner=0, mibreset_gemport, mibreset_max
} mibreset_parm_indx_t;
// shell line parsing
uint32_t ownerid;
uint32_t level;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != mibreset_max)
{
parm_error_completion(numparms, mibreset_max, buf, sfs_help_mib_reset);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &level);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], level[%d]\n", len, parsedargs, ownerid, level);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (level > TPM_ENUM_MAX_RESET_LEVEL)
{
printk(KERN_INFO "Invalid level[%d]\n", level);
}
else
{
if ((rc = _tpm_mib_reset(ownerid,
level)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_mib_reset failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_set_active_wan_bounce(uint32_t owner_id,
tpm_gmacs_enum_t active_wan)
{
tpm_ioctl_set_active_wan_t *tpm_set_active_wan_param = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_set_active_wan_param;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_SET_ACTIVE_WAN_SECTION;
tpm_set_active_wan_param->owner_id = owner_id;
tpm_set_active_wan_param->active_wan = active_wan;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_set_active_wan tpm_set_active_wan_bounce
#else
#define _tpm_set_active_wan tpm_set_active_wan
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_set_active_wan
*
* DESCRIPTION:
* This function sets active wan port
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_active_wan (const char *buf, size_t len)
{
typedef enum
{
activewan_owner=0, activewan_active_wan, activewan_max
} activewan_parm_indx_t;
// shell line parsing
uint32_t ownerid;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
tpm_gmacs_enum_t active_wan;
numparms = count_parameters(buf);
if (numparms != activewan_max)
{
parm_error_completion(numparms, activewan_max, buf, sfs_help_set_active_wan);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &active_wan);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], active_wan_int[%d]\n",
// len, parsedargs, ownerid, active_wan);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else if (active_wan >= TPM_MAX_NUM_GMACS)
{
printk(KERN_INFO "Invalid active_wan[%d]\n", active_wan);
}
else
{
if ((rc = _tpm_set_active_wan(ownerid,
active_wan)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_set_active_wan failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_hot_swap_profile_bounce(uint32_t owner_id,
tpm_eth_complex_profile_t profile_id)
{
tpm_ioctl_hot_swap_profile_t *tpm_hot_swap_profile_param = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_hot_swap_profile_param;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_HOT_SWAP_PROFILE_SECTION;
tpm_hot_swap_profile_param->owner_id = owner_id;
tpm_hot_swap_profile_param->profile_id = profile_id;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_hot_swap_profile tpm_hot_swap_profile_bounce
#else
#define _tpm_hot_swap_profile tpm_hot_swap_profile
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_hot_swap_profile
*
* DESCRIPTION:
* This function swap profile in run time
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_hot_swap_profile (const char *buf, size_t len)
{
typedef enum
{
hotswap_owner=0, hotswap_profile_id, hotswap_max
} hotswap_parm_indx_t;
// shell line parsing
uint32_t ownerid;
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
uint32_t profile_id;
numparms = count_parameters(buf);
if (numparms != hotswap_max)
{
parm_error_completion(numparms, hotswap_max, buf, sfs_help_hot_swap_profile);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d", &ownerid, &profile_id);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], profile_id_int[%d]\n",
// len, parsedargs, ownerid, profile_id);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_hot_swap_profile(ownerid,
profile_id)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_hot_swap_profile failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_set_port_hwf_admin_bounce(uint32_t owner_id,
tpm_gmacs_enum_t port,
uint8_t txp,
uint8_t enable)
{
tpm_ioctl_set_port_hwf_admin_t *tpm_set_port_hwf_admin_param = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_set_port_hwf_admin_param;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_SET_PORT_HWF_ADMIN_SECTION;
tpm_set_port_hwf_admin_param->owner_id = owner_id;
tpm_set_port_hwf_admin_param->port = port;
tpm_set_port_hwf_admin_param->txp = txp;
tpm_set_port_hwf_admin_param->enable = enable;
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_set_port_hwf_admin tpm_set_port_hwf_admin_bounce
#else
#define _tpm_set_port_hwf_admin tpm_proc_hwf_admin_set
#endif
/*******************************************************************************
* sfs_tpm_cfg_set_set_port_hwf_admin
*
* DESCRIPTION:
* This function set port hwf enable/disable
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_port_hwf_admin (const char *buf, size_t len)
{
typedef enum
{
setporthwfadmin_owner=0, setporthwfadmin_port, setporthwfadmin_txp,
setporthwfadmin_enable, setporthwfadmin_max
} setporthwfadmin_parm_indx_t;
// shell line parsing
int parsedargs;
int numparms;
//Used in API call
tpm_error_code_t rc;
uint32_t ownerid;
tpm_gmacs_enum_t port;
uint32_t txp;
uint32_t enable;
numparms = count_parameters(buf);
if (numparms != setporthwfadmin_max)
{
parm_error_completion(numparms, setporthwfadmin_max, buf, sfs_help_set_port_hwf_admin);
}
else
{
// Get parameters
parsedargs = sscanf(buf, "%d %d %d %d", &ownerid, &port, &txp, &enable);
// printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%d], port[%d], txp[%d], enable[%d]\n",
// len, parsedargs, ownerid, port, txp, enable);
if (parsedargs != numparms)
{
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
}
else
{
if ((rc = _tpm_set_port_hwf_admin(port, txp, enable)) == TPM_RC_OK)
{
printk(KERN_INFO "OK\n");
}
else
{
printk(KERN_INFO "%s: tpm_set_port_hwf_admin failed, rc[%d] - %s\n", __FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
}
/*******************************************************************************
* sfs_tpm_cfg_set_erase_section
*
* DESCRIPTION:
* This function erases a section per an application group.
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_set_erase_section(const char *buf, size_t len)
{
typedef enum
{
section_owner_id=0, section_api_type, erase_section_max
} erase_section_parm_indx_t;
/*shell line parsing*/
uint32_t ownerid;
uint32_t api_type;
int parsedargs;
int numparms;
tpm_error_code_t rc;
numparms = count_parameters(buf);
if (numparms != erase_section_max)
parm_error_completion(numparms, erase_section_max, buf, sfs_help_erase_section);
else {
/*get parameters*/
parsedargs = sscanf(buf, "%d %d", &ownerid, &api_type);
if(parsedargs != numparms)
printk(KERN_INFO "Parse failure - %d/%d parameters were parsed\n", parsedargs, numparms);
else if (api_type > TPM_MAX_API_TYPES)
printk(KERN_INFO "Invalid api type[%d]\n", api_type);
else {
if ((rc = tpm_erase_section(ownerid, api_type)) == TPM_RC_OK)
printk(KERN_INFO "OK\n");
else
printk(KERN_INFO "%s: tpm_erase_section failed, rc[%d] - %s\n",
__FUNCTION__, rc, get_tpm_err_str(rc));
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_add_cpu_wan_loopback_bounce(uint32_t owner_id,
tpm_pkt_frwd_t *pkt_frwd,
uint32_t *mod_idx)
{
tpm_ioctl_cpu_lpbk_t *tpm_ioctl_cpu_lpbk = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_ioctl_cpu_lpbk;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_CPU_LPBK_SECTION;
tpm_ioctl_cpu_lpbk->cpu_lpbk_cmd = MV_TPM_IOCTL_ADD_CPU_WAN_LPBK;
tpm_ioctl_cpu_lpbk->owner_id = owner_id;
memcpy(&(tpm_ioctl_cpu_lpbk->pkt_frwd), pkt_frwd, sizeof(tpm_pkt_frwd_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_add_cpu_wan_loopback tpm_add_cpu_wan_loopback_bounce
#else
#define _tpm_add_cpu_wan_loopback tpm_add_cpu_wan_loopback
#endif
/*******************************************************************************
* sfs_tpm_cfg_add_cpu_lpbk
*
* DESCRIPTION:
* This function adds CPU WAN loopback
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_add_cpu_lpbk (const char *buf, size_t len)
{
typedef enum
{
lpbk_owner=0, lpbk_port, lpbk_que, lpbk_gem, lpbk_max
} lpbk_parm_indx_t;
uint32_t ownerid;
uint32_t temp_port;
uint32_t temp_que;
uint32_t temp_gem;
int parsedargs;
int numparms;
tpm_error_code_t rc;
tpm_pkt_frwd_t frwd_entry;
uint32_t mod_idx;
numparms = count_parameters(buf);
if (numparms != lpbk_max)
{
parm_error_completion(numparms, lpbk_max, buf, sfs_help_cfg_cpu_lpbk);
}
else
{
/* Get parameters */
parsedargs = sscanf(buf, "%d 0x%x %d %d", &ownerid, &temp_port, &temp_que, &temp_gem);
/*
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%s] temp_port[0x%x],temp_que[%d],temp_gem[%d]\n",
len, parsedargs, ownerid, temp_port, temp_que, temp_gem);
*/
if (temp_que > 7)
{
printk(KERN_INFO "Invalid queue [%d]\n", temp_que);
}
else if (temp_gem > 4095)
{
printk(KERN_INFO "Invalid gem port [%d]\n", temp_gem);
}
else
{
frwd_entry.trg_port = (tpm_trg_port_type_t)temp_port;
frwd_entry.trg_queue = (uint8_t)temp_que;
frwd_entry.gem_port = (uint16_t)temp_gem;
rc = _tpm_add_cpu_wan_loopback(TPM_MOD_OWNER_TPM, &frwd_entry, &mod_idx);
if(TPM_RC_OK != rc)
{
printk(KERN_ERR "Failed to call tpm_add_cpu_wan_loopback, ret_code[%d]\n", rc);
}
else
{
printk(KERN_ERR "Call tpm_add_cpu_wan_loopback successfully, mod_idx[%d]\n", mod_idx);
}
}
}
}
#ifdef CONFIG_MV_TPM_SFS_2_IOCTL
tpm_error_code_t tpm_del_cpu_wan_loopback_bounce(uint32_t owner_id,
tpm_pkt_frwd_t *pkt_frwd)
{
tpm_ioctl_cpu_lpbk_t *tpm_ioctl_cpu_lpbk = &tpm_sfs_2_ioctl_command.tpm_cmd_data.tpm_ioctl_cpu_lpbk;
tpm_sfs_2_ioctl_command.cmd = MV_TPM_IOCTL_CPU_LPBK_SECTION;
tpm_ioctl_cpu_lpbk->cpu_lpbk_cmd = MV_TPM_IOCTL_DEL_CPU_WAN_LPBK;
tpm_ioctl_cpu_lpbk->owner_id = owner_id;
memcpy(&(tpm_ioctl_cpu_lpbk->pkt_frwd), pkt_frwd, sizeof(tpm_pkt_frwd_t));
up(&tpm_sfs_2_ioctl_sem);
return TPM_RC_OK;
}
#define _tpm_del_cpu_wan_loopback tpm_del_cpu_wan_loopback_bounce
#else
#define _tpm_del_cpu_wan_loopback tpm_del_cpu_wan_loopback
#endif
/*******************************************************************************
* sfs_tpm_cfg_del_cpu_lpbk
*
* DESCRIPTION:
* This function delete CPU WAN loopback
* INPUTS:
* buf - Shell parameters as char buffer
* len - Number of characters in buffer
*
*******************************************************************************/
void sfs_tpm_cfg_del_cpu_lpbk (const char *buf, size_t len)
{
typedef enum
{
lpbk_owner=0, lpbk_port, lpbk_que, lpbk_gem, lpbk_max
} lpbk_parm_indx_t;
uint32_t ownerid;
uint32_t temp_port;
uint32_t temp_que;
uint32_t temp_gem;
int parsedargs;
int numparms;
tpm_error_code_t rc;
tpm_pkt_frwd_t frwd_entry;
numparms = count_parameters(buf);
if (numparms != lpbk_max)
{
parm_error_completion(numparms, lpbk_max, buf, sfs_help_cfg_cpu_lpbk);
}
else
{
/* Get parameters */
parsedargs = sscanf(buf, "%d 0x%x %d %d", &ownerid, &temp_port, &temp_que, &temp_gem);
/*
printk(KERN_INFO "len=%d, parsedargs=%d. ownerid[%s] temp_port[0x%x],temp_que[%d],temp_gem[%d]\n",
len, parsedargs, ownerid, temp_port, temp_que, temp_gem);
*/
if (temp_que > 7)
{
printk(KERN_INFO "Invalid queue [%d]\n", temp_que);
}
else if (temp_gem > 4095)