Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e8f4a54 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

switchdev: push object ID back to object structure

parent 648b4a99
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -4437,7 +4437,6 @@ static int rocker_port_fdb_add(struct rocker_port *rocker_port,
}

static int rocker_port_obj_add(struct net_device *dev,
			       enum switchdev_obj_id id,
			       const struct switchdev_obj *obj,
			       struct switchdev_trans *trans)
{
@@ -4445,7 +4444,7 @@ static int rocker_port_obj_add(struct net_device *dev,
	const struct switchdev_obj_ipv4_fib *fib4;
	int err = 0;

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_VLAN:
		err = rocker_port_vlans_add(rocker_port, trans,
					    SWITCHDEV_OBJ_PORT_VLAN(obj));
@@ -4511,14 +4510,13 @@ static int rocker_port_fdb_del(struct rocker_port *rocker_port,
}

static int rocker_port_obj_del(struct net_device *dev,
			       enum switchdev_obj_id id,
			       const struct switchdev_obj *obj)
{
	struct rocker_port *rocker_port = netdev_priv(dev);
	const struct switchdev_obj_ipv4_fib *fib4;
	int err = 0;

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_VLAN:
		err = rocker_port_vlans_del(rocker_port,
					    SWITCHDEV_OBJ_PORT_VLAN(obj));
@@ -4593,14 +4591,13 @@ static int rocker_port_vlan_dump(const struct rocker_port *rocker_port,
}

static int rocker_port_obj_dump(struct net_device *dev,
				enum switchdev_obj_id id,
				struct switchdev_obj *obj,
				switchdev_obj_dump_cb_t *cb)
{
	const struct rocker_port *rocker_port = netdev_priv(dev);
	int err = 0;

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_FDB:
		err = rocker_port_fdb_dump(rocker_port,
					   SWITCHDEV_OBJ_PORT_FDB(obj), cb);
+4 −10
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ enum switchdev_obj_id {
};

struct switchdev_obj {
	enum switchdev_obj_id id;
};

/* SWITCHDEV_OBJ_ID_PORT_VLAN */
@@ -131,14 +132,11 @@ struct switchdev_ops {
					   struct switchdev_attr *attr,
					   struct switchdev_trans *trans);
	int	(*switchdev_port_obj_add)(struct net_device *dev,
					  enum switchdev_obj_id id,
					  const struct switchdev_obj *obj,
					  struct switchdev_trans *trans);
	int	(*switchdev_port_obj_del)(struct net_device *dev,
					  enum switchdev_obj_id id,
					  const struct switchdev_obj *obj);
	int	(*switchdev_port_obj_dump)(struct net_device *dev,
					   enum switchdev_obj_id id,
					   struct switchdev_obj *obj,
					   switchdev_obj_dump_cb_t *cb);
};
@@ -170,12 +168,11 @@ int switchdev_port_attr_get(struct net_device *dev,
			    struct switchdev_attr *attr);
int switchdev_port_attr_set(struct net_device *dev,
			    struct switchdev_attr *attr);
int switchdev_port_obj_add(struct net_device *dev, enum switchdev_obj_id id,
int switchdev_port_obj_add(struct net_device *dev,
			   const struct switchdev_obj *obj);
int switchdev_port_obj_del(struct net_device *dev, enum switchdev_obj_id id,
int switchdev_port_obj_del(struct net_device *dev,
			   const struct switchdev_obj *obj);
int switchdev_port_obj_dump(struct net_device *dev, enum switchdev_obj_id id,
			    struct switchdev_obj *obj,
int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj,
			    switchdev_obj_dump_cb_t *cb);
int register_switchdev_notifier(struct notifier_block *nb);
int unregister_switchdev_notifier(struct notifier_block *nb);
@@ -221,21 +218,18 @@ static inline int switchdev_port_attr_set(struct net_device *dev,
}

static inline int switchdev_port_obj_add(struct net_device *dev,
					 enum switchdev_obj_id id,
					 const struct switchdev_obj *obj)
{
	return -EOPNOTSUPP;
}

static inline int switchdev_port_obj_del(struct net_device *dev,
					 enum switchdev_obj_id id,
					 const struct switchdev_obj *obj)
{
	return -EOPNOTSUPP;
}

static inline int switchdev_port_obj_dump(struct net_device *dev,
					  enum switchdev_obj_id id,
					  const struct switchdev_obj *obj,
					  switchdev_obj_dump_cb_t *cb)
{
+2 −2
Original line number Diff line number Diff line
@@ -134,12 +134,12 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)
static void fdb_del_external_learn(struct net_bridge_fdb_entry *f)
{
	struct switchdev_obj_port_fdb fdb = {
		.obj.id = SWITCHDEV_OBJ_ID_PORT_FDB,
		.addr = f->addr.addr,
		.vid = f->vlan_id,
	};

	switchdev_port_obj_del(f->dst->dev, SWITCHDEV_OBJ_ID_PORT_FDB,
			       &fdb.obj);
	switchdev_port_obj_del(f->dst->dev, &fdb.obj);
}

static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f)
+4 −4
Original line number Diff line number Diff line
@@ -83,13 +83,13 @@ static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
		err = vlan_vid_add(dev, br->vlan_proto, vid);
	} else {
		struct switchdev_obj_port_vlan v = {
			.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
			.flags = flags,
			.vid_begin = vid,
			.vid_end = vid,
		};

		err = switchdev_port_obj_add(dev, SWITCHDEV_OBJ_ID_PORT_VLAN,
					     &v.obj);
		err = switchdev_port_obj_add(dev, &v.obj);
		if (err == -EOPNOTSUPP)
			err = 0;
	}
@@ -133,12 +133,12 @@ static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br,
		vlan_vid_del(dev, br->vlan_proto, vid);
	} else {
		struct switchdev_obj_port_vlan v = {
			.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
			.vid_begin = vid,
			.vid_end = vid,
		};

		err = switchdev_port_obj_del(dev, SWITCHDEV_OBJ_ID_PORT_VLAN,
					     &v.obj);
		err = switchdev_port_obj_del(dev, &v.obj);
		if (err == -EOPNOTSUPP)
			err = 0;
	}
+3 −6
Original line number Diff line number Diff line
@@ -474,7 +474,6 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
}

static int dsa_slave_port_obj_add(struct net_device *dev,
				  enum switchdev_obj_id id,
				  const struct switchdev_obj *obj,
				  struct switchdev_trans *trans)
{
@@ -485,7 +484,7 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
	 * supported, return -EOPNOTSUPP.
	 */

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_FDB:
		err = dsa_slave_port_fdb_add(dev,
					     SWITCHDEV_OBJ_PORT_FDB(obj),
@@ -505,12 +504,11 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
}

static int dsa_slave_port_obj_del(struct net_device *dev,
				  enum switchdev_obj_id id,
				  const struct switchdev_obj *obj)
{
	int err;

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_FDB:
		err = dsa_slave_port_fdb_del(dev,
					     SWITCHDEV_OBJ_PORT_FDB(obj));
@@ -528,13 +526,12 @@ static int dsa_slave_port_obj_del(struct net_device *dev,
}

static int dsa_slave_port_obj_dump(struct net_device *dev,
				   enum switchdev_obj_id id,
				   struct switchdev_obj *obj,
				   switchdev_obj_dump_cb_t *cb)
{
	int err;

	switch (id) {
	switch (obj->id) {
	case SWITCHDEV_OBJ_ID_PORT_FDB:
		err = dsa_slave_port_fdb_dump(dev,
					      SWITCHDEV_OBJ_PORT_FDB(obj),
Loading