]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: mscc: ocelot: transmit the "native VLAN" error via extack
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 19 Aug 2021 17:40:06 +0000 (20:40 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Aug 2021 13:39:52 +0000 (14:39 +0100)
We need to reject some more configurations in future patches, convert
the existing one to netlink extack.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/ocelot/felix.c
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/mscc/ocelot_net.c
include/soc/mscc/ocelot.h

index cbe23b20f3fa8212ec7c194f20172d00b6bd32ab..72d746f11fb9a353a5495b25040b4c6fb5ca165a 100644 (file)
@@ -742,7 +742,8 @@ static int felix_lag_change(struct dsa_switch *ds, int port)
 }
 
 static int felix_vlan_prepare(struct dsa_switch *ds, int port,
-                             const struct switchdev_obj_port_vlan *vlan)
+                             const struct switchdev_obj_port_vlan *vlan,
+                             struct netlink_ext_ack *extack)
 {
        struct ocelot *ocelot = ds->priv;
        u16 flags = vlan->flags;
@@ -760,7 +761,8 @@ static int felix_vlan_prepare(struct dsa_switch *ds, int port,
 
        return ocelot_vlan_prepare(ocelot, port, vlan->vid,
                                   flags & BRIDGE_VLAN_INFO_PVID,
-                                  flags & BRIDGE_VLAN_INFO_UNTAGGED);
+                                  flags & BRIDGE_VLAN_INFO_UNTAGGED,
+                                  extack);
 }
 
 static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
@@ -779,7 +781,7 @@ static int felix_vlan_add(struct dsa_switch *ds, int port,
        u16 flags = vlan->flags;
        int err;
 
-       err = felix_vlan_prepare(ds, port, vlan);
+       err = felix_vlan_prepare(ds, port, vlan, extack);
        if (err)
                return err;
 
index 8ec194178aa2bd0c2533a99bb01bff662feff6be..ccb8a9863890123fa6c25e628757faeb60e8325e 100644 (file)
@@ -259,16 +259,15 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
 EXPORT_SYMBOL(ocelot_port_vlan_filtering);
 
 int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
-                       bool untagged)
+                       bool untagged, struct netlink_ext_ack *extack)
 {
        struct ocelot_port *ocelot_port = ocelot->ports[port];
 
        /* Deny changing the native VLAN, but always permit deleting it */
        if (untagged && ocelot_port->native_vlan.vid != vid &&
            ocelot_port->native_vlan.valid) {
-               dev_err(ocelot->dev,
-                       "Port already has a native VLAN: %d\n",
-                       ocelot_port->native_vlan.vid);
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "Port already has a native VLAN");
                return -EBUSY;
        }
 
index 9044737936d21b452e9478e45bfad083491666cc..690f39e9351bf6dfc5e7cc7fe961aeeb3f70ec4a 100644 (file)
@@ -386,17 +386,6 @@ static int ocelot_setup_tc(struct net_device *dev, enum tc_setup_type type,
        return 0;
 }
 
-static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid,
-                                  bool untagged)
-{
-       struct ocelot_port_private *priv = netdev_priv(dev);
-       struct ocelot_port *ocelot_port = &priv->port;
-       struct ocelot *ocelot = ocelot_port->ocelot;
-       int port = priv->chip_port;
-
-       return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged);
-}
-
 static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
                               bool untagged)
 {
@@ -944,14 +933,26 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx,
        return err;
 }
 
+static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid,
+                                  bool untagged, struct netlink_ext_ack *extack)
+{
+       struct ocelot_port_private *priv = netdev_priv(dev);
+       struct ocelot_port *ocelot_port = &priv->port;
+       struct ocelot *ocelot = ocelot_port->ocelot;
+       int port = priv->chip_port;
+
+       return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack);
+}
+
 static int ocelot_port_obj_add_vlan(struct net_device *dev,
-                                   const struct switchdev_obj_port_vlan *vlan)
+                                   const struct switchdev_obj_port_vlan *vlan,
+                                   struct netlink_ext_ack *extack)
 {
        bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
        bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
        int ret;
 
-       ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged);
+       ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged, extack);
        if (ret)
                return ret;
 
@@ -1039,7 +1040,8 @@ static int ocelot_port_obj_add(struct net_device *dev, const void *ctx,
        switch (obj->id) {
        case SWITCHDEV_OBJ_ID_PORT_VLAN:
                ret = ocelot_port_obj_add_vlan(dev,
-                                              SWITCHDEV_OBJ_PORT_VLAN(obj));
+                                              SWITCHDEV_OBJ_PORT_VLAN(obj),
+                                              extack);
                break;
        case SWITCHDEV_OBJ_ID_PORT_MDB:
                ret = ocelot_port_obj_add_mdb(dev, SWITCHDEV_OBJ_PORT_MDB(obj));
index fb5681f7e61b60f332ce58ac6d4a31bf1fd18945..ac072303dadfbd6749833eb89e69aa30e26bfaf9 100644 (file)
@@ -825,7 +825,7 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port,
 int ocelot_fdb_del(struct ocelot *ocelot, int port,
                   const unsigned char *addr, u16 vid);
 int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
-                       bool untagged);
+                       bool untagged, struct netlink_ext_ack *extack);
 int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
                    bool untagged);
 int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);