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>
This commit is contained in:
parent
e27aca3760
commit
fefe5dc4af
@ -548,7 +548,8 @@ static void xrs700x_bridge_leave(struct dsa_switch *ds, int port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
|
static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
|
||||||
struct net_device *hsr)
|
struct net_device *hsr,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
unsigned int val = XRS_HSR_CFG_HSR_PRP;
|
unsigned int val = XRS_HSR_CFG_HSR_PRP;
|
||||||
struct dsa_port *partner = NULL, *dp;
|
struct dsa_port *partner = NULL, *dp;
|
||||||
@ -562,16 +563,21 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Only ports 1 and 2 can be HSR/PRP redundant ports. */
|
if (port != 1 && port != 2) {
|
||||||
if (port != 1 && port != 2)
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
|
"Only ports 1 and 2 can offload HSR/PRP");
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
if (ver == HSR_V1)
|
if (ver == HSR_V1) {
|
||||||
val |= XRS_HSR_CFG_HSR;
|
val |= XRS_HSR_CFG_HSR;
|
||||||
else if (ver == PRP_V1)
|
} else if (ver == PRP_V1) {
|
||||||
val |= XRS_HSR_CFG_PRP;
|
val |= XRS_HSR_CFG_PRP;
|
||||||
else
|
} else {
|
||||||
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
|
"Only HSR v1 and PRP v1 can be offloaded");
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
dsa_hsr_foreach_port(dp, ds, hsr) {
|
dsa_hsr_foreach_port(dp, ds, hsr) {
|
||||||
if (dp->index != port) {
|
if (dp->index != port) {
|
||||||
|
@ -1198,7 +1198,8 @@ struct dsa_switch_ops {
|
|||||||
* HSR integration
|
* HSR integration
|
||||||
*/
|
*/
|
||||||
int (*port_hsr_join)(struct dsa_switch *ds, int port,
|
int (*port_hsr_join)(struct dsa_switch *ds, int port,
|
||||||
struct net_device *hsr);
|
struct net_device *hsr,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
int (*port_hsr_leave)(struct dsa_switch *ds, int port,
|
int (*port_hsr_leave)(struct dsa_switch *ds, int port,
|
||||||
struct net_device *hsr);
|
struct net_device *hsr);
|
||||||
|
|
||||||
|
@ -2024,7 +2024,8 @@ void dsa_shared_port_link_unregister_of(struct dsa_port *dp)
|
|||||||
dsa_shared_port_setup_phy_of(dp, false);
|
dsa_shared_port_setup_phy_of(dp, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr)
|
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct dsa_switch *ds = dp->ds;
|
struct dsa_switch *ds = dp->ds;
|
||||||
int err;
|
int err;
|
||||||
@ -2034,7 +2035,7 @@ int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr)
|
|||||||
|
|
||||||
dp->hsr_dev = hsr;
|
dp->hsr_dev = hsr;
|
||||||
|
|
||||||
err = ds->ops->port_hsr_join(ds, dp->index, hsr);
|
err = ds->ops->port_hsr_join(ds, dp->index, hsr, extack);
|
||||||
if (err)
|
if (err)
|
||||||
dp->hsr_dev = NULL;
|
dp->hsr_dev = NULL;
|
||||||
|
|
||||||
|
@ -103,7 +103,8 @@ int dsa_port_phylink_create(struct dsa_port *dp);
|
|||||||
void dsa_port_phylink_destroy(struct dsa_port *dp);
|
void dsa_port_phylink_destroy(struct dsa_port *dp);
|
||||||
int dsa_shared_port_link_register_of(struct dsa_port *dp);
|
int dsa_shared_port_link_register_of(struct dsa_port *dp);
|
||||||
void dsa_shared_port_link_unregister_of(struct dsa_port *dp);
|
void dsa_shared_port_link_unregister_of(struct dsa_port *dp);
|
||||||
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr);
|
int dsa_port_hsr_join(struct dsa_port *dp, struct net_device *hsr,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr);
|
void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr);
|
||||||
int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast);
|
int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast);
|
||||||
void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast);
|
void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast);
|
||||||
|
@ -2862,7 +2862,7 @@ static int dsa_slave_changeupper(struct net_device *dev,
|
|||||||
}
|
}
|
||||||
} else if (is_hsr_master(info->upper_dev)) {
|
} else if (is_hsr_master(info->upper_dev)) {
|
||||||
if (info->linking) {
|
if (info->linking) {
|
||||||
err = dsa_port_hsr_join(dp, info->upper_dev);
|
err = dsa_port_hsr_join(dp, info->upper_dev, extack);
|
||||||
if (err == -EOPNOTSUPP) {
|
if (err == -EOPNOTSUPP) {
|
||||||
NL_SET_ERR_MSG_WEAK_MOD(extack,
|
NL_SET_ERR_MSG_WEAK_MOD(extack,
|
||||||
"Offloading not supported");
|
"Offloading not supported");
|
||||||
|
Loading…
Reference in New Issue
Block a user