aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain/uClibc/config-0.9.33.2/mips64el
Commit message (Expand)AuthorAgeFilesLines
* uClibc: update to 0.9.33.2, fixes #4420Felix Fietkau2012-05-151-0/+17
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
/*
 * Broadcom BCM5325E/536x switch configuration utility
 *
 * Copyright (C) 2005 Oleg I. Vdovikin
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
 * 02110-1301, USA.
 */
 
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>

/* linux stuff */
typedef u_int64_t u64;
typedef u_int32_t u32;
typedef u_int16_t u16;
typedef u_int8_t u8;

#include <linux/if.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
#include <linux/mii.h>

#include "etc53xx.h"
#define ROBO_PHY_ADDR	0x1E	/* robo switch phy address */

/* MII registers */
#define REG_MII_PAGE	0x10	/* MII Page register */
#define REG_MII_ADDR	0x11	/* MII Address register */
#define REG_MII_DATA0	0x18	/* MII Data register 0 */

#define REG_MII_PAGE_ENABLE	1
#define REG_MII_ADDR_WRITE	1
#define REG_MII_ADDR_READ	2

/* Private et.o ioctls */
#define SIOCGETCPHYRD           (SIOCDEVPRIVATE + 9)
#define SIOCSETCPHYWR           (SIOCDEVPRIVATE + 10)

typedef struct {
	struct ifreq ifr;
	int fd;
	int et;			/* use private ioctls */
} robo_t;

static u16 mdio_read(robo_t *robo, u16 phy_id, u8 reg)
{
	if (robo->et) {
		int args[2] = { reg };
		
		if (phy_id != ROBO_PHY_ADDR) {
			fprintf(stderr,
				"Access to real 'phy' registers unavaliable.\n"
				"Upgrade kernel driver.\n");

			return 0xffff;
		}
	
		robo->ifr.ifr_data = (caddr_t) args;
		if (ioctl(robo->fd, SIOCGETCPHYRD, (caddr_t)&robo->ifr) < 0) {
			perror("SIOCGETCPHYRD");
			exit(1);
		}
	
		return args[1];
	} else {
		struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
		mii->phy_id = phy_id;
		mii->reg_num = reg;
		if (ioctl(robo->fd, SIOCGMIIREG, &robo->ifr) < 0) {
			perror("SIOCGMIIREG");
			exit(1);
		}
		return mii->val_out;
	}
}

static void mdio_write(robo_t *robo, u16 phy_id, u8 reg, u16 val)
{
	if (robo->et) {
		int args[2] = { reg, val };

		if (phy_id != ROBO_PHY_ADDR) {
			fprintf(stderr,
				"Access to real 'phy' registers unavaliable.\n"
				"Upgrade kernel driver.\n");
			return;
		}
		
		robo->ifr.ifr_data = (caddr_t) args;
		if (ioctl(robo->fd, SIOCSETCPHYWR, (caddr_t)&robo->ifr) < 0) {
			perror("SIOCGETCPHYWR");
			exit(1);
		}
	} else {
		struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo->ifr.ifr_data;
		mii->phy_id = phy_id;
		mii->reg_num = reg;
		mii->val_in = val;
		if (ioctl(robo->fd, SIOCSMIIREG, &robo->ifr) < 0) {
			perror("SIOCSMIIREG");
			exit(1);
		}
	}
}

static int robo_reg(robo_t *robo, u8 page, u8 reg, u8 op)
{
	int i = 3;
	
	/* set page number */
	mdio_write(robo, ROBO_PHY_ADDR, REG_MII_PAGE, 
		(page << 8) | REG_MII_PAGE_ENABLE);
	
	/* set register address */
	mdio_write(robo, ROBO_PHY_ADDR, REG_MII_ADDR, 
		(reg << 8) | op);

	/* check if operation completed */
	while (i--) {
		if ((mdio_read(robo, ROBO_PHY_ADDR, REG_MII_ADDR) & 3) == 0)
			return 0;
	}

	fprintf(stderr, "robo_reg: timeout\n");
	exit(1);
	
	return 0;
}

static void robo_read(robo_t *robo, u8 page, u8 reg, u16 *val, int count)
{
	int i;
	
	robo_reg(robo, page, reg, REG_MII_ADDR_READ);
	
	for (i = 0; i < count; i++)
		val[i] = mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + i);
}

static u16 robo_read16(robo_t *robo, u8 page, u8 reg)
{
	robo_reg(robo, page, reg, REG_MII_ADDR_READ);
	
	return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0);
}

static u32 robo_read32(robo_t *robo, u8 page, u8 reg)
{
	robo_reg(robo, page, reg, REG_MII_ADDR_READ);
	
	return mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0) +
		(mdio_read(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1) << 16);
}

static void robo_write16(robo_t *robo, u8 page, u8 reg, u16 val16)
{
	/* write data */
	mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val16);

	robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
}

static void robo_write32(robo_t *robo, u8 page, u8 reg, u32 val32)
{
	/* write data */
	mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0, val32 & 65535);
	mdio_write(robo, ROBO_PHY_ADDR, REG_MII_DATA0 + 1, val32 >> 16);
	
	robo_reg(robo, page, reg, REG_MII_ADDR_WRITE);
}

/* checks that attached switch is 5325E/5350 */
static int robo_vlan5350(robo_t *robo)
{
	/* set vlan access id to 15 and read it back */
	u16 val16 = 15;
	robo_write16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
	
	/* 5365 will refuse this as it does not have this reg */
	return (robo_read16(robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350) == val16);
}

u8 port[6] = { 0, 1, 2, 3, 4, 8 };
char ports[6] = { 'W', '4', '3', '2', '1', 'C' };
char *rxtx[4] = { "enabled", "rx_disabled", "tx_disabled", "disabled" };
char *stp[8] = { "none", "disable", "block", "listen", "learn", "forward", "6", "7" };

struct {
	char *name;
	u16 bmcr;
} media[5] = { { "auto", BMCR_ANENABLE | BMCR_ANRESTART }, 
	{ "10HD", 0 }, { "10FD", BMCR_FULLDPLX },
	{ "100HD", BMCR_SPEED100 }, { "100FD", BMCR_SPEED100 | BMCR_FULLDPLX } };

struct {
	char *name;
	u16 value;
} mdix[3] = { { "auto", 0x0000 }, { "on", 0x1800 }, { "off", 0x0800 } };

void usage()
{
	fprintf(stderr, "Broadcom BCM5325E/536x switch configuration utility\n"
		"Copyright (C) 2005 Oleg I. Vdovikin\n\n"
		"This program is distributed in the hope that it will be useful,\n"
		"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
		"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
		"GNU General Public License for more details.\n\n");

	fprintf(stderr, "Usage: robocfg <op> ... <op>\n"
			"Operations are as below:\n"
			"\tshow\n"
			"\tswitch <enable|disable>\n"
			"\tport <port_number> [state <%s|%s|%s|%s>]\n\t\t[stp %s|%s|%s|%s|%s|%s] [tag <vlan_tag>]\n"
			"\t\t[media %s|%s|%s|%s|%s] [mdi-x %s|%s|%s]\n"
			"\tvlan <vlan_number> [ports <ports_list>]\n"
			"\tvlans <enable|disable|reset>\n\n"
			"\tports_list should be one argument, space separated, quoted if needed,\n"
			"\tport number could be followed by 't' to leave packet vlan tagged (CPU \n"
			"\tport default) or by 'u' to untag packet (other ports default) before \n"
			"\tbringing it to the port, '*' is ignored\n"
			"\nSamples:\n"
			"1) ASUS WL-500g Deluxe stock config (eth0 is WAN, eth0.1 is LAN):\n"
			"robocfg switch disable vlans enable reset vlan 0 ports \"0 5u\" vlan 1 ports \"1 2 3 4 5t\""
			" port 0 state enabled stp none switch enable\n"
			"2) WRT54g, WL-500g Deluxe OpenWRT config (vlan0 is LAN, vlan1 is WAN):\n"
			"robocfg switch disable vlans enable reset vlan 0 ports \"1 2 3 4 5t\" vlan 1 ports \"0 5t\""
			" port 0 state enabled stp none switch enable\n",
			rxtx[0], rxtx[1], rxtx[2], rxtx[3], stp[0], stp[1], stp[2], stp[3], stp[4], stp[5],
			media[0].name, media[1].name, media[2].name, media[3].name, media[4].name,
			mdix[0].name, mdix[1].name, mdix[2].name);
}

static robo_t robo;
int bcm53xx_probe(const char *dev)
{
	struct ethtool_drvinfo info;
	unsigned int phyid;
	int ret;

	fprintf(stderr, "probing %s\n", dev);

	strcpy(robo.ifr.ifr_name, dev);
	memset(&info, 0, sizeof(info));
	info.cmd = ETHTOOL_GDRVINFO;
	robo.ifr.ifr_data = (caddr_t)&info;
	ret = ioctl(robo.fd, SIOCETHTOOL, (caddr_t)&robo.ifr);
	if (ret < 0) {
		perror("SIOCETHTOOL");
		return ret;
	}

	if (	strcmp(info.driver, "et0") &&
		strcmp(info.driver, "b44") &&
		strcmp(info.driver, "bcm63xx_enet") ) {
			fprintf(stderr, "driver not supported %s\n", info.driver);
			return -ENOSYS;
	}

	/* try access using MII ioctls - get phy address */
	robo.et = 0;
	if (ioctl(robo.fd, SIOCGMIIPHY, &robo.ifr) < 0)
		robo.et = 1;

	if (robo.et) {
		unsigned int args[2] = { 2 };
		
		robo.ifr.ifr_data = (caddr_t) args;
		ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
		if (ret < 0) {
			perror("SIOCGETCPHYRD");
			return ret;
		}
		phyid = args[1] & 0xffff;
	
		args[0] = 3;
		robo.ifr.ifr_data = (caddr_t) args;
		ret = ioctl(robo.fd, SIOCGETCPHYRD, (caddr_t)&robo.ifr);
		if (ret < 0) {
			perror("SIOCGETCPHYRD");
			return ret;
		}
		phyid |= args[1] << 16;
	} else {
		struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&robo.ifr.ifr_data;
		mii->phy_id = ROBO_PHY_ADDR;
		mii->reg_num = 2;
		ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
		if (ret < 0) {
			perror("SIOCGMIIREG");
			return ret;
		}
		phyid = mii->val_out & 0xffff;

		mii->phy_id = ROBO_PHY_ADDR;
		mii->reg_num = 3;
		ret = ioctl(robo.fd, SIOCGMIIREG, &robo.ifr);
		if (ret < 0) {
			perror("SIOCGMIIREG");
			return ret;
		}
		phyid |= mii->val_out << 16;
	}

	if (phyid == 0xffffffff || phyid == 0x55210022) {
		perror("phyid");
		return -EIO;
	}
	
	return 0;
}

int
main(int argc, char *argv[])
{
	u16 val16;
	u16 mac[3];
	int i = 0, j;
	int robo5350 = 0;
	u32 phyid;
	
	if ((robo.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("socket");
		exit(1);
	}

	if (bcm53xx_probe("eth1")) {
		if (bcm53xx_probe("eth0")) {
			perror("bcm53xx_probe");
			exit(1);
		}
	}

	robo5350 = robo_vlan5350(&robo);
	
	for (i = 1; i < argc;) {
		if (strcasecmp(argv[i], "port") == 0 && (i + 1) < argc)
		{
			int index = atoi(argv[++i]);
			/* read port specs */
			while (++i < argc) {
				if (strcasecmp(argv[i], "state") == 0 && ++i < argc) {
					for (j = 0; j < 4 && strcasecmp(argv[i], rxtx[j]); j++);
					if (j < 4) {
						/* change state */
						robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
							(robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(3 << 0)) | (j << 0));
					} else {
						fprintf(stderr, "Invalid state '%s'.\n", argv[i]);
						exit(1);
					}
				} else
				if (strcasecmp(argv[i], "stp") == 0 && ++i < argc) {
					for (j = 0; j < 8 && strcasecmp(argv[i], stp[j]); j++);
					if (j < 8) {
						/* change stp */
						robo_write16(&robo,ROBO_CTRL_PAGE, port[index],
							(robo_read16(&robo, ROBO_CTRL_PAGE, port[index]) & ~(7 << 5)) | (j << 5));
					} else {
						fprintf(stderr, "Invalid stp '%s'.\n", argv[i]);
						exit(1);
					}
				} else
				if (strcasecmp(argv[i], "media") == 0 && ++i < argc) {
					for (j = 0; j < 5 && strcasecmp(argv[i], media[j].name); j++);
					if (j < 5) {
                                    		mdio_write(&robo, port[index], MII_BMCR, media[j].bmcr);
					} else {
						fprintf(stderr, "Invalid media '%s'.\n", argv[i]);
						exit(1);
					}
				} else
				if (strcasecmp(argv[i], "mdi-x") == 0 && ++i < argc) {
					for (j = 0; j < 3 && strcasecmp(argv[i], mdix[j].name); j++);
					if (j < 3) {
                                    		mdio_write(&robo, port[index], 0x1c, mdix[j].value |
						    (mdio_read(&robo, port[index], 0x1c) & ~0x1800));
					} else {
						fprintf(stderr, "Invalid mdi-x '%s'.\n", argv[i]);
						exit(1);
					}
				} else
				if (strcasecmp(argv[i], "tag") == 0 && ++i < argc) {
					j = atoi(argv[i]);
					/* change vlan tag */
					robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (index << 1), j);
				} else break;
			}
		} else
		if (strcasecmp(argv[i], "vlan") == 0 && (i + 1) < argc)
		{
			int index = atoi(argv[++i]);
			while (++i < argc) {
				if (strcasecmp(argv[i], "ports") == 0 && ++i < argc) {
					char *ports = argv[i];
					int untag = 0;
					int member = 0;
					
					while (*ports >= '0' && *ports <= '9') {
						j = *ports++ - '0';
						member |= 1 << j;
						
						/* untag if needed, CPU port requires special handling */
						if (*ports == 'u' || (j != 5 && (*ports == ' ' || *ports == 0))) 
						{
							untag |= 1 << j;
							if (*ports) ports++;
							/* change default vlan tag */
							robo_write16(&robo, ROBO_VLAN_PAGE, 
								ROBO_VLAN_PORT0_DEF_TAG + (j << 1), index);
						} else 
						if (*ports == '*' || *ports == 't' || *ports == ' ') ports++;
						else break;
						
						while (*ports == ' ') ports++;
					}
					
					if (*ports) {
						fprintf(stderr, "Invalid ports '%s'.\n", argv[i]);
						exit(1);
					} else {
						/* write config now */
						val16 = (index) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
						if (robo5350) {
							robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350,
								(1 << 20) /* valid */ | (untag << 6) | member);
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
						} else {
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE,
								(1 << 14)  /* valid */ | (untag << 7) | member);
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
						}
					}
				} else break;
			}
		} else
		if (strcasecmp(argv[i], "switch") == 0 && (i + 1) < argc)
		{
			/* enable/disable switching */
			robo_write16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE,
				(robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & ~2) |
				(*argv[++i] == 'e' ? 2 : 0));
			i++;
		} else
		if (strcasecmp(argv[i], "vlans") == 0 && (i + 1) < argc)
		{
			while (++i < argc) {
				if (strcasecmp(argv[i], "reset") == 0) {
					/* reset vlan validity bit */
					for (j = 0; j <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) 
					{
						/* write config now */
						val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */;
						if (robo5350) {
							robo_write32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0);
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
						} else {
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0);
							robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
						}
					}
				} else 
				if (strcasecmp(argv[i], "enable") == 0 || strcasecmp(argv[i], "disable") == 0) 
				{
					int disable = (*argv[i] == 'd') || (*argv[i] == 'D');
					/* enable/disable vlans */
					robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0, disable ? 0 :
						(1 << 7) /* 802.1Q VLAN */ | (3 << 5) /* mac check and hash */);

					robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL1, disable ? 0 :
						(1 << 1) | (1 << 2) | (1 << 3) /* RSV multicast */);

					robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL4, disable ? 0 :
						(1 << 6) /* drop invalid VID frames */);

					robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL5, disable ? 0 :
						(1 << 3) /* drop miss V table frames */);

				} else break;
			}
		} else
		if (strcasecmp(argv[i], "show") == 0)
		{
			break;
		} else {
			fprintf(stderr, "Invalid option %s\n", argv[i]);
			usage();
			exit(1);
		}
	}

	if (i == argc) {
		if (argc == 1) usage();
		return 0;
	}
	
	/* show config */
		
	printf("Switch: %sabled\n", robo_read16(&robo, ROBO_CTRL_PAGE, ROBO_SWITCH_MODE) & 2 ? "en" : "dis");

	for (i = 0; i < 6; i++) {
		printf(robo_read16(&robo, ROBO_STAT_PAGE, ROBO_LINK_STAT_SUMMARY) & (1 << port[i]) ?
			"Port %d(%c): %s%s " : "Port %d(%c):  DOWN ", i, ports[i],
			robo_read16(&robo, ROBO_STAT_PAGE, ROBO_SPEED_STAT_SUMMARY) & (1 << port[i]) ? "100" : " 10",
			robo_read16(&robo, ROBO_STAT_PAGE, ROBO_DUPLEX_STAT_SUMMARY) & (1 << port[i]) ? "FD" : "HD");
		
		val16 = robo_read16(&robo, ROBO_CTRL_PAGE, port[i]);
		
		printf("%s stp: %s vlan: %d ", rxtx[val16 & 3], stp[(val16 >> 5) & 7],
			robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (i << 1)));
			
		robo_read(&robo, ROBO_STAT_PAGE, ROBO_LSA_PORT0 + port[i] * 6, mac, 3);
		
		printf("mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
			mac[2] >> 8, mac[2] & 255, mac[1] >> 8, mac[1] & 255, mac[0] >> 8, mac[0] & 255);
	}
	
	val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_CTRL0);
	
	printf("VLANs: %s %sabled%s%s\n", 
		robo5350 ? "BCM5325/535x" : "BCM536x",
		(val16 & (1 << 7)) ? "en" : "dis", 
		(val16 & (1 << 6)) ? " mac_check" : "", 
		(val16 & (1 << 5)) ? " mac_hash" : "");
	
	/* scan VLANs */
	for (i = 0; i <= (robo5350 ? VLAN_ID_MAX5350 : VLAN_ID_MAX); i++) {
		/* issue read */
		val16 = (i) /* vlan */ | (0 << 12) /* read */ | (1 << 13) /* enable */;
		
		if (robo5350) {
			u32 val32;
			robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16);
			/* actual read */
			val32 = robo_read32(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
			if ((val32 & (1 << 20)) /* valid */) {
				printf("vlan%d:", i);
				for (j = 0; j < 6; j++) {
					if (val32 & (1 << j)) {
						printf(" %d%s", j, (val32 & (1 << (j + 6))) ? 
							(j == 5 ? "u" : "") : "t");
					}
				}
				printf("\n");
			}
		} else {
			robo_write16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16);
			/* actual read */
			val16 = robo_read16(&robo, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
			if ((val16 & (1 << 14)) /* valid */) {
				printf("vlan%d:", i);
				for (j = 0; j < 6; j++) {
					if (val16 & (1 << j)) {
						printf(" %d%s", j, (val16 & (1 << (j + 7))) ? 
							(j == 5 ? "u" : "") : "t");
					}
				}
				printf("\n");
			}
		}
	}
	
	return (0);
}