{ 38, 2, "Dot3StatsSymbolErrors " },
{ 40, 2, "Dot3InPauseFrames " },
{ 42, 2, "Dot3ControlInUnknownOpcodes " },
{ 38, 2, "Dot3StatsSymbolErrors " },
{ 40, 2, "Dot3InPauseFrames " },
{ 42, 2, "Dot3ControlInUnknownOpcodes " },
- { 44, 2, "IfOutOctets " },
- { 46, 2, "Dot3StatsSingleCollisionFrames " },
- { 48, 2, "Dot3StatMultipleCollisionFrames " },
- { 50, 2, "Dot3sDeferredTransmissions " },
- { 52, 2, "Dot3StatsLateCollisions " },
- { 54, 2, "EtherStatsCollisions " },
- { 56, 2, "Dot3StatsExcessiveCollisions " },
- { 58, 2, "Dot3OutPauseFrames " },
- { 60, 2, "Dot1dBasePortDelayExceededDiscards" },
- { 62, 2, "Dot1dTpPortInDiscards " },
- { 64, 2, "IfOutUcastPkts " },
- { 66, 2, "IfOutMulticastPkts " },
- { 68, 2, "IfOutBroadcastPkts " },
+ { 44, 4, "IfOutOctets " },
+ { 48, 2, "Dot3StatsSingleCollisionFrames " },
+ { 50, 2, "Dot3StatMultipleCollisionFrames " },
+ { 52, 2, "Dot3sDeferredTransmissions " },
+ { 54, 2, "Dot3StatsLateCollisions " },
+ { 56, 2, "EtherStatsCollisions " },
+ { 58, 2, "Dot3StatsExcessiveCollisions " },
+ { 60, 2, "Dot3OutPauseFrames " },
+ { 62, 2, "Dot1dBasePortDelayExceededDiscards" },
+ { 64, 2, "Dot1dTpPortInDiscards " },
+ { 66, 2, "IfOutUcastPkts " },
+ { 68, 2, "IfOutMulticastPkts " },
+ { 70, 2, "IfOutBroadcastPkts " },
-static int rtl8366s_read_phy_reg(struct rtl8366s *rtl,
+static inline struct rtl8366_smi *sw_to_rtl8366_smi(struct switch_dev *sw)
+{
+ struct rtl8366s *rtl = sw_to_rtl8366s(sw);
+ return &rtl->smi;
+}
+
+static int rtl8366s_reset_chip(struct rtl8366_smi *smi)
+{
+ int timeout = 10;
+ u32 data;
+
+ rtl8366_smi_write_reg(smi, RTL8366_RESET_CTRL_REG,
+ RTL8366_CHIP_CTRL_RESET_HW);
+ do {
+ msleep(1);
+ if (rtl8366_smi_read_reg(smi, RTL8366_RESET_CTRL_REG, &data))
+ return -EIO;
+
+ if (!(data & RTL8366_CHIP_CTRL_RESET_HW))
+ break;
+ } while (--timeout);
+
+ if (!timeout) {
+ printk("Timeout waiting for the switch to reset\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int rtl8366s_read_phy_reg(struct rtl8366_smi *smi,
- len = snprintf(rtl->buf, sizeof(rtl->buf),
- "port:%d link:%s speed:%s %s-duplex %s%s%s",
- val->port_vlan,
- (data & RTL8366S_PORT_STATUS_LINK_MASK) ? "up" : "down",
- rtl8366s_speed_str(data &
+ if (data & RTL8366S_PORT_STATUS_LINK_MASK) {
+ len = snprintf(rtl->buf, sizeof(rtl->buf),
+ "port:%d link:up speed:%s %s-duplex %s%s%s",
+ val->port_vlan,
+ rtl8366s_speed_str(data &
- (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
- "full" : "half",
- (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
- "tx-pause ": "",
- (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
- "rx-pause " : "",
- (data & RTL8366S_PORT_STATUS_AN_MASK) ? "nway ": "");
+ (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
+ "full" : "half",
+ (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
+ "tx-pause ": "",
+ (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
+ "rx-pause " : "",
+ (data & RTL8366S_PORT_STATUS_AN_MASK) ?
+ "nway ": "");
+ } else {
+ len = snprintf(rtl->buf, sizeof(rtl->buf), "port:%d link: down",
+ val->port_vlan);
+ }
for (i = 0; i < RTL8366S_MIB_COUNT; ++i) {
len += snprintf(buf + len, sizeof(rtl->buf) - len,
"%d:%s\t", i, rtl8366s_mib_counters[i].name);
for (i = 0; i < RTL8366S_MIB_COUNT; ++i) {
len += snprintf(buf + len, sizeof(rtl->buf) - len,
"%d:%s\t", i, rtl8366s_mib_counters[i].name);
- struct rtl8366s *rtl = sw_to_rtl8366s(dev);
- struct rtl8366_smi *smi = &rtl->smi;
- int timeout = 10;
- u32 data;
-
- rtl8366_smi_write_reg(smi, RTL8366_RESET_CTRL_REG,
- RTL8366_CHIP_CTRL_RESET_HW);
- do {
- msleep(1);
- if (rtl8366_smi_read_reg(smi, RTL8366_RESET_CTRL_REG, &data))
- return -EIO;
-
- if (!(data & RTL8366_CHIP_CTRL_RESET_HW))
- break;
- } while (--timeout);
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ int err;
-static int rtl8366s_mii_init(struct rtl8366s *rtl)
-{
- int ret;
- int i;
-
- rtl->mii_bus = mdiobus_alloc();
- if (rtl->mii_bus == NULL) {
- ret = -ENOMEM;
- goto err;
- }
-
- rtl->mii_bus->priv = (void *) rtl;
- rtl->mii_bus->name = "rtl8366-rtl";
- rtl->mii_bus->read = rtl8366s_mii_read;
- rtl->mii_bus->write = rtl8366s_mii_write;
- snprintf(rtl->mii_bus->id, MII_BUS_ID_SIZE, "%s",
- dev_name(rtl->parent));
- rtl->mii_bus->parent = rtl->parent;
- rtl->mii_bus->phy_mask = ~(0x1f);
- rtl->mii_bus->irq = rtl->mii_irq;
- for (i = 0; i < PHY_MAX_ADDR; i++)
- rtl->mii_irq[i] = PHY_POLL;
-
- ret = mdiobus_register(rtl->mii_bus);
- if (ret)
- goto err_free;
-
- return 0;
-
- err_free:
- mdiobus_free(rtl->mii_bus);
- err:
- return ret;
-}
-
-static void rtl8366s_mii_cleanup(struct rtl8366s *rtl)
-{
- mdiobus_unregister(rtl->mii_bus);
- mdiobus_free(rtl->mii_bus);
-}
-