Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <davem@davemloft.net>

+89 -53
+89 -53
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
··· 289 289 int err; 290 290 291 291 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); 293 293 return -EEXIST; 294 294 } 295 295 ··· 1509 1509 struct device *dev = (struct device *)arg; 1510 1510 struct ethsw_core *ethsw = dev_get_drvdata(dev); 1511 1511 struct ethsw_port_priv *port_priv; 1512 - u32 status = ~0; 1513 1512 int err, if_id; 1514 1513 bool had_mac; 1514 + u32 status; 1515 1515 1516 1516 err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, 1517 1517 DPSW_IRQ_INDEX_IF, &status); ··· 1523 1523 if_id = (status & 0xFFFF0000) >> 16; 1524 1524 port_priv = ethsw->ports[if_id]; 1525 1525 1526 - if (status & DPSW_IRQ_EVENT_LINK_CHANGED) { 1526 + if (status & DPSW_IRQ_EVENT_LINK_CHANGED) 1527 1527 dpaa2_switch_port_link_state_update(port_priv->netdev); 1528 - dpaa2_switch_port_set_mac_addr(port_priv); 1529 - } 1530 1528 1531 1529 if (status & DPSW_IRQ_EVENT_ENDPOINT_CHANGED) { 1530 + dpaa2_switch_port_set_mac_addr(port_priv); 1532 1531 /* We can avoid locking because the "endpoint changed" IRQ 1533 1532 * handler is the only one who changes priv->mac at runtime, 1534 1533 * so we are not racing with anyone. ··· 1539 1540 dpaa2_switch_port_connect_mac(port_priv); 1540 1541 } 1541 1542 1542 - out: 1543 1543 err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, 1544 1544 DPSW_IRQ_INDEX_IF, status); 1545 1545 if (err) 1546 1546 dev_err(dev, "Can't clear irq status (err %d)\n", err); 1547 1547 1548 + out: 1548 1549 return IRQ_HANDLED; 1549 1550 } 1550 1551 1551 1552 static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev) 1552 1553 { 1554 + u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED | DPSW_IRQ_EVENT_ENDPOINT_CHANGED; 1553 1555 struct device *dev = &sw_dev->dev; 1554 1556 struct ethsw_core *ethsw = dev_get_drvdata(dev); 1555 - u32 mask = DPSW_IRQ_EVENT_LINK_CHANGED; 1556 1557 struct fsl_mc_device_irq *irq; 1557 1558 int err; 1558 1559 ··· 1774 1775 /* Make sure that the VLAN is not already configured 1775 1776 * on the switch port 1776 1777 */ 1777 - if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER) 1778 + if (port_priv->vlans[vlan->vid] & ETHSW_VLAN_MEMBER) { 1779 + netdev_err(netdev, "VLAN %d already configured\n", vlan->vid); 1778 1780 return -EEXIST; 1781 + } 1779 1782 1780 1783 /* Check if there is space for a new VLAN */ 1781 1784 err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, ··· 2004 2003 struct netlink_ext_ack *extack) 2005 2004 { 2006 2005 struct ethsw_port_priv *port_priv = netdev_priv(netdev); 2006 + struct dpaa2_switch_fdb *old_fdb = port_priv->fdb; 2007 2007 struct ethsw_core *ethsw = port_priv->ethsw_data; 2008 - struct ethsw_port_priv *other_port_priv; 2009 - struct net_device *other_dev; 2010 - struct list_head *iter; 2011 2008 bool learn_ena; 2012 2009 int err; 2013 - 2014 - netdev_for_each_lower_dev(upper_dev, other_dev, iter) { 2015 - if (!dpaa2_switch_port_dev_check(other_dev)) 2016 - continue; 2017 - 2018 - other_port_priv = netdev_priv(other_dev); 2019 - if (other_port_priv->ethsw_data != port_priv->ethsw_data) { 2020 - NL_SET_ERR_MSG_MOD(extack, 2021 - "Interface from a different DPSW is in the bridge already"); 2022 - return -EINVAL; 2023 - } 2024 - } 2025 2010 2026 2011 /* Delete the previously manually installed VLAN 1 */ 2027 2012 err = dpaa2_switch_port_del_vlan(port_priv, 1); ··· 2023 2036 2024 2037 /* Setup the egress flood policy (broadcast, unknown unicast) */ 2025 2038 err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); 2039 + if (err) 2040 + goto err_egress_flood; 2041 + 2042 + /* Recreate the egress flood domain of the FDB that we just left. */ 2043 + err = dpaa2_switch_fdb_set_egress_flood(ethsw, old_fdb->fdb_id); 2026 2044 if (err) 2027 2045 goto err_egress_flood; 2028 2046 ··· 2147 2155 struct net_device *upper_dev, 2148 2156 struct netlink_ext_ack *extack) 2149 2157 { 2158 + struct ethsw_port_priv *port_priv = netdev_priv(netdev); 2159 + struct ethsw_port_priv *other_port_priv; 2160 + struct net_device *other_dev; 2161 + struct list_head *iter; 2150 2162 int err; 2151 2163 2152 2164 if (!br_vlan_enabled(upper_dev)) { ··· 2165 2169 return 0; 2166 2170 } 2167 2171 2172 + netdev_for_each_lower_dev(upper_dev, other_dev, iter) { 2173 + if (!dpaa2_switch_port_dev_check(other_dev)) 2174 + continue; 2175 + 2176 + other_port_priv = netdev_priv(other_dev); 2177 + if (other_port_priv->ethsw_data != port_priv->ethsw_data) { 2178 + NL_SET_ERR_MSG_MOD(extack, 2179 + "Interface from a different DPSW is in the bridge already"); 2180 + return -EINVAL; 2181 + } 2182 + } 2183 + 2184 + return 0; 2185 + } 2186 + 2187 + static int dpaa2_switch_port_prechangeupper(struct net_device *netdev, 2188 + struct netdev_notifier_changeupper_info *info) 2189 + { 2190 + struct netlink_ext_ack *extack; 2191 + struct net_device *upper_dev; 2192 + int err; 2193 + 2194 + if (!dpaa2_switch_port_dev_check(netdev)) 2195 + return 0; 2196 + 2197 + extack = netdev_notifier_info_to_extack(&info->info); 2198 + upper_dev = info->upper_dev; 2199 + if (netif_is_bridge_master(upper_dev)) { 2200 + err = dpaa2_switch_prechangeupper_sanity_checks(netdev, 2201 + upper_dev, 2202 + extack); 2203 + if (err) 2204 + return err; 2205 + 2206 + if (!info->linking) 2207 + dpaa2_switch_port_pre_bridge_leave(netdev); 2208 + } 2209 + 2210 + return 0; 2211 + } 2212 + 2213 + static int dpaa2_switch_port_changeupper(struct net_device *netdev, 2214 + struct netdev_notifier_changeupper_info *info) 2215 + { 2216 + struct netlink_ext_ack *extack; 2217 + struct net_device *upper_dev; 2218 + 2219 + if (!dpaa2_switch_port_dev_check(netdev)) 2220 + return 0; 2221 + 2222 + extack = netdev_notifier_info_to_extack(&info->info); 2223 + 2224 + upper_dev = info->upper_dev; 2225 + if (netif_is_bridge_master(upper_dev)) { 2226 + if (info->linking) 2227 + return dpaa2_switch_port_bridge_join(netdev, 2228 + upper_dev, 2229 + extack); 2230 + else 2231 + return dpaa2_switch_port_bridge_leave(netdev); 2232 + } 2233 + 2168 2234 return 0; 2169 2235 } 2170 2236 ··· 2234 2176 unsigned long event, void *ptr) 2235 2177 { 2236 2178 struct net_device *netdev = netdev_notifier_info_to_dev(ptr); 2237 - struct netdev_notifier_changeupper_info *info = ptr; 2238 - struct netlink_ext_ack *extack; 2239 - struct net_device *upper_dev; 2240 2179 int err = 0; 2241 - 2242 - if (!dpaa2_switch_port_dev_check(netdev)) 2243 - return NOTIFY_DONE; 2244 - 2245 - extack = netdev_notifier_info_to_extack(&info->info); 2246 2180 2247 2181 switch (event) { 2248 2182 case NETDEV_PRECHANGEUPPER: 2249 - upper_dev = info->upper_dev; 2250 - if (!netif_is_bridge_master(upper_dev)) 2251 - break; 2252 - 2253 - err = dpaa2_switch_prechangeupper_sanity_checks(netdev, 2254 - upper_dev, 2255 - extack); 2183 + err = dpaa2_switch_port_prechangeupper(netdev, ptr); 2256 2184 if (err) 2257 - goto out; 2258 - 2259 - if (!info->linking) 2260 - dpaa2_switch_port_pre_bridge_leave(netdev); 2185 + return notifier_from_errno(err); 2261 2186 2262 2187 break; 2263 2188 case NETDEV_CHANGEUPPER: 2264 - upper_dev = info->upper_dev; 2265 - if (netif_is_bridge_master(upper_dev)) { 2266 - if (info->linking) 2267 - err = dpaa2_switch_port_bridge_join(netdev, 2268 - upper_dev, 2269 - extack); 2270 - else 2271 - err = dpaa2_switch_port_bridge_leave(netdev); 2272 - } 2189 + err = dpaa2_switch_port_changeupper(netdev, ptr); 2190 + if (err) 2191 + return notifier_from_errno(err); 2192 + 2273 2193 break; 2274 2194 } 2275 2195 2276 - out: 2277 - return notifier_from_errno(err); 2196 + return NOTIFY_DONE; 2278 2197 } 2279 2198 2280 2199 struct ethsw_switchdev_event_work { ··· 3329 3294 port_netdev->features = NETIF_F_HW_VLAN_CTAG_FILTER | 3330 3295 NETIF_F_HW_VLAN_STAG_FILTER | 3331 3296 NETIF_F_HW_TC; 3297 + port_netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; 3332 3298 3333 3299 err = dpaa2_switch_port_init(port_priv, port_idx); 3334 3300 if (err)