confparse.y revision 7c478bd95313f5f23a4c958a745db2134aa03244
%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <sys/wrsm_config.h>
#include "util.h"
#include "wrsmconf.h"
#include "wrsmconf_impl.h"
int yyerror(const char *);
static int num_ctlrs = 0;
static int nmembers = 0;
static int nwcis = 0;
static int ngroups = 0;
static int npolicy = 0;
static int nroutes = 0;
static wrsm_wci_data_t **cur_wci_list;
static wrsm_wci_data_t *cur_wci;
struct intlist {
int length;
int *list;
};
#ifdef DEBUG
#else
#define TRACE(s)
#endif /* DEBUG */
%}
%union {
char *name;
int value;
boolean_t bool;
}
%%
{ nmembers=0; } net_members
int i;
TRACE("controller");
num_ctlrs++;
}
;
TRACE("net_members 1");
++nmembers;
sizeof(wrsm_net_member_t *) * nmembers);
}
| net_member {
TRACE("net_members 2");
++nmembers;
$$ = (wrsm_net_member_t **)malloc(
sizeof(wrsm_net_member_t *) * nmembers);
}
;
int i;
TRACE("net_member");
$$->cnodeid = $2;
$$->fmnodeid = $5;
/*
* The first ncslice listed in the file becomes the last
* ncslice in the int list. So pick off the last one as
* the small page ncslice, and sort the rest based on
* large page index (lower 3 bits).
*/
memset(&($$->exported_ncslices), 0,
sizeof($$->exported_ncslices));
char errmsg[128];
"cnode %d: Large ncslice 0x%x attempts "
"to use position %d which is already "
"used by ncslice 0x%x",
}
}
memset(&($$->imported_ncslices), 0,
sizeof($$->imported_ncslices));
char errmsg[128];
"cnode %d: Large ncslice 0x%x attempts "
"to use position %d which is already "
"used by ncslice 0x%x",
}
}
$$->local_offset = $16;
$$->comm_ncslice = $18;
$$->comm_offset = $19;
}
;
TRACE("routing");
$$ = (wrsm_routing_data_t *)malloc
(sizeof(wrsm_routing_data_t));
}
wcis:
TRACE("wcis 1");
++nwcis;
sizeof(wrsm_wci_data_t *) * nwcis);
}
| wci {
TRACE("wcis 2");
++nwcis;
$$ = (wrsm_wci_data_t **)malloc(
sizeof(wrsm_wci_data_t *) * nwcis);
}
;
wci:
WCI {
}
}
TRACE("wci");
$$ = cur_wci;
$$->port = $5;
$$->local_wnode = $7;
$$->local_gnid = $9;
$$->route_map_striping = $11;
$$->topology_type = $12;
}
;
;
;
TRACE("triplet");
}
;
;
;
|
;
link:
TRACE("link");
yyerror("Illegal link number");
}
;
;
;
TRACE("routing_policies 1");
++npolicy;
$$ = (wrsm_routing_policy_t **)realloc
}
| routing_policy {
TRACE("routing_policies 2");
++npolicy;
$$ = (wrsm_routing_policy_t **)malloc
(sizeof(wrsm_routing_policy_t *) * npolicy);
}
;
int i;
TRACE("routing_policy");
$$ = (wrsm_routing_policy_t *)malloc
(sizeof(wrsm_routing_policy_t));
$$->cnodeid = $2;
$$->wcis_balanced = $6;
$$->striping_important = $7;
}
}
;
;
;
TRACE("preferred_routes 1");
++nroutes;
}
| preferred_route {
TRACE("preferred_routes 2");
++nroutes;
}
;
int i;
TRACE("preferred_route 1");
$$->striping_level = $3;
$$->method = $4;
$$->route_type = route_wci;
if ($6) {
for (i = 0; i < $6->length; ++i)
}
}
RB {
int i;
TRACE("preferred_route 2");
$$->striping_level = $3;
$$->method = $4;
$$->route_type = route_stripe_group;
if ($6) {
for (i = 0; i < $6->length; ++i)
}
}
;
TRACE("striping_level");
$$ = $2;
}
;
TRACE("routing_method");
$$ = $2;
}
;
TRACE("use_wci");
$$ = $2;
}
;
TRACE("use_stripe");
$$ = $2;
}
;
| { $$ = NULL; }
;
| { $$ = NULL; }
;
TRACE("stripe_groups");
++ngroups;
}
| { $$ = NULL; }
;
int i;
TRACE("stripe_group");
$$->group_id = $2;
Error("Too many wcis in stripe group");
else {
for (i = 0; i < $$->nwcis; ++i)
free($5);
}
}
;
TRACE("int_list 1");
$$ = $2;
$$->length++;
}
| INT {
TRACE("int_list 2");
$$->length = 1;
}
;
%%
static int
compare_member(const void *a, const void *b)
{
TRACE("compare_member");
}
static int
compare_policy(const void *a, const void *b)
{
TRACE("compare_policy");
}
static int
compare_stripe_group(const void *a, const void *b)
{
TRACE("compare_stripe_group");
}
static int
compare_wci(const void *a, const void *b)
{
TRACE("compare_wci");
}
static void
{
int i, j;
TRACE("postprocess_controller");
/* sort network members by cnodeid */
sizeof (wrsm_net_member_t *),
/* sort routing policies by cnodeid */
sizeof (wrsm_routing_policy_t *), &compare_policy);
/* sort stripe groupd by group id */
sizeof (wrsm_stripe_group_t *),
/* sort wcis by safari port id */
sizeof (wrsm_wci_data_t *), &compare_wci);
/* Reverse the order of the preferred routes list */
int nroutes =
for (j = 0; j < (nroutes/2); ++j) {
}
}
/* Reverse the order of the stripe groups */
for (j = 0; j < (nwcis / 2); ++j) {
}
}
}
}
{
int i;
int j;
TRACE("wrsm_find_controller");
for (i = 0; i < num_ctlrs; i++) {
return (&controller[i]);
}
}
}
return (NULL);
}
{
int i;
int j;
TRACE("wrsm_find_controller_by_hostname");
if (!host)
return (NULL);
for (i = 0; i < num_ctlrs; i++) {
return (&controller[i]);
}
}
return (NULL);
}
void
{
int i;
TRACE("wrsm_yacc_reset");
for (i = 0; i < num_ctlrs; i++) {
wrsm_cf_free(&controller[i], 0);
}
num_ctlrs = 0;
nmembers = 0;
nwcis = 0;
ngroups = 0;
npolicy = 0;
nroutes = 0;
}