Lines Matching +full:realtek +full:- +full:smi

1 // SPDX-License-Identifier: GPL-2.0
2 /* Realtek SMI library helpers for the RTL8366x variants
6 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
14 #include "realtek.h"
22 for (i = 0; i < priv->num_ports; i++) { in rtl8366_mc_is_used()
25 ret = priv->ops->get_mc_index(priv, i, &index); in rtl8366_mc_is_used()
40 * rtl8366_obtain_mc() - retrieve or allocate a VLAN member configuration
41 * @priv: the Realtek SMI device instance
55 for (i = 0; i < priv->num_vlan_mc; i++) { in rtl8366_obtain_mc()
56 ret = priv->ops->get_vlan_mc(priv, i, vlanmc); in rtl8366_obtain_mc()
58 dev_err(priv->dev, "error searching for VLAN MC %d for VID %d\n", in rtl8366_obtain_mc()
63 if (vid == vlanmc->vid) in rtl8366_obtain_mc()
68 for (i = 0; i < priv->num_vlan_mc; i++) { in rtl8366_obtain_mc()
69 ret = priv->ops->get_vlan_mc(priv, i, vlanmc); in rtl8366_obtain_mc()
71 dev_err(priv->dev, "error searching for VLAN MC %d for VID %d\n", in rtl8366_obtain_mc()
76 if (vlanmc->vid == 0 && vlanmc->member == 0) { in rtl8366_obtain_mc()
78 ret = priv->ops->get_vlan_4k(priv, vid, &vlan4k); in rtl8366_obtain_mc()
80 dev_err(priv->dev, "error looking for 4K VLAN MC %d for VID %d\n", in rtl8366_obtain_mc()
85 vlanmc->vid = vid; in rtl8366_obtain_mc()
86 vlanmc->member = vlan4k.member; in rtl8366_obtain_mc()
87 vlanmc->untag = vlan4k.untag; in rtl8366_obtain_mc()
88 vlanmc->fid = vlan4k.fid; in rtl8366_obtain_mc()
89 ret = priv->ops->set_vlan_mc(priv, i, vlanmc); in rtl8366_obtain_mc()
91 dev_err(priv->dev, "unable to set/update VLAN MC %d for VID %d\n", in rtl8366_obtain_mc()
96 dev_dbg(priv->dev, "created new MC at index %d for VID %d\n", in rtl8366_obtain_mc()
103 for (i = 0; i < priv->num_vlan_mc; i++) { in rtl8366_obtain_mc()
112 ret = priv->ops->get_vlan_4k(priv, vid, &vlan4k); in rtl8366_obtain_mc()
116 vlanmc->vid = vid; in rtl8366_obtain_mc()
117 vlanmc->member = vlan4k.member; in rtl8366_obtain_mc()
118 vlanmc->untag = vlan4k.untag; in rtl8366_obtain_mc()
119 vlanmc->fid = vlan4k.fid; in rtl8366_obtain_mc()
120 ret = priv->ops->set_vlan_mc(priv, i, vlanmc); in rtl8366_obtain_mc()
122 dev_err(priv->dev, "unable to set/update VLAN MC %d for VID %d\n", in rtl8366_obtain_mc()
126 dev_dbg(priv->dev, "recycled MC at index %i for VID %d\n", in rtl8366_obtain_mc()
132 dev_err(priv->dev, "all VLAN member configurations are in use\n"); in rtl8366_obtain_mc()
133 return -ENOSPC; in rtl8366_obtain_mc()
144 if (!priv->ops->is_vlan_valid(priv, vid)) in rtl8366_set_vlan()
145 return -EINVAL; in rtl8366_set_vlan()
147 dev_dbg(priv->dev, in rtl8366_set_vlan()
152 ret = priv->ops->get_vlan_4k(priv, vid, &vlan4k); in rtl8366_set_vlan()
159 ret = priv->ops->set_vlan_4k(priv, &vlan4k); in rtl8366_set_vlan()
163 dev_dbg(priv->dev, in rtl8366_set_vlan()
179 ret = priv->ops->set_vlan_mc(priv, mc, &vlanmc); in rtl8366_set_vlan()
181 dev_err(priv->dev, "failed to commit changes to VLAN MC index %d for VID %d\n", in rtl8366_set_vlan()
184 dev_dbg(priv->dev, in rtl8366_set_vlan()
199 if (!priv->ops->is_vlan_valid(priv, vid)) in rtl8366_set_pvid()
200 return -EINVAL; in rtl8366_set_pvid()
208 ret = priv->ops->set_mc_index(priv, port, mc); in rtl8366_set_pvid()
210 dev_err(priv->dev, "set PVID: failed to set MC index %d for port %d\n", in rtl8366_set_pvid()
215 dev_dbg(priv->dev, "set PVID: the PVID for port %d set to %d using existing MC index %d\n", in rtl8366_set_pvid()
232 ret = priv->ops->enable_vlan(priv, true); in rtl8366_enable_vlan4k()
236 priv->vlan_enabled = true; in rtl8366_enable_vlan4k()
239 ret = priv->ops->enable_vlan4k(priv, enable); in rtl8366_enable_vlan4k()
243 priv->vlan4k_enabled = enable; in rtl8366_enable_vlan4k()
252 ret = priv->ops->enable_vlan(priv, enable); in rtl8366_enable_vlan()
256 priv->vlan_enabled = enable; in rtl8366_enable_vlan()
262 priv->vlan4k_enabled = false; in rtl8366_enable_vlan()
263 ret = priv->ops->enable_vlan4k(priv, false); in rtl8366_enable_vlan()
285 for (i = 0; i < priv->num_vlan_mc; i++) { in rtl8366_reset_vlan()
286 ret = priv->ops->set_vlan_mc(priv, i, &vlanmc); in rtl8366_reset_vlan()
299 bool untagged = !!(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED); in rtl8366_vlan_add()
300 bool pvid = !!(vlan->flags & BRIDGE_VLAN_INFO_PVID); in rtl8366_vlan_add()
301 struct realtek_priv *priv = ds->priv; in rtl8366_vlan_add()
306 if (!priv->ops->is_vlan_valid(priv, vlan->vid)) { in rtl8366_vlan_add()
308 return -EINVAL; in rtl8366_vlan_add()
321 dev_dbg(priv->dev, "add VLAN %d on port %d, %s, %s\n", in rtl8366_vlan_add()
322 vlan->vid, port, untagged ? "untagged" : "tagged", in rtl8366_vlan_add()
330 ret = rtl8366_set_vlan(priv, vlan->vid, member, untag, 0); in rtl8366_vlan_add()
332 dev_err(priv->dev, "failed to set up VLAN %04x", vlan->vid); in rtl8366_vlan_add()
339 ret = rtl8366_set_pvid(priv, port, vlan->vid); in rtl8366_vlan_add()
341 dev_err(priv->dev, "failed to set PVID on port %d to VLAN %04x", in rtl8366_vlan_add()
342 port, vlan->vid); in rtl8366_vlan_add()
353 struct realtek_priv *priv = ds->priv; in rtl8366_vlan_del()
356 dev_dbg(priv->dev, "del VLAN %d on port %d\n", vlan->vid, port); in rtl8366_vlan_del()
358 for (i = 0; i < priv->num_vlan_mc; i++) { in rtl8366_vlan_del()
361 ret = priv->ops->get_vlan_mc(priv, i, &vlanmc); in rtl8366_vlan_del()
365 if (vlan->vid == vlanmc.vid) { in rtl8366_vlan_del()
379 ret = priv->ops->set_vlan_mc(priv, i, &vlanmc); in rtl8366_vlan_del()
381 dev_err(priv->dev, in rtl8366_vlan_del()
383 vlan->vid); in rtl8366_vlan_del()
397 struct realtek_priv *priv = ds->priv; in rtl8366_get_strings()
400 if (port >= priv->num_ports) in rtl8366_get_strings()
403 for (i = 0; i < priv->num_mib_counters; i++) in rtl8366_get_strings()
404 ethtool_puts(&data, priv->mib_counters[i].name); in rtl8366_get_strings()
410 struct realtek_priv *priv = ds->priv; in rtl8366_get_sset_count()
415 if (port >= priv->num_ports) in rtl8366_get_sset_count()
416 return -EINVAL; in rtl8366_get_sset_count()
418 return priv->num_mib_counters; in rtl8366_get_sset_count()
424 struct realtek_priv *priv = ds->priv; in rtl8366_get_ethtool_stats()
428 if (port >= priv->num_ports) in rtl8366_get_ethtool_stats()
431 for (i = 0; i < priv->num_mib_counters; i++) { in rtl8366_get_ethtool_stats()
435 mib = &priv->mib_counters[i]; in rtl8366_get_ethtool_stats()
436 ret = priv->ops->get_mib_counter(priv, port, mib, &mibvalue); in rtl8366_get_ethtool_stats()
438 dev_err(priv->dev, "error reading MIB counter %s\n", in rtl8366_get_ethtool_stats()
439 mib->name); in rtl8366_get_ethtool_stats()