static int handle_vlan_port_write(void *driver, char *buf, int nr) { switch_driver *d = (switch_driver *) driver; switch_vlan_config *c = switch_parse_vlan(d, buf); int j; __u16 val16; if (c == NULL) return -EINVAL; for (j = 0; j < d->ports; j++) { if ((c->untag | c->pvid) & (1 << j)) /* change default vlan tag */ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr); } /* write config now */ val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; if (is_5350) { robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, (1 << 20) /* valid */ | (c->untag << 6) | c->port); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); } else { robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, (1 << 14) /* valid */ | (c->untag << 7) | c->port); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); } return 0; }
static int handle_vlan_port_write(void *driver, char *buf, int nr) { switch_driver *d = (switch_driver *) driver; switch_vlan_config *c = switch_parse_vlan(d, buf); int j; __u16 val16; if (c == NULL) return -EINVAL; for (j = 0; j < d->ports; j++) { if ((c->untag | c->pvid) & (1 << j)) /* change default vlan tag */ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr); } /* write config now */ if (robo.devid != ROBO_DEVICE_ID_5325) { __u8 regoff = ((robo.devid == ROBO_DEVICE_ID_5395) || (robo.devid == ROBO_DEVICE_ID_53115)) ? 0x20 : 0; robo_write32(ROBO_ARLIO_PAGE, 0x63 + regoff, (c->untag << 9) | c->port); robo_write16(ROBO_ARLIO_PAGE, 0x61 + regoff, nr); robo_write16(ROBO_ARLIO_PAGE, 0x60 + regoff, 1 << 7); return 0; } val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; if (robo.is_5350) { robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, (1 << 20) /* valid */ | (c->untag << 6) | c->port); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); } else { robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, (1 << 14) /* valid */ | (c->untag << 7) | c->port); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); } return 0; }
static int handle_vlan_port_write(char *buf, int nr) { int untag = 0; int member = 0; int j; __u16 val16; while (*buf >= '0' && *buf <= '9') { j = *buf++ - '0'; member |= 1 << j; /* untag if needed, CPU port requires special handling */ if (*buf == 'u' || (j != 5 && (isspace(*buf) || *buf == 0))) { untag |= 1 << j; if (*buf) buf++; /* change default vlan tag */ robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), nr); } else if (*buf == '*' || *buf == 't' || isspace(*buf)) { buf++; } else break; while (isspace(*buf)) buf++; } if (*buf) { return -1; } else { /* write config now */ val16 = (nr) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; if (is_5350) { robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, (1 << 20) /* valid */ | (untag << 6) | member); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, val16); } else { robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, (1 << 14) /* valid */ | (untag << 7) | member); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); } } return 0; }
static int handle_reset(void *driver, char *buf, int nr) { switch_driver *d = (switch_driver *) driver; switch_vlan_config *c = switch_parse_vlan(d, buf); int j; __u16 val16; if (c == NULL) return -EINVAL; /* disable switching */ set_switch(0); /* reset vlans */ for (j = 0; j <= ((robo.is_5350) ? VLAN_ID_MAX5350 : VLAN_ID_MAX); j++) { /* write config now */ val16 = (j) /* vlan */ | (1 << 12) /* write */ | (1 << 13) /* enable */; if (robo.is_5350) robo_write32(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE_5350, 0); else robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_WRITE, 0); robo_write16(ROBO_VLAN_PAGE, robo.is_5350 ? ROBO_VLAN_TABLE_ACCESS_5350 : ROBO_VLAN_TABLE_ACCESS, val16); } /* reset ports to a known good state */ for (j = 0; j < d->ports; j++) { robo_write16(ROBO_CTRL_PAGE, robo.port[j], 0x0000); robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_PORT0_DEF_TAG + (j << 1), 0); } /* enable switching */ set_switch(1); /* enable vlans */ handle_enable_vlan_write(driver, "1", 0); return 0; }