Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1236117

Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_*

Path csiph.com!goblin1!goblin.stu.neva.ru!news2.arglkargh.de!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Jiri Pirko <jiri@resnulli.us>
Newsgroups linux.kernel
Subject Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_*
Date Wed, 30 Sep 2015 12:40:05 +0200
Message-ID <qemXP-2nj-89@gated-at.bofh.it> (permalink)
References <qe5Dz-2XB-3@gated-at.bofh.it> <qe5DA-2XB-15@gated-at.bofh.it>
X-Original-To Vivien Didelot <vivien.didelot@savoirfairelinux.com>
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=4OHA8+FrJ8XJwtdYnn7sCblVvROUkaWQN7QdCHnBrJA=; b=PukSHEm/Z7XKwqLxnpPENmArNwJie1pDdwcAZbz+vERtTZe4DBP143tvVk8FJH0VOT D85HdEzA+3gOdYCjHlF34lwFWDk4cUzbpfPk2cb5jTgpaR2ehLFZfyJp8cyFn5pSmJ/e kw3ia4I4GTZRm/GoU6YIK8HSHWevhZRrbTy7LZFv7nRqOLtAxQivCqChRIFQhIHhzOQR PYTa2VcPcuTCsSqduSPWMIEigg88H0tNv2URxWQNsWOMN+IthG4xQ5SaLlaWQl+zRuWv c3dBaTGGrZle33vcspiN64qXLyGif+77Dyq9u5e4h/MdMxAmdCmzrn966tOeSSr3cR/N 1Y8w==
X-Gm-Message-State ALoCoQlj0flAni60NufCFsyskAu5oWtgNA+6Z7X+MRLkQXW2iQ/KSQwLVSqgEtqglaveuMS9Fgvo
X-Received by 10.180.86.100 with SMTP id o4mr29534434wiz.59.1443609380174; Wed, 30 Sep 2015 03:36:20 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 118
Organization linux.* mail to news gateway
X-Original-Cc netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" <davem@davemloft.net>, Scott Feldman <sfeldma@gmail.com>, Florian Fainelli <f.fainelli@gmail.com>, Andrew Lunn <andrew@lunn.ch>
X-Original-Date Wed, 30 Sep 2015 12:36:18 +0200
X-Original-Message-ID <20150930103618.GC2098@nanopsycho.orion>
X-Original-References <1443542838-19234-1-git-send-email-vivien.didelot@savoirfairelinux.com> <1443542838-19234-7-git-send-email-vivien.didelot@savoirfairelinux.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1236117

Show key headers only | View raw


Tue, Sep 29, 2015 at 06:07:18PM CEST, vivien.didelot@savoirfairelinux.com wrote:
>Now that switchdev and its drivers directly use specific switchdev_obj_*
>structures, move them out of the switchdev_obj union and get rif of this
>outer structure.
>
>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
>---
> include/net/switchdev.h | 53 ++++++++++++++++++++++++-------------------------
> 1 file changed, 26 insertions(+), 27 deletions(-)
>
>diff --git a/include/net/switchdev.h b/include/net/switchdev.h
>index bcadac3..e11425e 100644
>--- a/include/net/switchdev.h
>+++ b/include/net/switchdev.h
>@@ -64,30 +64,29 @@ enum switchdev_obj_id {
> 	SWITCHDEV_OBJ_PORT_FDB,
> };
> 
>-struct switchdev_obj {
>-	enum switchdev_obj_id id;
>-	int (*cb)(struct switchdev_obj *obj);
>-	union {
>-		struct switchdev_obj_vlan {		/* PORT_VLAN */
>-			u16 flags;
>-			u16 vid_begin;
>-			u16 vid_end;
>-		} vlan;
>-		struct switchdev_obj_ipv4_fib {		/* IPV4_FIB */
>-			u32 dst;
>-			int dst_len;
>-			struct fib_info *fi;
>-			u8 tos;
>-			u8 type;
>-			u32 nlflags;
>-			u32 tb_id;
>-		} ipv4_fib;
>-		struct switchdev_obj_fdb {		/* PORT_FDB */
>-			const unsigned char *addr;
>-			u16 vid;
>-			u16 ndm_state;
>-		} fdb;
>-	} u;
>+/* SWITCHDEV_OBJ_PORT_VLAN */
>+struct switchdev_obj_vlan {
>+	u16 flags;
>+	u16 vid_begin;
>+	u16 vid_end;
>+};
>+
>+/* SWITCHDEV_OBJ_IPV4_FIB */
>+struct switchdev_obj_ipv4_fib {
>+	u32 dst;
>+	int dst_len;
>+	struct fib_info *fi;
>+	u8 tos;
>+	u8 type;
>+	u32 nlflags;
>+	u32 tb_id;
>+};
>+
>+/* SWITCHDEV_OBJ_PORT_FDB */
>+struct switchdev_obj_fdb {
>+	const unsigned char *addr;
>+	u16 vid;
>+	u16 ndm_state;
> };


I don't like these structs being passed down as a "void *". I think that
we should have some "common" struct for these objects, event if it would
be empty and pass it down. "void *" does not look good at all, does not
tell the reader what that param is about. How about:

struct switchdev_obj {
};

struct switchdev_obj_vlan {
	struct switchdev_obj obj;
	u16 flags;
	u16 vid_begin;
	u16 vid_end;
};
#define SWITCHDEV_OBJ_VLAN(obj)	\
	container_of(obj, struct switchdev_obj_vlan, obj)

/* SWITCHDEV_OBJ_IPV4_FIB */
struct switchdev_obj_ipv4_fib {
	struct switchdev_obj obj;
	u32 dst;
	int dst_len;
	struct fib_info *fi;
	u8 tos;
	u8 type;
	u32 nlflags;
	u32 tb_id;
};
#define SWITCHDEV_OBJ_IPV4_FIB(obj)	\
	container_of(obj, struct switchdev_obj_ipv4_fib, obj)

/* SWITCHDEV_OBJ_PORT_FDB */
struct switchdev_obj_fdb {
	struct switchdev_obj obj;
	const unsigned char *addr;
	u16 vid;
	u16 ndm_state;
};
#define SWITCHDEV_OBJ_FDB(obj)	\
	container_of(obj, struct switchdev_obj_fdb, obj)
 

then pass struct switchdev_obj *obj down to drivers and in driver, get
original object by SWITCHDEV_OBJ_* ?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2015-09-29 18:10 +0200
  Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct  switchdev_obj_* Jiri Pirko <jiri@resnulli.us> - 2015-09-30 12:40 +0200
    Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Scott Feldman <sfeldma@gmail.com> - 2015-09-30 17:00 +0200
      Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct  switchdev_obj_* Jiri Pirko <jiri@resnulli.us> - 2015-09-30 17:10 +0200

csiph-web