Skip to content

Commit 3b83fa9

Browse files
committed
Merge branch 'dpaa2-switch-small-improvements'
Ioana Ciornei says: ==================== dpaa2-switch: small improvements This patch set consists of a series of small improvements on the dpaa2-switch driver ranging from adding some more verbosity when encountering errors to reorganizing code to be easily extensible. Changes in v3: - 4/8: removed the fixes tag and moved it to the commit message - 5/8: specified that there is no user-visible effect - 6/8: removed the initialization of the err variable Changes in v2: - No changes to the actual diff, only rephrased some commit messages and added more information. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d11db8a + 71150d9 commit 3b83fa9

File tree

1 file changed

+84
-48
lines changed

1 file changed

+84
-48
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 84 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int dpaa2_switch_port_add_vlan(struct ethsw_port_priv *port_priv,
289289
int err;
290290

291291
if (port_priv->vlans[vid]) {
292-
netdev_warn(netdev, "VLAN %d already configured\n", vid);
292+
netdev_err(netdev, "VLAN %d already configured\n", vid);
293293
return -EEXIST;
294294
}
295295

@@ -1509,9 +1509,9 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
15091509
struct device *dev = (struct device *)arg;
15101510
struct ethsw_core *ethsw = dev_get_drvdata(dev);
15111511
struct ethsw_port_priv *port_priv;
1512-
u32 status = ~0;
15131512
int err, if_id;
15141513
bool had_mac;
1514+
u32 status;
15151515

15161516
err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
15171517
DPSW_IRQ_INDEX_IF, &status);
@@ -1523,12 +1523,11 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
15231523
if_id = (status & 0xFFFF0000) >> 16;
15241524
port_priv = ethsw->ports[if_id];
15251525

1526-
if (status & DPSW_IRQ_EVENT_LINK_CHANGED) {
1526+
if (status & DPSW_IRQ_EVENT_LINK_CHANGED)
15271527
dpaa2_switch_port_link_state_update(port_priv->netdev);
1528-
dpaa2_switch_port_set_mac_addr(port_priv);
1529-
}
15301528

15311529
if (status & DPSW_IRQ_EVENT_ENDPOINT_CHANGED) {
1530+
dpaa2_switch_port_set_mac_addr(port_priv);
15321531
/* We can avoid locking because the "endpoint changed" IRQ
15331532
* handler is the only one who changes priv->mac at runtime,
15341533
* so we are not racing with anyone.
@@ -1540,20 +1539,20 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
15401539
dpaa2_switch_port_connect_mac(port_priv);
15411540
}
15421541

1543-
out:
15441542
err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
15451543
DPSW_IRQ_INDEX_IF, status);
15461544
if (err)
15471545
dev_err(dev, "Can't clear irq status (err %d)\n", err);
15481546

1547+
out:
15491548
return IRQ_HANDLED;
15501549
}
15511550

15521551
static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
15531552
{
1553+
u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED | DPSW_IRQ_EVENT_ENDPOINT_CHANGED;
15541554
struct device *dev = &sw_dev->dev;
15551555
struct ethsw_core *ethsw = dev_get_drvdata(dev);
1556-
u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED;
15571556
struct fsl_mc_device_irq *irq;
15581557
int err;
15591558

@@ -1775,8 +1774,10 @@ int dpaa2_switch_port_vlans_add(struct net_device *netdev,
17751774
/* Make sure that the VLAN is not already configured
17761775
* on the switch port
17771776
*/
1778-
if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER)
1777+
if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER) {
1778+
netdev_err(netdev, "VLAN %d already configured\n", vlan->vid);
17791779
return -EEXIST;
1780+
}
17801781

17811782
/* Check if there is space for a new VLAN */
17821783
err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle,
@@ -2003,25 +2004,11 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
20032004
struct netlink_ext_ack *extack)
20042005
{
20052006
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
2007+
struct dpaa2_switch_fdb *old_fdb = port_priv->fdb;
20062008
struct ethsw_core *ethsw = port_priv->ethsw_data;
2007-
struct ethsw_port_priv *other_port_priv;
2008-
struct net_device *other_dev;
2009-
struct list_head *iter;
20102009
bool learn_ena;
20112010
int err;
20122011

2013-
netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
2014-
if (!dpaa2_switch_port_dev_check(other_dev))
2015-
continue;
2016-
2017-
other_port_priv = netdev_priv(other_dev);
2018-
if (other_port_priv->ethsw_data != port_priv->ethsw_data) {
2019-
NL_SET_ERR_MSG_MOD(extack,
2020-
"Interface from a different DPSW is in the bridge already");
2021-
return -EINVAL;
2022-
}
2023-
}
2024-
20252012
/* Delete the previously manually installed VLAN 1 */
20262013
err = dpaa2_switch_port_del_vlan(port_priv, 1);
20272014
if (err)
@@ -2039,6 +2026,11 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
20392026
if (err)
20402027
goto err_egress_flood;
20412028

2029+
/* Recreate the egress flood domain of the FDB that we just left. */
2030+
err = dpaa2_switch_fdb_set_egress_flood(ethsw, old_fdb->fdb_id);
2031+
if (err)
2032+
goto err_egress_flood;
2033+
20422034
err = switchdev_bridge_port_offload(netdev, netdev, NULL,
20432035
NULL, NULL, false, extack);
20442036
if (err)
@@ -2155,6 +2147,10 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
21552147
struct net_device *upper_dev,
21562148
struct netlink_ext_ack *extack)
21572149
{
2150+
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
2151+
struct ethsw_port_priv *other_port_priv;
2152+
struct net_device *other_dev;
2153+
struct list_head *iter;
21582154
int err;
21592155

21602156
if (!br_vlan_enabled(upper_dev)) {
@@ -2169,54 +2165,93 @@ dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
21692165
return 0;
21702166
}
21712167

2168+
netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
2169+
if (!dpaa2_switch_port_dev_check(other_dev))
2170+
continue;
2171+
2172+
other_port_priv = netdev_priv(other_dev);
2173+
if (other_port_priv->ethsw_data != port_priv->ethsw_data) {
2174+
NL_SET_ERR_MSG_MOD(extack,
2175+
"Interface from a different DPSW is in the bridge already");
2176+
return -EINVAL;
2177+
}
2178+
}
2179+
21722180
return 0;
21732181
}
21742182

2175-
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
2176-
unsigned long event, void *ptr)
2183+
static int dpaa2_switch_port_prechangeupper(struct net_device *netdev,
2184+
struct netdev_notifier_changeupper_info *info)
21772185
{
2178-
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
2179-
struct netdev_notifier_changeupper_info *info = ptr;
21802186
struct netlink_ext_ack *extack;
21812187
struct net_device *upper_dev;
2182-
int err = 0;
2188+
int err;
21832189

21842190
if (!dpaa2_switch_port_dev_check(netdev))
2185-
return NOTIFY_DONE;
2191+
return 0;
21862192

21872193
extack = netdev_notifier_info_to_extack(&info->info);
2188-
2189-
switch (event) {
2190-
case NETDEV_PRECHANGEUPPER:
2191-
upper_dev = info->upper_dev;
2192-
if (!netif_is_bridge_master(upper_dev))
2193-
break;
2194-
2194+
upper_dev = info->upper_dev;
2195+
if (netif_is_bridge_master(upper_dev)) {
21952196
err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
21962197
upper_dev,
21972198
extack);
21982199
if (err)
2199-
goto out;
2200+
return err;
22002201

22012202
if (!info->linking)
22022203
dpaa2_switch_port_pre_bridge_leave(netdev);
2204+
}
2205+
2206+
return 0;
2207+
}
2208+
2209+
static int dpaa2_switch_port_changeupper(struct net_device *netdev,
2210+
struct netdev_notifier_changeupper_info *info)
2211+
{
2212+
struct netlink_ext_ack *extack;
2213+
struct net_device *upper_dev;
2214+
2215+
if (!dpaa2_switch_port_dev_check(netdev))
2216+
return 0;
2217+
2218+
extack = netdev_notifier_info_to_extack(&info->info);
2219+
2220+
upper_dev = info->upper_dev;
2221+
if (netif_is_bridge_master(upper_dev)) {
2222+
if (info->linking)
2223+
return dpaa2_switch_port_bridge_join(netdev,
2224+
upper_dev,
2225+
extack);
2226+
else
2227+
return dpaa2_switch_port_bridge_leave(netdev);
2228+
}
2229+
2230+
return 0;
2231+
}
2232+
2233+
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
2234+
unsigned long event, void *ptr)
2235+
{
2236+
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
2237+
int err = 0;
2238+
2239+
switch (event) {
2240+
case NETDEV_PRECHANGEUPPER:
2241+
err = dpaa2_switch_port_prechangeupper(netdev, ptr);
2242+
if (err)
2243+
return notifier_from_errno(err);
22032244

22042245
break;
22052246
case NETDEV_CHANGEUPPER:
2206-
upper_dev = info->upper_dev;
2207-
if (netif_is_bridge_master(upper_dev)) {
2208-
if (info->linking)
2209-
err = dpaa2_switch_port_bridge_join(netdev,
2210-
upper_dev,
2211-
extack);
2212-
else
2213-
err = dpaa2_switch_port_bridge_leave(netdev);
2214-
}
2247+
err = dpaa2_switch_port_changeupper(netdev, ptr);
2248+
if (err)
2249+
return notifier_from_errno(err);
2250+
22152251
break;
22162252
}
22172253

2218-
out:
2219-
return notifier_from_errno(err);
2254+
return NOTIFY_DONE;
22202255
}
22212256

22222257
struct ethsw_switchdev_event_work {
@@ -3294,6 +3329,7 @@ static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
32943329
port_netdev->features = NETIF_F_HW_VLAN_CTAG_FILTER |
32953330
NETIF_F_HW_VLAN_STAG_FILTER |
32963331
NETIF_F_HW_TC;
3332+
port_netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
32973333

32983334
err = dpaa2_switch_port_init(port_priv, port_idx);
32993335
if (err)

0 commit comments

Comments
 (0)