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

net: dsa: propagate extack to ds->ops->port_hsr_join()

Drivers can provide meaningful error messages which state a reason why
they can't perform an offload, and dsa_slave_changeupper() already has
the infrastructure to propagate these over netlink rather than printing
to the kernel log. So pass the extack argument and modify the xrs700x
driver's port_hsr_join() prototype.

Also take the opportunity and use the extack for the 2 -EOPNOTSUPP cases
from xrs700x_hsr_join().

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Vladimir Oltean and committed by
Paolo Abeni
fefe5dc4 e27aca37

+20 -11
+12 -6
drivers/net/dsa/xrs700x/xrs700x.c
··· 548 548 } 549 549 550 550 static int xrs700x_hsr_join(struct dsa_switch *ds, int port, 551 - struct net_device *hsr) 551 + struct net_device *hsr, 552 + struct netlink_ext_ack *extack) 552 553 { 553 554 unsigned int val = XRS_HSR_CFG_HSR_PRP; 554 555 struct dsa_port *partner = NULL, *dp; ··· 563 562 if (ret) 564 563 return ret; 565 564 566 - /* Only ports 1 and 2 can be HSR/PRP redundant ports. */ 567 - if (port != 1 && port != 2) 565 + if (port != 1 && port != 2) { 566 + NL_SET_ERR_MSG_MOD(extack, 567 + "Only ports 1 and 2 can offload HSR/PRP"); 568 568 return -EOPNOTSUPP; 569 + } 569 570 570 - if (ver == HSR_V1) 571 + if (ver == HSR_V1) { 571 572 val |= XRS_HSR_CFG_HSR; 572 - else if (ver == PRP_V1) 573 + } else if (ver == PRP_V1) { 573 574 val |= XRS_HSR_CFG_PRP; 574 - else 575 + } else { 576 + NL_SET_ERR_MSG_MOD(extack, 577 + "Only HSR v1 and PRP v1 can be offloaded"); 575 578 return -EOPNOTSUPP; 579 + } 576 580 577 581 dsa_hsr_foreach_port(dp, ds, hsr) { 578 582 if (dp->index != port) {
+2 -1
include/net/dsa.h
··· 1198 1198 * HSR integration 1199 1199 */ 1200 1200 int (*port_hsr_join)(struct dsa_switch *ds, int port, 1201 - struct net_device *hsr); 1201 + struct net_device *hsr, 1202 + struct netlink_ext_ack *extack); 1202 1203 int (*port_hsr_leave)(struct dsa_switch *ds, int port, 1203 1204 struct net_device *hsr); 1204 1205
+3 -2
net/dsa/port.c
··· 2024 2024 dsa_shared_port_setup_phy_of(dp, false); 2025 2025 } 2026 2026 2027 - int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr) 2027 + int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr, 2028 + struct netlink_ext_ack *extack) 2028 2029 { 2029 2030 struct dsa_switch *ds = dp->ds; 2030 2031 int err; ··· 2035 2034 2036 2035 dp->hsr_dev = hsr; 2037 2036 2038 - err = ds->ops->port_hsr_join(ds, dp->index, hsr); 2037 + err = ds->ops->port_hsr_join(ds, dp->index, hsr, extack); 2039 2038 if (err) 2040 2039 dp->hsr_dev = NULL; 2041 2040
+2 -1
net/dsa/port.h
··· 103 103 void dsa_port_phylink_destroy(struct dsa_port *dp); 104 104 int dsa_shared_port_link_register_of(struct dsa_port *dp); 105 105 void dsa_shared_port_link_unregister_of(struct dsa_port *dp); 106 - int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr); 106 + int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr, 107 + struct netlink_ext_ack *extack); 107 108 void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr); 108 109 int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast); 109 110 void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast);
+1 -1
net/dsa/slave.c
··· 2862 2862 } 2863 2863 } else if (is_hsr_master(info->upper_dev)) { 2864 2864 if (info->linking) { 2865 - err = dsa_port_hsr_join(dp, info->upper_dev); 2865 + err = dsa_port_hsr_join(dp, info->upper_dev, extack); 2866 2866 if (err == -EOPNOTSUPP) { 2867 2867 NL_SET_ERR_MSG_WEAK_MOD(extack, 2868 2868 "Offloading not supported");