Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2 13/22] tc/class: make filter variables static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

Only used in this file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/tc_class.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tc/tc_class.c b/tc/tc_class.c
index 7e4e17fd7f39..7ac700d7ab31 100644
--- a/tc/tc_class.c
+++ b/tc/tc_class.c
@@ -153,9 +153,9 @@ static int tc_class_modify(int cmd, unsigned int flags, int argc, char **argv)
 	return 0;
 }
 
-int filter_ifindex;
-__u32 filter_qdisc;
-__u32 filter_classid;
+static int filter_ifindex;
+static __u32 filter_qdisc;
+static __u32 filter_classid;
 
 static void graph_node_add(__u32 parent_id, __u32 id, void *data,
 		int len)
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 14/22] tc/police: make print_police static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

print_police function only used by m_police.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_police.c | 10 +++++++---
 tc/tc_util.h  |  3 ---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tc/m_police.c b/tc/m_police.c
index f3b07f7b0439..d645999ba08b 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -25,6 +25,10 @@
 #include "utils.h"
 #include "tc_util.h"
 
+static int act_parse_police(struct action_util *a, int *argc_p,
+			    char ***argv_p, int tca_id, struct nlmsghdr *n);
+static int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
+
 struct action_util police_action_util = {
 	.id = "police",
 	.parse_aopt = act_parse_police,
@@ -50,8 +54,8 @@ static void explain1(char *arg)
 	fprintf(stderr, "Illegal \"%s\"\n", arg);
 }
 
-int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
-		     int tca_id, struct nlmsghdr *n)
+static int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
+			    int tca_id, struct nlmsghdr *n)
 {
 	int argc = *argc_p;
 	char **argv = *argv_p;
@@ -256,7 +260,7 @@ int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
 	return act_parse_police(NULL, argc_p, argv_p, tca_id, n);
 }
 
-int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
+static int print_police(struct action_util *a, FILE *f, struct rtattr *arg)
 {
 	SPRINT_BUF(b1);
 	SPRINT_BUF(b2);
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 76fd986d6e4c..e22c6da25696 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -117,9 +117,6 @@ int parse_action_control_slash(int *argc_p, char ***argv_p,
 			       int *result1_p, int *result2_p, bool allow_num);
 void print_action_control(FILE *f, const char *prefix,
 			  int action, const char *suffix);
-int act_parse_police(struct action_util *a, int *argc_p,
-		     char ***argv_p, int tca_id, struct nlmsghdr *n);
-int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
 int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
 int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts);
 int tc_print_ipt(FILE *f, const struct rtattr *tb);
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 15/22] ss: make local variables static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

Several variables only used in this code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 misc/ss.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index 4d12fb5d19df..e4d6ae489e79 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -96,20 +96,20 @@ static int security_get_initial_context(char *name,  char **context)
 }
 #endif
 
-int resolve_services = 1;
+static int resolve_services = 1;
 int preferred_family = AF_UNSPEC;
-int show_options;
+static int show_options;
 int show_details;
-int show_users;
-int show_mem;
-int show_tcpinfo;
-int show_bpf;
-int show_proc_ctx;
-int show_sock_ctx;
-int show_header = 1;
-int follow_events;
-int sctp_ino;
-int show_tipcinfo;
+static int show_users;
+static int show_mem;
+static int show_tcpinfo;
+static int show_bpf;
+static int show_proc_ctx;
+static int show_sock_ctx;
+static int show_header = 1;
+static int follow_events;
+static int sctp_ino;
+static int show_tipcinfo;
 
 enum col_id {
 	COL_NETID,
@@ -494,7 +494,7 @@ struct user_ent {
 };
 
 #define USER_ENT_HASH_SIZE	256
-struct user_ent *user_ent_hash[USER_ENT_HASH_SIZE];
+static struct user_ent *user_ent_hash[USER_ENT_HASH_SIZE];
 
 static int user_ent_hashfn(unsigned int ino)
 {
@@ -1404,7 +1404,7 @@ struct scache {
 	const char *proto;
 };
 
-struct scache *rlist;
+static struct scache *rlist;
 
 static void init_service_resolver(void)
 {
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 16/22] tc/pedit: make functions static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

The parse and pack functions are only used by the pedit routines.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_pedit.c | 33 ++++++++++++++-------------------
 tc/m_pedit.h | 15 ---------------
 2 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 2aeb56d9615f..6f8d078b7d3c 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -118,7 +118,7 @@ noexist:
 	return p;
 }
 
-int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
+static int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
 {
 	struct tc_pedit_sel *sel = &_sel->sel;
 	struct m_pedit_key_ex *keys_ex = _sel->keys_ex;
@@ -155,8 +155,8 @@ int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
 	return 0;
 }
 
-int pack_key32(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey)
+static int pack_key32(__u32 retain, struct m_pedit_sel *sel,
+		      struct m_pedit_key *tkey)
 {
 	if (tkey->off > (tkey->off & ~3)) {
 		fprintf(stderr,
@@ -169,8 +169,8 @@ int pack_key32(__u32 retain, struct m_pedit_sel *sel,
 	return pack_key(sel, tkey);
 }
 
-int pack_key16(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey)
+static int pack_key16(__u32 retain, struct m_pedit_sel *sel,
+		      struct m_pedit_key *tkey)
 {
 	int ind, stride;
 	__u32 m[4] = { 0x0000FFFF, 0xFF0000FF, 0xFFFF0000 };
@@ -197,10 +197,10 @@ int pack_key16(__u32 retain, struct m_pedit_sel *sel,
 		printf("pack_key16: Final val %08x mask %08x\n",
 		       tkey->val, tkey->mask);
 	return pack_key(sel, tkey);
-
 }
 
-int pack_key8(__u32 retain, struct m_pedit_sel *sel, struct m_pedit_key *tkey)
+static int pack_key8(__u32 retain, struct m_pedit_sel *sel,
+		     struct m_pedit_key *tkey)
 {
 	int ind, stride;
 	__u32 m[4] = { 0x00FFFFFF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00 };
@@ -283,7 +283,7 @@ static int pack_ipv6(struct m_pedit_sel *sel, struct m_pedit_key *tkey,
 	return 0;
 }
 
-int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type)
+static int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type)
 {
 	int argc = *argc_p;
 	char **argv = *argv_p;
@@ -433,8 +433,8 @@ done:
 
 }
 
-int parse_offset(int *argc_p, char ***argv_p, struct m_pedit_sel *sel,
-		 struct m_pedit_key *tkey)
+static int parse_offset(int *argc_p, char ***argv_p, struct m_pedit_sel *sel,
+			struct m_pedit_key *tkey)
 {
 	int off;
 	__u32 len, retain;
@@ -612,8 +612,8 @@ static int pedit_keys_ex_addattr(struct m_pedit_sel *sel, struct nlmsghdr *n)
 	return 0;
 }
 
-int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
-		struct nlmsghdr *n)
+static int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p,
+		       int tca_id, struct nlmsghdr *n)
 {
 	struct m_pedit_sel sel = {};
 
@@ -705,7 +705,7 @@ int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 	return 0;
 }
 
-const char *pedit_htype_str[] = {
+static const char * const pedit_htype_str[] = {
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK] = "",
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_ETH] = "eth",
 	[TCA_PEDIT_KEY_EX_HDR_TYPE_IP4] = "ipv4",
@@ -730,7 +730,7 @@ static void print_pedit_location(FILE *f,
 	fprintf(f, "%c%d", (int)off  >= 0 ? '+' : '-', abs((int)off));
 }
 
-int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
+static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
 {
 	struct tc_pedit_sel *sel;
 	struct rtattr *tb[TCA_PEDIT_MAX + 1];
@@ -826,11 +826,6 @@ int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
 	return 0;
 }
 
-int pedit_print_xstats(struct action_util *au, FILE *f, struct rtattr *xstats)
-{
-	return 0;
-}
-
 struct action_util pedit_action_util = {
 	.id = "pedit",
 	.parse_aopt = parse_pedit,
diff --git a/tc/m_pedit.h b/tc/m_pedit.h
index b6b274bd08c7..5d3628a70b99 100644
--- a/tc/m_pedit.h
+++ b/tc/m_pedit.h
@@ -71,22 +71,7 @@ struct m_pedit_util {
 			       struct m_pedit_key *tkey);
 };
 
-int pack_key(struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int pack_key32(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey);
-int pack_key16(__u32 retain, struct m_pedit_sel *sel,
-	       struct m_pedit_key *tkey);
-int pack_key8(__u32 retain, struct m_pedit_sel *sel,
-		     struct m_pedit_key *tkey);
-int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type);
 int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type,
 	      __u32 retain,
 	      struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int parse_offset(int *argc_p, char ***argv_p,
-		 struct m_pedit_sel *sel, struct m_pedit_key *tkey);
-int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p,
-		int tca_id, struct nlmsghdr *n);
-int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg);
-int pedit_print_xstats(struct action_util *au, FILE *f,
-		       struct rtattr *xstats);
 #endif
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 17/22] tc/ematch: make local functions static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

The print handling is only used in tc/m_ematch.c

Remove unused function to print_ematch_tree.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_ematch.c | 30 +++---------------------------
 tc/m_ematch.h |  1 -
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/tc/m_ematch.c b/tc/m_ematch.c
index a524b520b276..8840a0dc62a1 100644
--- a/tc/m_ematch.c
+++ b/tc/m_ematch.c
@@ -38,6 +38,8 @@ struct ematch *ematch_root;
 static int begin_argc;
 static char **begin_argv;
 
+static void bstr_print(FILE *fd, const struct bstr *b, int ascii);
+
 static inline void map_warning(int num, char *kind)
 {
 	fprintf(stderr,
@@ -548,7 +550,7 @@ unsigned long bstrtoul(const struct bstr *b)
 	return l;
 }
 
-void bstr_print(FILE *fd, const struct bstr *b, int ascii)
+static void bstr_print(FILE *fd, const struct bstr *b, int ascii)
 {
 	int i;
 	char *s = b->data;
@@ -565,29 +567,3 @@ void bstr_print(FILE *fd, const struct bstr *b, int ascii)
 		fprintf(fd, "\"");
 	}
 }
-
-void print_ematch_tree(const struct ematch *tree)
-{
-	const struct ematch *t;
-
-	for (t = tree; t; t = t->next) {
-		if (t->inverted)
-			printf("NOT ");
-
-		if (t->child) {
-			printf("(");
-			print_ematch_tree(t->child);
-			printf(")");
-		} else {
-			struct bstr *b;
-
-			for (b = t->args; b; b = b->next)
-				printf("%s%s", b->data, b->next ? " " : "");
-		}
-
-		if (t->relation == TCF_EM_REL_AND)
-			printf(" AND ");
-		else if (t->relation == TCF_EM_REL_OR)
-			printf(" OR ");
-	}
-}
diff --git a/tc/m_ematch.h b/tc/m_ematch.h
index 356f2eded7fc..c4443ee22942 100644
--- a/tc/m_ematch.h
+++ b/tc/m_ematch.h
@@ -51,7 +51,6 @@ static inline struct bstr *bstr_next(struct bstr *b)
 }
 
 unsigned long bstrtoul(const struct bstr *b);
-void bstr_print(FILE *fd, const struct bstr *b, int ascii);
 
 struct ematch {
 	struct bstr	*args;
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 18/22] tc/util: make local functions static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

The tc util library parse/print has functions only used locally
(and some dead code removed).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/tc_util.c | 17 +++--------------
 tc/tc_util.h |  5 -----
 2 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index a082c73c9350..82856a85170b 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -190,7 +190,7 @@ static const struct rate_suffix {
 	{ NULL }
 };
 
-int parse_percent_rate(char *rate, const char *str, const char *dev)
+static int parse_percent_rate(char *rate, const char *str, const char *dev)
 {
 	long dev_mbit;
 	int ret;
@@ -409,7 +409,7 @@ void print_devname(enum output_type type, int ifindex)
 			   "dev", "%s ", ifname);
 }
 
-void print_size(char *buf, int len, __u32 sz)
+static void print_size(char *buf, int len, __u32 sz)
 {
 	double tmp = sz;
 
@@ -427,17 +427,6 @@ char *sprint_size(__u32 size, char *buf)
 	return buf;
 }
 
-void print_qdisc_handle(char *buf, int len, __u32 h)
-{
-	snprintf(buf, len, "%x:", TC_H_MAJ(h)>>16);
-}
-
-char *sprint_qdisc_handle(__u32 h, char *buf)
-{
-	print_qdisc_handle(buf, SPRINT_BSIZE-1, h);
-	return buf;
-}
-
 static const char *action_n2a(int action)
 {
 	static char buf[64];
@@ -709,7 +698,7 @@ int get_linklayer(unsigned int *val, const char *arg)
 	return 0;
 }
 
-void print_linklayer(char *buf, int len, unsigned int linklayer)
+static void print_linklayer(char *buf, int len, unsigned int linklayer)
 {
 	switch (linklayer) {
 	case LINKLAYER_UNSPEC:
diff --git a/tc/tc_util.h b/tc/tc_util.h
index e22c6da25696..825fea36a080 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -73,7 +73,6 @@ const char *get_tc_lib(void);
 struct qdisc_util *get_qdisc_kind(const char *str);
 struct filter_util *get_filter_kind(const char *str);
 
-int parse_percent_rate(char *rate, const char *str, const char *dev);
 int get_qdisc_handle(__u32 *h, const char *str);
 int get_rate(unsigned int *rate, const char *str);
 int get_percent_rate(unsigned int *rate, const char *str, const char *dev);
@@ -84,14 +83,10 @@ int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
 int get_linklayer(unsigned int *val, const char *arg);
 
 void print_rate(char *buf, int len, __u64 rate);
-void print_size(char *buf, int len, __u32 size);
-void print_qdisc_handle(char *buf, int len, __u32 h);
-void print_linklayer(char *buf, int len, unsigned int linklayer);
 void print_devname(enum output_type type, int ifindex);
 
 char *sprint_rate(__u64 rate, char *buf);
 char *sprint_size(__u32 size, char *buf);
-char *sprint_qdisc_handle(__u32 h, char *buf);
 char *sprint_tc_classid(__u32 h, char *buf);
 char *sprint_ticks(__u32 ticks, char *buf);
 char *sprint_linklayer(unsigned int linklayer, char *buf);
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 19/22] tc/meta: make meta_table static and const
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

The mapping table is only used by em_meta.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/em_meta.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tc/em_meta.c b/tc/em_meta.c
index d94fe88d9b2f..2ddc65ed6cb6 100644
--- a/tc/em_meta.c
+++ b/tc/em_meta.c
@@ -38,7 +38,7 @@ static void meta_print_usage(FILE *fd)
 	    "For a list of meta identifiers, use meta(list).\n");
 }
 
-struct meta_entry {
+static const struct meta_entry {
 	int		id;
 	char *kind;
 	char *mask;
@@ -121,7 +121,7 @@ static inline int map_type(char k)
 	return INT_MAX;
 }
 
-static struct meta_entry *lookup_meta_entry(struct bstr *kind)
+static const struct meta_entry *lookup_meta_entry(struct bstr *kind)
 {
 	int i;
 
@@ -133,7 +133,7 @@ static struct meta_entry *lookup_meta_entry(struct bstr *kind)
 	return NULL;
 }
 
-static struct meta_entry *lookup_meta_entry_byid(int id)
+static const struct meta_entry *lookup_meta_entry_byid(int id)
 {
 	int i;
 
@@ -168,8 +168,8 @@ static inline void dump_value(struct nlmsghdr *n, int tlv, unsigned long val,
 static inline int is_compatible(struct tcf_meta_val *what,
 				struct tcf_meta_val *needed)
 {
+	const struct meta_entry *entry;
 	char *p;
-	struct meta_entry *entry;
 
 	entry = lookup_meta_entry_byid(TCF_META_ID(what->kind));
 
@@ -249,7 +249,7 @@ static inline struct bstr *
 parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
 	     unsigned long *dst, struct tcf_meta_val *left)
 {
-	struct meta_entry *entry;
+	const struct meta_entry *entry;
 	unsigned long num;
 	struct bstr *a;
 
@@ -461,7 +461,7 @@ static int print_object(FILE *fd, struct tcf_meta_val *obj, struct rtattr *rta)
 {
 	int id = TCF_META_ID(obj->kind);
 	int type = TCF_META_TYPE(obj->kind);
-	struct meta_entry *entry;
+	const struct meta_entry *entry;
 
 	if (id == TCF_META_ID_VALUE)
 		return print_value(fd, type, rta);
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 20/22] tc/action: make variables static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/m_action.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tc/m_action.c b/tc/m_action.c
index e90867fc6c25..d5fd5affe703 100644
--- a/tc/m_action.c
+++ b/tc/m_action.c
@@ -30,9 +30,9 @@
 
 static struct action_util *action_list;
 #ifdef CONFIG_GACT
-int gact_ld; /* f*ckin backward compatibility */
+static int gact_ld; /* f*ckin backward compatibility */
 #endif
-int tab_flush;
+static int tab_flush;
 
 static void act_usage(void)
 {
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 21/22] tc/pedit: use structure initialization
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

The pedit callback structure table should be iniatialized using
structure initialization to avoid structure changes problems.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/p_eth.c  | 5 ++---
 tc/p_icmp.c | 5 ++---
 tc/p_ip.c   | 5 ++---
 tc/p_ip6.c  | 5 ++---
 tc/p_tcp.c  | 5 ++---
 tc/p_udp.c  | 5 ++---
 6 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/tc/p_eth.c b/tc/p_eth.c
index 53ce736a1d78..674f9c11202a 100644
--- a/tc/p_eth.c
+++ b/tc/p_eth.c
@@ -68,7 +68,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_eth = {
-	NULL,
-	"eth",
-	parse_eth,
+	.id = "eth",
+	.parse_peopt = parse_eth,
 };
diff --git a/tc/p_icmp.c b/tc/p_icmp.c
index 2c1baf82f7ad..15ce32309e39 100644
--- a/tc/p_icmp.c
+++ b/tc/p_icmp.c
@@ -55,7 +55,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_icmp = {
-	NULL,
-	"icmp",
-	parse_icmp,
+	.id = "icmp",
+	.parse_peopt = parse_icmp,
 };
diff --git a/tc/p_ip.c b/tc/p_ip.c
index e9fd6f834efc..c385ac6dbcaa 100644
--- a/tc/p_ip.c
+++ b/tc/p_ip.c
@@ -156,7 +156,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_ip = {
-	NULL,
-	"ip",
-	parse_ip,
+	.id = "ip",
+	.parse_peopt = parse_ip,
 };
diff --git a/tc/p_ip6.c b/tc/p_ip6.c
index bc45ab70d319..dbfdca42cce7 100644
--- a/tc/p_ip6.c
+++ b/tc/p_ip6.c
@@ -84,7 +84,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_ip6 = {
-	NULL,
-	"ipv6",
-	parse_ip6,
+	.id = "ipv6",
+	.parse_peopt = parse_ip6,
 };
diff --git a/tc/p_tcp.c b/tc/p_tcp.c
index eeb68fcf87b3..d2dbfd719526 100644
--- a/tc/p_tcp.c
+++ b/tc/p_tcp.c
@@ -67,7 +67,6 @@ done:
 	return res;
 }
 struct m_pedit_util p_pedit_tcp = {
-	NULL,
-	"tcp",
-	parse_tcp,
+	.id = "tcp",
+	.parse_peopt = parse_tcp,
 };
diff --git a/tc/p_udp.c b/tc/p_udp.c
index 68c688efd110..bab456de9831 100644
--- a/tc/p_udp.c
+++ b/tc/p_udp.c
@@ -61,7 +61,6 @@ done:
 }
 
 struct m_pedit_util p_pedit_udp = {
-	NULL,
-	"udp",
-	parse_udp,
+	.id = "udp",
+	.parse_peopt = parse_udp,
 };
-- 
2.17.1

^ permalink raw reply related

* [PATCH iproute2 22/22] rdma: make local functions static
From: Stephen Hemminger @ 2018-11-15 22:36 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger
In-Reply-To: <20181115223640.411-1-stephen@networkplumber.org>

Several functions only used inside utils.c

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 rdma/rdma.h  | 11 -----------
 rdma/utils.c | 12 ++++++------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/rdma/rdma.h b/rdma/rdma.h
index c3b7530b6cc7..05c3c69b07fd 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -74,13 +74,6 @@ struct rd_cmd {
 	int (*func)(struct rd *rd);
 };
 
-/*
- * Parser interface
- */
-bool rd_no_arg(struct rd *rd);
-void rd_arg_inc(struct rd *rd);
-
-char *rd_argv(struct rd *rd);
 
 /*
  * Commands interface
@@ -95,8 +88,6 @@ void rd_free(struct rd *rd);
 int rd_set_arg_to_devname(struct rd *rd);
 int rd_argc(struct rd *rd);
 
-int strcmpx(const char *str1, const char *str2);
-
 /*
  * Device manipulation
  */
@@ -117,14 +108,12 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t seq);
 void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags);
 int rd_dev_init_cb(const struct nlmsghdr *nlh, void *data);
 int rd_attr_cb(const struct nlattr *attr, void *data);
-int rd_attr_check(const struct nlattr *attr, int *typep);
 
 /*
  * Print helpers
  */
 void print_driver_table(struct rd *rd, struct nlattr *tb);
 void newline(struct rd *rd);
-void newline_indent(struct rd *rd);
 #define MAX_LINE_LENGTH 80
 
 #endif /* _RDMA_TOOL_H_ */
diff --git a/rdma/utils.c b/rdma/utils.c
index 4840bf226d54..1a0cf56800d4 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -18,14 +18,14 @@ int rd_argc(struct rd *rd)
 	return rd->argc;
 }
 
-char *rd_argv(struct rd *rd)
+static char *rd_argv(struct rd *rd)
 {
 	if (!rd_argc(rd))
 		return NULL;
 	return *rd->argv;
 }
 
-int strcmpx(const char *str1, const char *str2)
+static int strcmpx(const char *str1, const char *str2)
 {
 	if (strlen(str1) > strlen(str2))
 		return -1;
@@ -39,7 +39,7 @@ static bool rd_argv_match(struct rd *rd, const char *pattern)
 	return strcmpx(rd_argv(rd), pattern) == 0;
 }
 
-void rd_arg_inc(struct rd *rd)
+static void rd_arg_inc(struct rd *rd)
 {
 	if (!rd_argc(rd))
 		return;
@@ -47,7 +47,7 @@ void rd_arg_inc(struct rd *rd)
 	rd->argv++;
 }
 
-bool rd_no_arg(struct rd *rd)
+static bool rd_no_arg(struct rd *rd)
 {
 	return rd_argc(rd) == 0;
 }
@@ -404,7 +404,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
 	[RDMA_NLDEV_ATTR_DRIVER_U64] = MNL_TYPE_U64,
 };
 
-int rd_attr_check(const struct nlattr *attr, int *typep)
+static int rd_attr_check(const struct nlattr *attr, int *typep)
 {
 	int type;
 
@@ -696,7 +696,7 @@ void newline(struct rd *rd)
 		pr_out("\n");
 }
 
-void newline_indent(struct rd *rd)
+static void newline_indent(struct rd *rd)
 {
 	newline(rd);
 	if (!rd->json_output)
-- 
2.17.1

^ permalink raw reply related

* Re: [PATCH v3 net-next 0/4] net: batched receive in GRO path
From: Edward Cree @ 2018-11-15 22:37 UTC (permalink / raw)
  To: linux-net-drivers, davem; +Cc: netdev, eric.dumazet
In-Reply-To: <8e9ea3c4-82e0-a34c-08ea-32a387e4c9e1@solarflare.com>

Some corrections as it looks like I didn't proofread this carefully enough
 before sending it...

On 14/11/18 18:07, Edward Cree wrote:
> Payload_size in all tests was 8000 bytes.
This was for TCP tests; the UDP test used 1-byte payloads.

> UDP Stream (GRO off):
> net-next: 7.808 Gb/s
> after #4: 7.848 Gb/s
These numbers were Mb/s, not Gb/s.
>   0.5% slower; p = 0.144
And of course the 'after' state was 0.5% _faster_.
> * UDP throughput might be slightly slowed (probably by patch #3) but it's
>   not statistically significant.
Ditto here, UDP has not been slowed.

-Ed

^ permalink raw reply

* Re: [PATCH v3 net-next 0/4] net: batched receive in GRO path
From: Edward Cree @ 2018-11-15 22:45 UTC (permalink / raw)
  To: Eric Dumazet, linux-net-drivers, davem; +Cc: netdev
In-Reply-To: <910e5d7d-25c9-d514-2634-f5a2e92eabe9@gmail.com>

On 15/11/18 22:01, Eric Dumazet wrote:
> On 11/15/2018 01:45 PM, Edward Cree wrote:
>> If napi->poll() is only handling one packet, surely GRO can't do anything
>>  useful either?  (AIUI at the end of the poll the GRO lists get flushed.)
> That is my point.
>
> Adding yet another layer that will add no gain but add more waste of cpu cycles.
>
> In fact I know many people disabling GRO in some cases because it adds ~5% penalty
> for traffic that is not aggregated.
Does there maybe need to be an (ethtool -K) option to disable batch receive,
 then, for this kind of user?

>>  Is it maybe a sign that you're just spreading over too many queues??
> Not really. You also want to be able to receive more traffic if the need comes.
Oh I see, this is about using less CPU when not maxed out, rather than
 increasing the maximum performance.
I did see a 6% RXCPU usage increase in the "TCP RR, GRO on" test.  (Before=
 188.7%, after=200%, Welch p<0.001, Cohen's d=6.2.)  I'll try adding a "skip
 batching for short lists" and retest, see if that improves matters.

^ permalink raw reply

* Re: [PATCH net-next 00/11] mlxsw: spectrum: acl: Introduce ERP sharing by multiple masks
From: David Miller @ 2018-11-15 23:00 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, mlxsw
In-Reply-To: <20181114082138.14284-1-idosch@mellanox.com>

From: Ido Schimmel <idosch@mellanox.com>
Date: Wed, 14 Nov 2018 08:22:25 +0000

> Jiri says:
> 
> The Spectrum-2 hardware has limitation number of ERPs per-region. In
> order to accommodate more masks than number of ERPs, the hardware
> supports to insert rules with delta bits. By that, the rules with masks
> that differ in up-to 8 consecutive bits can share the same ERP.
> 
> Patches 1 and 2 fix couple of issues that would appear in existing
> selftests after adding delta support
> 
> Patch 3 introduces a generic object aggregation library. Now it is
> static, but it will get extended for recalculation of aggregations in
> the future in order to reach more optimal aggregation.
> 
> Patch 4 just simply converts existing ERP code to use the objagg library
> instead of a rhashtable.
> 
> Patches 5-9 do more or less small changes to prepare ground for the last
> patch.
> 
> Patch 10 fills-up delta callbacks of objagg library and utilizes the
> delta bits for rule insertion.
> 
> The last patch adds selftest to test the mlxsw Spectrum-2 delta flows.

Series applied, but I had to fix the following warning:

====================
[PATCH] test_objagg: Fix warning.

lib/test_objagg.c: In function ‘test_delta_action_item’:
./include/linux/printk.h:308:2: warning: ‘errmsg’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 lib/test_objagg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/test_objagg.c b/lib/test_objagg.c
index aac5d8e8800c..ab57144bb0cd 100644
--- a/lib/test_objagg.c
+++ b/lib/test_objagg.c
@@ -769,6 +769,7 @@ static int test_delta_action_item(struct world *world,
 	if (err)
 		goto errout;
 
+	errmsg = NULL;
 	err = check_expect_stats(objagg, &action_item->expect_stats, &errmsg);
 	if (err) {
 		pr_err("Key %u: Stats: %s\n", action_item->key_id, errmsg);
-- 
2.19.1


^ permalink raw reply related

* Re: [PATCH net-next 1/8] net: eth: altera: tse_start_xmit ignores tx_buffer call response
From: Thor Thayer @ 2018-11-15 23:07 UTC (permalink / raw)
  To: Dalon Westergreen, netdev, dinguyen; +Cc: Dalon Westergreen
In-Reply-To: <20181115005047.28464-2-dwesterg@gmail.com>

On 11/14/18 6:50 PM, Dalon Westergreen wrote:
> From: Dalon Westergreen <dalon.westergreen@intel.com>
> 
> The return from tx_buffer call in tse_start_xmit is
> inapropriately ignored.  tse_buffer calls should return
> 0 for success or NETDEV_TX_BUSY.  tse_start_xmit should
> return not report a successful transmit when the tse_buffer
> call returns an error condition.
> 
> In addition to the above, the msgdma and sgdma do not return
> the same value on success or failure.  The sgdma_tx_buffer
> returned 0 on failure and a positive number of transmitted
> packets on success.  Given that it only ever sends 1 packet,
> this made no sense.  The msgdma implementation msgdma_tx_buffer
> returns 0 on success.
> 
>    -> Don't ignore the return from tse_buffer calls
>    -> Fix sgdma tse_buffer call to return 0 on success
>       and NETDEV_TX_BUSY on failure.
> 
> Signed-off-by: Dalon Westergreen <dalon.westergreen@intel.com>
> ---
>   drivers/net/ethernet/altera/altera_sgdma.c    | 14 ++++++++------
>   drivers/net/ethernet/altera/altera_tse_main.c |  4 +++-
>   2 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/altera/altera_sgdma.c b/drivers/net/ethernet/altera/altera_sgdma.c
> index 88ef67a998b4..eb47b9b820bb 100644
> --- a/drivers/net/ethernet/altera/altera_sgdma.c
> +++ b/drivers/net/ethernet/altera/altera_sgdma.c
> @@ -15,6 +15,7 @@
>    */
>   
>   #include <linux/list.h>
> +#include <linux/netdevice.h>
>   #include "altera_utils.h"
>   #include "altera_tse.h"
>   #include "altera_sgdmahw.h"
> @@ -170,10 +171,11 @@ void sgdma_clear_txirq(struct altera_tse_private *priv)
>   		    SGDMA_CTRLREG_CLRINT);
>   }
>   
> -/* transmits buffer through SGDMA. Returns number of buffers
> - * transmitted, 0 if not possible.
> - *
> - * tx_lock is held by the caller
> +/* transmits buffer through SGDMA.
> + *   original behavior returned the number of transmitted packets (always 1) &
> + *   returned 0 on error.  This differs from the msgdma.  the calling function
> + *   will now actually look at the code, so from now, 0 is good and return
> + *   NETDEV_TX_BUSY when busy.
>    */
>   int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)
>   {
> @@ -185,7 +187,7 @@ int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)
>   
>   	/* wait 'til the tx sgdma is ready for the next transmit request */
>   	if (sgdma_txbusy(priv))
> -		return 0;
> +		return NETDEV_TX_BUSY;
>   
>   	sgdma_setup_descrip(cdesc,			/* current descriptor */
>   			    ndesc,			/* next descriptor */
> @@ -202,7 +204,7 @@ int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)
>   	/* enqueue the request to the pending transmit queue */
>   	queue_tx(priv, buffer);
>   
> -	return 1;
> +	return 0;
>   }
>   
>   
> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index baca8f704a45..dcb330129e23 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -606,7 +606,9 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev)
>   	buffer->dma_addr = dma_addr;
>   	buffer->len = nopaged_len;
>   
> -	priv->dmaops->tx_buffer(priv, buffer);
> +	ret = priv->dmaops->tx_buffer(priv, buffer);
> +	if (ret)
> +		goto out;
>   
>   	skb_tx_timestamp(skb);
>   
> 
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply

* Re: [PATCH net-next 2/8] net: eth: altera: set rx and tx ring size before init_dma call
From: Thor Thayer @ 2018-11-15 23:08 UTC (permalink / raw)
  To: Dalon Westergreen, netdev, dinguyen; +Cc: Dalon Westergreen
In-Reply-To: <20181115005047.28464-3-dwesterg@gmail.com>

On 11/14/18 6:50 PM, Dalon Westergreen wrote:
> From: Dalon Westergreen <dalon.westergreen@intel.com>
> 
> It is more appropriate to set the rx and tx ring size before calling
> the init function for the dma.
> 
> Signed-off-by: Dalon Westergreen <dalon.westergreen@intel.com>
> ---
>   drivers/net/ethernet/altera/altera_tse_main.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index dcb330129e23..0c0e8f9bba9b 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -1166,6 +1166,10 @@ static int tse_open(struct net_device *dev)
>   	int i;
>   	unsigned long int flags;
>   
> +	/* set tx and rx ring size */
> +	priv->rx_ring_size = dma_rx_num;
> +	priv->tx_ring_size = dma_tx_num;
> +
>   	/* Reset and configure TSE MAC and probe associated PHY */
>   	ret = priv->dmaops->init_dma(priv);
>   	if (ret != 0) {
> @@ -1208,8 +1212,6 @@ static int tse_open(struct net_device *dev)
>   	priv->dmaops->reset_dma(priv);
>   
>   	/* Create and initialize the TX/RX descriptors chains. */
> -	priv->rx_ring_size = dma_rx_num;
> -	priv->tx_ring_size = dma_tx_num;
>   	ret = alloc_init_skbufs(priv);
>   	if (ret) {
>   		netdev_err(dev, "DMA descriptors initialization failed\n");
> 
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply

* Re: [net-next 00/14][pull request] 40GbE Intel Wired LAN Driver Updates 2018-11-14
From: David Miller @ 2018-11-15 23:06 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, nhorman, sassmann
In-Reply-To: <20181114231032.4013-1-jeffrey.t.kirsher@intel.com>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Wed, 14 Nov 2018 15:10:18 -0800

> This series contains updates to i40e and virtchnl.

Pulled, thanks Jeff.

^ permalink raw reply

* Re: [PATCH net-next 3/8] net: eth: altera: tse: fix altera_dmaops declaration
From: Thor Thayer @ 2018-11-15 23:10 UTC (permalink / raw)
  To: Dalon Westergreen, netdev, dinguyen; +Cc: Dalon Westergreen
In-Reply-To: <20181115005047.28464-4-dwesterg@gmail.com>

On 11/14/18 6:50 PM, Dalon Westergreen wrote:
> From: Dalon Westergreen <dalon.westergreen@intel.com>
> 
> The declaration of struct altera_dmaops does not have
> identifier names.  Add identifier names to confrom with
> required coding styles.
> 
> Signed-off-by: Dalon Westergreen <dalon.westergreen@intel.com>
> ---
>   drivers/net/ethernet/altera/altera_tse.h | 30 +++++++++++++-----------
>   1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h
> index e2feee87180a..d5b97e02e6d6 100644
> --- a/drivers/net/ethernet/altera/altera_tse.h
> +++ b/drivers/net/ethernet/altera/altera_tse.h
> @@ -396,20 +396,22 @@ struct altera_tse_private;
>   struct altera_dmaops {
>   	int altera_dtype;
>   	int dmamask;
> -	void (*reset_dma)(struct altera_tse_private *);
> -	void (*enable_txirq)(struct altera_tse_private *);
> -	void (*enable_rxirq)(struct altera_tse_private *);
> -	void (*disable_txirq)(struct altera_tse_private *);
> -	void (*disable_rxirq)(struct altera_tse_private *);
> -	void (*clear_txirq)(struct altera_tse_private *);
> -	void (*clear_rxirq)(struct altera_tse_private *);
> -	int (*tx_buffer)(struct altera_tse_private *, struct tse_buffer *);
> -	u32 (*tx_completions)(struct altera_tse_private *);
> -	void (*add_rx_desc)(struct altera_tse_private *, struct tse_buffer *);
> -	u32 (*get_rx_status)(struct altera_tse_private *);
> -	int (*init_dma)(struct altera_tse_private *);
> -	void (*uninit_dma)(struct altera_tse_private *);
> -	void (*start_rxdma)(struct altera_tse_private *);
> +	void (*reset_dma)(struct altera_tse_private *priv);
> +	void (*enable_txirq)(struct altera_tse_private *priv);
> +	void (*enable_rxirq)(struct altera_tse_private *priv);
> +	void (*disable_txirq)(struct altera_tse_private *priv);
> +	void (*disable_rxirq)(struct altera_tse_private *priv);
> +	void (*clear_txirq)(struct altera_tse_private *priv);
> +	void (*clear_rxirq)(struct altera_tse_private *priv);
> +	int (*tx_buffer)(struct altera_tse_private *priv,
> +			 struct tse_buffer *buffer);
> +	u32 (*tx_completions)(struct altera_tse_private *priv);
> +	void (*add_rx_desc)(struct altera_tse_private *priv,
> +			    struct tse_buffer *buffer);
> +	u32 (*get_rx_status)(struct altera_tse_private *priv);
> +	int (*init_dma)(struct altera_tse_private *priv);
> +	void (*uninit_dma)(struct altera_tse_private *priv);
> +	void (*start_rxdma)(struct altera_tse_private *priv);
>   };
>   
>   /* This structure is private to each device.
> 
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply

* Re: [PATCH v3 net-next 0/4] net: batched receive in GRO path
From: Eric Dumazet @ 2018-11-15 23:08 UTC (permalink / raw)
  To: Edward Cree, Eric Dumazet, linux-net-drivers, davem; +Cc: netdev
In-Reply-To: <1098391b-1b2e-3d75-f5ab-8f592843a955@solarflare.com>



On 11/15/2018 02:45 PM, Edward Cree wrote:
> On 15/11/18 22:01, Eric Dumazet wrote:
>> On 11/15/2018 01:45 PM, Edward Cree wrote:
>>> If napi->poll() is only handling one packet, surely GRO can't do anything
>>>  useful either?  (AIUI at the end of the poll the GRO lists get flushed.)
>> That is my point.
>>
>> Adding yet another layer that will add no gain but add more waste of cpu cycles.
>>
>> In fact I know many people disabling GRO in some cases because it adds ~5% penalty
>> for traffic that is not aggregated.
> Does there maybe need to be an (ethtool -K) option to disable batch receive,
>  then, for this kind of user?

I do not want to hold on your patches, only to remind us that we add a lot of
features and stuff that might help in some cases only.

Another example is the IP early demux for UDP packets, which is clearly
a waste of time when the receiving socket is not a connected socket.

^ permalink raw reply

* Re: [PATCH][net-next][v2] net: remove BUG_ON from __pskb_pull_tail
From: David Miller @ 2018-11-15 23:08 UTC (permalink / raw)
  To: lirongqing; +Cc: netdev
In-Reply-To: <1542071812-14338-1-git-send-email-lirongqing@baidu.com>

From: Li RongQing <lirongqing@baidu.com>
Date: Tue, 13 Nov 2018 09:16:52 +0800

> if list is NULL pointer, and the following access of list
> will trigger panic, which is same as BUG_ON
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>

Applied.

^ permalink raw reply

* [v3, PATCH 1/2] net:stmmac: dwmac-mediatek: add support for mt2712
From: Biao Huang @ 2018-11-16  9:18 UTC (permalink / raw)
  To: davem, robh+dt
  Cc: honghui.zhang, yt.shen, liguo.zhang, mark.rutland, nelson.chang,
	matthias.bgg, biao.huang, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek, joabreu, andrew

Add Ethernet support for MediaTek SoCs from the mt2712 family

Change-Id: Id3c535627088227793bd36405994edf2dc765e6a
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |    8 +
 drivers/net/ethernet/stmicro/stmmac/Makefile       |    1 +
 .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c   |  383 ++++++++++++++++++++
 3 files changed, 392 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c

diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index edf2036..28a7a28 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -75,6 +75,14 @@ config DWMAC_LPC18XX
 	---help---
 	  Support for NXP LPC18xx/43xx DWMAC Ethernet.
 
+config DWMAC_MEDIATEK
+	tristate "MediaTek MT27xx GMAC support"
+	depends on OF && (ARCH_MEDIATEK || COMPILE_TEST)
+	help
+	  Support for MediaTek GMAC Ethernet controller.
+
+	  This selects the MT2712 SoC support for the stmmac driver.
+
 config DWMAC_MESON
 	tristate "Amlogic Meson dwmac support"
 	default ARCH_MESON
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 99967a8..bf09701 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_ANARION)	+= dwmac-anarion.o
 obj-$(CONFIG_DWMAC_IPQ806X)	+= dwmac-ipq806x.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
+obj-$(CONFIG_DWMAC_MEDIATEK)	+= dwmac-mediatek.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o dwmac-meson8b.o
 obj-$(CONFIG_DWMAC_OXNAS)	+= dwmac-oxnas.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
new file mode 100644
index 0000000..a80b3e0
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -0,0 +1,383 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ */
+#include <linux/io.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_net.h>
+#include <linux/regmap.h>
+#include <linux/stmmac.h>
+
+#include "stmmac.h"
+#include "stmmac_platform.h"
+
+/* Peri Configuration register */
+#define PERI_ETH_PHY_INTF_SEL	0x418
+#define PHY_INTF_MII_GMII	0
+#define PHY_INTF_RGMII		1
+#define PHY_INTF_RMII		4
+#define RMII_CLK_SRC_RXC	BIT(4)
+#define RMII_CLK_SRC_INTERNAL	BIT(5)
+
+#define PERI_ETH_PHY_DLY	0x428
+#define PHY_DLY_GTXC_INV	BIT(6)
+#define PHY_DLY_GTXC_ENABLE	BIT(5)
+#define PHY_DLY_GTXC_STAGES	GENMASK(4, 0)
+#define PHY_DLY_TXC_INV		BIT(20)
+#define PHY_DLY_TXC_ENABLE	BIT(19)
+#define PHY_DLY_TXC_STAGES	GENMASK(18, 14)
+#define PHY_DLY_TXC_SHIFT	14
+#define PHY_DLY_RXC_INV		BIT(13)
+#define PHY_DLY_RXC_ENABLE	BIT(12)
+#define PHY_DLY_RXC_STAGES	GENMASK(11, 7)
+#define PHY_DLY_RXC_SHIFT	7
+
+#define PERI_ETH_DLY_FINE	0x800
+#define ETH_RMII_DLY_TX_INV	BIT(2)
+#define ETH_FINE_DLY_GTXC	BIT(1)
+#define ETH_FINE_DLY_RXC	BIT(0)
+
+enum dwmac_clks_map {
+	DWMAC_CLK_AXI_DRAM,
+	DWMAC_CLK_APB_REG,
+	DWMAC_CLK_MAC_EXT,
+	DWMAC_CLK_MAC_PARENT,
+	DWMAC_CLK_PTP_REF,
+	DWMAC_CLK_PTP_PARENT,
+	DWMAC_CLK_PTP_TOP,
+	DWMAC_CLK_MAX
+};
+
+struct mac_delay_struct {
+	u32 tx_delay;
+	u32 rx_delay;
+	u32 tx_inv;
+	u32 rx_inv;
+};
+
+struct mediatek_dwmac_plat_data {
+	struct device *dev;
+	struct regmap *peri_regmap;
+	struct clk *clks[DWMAC_CLK_MAX];
+	struct device_node *np;
+	int phy_mode;
+	struct mac_delay_struct mac_delay;
+	const struct mediatek_dwmac_variant *variant;
+	int fine_tune;
+	int rmii_rxc;
+};
+
+struct mediatek_dwmac_variant {
+	int (*dwmac_config_dt)(struct mediatek_dwmac_plat_data *plat);
+	int (*dwmac_enable_clks)(struct mediatek_dwmac_plat_data *plat);
+	void (*dwmac_disable_clks)(struct mediatek_dwmac_plat_data *plat);
+	u32 rx_delay_max;
+	u32 tx_delay_max;
+};
+
+static const char * const mediatek_dwmac_clks_name[] = {
+	"axi", "apb", "mac_ext", "mac_parent", "ptp_ref", "ptp_parent", "ptp_top"
+};
+
+static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
+{
+	int rmii_rxc = plat->rmii_rxc ? RMII_CLK_SRC_RXC : 0;
+	u32 intf_val = 0;
+
+	/* select phy interface in top control domain */
+	switch (plat->phy_mode) {
+	case PHY_INTERFACE_MODE_MII:
+		intf_val |= PHY_INTF_MII_GMII;
+		break;
+	case PHY_INTERFACE_MODE_RMII:
+		intf_val |= PHY_INTF_RMII;
+		intf_val |= rmii_rxc;
+		break;
+	case PHY_INTERFACE_MODE_RGMII:
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		intf_val |= PHY_INTF_RGMII;
+		break;
+	default:
+		dev_err(plat->dev, "phy interface not supported\n");
+		return -EINVAL;
+	}
+
+	regmap_write(plat->peri_regmap, PERI_ETH_PHY_INTF_SEL, intf_val);
+
+	return 0;
+}
+
+static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
+{
+	struct mac_delay_struct *mac_delay = &plat->mac_delay;
+	u32 delay_val = 0;
+	u32 fine_val = 0;
+
+	switch (plat->phy_mode) {
+	case PHY_INTERFACE_MODE_MII:
+		delay_val |= mac_delay->tx_delay ? PHY_DLY_TXC_ENABLE : 0;
+		delay_val |= (mac_delay->tx_delay << PHY_DLY_TXC_SHIFT) &
+			     PHY_DLY_TXC_STAGES;
+		delay_val |= mac_delay->tx_inv ? PHY_DLY_TXC_INV : 0;
+		delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+		delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+			     PHY_DLY_RXC_STAGES;
+		delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+		break;
+	case PHY_INTERFACE_MODE_RMII:
+		if (plat->rmii_rxc) {
+			delay_val |= mac_delay->rx_delay ?
+				     PHY_DLY_RXC_ENABLE : 0;
+			delay_val |= (mac_delay->rx_delay <<
+				      PHY_DLY_RXC_SHIFT) & PHY_DLY_RXC_STAGES;
+			delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+			fine_val |= mac_delay->tx_inv ?
+				     ETH_RMII_DLY_TX_INV : 0;
+		} else {
+			delay_val |= mac_delay->rx_delay ?
+				     PHY_DLY_TXC_ENABLE : 0;
+			delay_val |= (mac_delay->rx_delay <<
+				     PHY_DLY_TXC_SHIFT) & PHY_DLY_TXC_STAGES;
+			delay_val |= mac_delay->rx_inv ? PHY_DLY_TXC_INV : 0;
+			fine_val |= mac_delay->tx_inv ?
+				     ETH_RMII_DLY_TX_INV : 0;
+		}
+		break;
+	case PHY_INTERFACE_MODE_RGMII:
+		fine_val = plat->fine_tune ?
+			    (ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC) : 0;
+		delay_val |= mac_delay->tx_delay ? PHY_DLY_GTXC_ENABLE : 0;
+		delay_val |= mac_delay->tx_delay & PHY_DLY_GTXC_STAGES;
+		delay_val |= mac_delay->tx_inv ? PHY_DLY_GTXC_INV : 0;
+		delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+		delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+			     PHY_DLY_RXC_STAGES;
+		delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		fine_val = plat->fine_tune ? ETH_FINE_DLY_RXC : 0;
+		delay_val |= mac_delay->rx_delay ? PHY_DLY_RXC_ENABLE : 0;
+		delay_val |= (mac_delay->rx_delay << PHY_DLY_RXC_SHIFT) &
+			     PHY_DLY_RXC_STAGES;
+		delay_val |= mac_delay->rx_inv ? PHY_DLY_RXC_INV : 0;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+		fine_val = plat->fine_tune ? ETH_FINE_DLY_GTXC : 0;
+		delay_val |= mac_delay->tx_delay ? PHY_DLY_GTXC_ENABLE : 0;
+		delay_val |= mac_delay->tx_delay & PHY_DLY_GTXC_STAGES;
+		delay_val |= mac_delay->tx_inv ? PHY_DLY_GTXC_INV : 0;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		break;
+	default:
+		dev_err(plat->dev, "phy interface not supported\n");
+		return -EINVAL;
+	}
+	regmap_write(plat->peri_regmap, PERI_ETH_PHY_DLY, delay_val);
+	regmap_write(plat->peri_regmap, PERI_ETH_DLY_FINE, fine_val);
+
+	return 0;
+}
+
+static int mt2712_get_clks(struct mediatek_dwmac_plat_data *plat)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(plat->clks); i++) {
+		plat->clks[i] = devm_clk_get(plat->dev,
+					     mediatek_dwmac_clks_name[i]);
+		if (IS_ERR(plat->clks[i]))
+			return PTR_ERR(plat->clks[i]);
+	}
+
+	return 0;
+}
+
+static int mt2712_enable_clks(struct mediatek_dwmac_plat_data *plat)
+{
+	int clk, ret;
+
+	for (clk = 0; clk < DWMAC_CLK_MAX ; clk++) {
+		ret = clk_prepare_enable(plat->clks[clk]);
+		if (ret)
+			goto err_disable_clks;
+	}
+
+	ret = clk_set_parent(plat->clks[DWMAC_CLK_MAC_EXT], plat->clks[DWMAC_CLK_MAC_PARENT]);
+	if (ret)
+		goto err_disable_clks;
+
+	ret = clk_set_parent(plat->clks[DWMAC_CLK_PTP_REF], plat->clks[DWMAC_CLK_PTP_PARENT]);
+	if (ret)
+		goto err_disable_clks;
+
+	return 0;
+
+err_disable_clks:
+	while (--clk >= 0)
+		clk_disable_unprepare(plat->clks[clk]);
+
+	return ret;
+}
+
+static void mt2712_disable_clks(struct mediatek_dwmac_plat_data *plat)
+{
+	int clk;
+
+	for (clk = DWMAC_CLK_MAX - 1; clk >= 0; clk--)
+		clk_disable_unprepare(plat->clks[clk]);
+}
+
+static int mt2712_config_dt(struct mediatek_dwmac_plat_data *plat)
+{
+	u32 tx_delay, rx_delay;
+
+	plat->peri_regmap = syscon_regmap_lookup_by_compatible("mediatek,mt2712-pericfg");
+	if (IS_ERR(plat->peri_regmap)) {
+		dev_err(plat->dev, "Failed to get pericfg syscon\n");
+		return PTR_ERR(plat->peri_regmap);
+	}
+
+	if (!of_property_read_u32(plat->np, "tx-delay", &tx_delay)) {
+		if (tx_delay < plat->variant->tx_delay_max) {
+			plat->mac_delay.tx_delay = tx_delay;
+		} else {
+			dev_err(plat->dev, "Invalid TX clock delay: %d\n", tx_delay);
+			return -EINVAL;
+		}
+	}
+
+	if (!of_property_read_u32(plat->np, "rx-delay", &rx_delay)) {
+		if (rx_delay < plat->variant->rx_delay_max) {
+			plat->mac_delay.rx_delay = rx_delay;
+		} else {
+			dev_err(plat->dev, "Invalid RX clock delay: %d\n", rx_delay);
+			return -EINVAL;
+		}
+	}
+
+	plat->mac_delay.tx_inv = of_property_read_bool(plat->np, "txc-inverse");
+
+	plat->mac_delay.rx_inv = of_property_read_bool(plat->np, "rxc-inverse");
+
+	plat->fine_tune = of_property_read_bool(plat->np, "fine-tune");
+
+	plat->rmii_rxc = of_property_read_bool(plat->np, "rmii-rxc");
+
+	mt2712_set_interface(plat);
+
+	mt2712_set_delay(plat);
+
+	return mt2712_get_clks(plat);
+}
+
+static const struct mediatek_dwmac_variant mt2712_gmac_variant = {
+		.dwmac_config_dt = mt2712_config_dt,
+		.dwmac_enable_clks = mt2712_enable_clks,
+		.dwmac_disable_clks = mt2712_disable_clks,
+		.rx_delay_max = 32,
+		.tx_delay_max = 32,
+};
+
+static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
+{
+	const struct mediatek_dwmac_variant *variant = plat->variant;
+
+	/* Set the DMA mask, 4GB mode enabled */
+	dma_set_mask_and_coherent(plat->dev, DMA_BIT_MASK(33));
+
+	return variant->dwmac_config_dt(plat);
+}
+
+static int mediatek_dwmac_init(struct platform_device *pdev, void *priv)
+{
+	struct mediatek_dwmac_plat_data *plat = priv;
+	const struct mediatek_dwmac_variant *variant = plat->variant;
+
+	return variant->dwmac_enable_clks(plat);
+}
+
+static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv)
+{
+	struct mediatek_dwmac_plat_data *plat = priv;
+	const struct mediatek_dwmac_variant *variant = plat->variant;
+
+	variant->dwmac_disable_clks(plat);
+}
+
+static int mediatek_dwmac_probe(struct platform_device *pdev)
+{
+	int ret = 0;
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	struct mediatek_dwmac_plat_data *priv_plat;
+
+	priv_plat = devm_kzalloc(&pdev->dev, sizeof(*priv_plat), GFP_KERNEL);
+	if (!priv_plat)
+		return -ENOMEM;
+
+	priv_plat->variant = of_device_get_match_data(&pdev->dev);
+	if (!priv_plat->variant) {
+		dev_err(&pdev->dev, "Missing dwmac-mediatek variant\n");
+		return -EINVAL;
+	}
+
+	priv_plat->dev = &pdev->dev;
+	priv_plat->np = pdev->dev.of_node;
+	priv_plat->phy_mode = of_get_phy_mode(priv_plat->np);
+
+	ret = mediatek_dwmac_config_dt(priv_plat);
+	if (ret)
+		return ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
+	plat_dat->interface = priv_plat->phy_mode;
+	/* clk_csr_i = 250-300MHz & MDC = clk_csr_i/124 */
+	plat_dat->clk_csr = 5;
+	plat_dat->has_gmac4 = 1;
+	plat_dat->has_gmac = 0;
+	plat_dat->pmt = 0;
+	plat_dat->maxmtu = ETH_DATA_LEN;
+	plat_dat->bsp_priv = priv_plat;
+	plat_dat->init = mediatek_dwmac_init;
+	plat_dat->exit = mediatek_dwmac_exit;
+	mediatek_dwmac_init(pdev, priv_plat);
+
+	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+	if (ret) {
+		stmmac_remove_config_dt(pdev, plat_dat);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct of_device_id mediatek_dwmac_match[] = {
+	{ .compatible = "mediatek,mt2712-gmac",
+	  .data = &mt2712_gmac_variant },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, mediatek_dwmac_match);
+
+static struct platform_driver mediatek_dwmac_driver = {
+	.probe  = mediatek_dwmac_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "dwmac-mediatek",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = mediatek_dwmac_match,
+	},
+};
+module_platform_driver(mediatek_dwmac_driver);
-- 
1.7.9.5

^ permalink raw reply related

* [v3, PATCH 2/2] dt-binding: mediatek-dwmac: add binding document for MediaTek MT2712 DWMAC
From: Biao Huang @ 2018-11-16  9:18 UTC (permalink / raw)
  To: davem, robh+dt
  Cc: honghui.zhang, yt.shen, liguo.zhang, mark.rutland, nelson.chang,
	matthias.bgg, biao.huang, netdev, devicetree, linux-kernel,
	linux-arm-kernel, linux-mediatek, joabreu, andrew
In-Reply-To: <1542359926-28800-1-git-send-email-biao.huang@mediatek.com>

The commit adds the device tree binding documentation for the MediaTek DWMAC
found on MediaTek MT2712.

Change-Id: I3728666bf65927164bd82fa8dddb90df8270bd44
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 .../devicetree/bindings/net/mediatek-dwmac.txt     |   77 ++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt

diff --git a/Documentation/devicetree/bindings/net/mediatek-dwmac.txt b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
new file mode 100644
index 0000000..7fd56e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
@@ -0,0 +1,77 @@
+MediaTek DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible:  Should be "mediatek,mt2712-gmac" for MT2712 SoC
+- reg:  Address and length of the register set for the device
+- interrupts:  Should contain the MAC interrupts
+- interrupt-names: Should contain a list of interrupt names corresponding to
+	the interrupts in the interrupts property, if available.
+	Should be "macirq" for the main MAC IRQ
+- clocks: Must contain a phandle for each entry in clock-names.
+- clock-names: The name of the clock listed in the clocks property. These are
+	"axi", "apb", "mac_ext", "mac_parent", "ptp_ref", "ptp_parent", "ptp_top"
+	for MT2712 SoC
+- mac-address: See ethernet.txt in the same directory
+- phy-mode: See ethernet.txt in the same directory
+
+Optional properties:
+- tx-delay: TX clock delay macro value. Range is 0~31. Default is 0.
+	It should be defined for rgmii/rgmii-rxid/mii interface.
+- rx-delay: RX clock delay macro value. Range is 0~31. Default is 0.
+	It should be defined for rgmii/rgmii-txid/mii/rmii interface.
+- fine-tune: This property will select coarse-tune delay or fine delay
+	for rgmii interface.
+	If fine-tune delay is enabled, tx-delay/rx-delay is 170+/-50ps
+	per stage.
+	Else coarse-tune delay is enabled, tx-delay/rx-delay is 0.55+/-0.2ns
+	per stage.
+	This property do not apply to non-rgmii PHYs.
+	Only coarse-tune delay is supported for mii/rmii PHYs.
+- rmii-rxc: Reference clock of rmii is from external PHYs,
+	and it can be connected to TXC or RXC pin on MT2712 SoC.
+	If ref_clk <--> TXC, disable it.
+	Else ref_clk <--> RXC, enable it.
+- txc-inverse: Inverse tx clock for mii/rgmii.
+	Inverse tx clock inside MAC relative to reference clock for rmii,
+	and it rarely happen.
+- rxc-inverse: Inverse rx clock for mii/rgmii interfaces.
+	Inverse reference clock for rmii.
+
+Example:
+	eth: ethernet@1101c000 {
+		compatible = "mediatek,mt2712-gmac";
+		reg = <0 0x1101c000 0 0x1300>;
+		interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
+		interrupt-names = "macirq";
+		phy-mode ="rgmii-id";
+		mac-address = [00 55 7b b5 7d f7];
+		clock-names = "axi",
+			      "apb",
+			      "mac_ext",
+			      "mac_parent",
+			      "ptp_ref",
+			      "ptp_parent",
+			      "ptp_top";
+		clocks = <&pericfg CLK_PERI_GMAC>,
+			 <&pericfg CLK_PERI_GMAC_PCLK>,
+			 <&topckgen CLK_TOP_ETHER_125M_SEL>,
+			 <&topckgen CLK_TOP_ETHERPLL_125M>,
+			 <&topckgen CLK_TOP_ETHER_50M_SEL>,
+			 <&topckgen CLK_TOP_APLL1_D3>,
+			 <&topckgen CLK_TOP_APLL1>;
+		snps,txpbl = <32>;
+		snps,rxpbl = <32>;
+		snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
+		snps,reset-active-low;
+		tx-delay = <9>;
+		rx-delay = <9>;
+		fine-tune;
+		rmii-rxc;
+		txc-inverse;
+		rxc-inverse;
+	};
-- 
1.7.9.5

^ permalink raw reply related

* Re: [PATCH net-next 4/8] net: eth: altera: tse: add optional function to start tx dma
From: Thor Thayer @ 2018-11-15 23:12 UTC (permalink / raw)
  To: Dalon Westergreen, netdev, dinguyen; +Cc: Dalon Westergreen
In-Reply-To: <20181115005047.28464-5-dwesterg@gmail.com>

On 11/14/18 6:50 PM, Dalon Westergreen wrote:
> From: Dalon Westergreen <dalon.westergreen@intel.com>
> 
> Allow for optional start up of tx dma if the start_txdma
> function is defined in altera_dmaops.
> 
> Signed-off-by: Dalon Westergreen <dalon.westergreen@intel.com>
> ---
>   drivers/net/ethernet/altera/altera_tse.h      | 1 +
>   drivers/net/ethernet/altera/altera_tse_main.c | 5 +++++
>   2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h
> index d5b97e02e6d6..7f246040135d 100644
> --- a/drivers/net/ethernet/altera/altera_tse.h
> +++ b/drivers/net/ethernet/altera/altera_tse.h
> @@ -412,6 +412,7 @@ struct altera_dmaops {
>   	int (*init_dma)(struct altera_tse_private *priv);
>   	void (*uninit_dma)(struct altera_tse_private *priv);
>   	void (*start_rxdma)(struct altera_tse_private *priv);
> +	void (*start_txdma)(struct altera_tse_private *priv);
>   };
>   
>   /* This structure is private to each device.
> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index 0c0e8f9bba9b..f6b6a14b1ce9 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -1256,6 +1256,9 @@ static int tse_open(struct net_device *dev)
>   
>   	priv->dmaops->start_rxdma(priv);
>   
> +	if (priv->dmaops->start_txdma)
> +		priv->dmaops->start_txdma(priv);
> +
>   	/* Start MAC Rx/Tx */
>   	spin_lock(&priv->mac_cfg_lock);
>   	tse_set_mac(priv, true);
> @@ -1658,6 +1661,7 @@ static const struct altera_dmaops altera_dtype_sgdma = {
>   	.init_dma = sgdma_initialize,
>   	.uninit_dma = sgdma_uninitialize,
>   	.start_rxdma = sgdma_start_rxdma,
> +	.start_txdma = NULL,
>   };
>   
>   static const struct altera_dmaops altera_dtype_msgdma = {
> @@ -1677,6 +1681,7 @@ static const struct altera_dmaops altera_dtype_msgdma = {
>   	.init_dma = msgdma_initialize,
>   	.uninit_dma = msgdma_uninitialize,
>   	.start_rxdma = msgdma_start_rxdma,
> +	.start_txdma = NULL,
>   };
>   
>   static const struct of_device_id altera_tse_ids[] = {
> 
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply

* Re: [PATCH][net-next] net: slightly optimize eth_type_trans
From: David Miller @ 2018-11-15 23:11 UTC (permalink / raw)
  To: lirongqing; +Cc: netdev
In-Reply-To: <1542072871-21208-1-git-send-email-lirongqing@baidu.com>

From: Li RongQing <lirongqing@baidu.com>
Date: Tue, 13 Nov 2018 09:34:31 +0800

> netperf udp stream shows that eth_type_trans takes certain cpu,
> so adjust the mac address check order, and firstly check if it
> is device address, and only check if it is multicast address
> only if not the device address.
> 
> After this change:
> To unicast, and skb dst mac is device mac, this is most of time
> reduce a comparision
> To unicast, and skb dst mac is not device mac, nothing change
> To multicast, increase a comparision
> 
> Before:
> 1.03%  [kernel]          [k] eth_type_trans
> 
> After:
> 0.78%  [kernel]          [k] eth_type_trans
> 
> Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>

Applied.

^ permalink raw reply

* Re: [PATCH net-next 5/8] net: eth: altera: tse: Move common functions to altera_utils
From: Thor Thayer @ 2018-11-15 23:14 UTC (permalink / raw)
  To: Dalon Westergreen, netdev, dinguyen; +Cc: Dalon Westergreen
In-Reply-To: <20181115005047.28464-6-dwesterg@gmail.com>

On 11/14/18 6:50 PM, Dalon Westergreen wrote:
> From: Dalon Westergreen <dalon.westergreen@intel.com>
> 
> Move request_and_map and other shared functions to altera_utils. This
> is the first step to moving common code out of tse specific code so
> that it can be shared with future altera ethernet ip.
> 
> Signed-off-by: Dalon Westergreen <dalon.westergreen@intel.com>
> ---
>   drivers/net/ethernet/altera/altera_tse.h      | 45 ------------------
>   .../net/ethernet/altera/altera_tse_ethtool.c  |  1 +
>   drivers/net/ethernet/altera/altera_tse_main.c | 32 +------------
>   drivers/net/ethernet/altera/altera_utils.c    | 30 ++++++++++++
>   drivers/net/ethernet/altera/altera_utils.h    | 46 +++++++++++++++++++
>   5 files changed, 78 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h
> index 7f246040135d..f435fb0eca90 100644
> --- a/drivers/net/ethernet/altera/altera_tse.h
> +++ b/drivers/net/ethernet/altera/altera_tse.h
> @@ -500,49 +500,4 @@ struct altera_tse_private {
>    */
>   void altera_tse_set_ethtool_ops(struct net_device *);
>   
> -static inline
> -u32 csrrd32(void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -	return readl(paddr);
> -}
> -
> -static inline
> -u16 csrrd16(void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -	return readw(paddr);
> -}
> -
> -static inline
> -u8 csrrd8(void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -	return readb(paddr);
> -}
> -
> -static inline
> -void csrwr32(u32 val, void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -
> -	writel(val, paddr);
> -}
> -
> -static inline
> -void csrwr16(u16 val, void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -
> -	writew(val, paddr);
> -}
> -
> -static inline
> -void csrwr8(u8 val, void __iomem *mac, size_t offs)
> -{
> -	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> -
> -	writeb(val, paddr);
> -}
> -
>   #endif /* __ALTERA_TSE_H__ */
> diff --git a/drivers/net/ethernet/altera/altera_tse_ethtool.c b/drivers/net/ethernet/altera/altera_tse_ethtool.c
> index 7c367713c3e6..2998655ab316 100644
> --- a/drivers/net/ethernet/altera/altera_tse_ethtool.c
> +++ b/drivers/net/ethernet/altera/altera_tse_ethtool.c
> @@ -33,6 +33,7 @@
>   #include <linux/phy.h>
>   
>   #include "altera_tse.h"
> +#include "altera_utils.h"
>   
>   #define TSE_STATS_LEN	31
>   #define TSE_NUM_REGS	128
> diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> index f6b6a14b1ce9..b25d03506470 100644
> --- a/drivers/net/ethernet/altera/altera_tse_main.c
> +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> @@ -34,7 +34,6 @@
>   #include <linux/if_vlan.h>
>   #include <linux/init.h>
>   #include <linux/interrupt.h>
> -#include <linux/io.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
>   #include <linux/mii.h>
> @@ -44,7 +43,7 @@
>   #include <linux/of_net.h>
>   #include <linux/of_platform.h>
>   #include <linux/phy.h>
> -#include <linux/platform_device.h>
> +#include <linux/ptp_classify.h>
>   #include <linux/skbuff.h>
>   #include <asm/cacheflush.h>
>   
> @@ -1332,35 +1331,6 @@ static struct net_device_ops altera_tse_netdev_ops = {
>   	.ndo_validate_addr	= eth_validate_addr,
>   };
>   
> -static int request_and_map(struct platform_device *pdev, const char *name,
> -			   struct resource **res, void __iomem **ptr)
> -{
> -	struct resource *region;
> -	struct device *device = &pdev->dev;
> -
> -	*res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> -	if (*res == NULL) {
> -		dev_err(device, "resource %s not defined\n", name);
> -		return -ENODEV;
> -	}
> -
> -	region = devm_request_mem_region(device, (*res)->start,
> -					 resource_size(*res), dev_name(device));
> -	if (region == NULL) {
> -		dev_err(device, "unable to request %s\n", name);
> -		return -EBUSY;
> -	}
> -
> -	*ptr = devm_ioremap_nocache(device, region->start,
> -				    resource_size(region));
> -	if (*ptr == NULL) {
> -		dev_err(device, "ioremap_nocache of %s failed!", name);
> -		return -ENOMEM;
> -	}
> -
> -	return 0;
> -}
> -
>   /* Probe Altera TSE MAC device
>    */
>   static int altera_tse_probe(struct platform_device *pdev)
> diff --git a/drivers/net/ethernet/altera/altera_utils.c b/drivers/net/ethernet/altera/altera_utils.c
> index d7eeb1713ad2..bc33b7f0b0c5 100644
> --- a/drivers/net/ethernet/altera/altera_utils.c
> +++ b/drivers/net/ethernet/altera/altera_utils.c
> @@ -42,3 +42,33 @@ int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask)
>   	u32 value = csrrd32(ioaddr, offs);
>   	return (value & bit_mask) ? 0 : 1;
>   }
> +
> +int request_and_map(struct platform_device *pdev, const char *name,
> +		    struct resource **res, void __iomem **ptr)
> +{
> +	struct resource *region;
> +	struct device *device = &pdev->dev;
> +
> +	*res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> +	if (!*res) {
> +		dev_err(device, "resource %s not defined\n", name);
> +		return -ENODEV;
> +	}
> +
> +	region = devm_request_mem_region(device, (*res)->start,
> +					 resource_size(*res), dev_name(device));
> +	if (!region) {
> +		dev_err(device, "unable to request %s\n", name);
> +		return -EBUSY;
> +	}
> +
> +	*ptr = devm_ioremap_nocache(device, region->start,
> +				    resource_size(region));
> +	if (!*ptr) {
> +		dev_err(device, "ioremap_nocache of %s failed!", name);
> +		return -ENOMEM;
> +	}
> +
> +	return 0;
> +}
> +
> diff --git a/drivers/net/ethernet/altera/altera_utils.h b/drivers/net/ethernet/altera/altera_utils.h
> index baf100ccf587..bb7eff792bb7 100644
> --- a/drivers/net/ethernet/altera/altera_utils.h
> +++ b/drivers/net/ethernet/altera/altera_utils.h
> @@ -14,7 +14,9 @@
>    * this program.  If not, see <http://www.gnu.org/licenses/>.
>    */
>   
> +#include <linux/io.h>
>   #include <linux/kernel.h>
> +#include <linux/platform_device.h>
>   
>   #ifndef __ALTERA_UTILS_H__
>   #define __ALTERA_UTILS_H__
> @@ -23,5 +25,49 @@ void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask);
>   void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask);
>   int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask);
>   int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask);
> +int request_and_map(struct platform_device *pdev, const char *name,
> +		    struct resource **res, void __iomem **ptr);
> +
> +static inline u32 csrrd32(void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	return readl(paddr);
> +}
> +
> +static inline u16 csrrd16(void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	return readw(paddr);
> +}
> +
> +static inline u8 csrrd8(void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	return readb(paddr);
> +}
> +
> +static inline void csrwr32(u32 val, void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	writel(val, paddr);
> +}
> +
> +static inline void csrwr16(u16 val, void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	writew(val, paddr);
> +}
> +
> +static inline void csrwr8(u8 val, void __iomem *mac, size_t offs)
> +{
> +	void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs);
> +
> +	writeb(val, paddr);
> +}
>   
>   #endif /* __ALTERA_UTILS_H__*/
> 
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply

* Re: [Patch net-next] net: remove unused skb_send_sock()
From: David Miller @ 2018-11-15 23:13 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, john.fastabend
In-Reply-To: <20181113020524.1569-1-xiyou.wangcong@gmail.com>

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Mon, 12 Nov 2018 18:05:24 -0800

> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

John, any plans to use this?  Looks like only skb_send_sock_lock()
currently has a user.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox