/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <ipp/ipp_config.h>
/* DDI file for tokenmt ipp module */
/* Default DSCP to colour mapping for colour-aware meter */
};
/* Initialize stats */
/* Stats callback function */
static int tokenmt_update_stats(ipp_stat_t *, void *, int);
tokenmt_create_action, /* ippo_action_create */
tokenmt_modify_action, /* ippo_action_modify */
tokenmt_destroy_action, /* ippo_action_destroy */
tokenmt_info, /* ippo_action_info */
tokenmt_invoke_action /* ippo_action_invoke */
};
extern struct mod_ops mod_ippops;
/*
* Module linkage information for the kernel.
*/
};
(void *)&modlipp,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
/* ARGSUSED */
static int
{
char *next_action;
return (ENOMEM);
}
/* parse red next action name */
&next_action)) != 0) {
tokenmt0dbg(("tokenmt_create_action:invalid config, red "\
"action name missing\n"));
return (rc);
}
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_create_action: red action invalid\n"));
return (EINVAL);
}
/* parse yellow next action name, if present this is Two Rate meter */
&next_action)) == 0) {
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_create_action: yellow action "\
"invalid\n"));
return (EINVAL);
}
} else {
}
/* parse green next action name */
&next_action)) != 0) {
tokenmt0dbg(("tokenmt_create_action:invalid config, green " \
"action name missing\n"));
return (rc);
}
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_create_action: green action invalid\n"));
return (EINVAL);
}
/* parse committed rate - in kilo bits / sec */
&cfg_parms->committed_rate)) != 0) {
tokenmt0dbg(("tokenmt_create_action: invalid config, "\
" committed rate missing\n"));
return (rc);
}
if (cfg_parms->committed_rate == 0) {
tokenmt0dbg(("tokenmt_create_action: invalid committed rate, "\
return (EINVAL);
}
/* parse committed burst in bits */
&cfg_parms->committed_burst)) != 0) {
tokenmt0dbg(("tokenmt_create_action: invalid config, "\
" committed burst missing\n"));
return (rc);
}
/*
* If the peak burst size is specified, make sure we have the
* yellow action.
*/
&cfg_parms->peak_burst)) == 0) {
tokenmt0dbg(("tokenmt_create_action: peak burst "\
"specified without yellow action\n"));
return (EINVAL);
}
tokenmt0dbg(("tokenmt_create_action: peak burst must be "\
"provided with yellow action\n"));
return (EINVAL);
}
/* Check if we have a peak_rate */
tokenmt0dbg(("tokenmt_create_action: peak rate "\
"specified without yellow action\n"));
return (EINVAL);
tokenmt0dbg(("tokenmt_create_action: invalid "\
return (EINVAL);
}
} else {
}
/* Validate the committed and peak burst size */
if ((cfg_parms->committed_burst == 0) &&
(cfg_parms->peak_burst == 0)) {
tokenmt0dbg(("tokenmt_create_action: at least one "\
"burst size must be non-zero\n"));
return (EINVAL);
}
} else { /* TRTCL_TOKENMT */
if ((cfg_parms->committed_burst == 0) ||
(cfg_parms->peak_burst == 0)) {
tokenmt0dbg(("tokenmt_create_action: both the "\
"burst sizes must be non-zero\n"));
return (EINVAL);
}
}
/* just copy default colour mapping */
sizeof (default_dscp_to_colour));
/* parse mode, if present */
&mode)) != 0) {
} else {
}
/* Get the dscp to colour mapping array */
if (cfg_parms->colour_aware) {
int count;
continue;
}
}
}
/* parse stats */
!= 0) {
} else {
}
/* Initialize other stuff */
if (tokenmt_data == NULL) {
return (ENOMEM);
}
/* Initialize stats, if required */
return (rc);
}
}
/* set action chain reference */
tokenmt0dbg(("tokenmt_create_action: ipp_action_ref " \
"returned with error %d", rc));
goto cleanup;
}
tokenmt0dbg(("tokenmt_create_action: ipp_action_ref " \
"returned with error %d", rc));
goto cleanup;
}
flags)) != 0) {
tokenmt0dbg(("tokenmt_create_action: ipp_action_ref "\
"returned with error %d", rc));
flags);
flags);
goto cleanup;
}
}
return (0);
}
return (rc);
}
static int
{
char *next_action_name;
!= 0) {
tokenmt0dbg(("tokenmt_modify_action: invalid configuration "\
"type"));
return (err);
}
if (config_type != IPP_SET) {
tokenmt0dbg(("tokenmt_modify_action: invalid configuration "\
"type %d", config_type));
return (EINVAL);
}
tokenmt0dbg(("tokenmt_modify_action: memory allocation "\
"failure\n"));
return (ENOMEM);
}
/* Just copy all and change as needed */
/* parse red action name, if present */
&next_action_name)) == 0) {
/* Get action id */
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_modify_action: next_action "\
"invalid"));
return (EINVAL);
}
}
/* parse yellow action name, if present */
&next_action_name)) == 0) {
/* Get action id */
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_modify_action: next_action "\
"invalid"));
return (EINVAL);
}
} else {
}
/* parse green action name, if present */
&next_action_name)) == 0) {
/* Get action id */
== IPP_ACTION_INVAL) {
tokenmt0dbg(("tokenmt_modify_action: next_action "\
"invalid"));
return (EINVAL);
}
}
/* parse committed rate, if present */
== 0) {
if (rate == 0) {
tokenmt0dbg(("tokenmt_modify_action: invalid "\
return (EINVAL);
}
}
/* parse committed burst, if present */
}
} else {
cfg_parms->peak_burst = 0;
}
/* If the peak rate is not specified, then it means single rate meter */
tokenmt0dbg(("tokenmt_modify_action: invalid "\
return (EINVAL);
}
} else {
}
if ((cfg_parms->peak_burst != 0) ||
tokenmt0dbg(("tokenmt_modify_action: yellow action "\
"missing\n"));
return (EINVAL);
}
} else {
(cfg_parms->peak_burst == 0)) {
tokenmt0dbg(("tokenmt_modify_action: peak "\
return (EINVAL);
}
}
/* Validate the committed and peak burst size */
if ((cfg_parms->committed_burst == 0) &&
(cfg_parms->peak_burst == 0)) {
tokenmt0dbg(("tokenmt_modify_action: at least one "\
"burst size must be non-zero\n"));
return (EINVAL);
}
} else { /* TRTCL_TOKENMT */
if ((cfg_parms->committed_burst == 0) ||
(cfg_parms->peak_burst == 0)) {
tokenmt0dbg(("tokenmt_modify_action: both the "\
"burst sizes must be non-zero\n"));
return (EINVAL);
}
}
/* parse mode */
} else {
}
if (cfg_parms->colour_aware) {
&colour_tbl, &nelem) == 0) {
int count;
continue;
}
} else {
sizeof (default_dscp_to_colour));
}
}
/* parse stats, if present */
return (err);
}
}
}
/* Can we ref all the new actions? */
tokenmt0dbg(("tokenmt_modify_data: can't ref. red action\n"));
return (err);
}
tokenmt0dbg(("tokenmt_modify_data:can't ref. green action\n"));
return (err);
}
flags)) != 0) {
tokenmt0dbg(("tokenmt_modify_data:can't ref. yellow "\
"action\n"));
flags);
flags);
return (err);
}
}
/* Actually modify the configuration */
/* Un-ref the old actions */
}
/* Free the old configuration */
return (0);
}
static int
{
int rc;
}
/* unreference the action */
}
return (0);
}
static int
{
int rc;
/* get mblk from ipp_packet structure */
/* meter packet as configured */
return (rc);
} else {
}
}
static int
int rc = 0;
/* install stats entry */
tokenmt0dbg(("tokenmt_statinit: ipp_stat_create failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
tokenmt0dbg(("tokenmt_statinit:ipp_stat_named_init failed "\
" with %d\n", rc));
return (rc);
}
return (rc);
}
static int
{
rw);
return (0);
}
/* ARGSUSED */
static int
{
char *next_action;
int rc;
/* allocate nvlist to be passed back */
tokenmt0dbg(("tokenmt_info: memory allocation failure\n"));
return (rc);
}
/* look up red next action with the next action id */
tokenmt0dbg(("tokenmt_info: red_action not available\n"));
return (rc);
}
/* add next action name */
next_action)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding red_action\n"));
return (rc);
}
/* free action name */
/* look up yellow next action with the next action id */
&next_action)) != 0) {
tokenmt0dbg(("tokenmt_info: yellow_action not "\
"available\n"));
return (rc);
}
/* add next action name */
next_action)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding "\
"yellow_action\n"));
return (rc);
}
/* free action name */
}
/* look up green next action with the next action id */
&next_action)) != 0) {
tokenmt0dbg(("tokenmt_info: green_action not available\n"));
return (rc);
}
/* add next action name */
next_action)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding green_action\n"));
return (rc);
}
/* free action name */
/* add config type */
tokenmt0dbg(("tokenmt_info: error adding config_type\n"));
return (rc);
}
/* add committed_rate */
cfg_parms->committed_rate)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding committed_rate\n"));
return (rc);
}
/* add peak rate */
tokenmt0dbg(("tokenmt_info: error adding peak_rate\n"));
return (rc);
}
}
/* add committed_burst */
cfg_parms->committed_burst)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding committed_burst\n"));
return (rc);
}
/* add peak_burst */
if (cfg_parms->peak_burst != 0) {
cfg_parms->peak_burst)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding peak "\
"burst\n"));
return (rc);
}
}
/* add colour aware */
cfg_parms->colour_aware)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding mode\n"));
return (rc);
}
if (cfg_parms->colour_aware) {
sizeof (cfg_parms->dscp_to_colour));
dscp_to_colour, 64)) != 0) {
tokenmt0dbg(("tokenmt_info: error adding colour "\
"array\n"));
return (rc);
}
}
tokenmt0dbg(("tokenmt_info: error adding stats status\n"));
return (rc);
}
/* call back with nvlist */
return (rc);
}