Skip to content

Commit 01af940

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: transmit the "native VLAN" error via extack
We need to reject some more configurations in future patches, convert the existing one to netlink extack. Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f2aea90 commit 01af940

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

drivers/net/dsa/ocelot/felix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ static int felix_lag_change(struct dsa_switch *ds, int port)
742742
}
743743

744744
static int felix_vlan_prepare(struct dsa_switch *ds, int port,
745-
const struct switchdev_obj_port_vlan *vlan)
745+
const struct switchdev_obj_port_vlan *vlan,
746+
struct netlink_ext_ack *extack)
746747
{
747748
struct ocelot *ocelot = ds->priv;
748749
u16 flags = vlan->flags;
@@ -760,7 +761,8 @@ static int felix_vlan_prepare(struct dsa_switch *ds, int port,
760761

761762
return ocelot_vlan_prepare(ocelot, port, vlan->vid,
762763
flags & BRIDGE_VLAN_INFO_PVID,
763-
flags & BRIDGE_VLAN_INFO_UNTAGGED);
764+
flags & BRIDGE_VLAN_INFO_UNTAGGED,
765+
extack);
764766
}
765767

766768
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,
779781
u16 flags = vlan->flags;
780782
int err;
781783

782-
err = felix_vlan_prepare(ds, port, vlan);
784+
err = felix_vlan_prepare(ds, port, vlan, extack);
783785
if (err)
784786
return err;
785787

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,15 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
259259
EXPORT_SYMBOL(ocelot_port_vlan_filtering);
260260

261261
int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
262-
bool untagged)
262+
bool untagged, struct netlink_ext_ack *extack)
263263
{
264264
struct ocelot_port *ocelot_port = ocelot->ports[port];
265265

266266
/* Deny changing the native VLAN, but always permit deleting it */
267267
if (untagged && ocelot_port->native_vlan.vid != vid &&
268268
ocelot_port->native_vlan.valid) {
269-
dev_err(ocelot->dev,
270-
"Port already has a native VLAN: %d\n",
271-
ocelot_port->native_vlan.vid);
269+
NL_SET_ERR_MSG_MOD(extack,
270+
"Port already has a native VLAN");
272271
return -EBUSY;
273272
}
274273

drivers/net/ethernet/mscc/ocelot_net.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,6 @@ static int ocelot_setup_tc(struct net_device *dev, enum tc_setup_type type,
386386
return 0;
387387
}
388388

389-
static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid,
390-
bool untagged)
391-
{
392-
struct ocelot_port_private *priv = netdev_priv(dev);
393-
struct ocelot_port *ocelot_port = &priv->port;
394-
struct ocelot *ocelot = ocelot_port->ocelot;
395-
int port = priv->chip_port;
396-
397-
return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged);
398-
}
399-
400389
static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
401390
bool untagged)
402391
{
@@ -944,14 +933,26 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx,
944933
return err;
945934
}
946935

936+
static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid,
937+
bool untagged, struct netlink_ext_ack *extack)
938+
{
939+
struct ocelot_port_private *priv = netdev_priv(dev);
940+
struct ocelot_port *ocelot_port = &priv->port;
941+
struct ocelot *ocelot = ocelot_port->ocelot;
942+
int port = priv->chip_port;
943+
944+
return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack);
945+
}
946+
947947
static int ocelot_port_obj_add_vlan(struct net_device *dev,
948-
const struct switchdev_obj_port_vlan *vlan)
948+
const struct switchdev_obj_port_vlan *vlan,
949+
struct netlink_ext_ack *extack)
949950
{
950951
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
951952
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
952953
int ret;
953954

954-
ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged);
955+
ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged, extack);
955956
if (ret)
956957
return ret;
957958

@@ -1039,7 +1040,8 @@ static int ocelot_port_obj_add(struct net_device *dev, const void *ctx,
10391040
switch (obj->id) {
10401041
case SWITCHDEV_OBJ_ID_PORT_VLAN:
10411042
ret = ocelot_port_obj_add_vlan(dev,
1042-
SWITCHDEV_OBJ_PORT_VLAN(obj));
1043+
SWITCHDEV_OBJ_PORT_VLAN(obj),
1044+
extack);
10431045
break;
10441046
case SWITCHDEV_OBJ_ID_PORT_MDB:
10451047
ret = ocelot_port_obj_add_mdb(dev, SWITCHDEV_OBJ_PORT_MDB(obj));

include/soc/mscc/ocelot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port,
825825
int ocelot_fdb_del(struct ocelot *ocelot, int port,
826826
const unsigned char *addr, u16 vid);
827827
int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
828-
bool untagged);
828+
bool untagged, struct netlink_ext_ack *extack);
829829
int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
830830
bool untagged);
831831
int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);

0 commit comments

Comments
 (0)