}
EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_mib);
+int rtl8366_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats,
+ int txb_id, int rxb_id)
+{
+ struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
+ unsigned long long counter = 0;
+ int ret;
+
+ if (port >= smi->num_ports)
+ return -EINVAL;
+
+ ret = smi->ops->get_mib_counter(smi, txb_id, port, &counter);
+ if (ret)
+ return ret;
+
+ stats->tx_bytes = counter;
+
+ ret = smi->ops->get_mib_counter(smi, rxb_id, port, &counter);
+ if (ret)
+ return ret;
+
+ stats->rx_bytes = counter;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rtl8366_sw_get_port_stats);
+
int rtl8366_sw_get_vlan_info(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val)
int rtl8366_sw_set_vlan_enable(struct switch_dev *dev,
const struct switch_attr *attr,
struct switch_val *val);
+int rtl8366_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats,
+ int txb_id, int rxb_id);
struct rtl8366_smi* rtl8366_smi_probe(struct platform_device *pdev);
#define RTL8366RB_QOS_DEFAULT_PREIFG 1
+#define RTL8366RB_MIB_RXB_ID 0 /* IfInOctets */
+#define RTL8366RB_MIB_TXB_ID 20 /* IfOutOctets */
+
static struct rtl8366_mib_counter rtl8366rb_mib_counters[] = {
{ 0, 0, 4, "IfInOctets" },
{ 0, 4, 4, "EtherStatsOctets" },
RTL8366RB_MIB_CTRL_PORT_RESET(val->port_vlan));
}
+static int rtl8366rb_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats)
+{
+ return (rtl8366_sw_get_port_stats(dev, port, stats,
+ RTL8366RB_MIB_TXB_ID, RTL8366RB_MIB_RXB_ID));
+}
+
static struct switch_attr rtl8366rb_globals[] = {
{
.type = SWITCH_TYPE_INT,
.set_port_pvid = rtl8366_sw_set_port_pvid,
.reset_switch = rtl8366_sw_reset_switch,
.get_port_link = rtl8366rb_sw_get_port_link,
+ .get_port_stats = rtl8366rb_sw_get_port_stats,
};
static int rtl8366rb_switch_init(struct rtl8366_smi *smi)
#define RTL8366S_VLAN_FID_SHIFT 12
#define RTL8366S_VLAN_FID_MASK 0x7
+#define RTL8366S_MIB_RXB_ID 0 /* IfInOctets */
+#define RTL8366S_MIB_TXB_ID 20 /* IfOutOctets */
+
static struct rtl8366_mib_counter rtl8366s_mib_counters[] = {
{ 0, 0, 4, "IfInOctets" },
{ 0, 4, 4, "EtherStatsOctets" },
0, (1 << (val->port_vlan + 3)));
}
+static int rtl8366s_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats)
+{
+ return (rtl8366_sw_get_port_stats(dev, port, stats,
+ RTL8366S_MIB_TXB_ID, RTL8366S_MIB_RXB_ID));
+}
+
static struct switch_attr rtl8366s_globals[] = {
{
.type = SWITCH_TYPE_INT,
.set_port_pvid = rtl8366_sw_set_port_pvid,
.reset_switch = rtl8366_sw_reset_switch,
.get_port_link = rtl8366s_sw_get_port_link,
+ .get_port_stats = rtl8366s_sw_get_port_stats,
};
static int rtl8366s_switch_init(struct rtl8366_smi *smi)
u16 val;
};
+#define RTL8367_MIB_RXB_ID 0 /* IfInOctets */
+#define RTL8367_MIB_TXB_ID 20 /* IfOutOctets */
+
static struct rtl8366_mib_counter rtl8367_mib_counters[] = {
{ 0, 0, 4, "IfInOctets" },
{ 0, 4, 2, "Dot3StatsFCSErrors" },
RTL8367_MIB_CTRL_PORT_RESET_MASK(port % 8));
}
+static int rtl8367_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats)
+{
+ return (rtl8366_sw_get_port_stats(dev, port, stats,
+ RTL8367_MIB_TXB_ID, RTL8367_MIB_RXB_ID));
+}
+
static struct switch_attr rtl8367_globals[] = {
{
.type = SWITCH_TYPE_INT,
.set_port_pvid = rtl8366_sw_set_port_pvid,
.reset_switch = rtl8366_sw_reset_switch,
.get_port_link = rtl8367_sw_get_port_link,
+ .get_port_stats = rtl8367_sw_get_port_stats,
};
static int rtl8367_switch_init(struct rtl8366_smi *smi)
u16 val;
};
+#define RTL8367B_MIB_RXB_ID 0 /* IfInOctets */
+#define RTL8367B_MIB_TXB_ID 28 /* IfOutOctets */
+
static struct rtl8366_mib_counter
rtl8367b_mib_counters[RTL8367B_NUM_MIB_COUNTERS] = {
{0, 0, 4, "ifInOctets" },
RTL8367B_MIB_CTRL0_PORT_RESET_MASK(port % 8));
}
+static int rtl8367b_sw_get_port_stats(struct switch_dev *dev, int port,
+ struct switch_port_stats *stats)
+{
+ return (rtl8366_sw_get_port_stats(dev, port, stats,
+ RTL8367B_MIB_TXB_ID, RTL8367B_MIB_RXB_ID));
+}
+
static struct switch_attr rtl8367b_globals[] = {
{
.type = SWITCH_TYPE_INT,
.set_port_pvid = rtl8366_sw_set_port_pvid,
.reset_switch = rtl8366_sw_reset_switch,
.get_port_link = rtl8367b_sw_get_port_link,
+ .get_port_stats = rtl8367b_sw_get_port_stats,
};
static int rtl8367b_switch_init(struct rtl8366_smi *smi)