Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 1/6] net-tc: remove unused tc_verd fields
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

Remove the last reference to tc_verd's munge and redirect ttl bits.
These fields are no longer used.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/uapi/linux/pkt_cls.h | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index cb4bcdc58543..c769f71972f5 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -17,10 +17,6 @@
 
 /* verdict bit breakdown 
  *
-bit 0: when set -> this packet has been munged already
-
-bit 1: when set -> It is ok to munge this packet
-
 bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
 assume loop
 
@@ -31,8 +27,6 @@ bit 6,7: Where this packet was last seen
 
 bit 8: when set --> Request not to classify on ingress. 
 
-bits 9,10,11: redirect counter -  redirect TTL. Loop avoidance
-
  *
  * */
 
@@ -56,7 +50,6 @@ bits 9,10,11: redirect counter -  redirect TTL. Loop avoidance
 #define SET_TC_AT(v,n)   ((V_TC_AT(n)) | (v & ~M_TC_AT))
 
 #define MAX_REC_LOOP 4
-#define MAX_RED_LOOP 4
 #endif
 
 /* Action attributes */
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* [PATCH net-next 2/6] net-tc: make MAX_RECLASSIFY_LOOP local
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

This field is no longer kept in tc_verd. Remove it from the global
definition of that struct.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/uapi/linux/pkt_cls.h | 5 -----
 net/sched/sch_api.c          | 3 ++-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index c769f71972f5..bba23dbb3ab6 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -17,9 +17,6 @@
 
 /* verdict bit breakdown 
  *
-bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
-assume loop
-
 bit 6,7: Where this packet was last seen 
 0: Above the transmit example at the socket level
 1: on the Ingress
@@ -48,8 +45,6 @@ bit 8: when set --> Request not to classify on ingress.
 #define G_TC_AT(x)       _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
 #define V_TC_AT(x)       _TC_MAKEVALUE(x,S_TC_AT)
 #define SET_TC_AT(v,n)   ((V_TC_AT(n)) | (v & ~M_TC_AT))
-
-#define MAX_REC_LOOP 4
 #endif
 
 /* Action attributes */
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index d7b93429f0cc..ef53ede11590 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1861,6 +1861,7 @@ int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 {
 	__be16 protocol = tc_skb_protocol(skb);
 #ifdef CONFIG_NET_CLS_ACT
+	const int max_reclassify_loop = 4;
 	const struct tcf_proto *old_tp = tp;
 	int limit = 0;
 
@@ -1885,7 +1886,7 @@ int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
 	return TC_ACT_UNSPEC; /* signal: continue lookup */
 #ifdef CONFIG_NET_CLS_ACT
 reset:
-	if (unlikely(limit++ >= MAX_REC_LOOP)) {
+	if (unlikely(limit++ >= max_reclassify_loop)) {
 		net_notice_ratelimited("%s: reclassify loop, rule prio %u, protocol %02x\n",
 				       tp->q->ops->id, tp->prio & 0xffff,
 				       ntohs(tp->protocol));
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* [PATCH net-next 3/6] net-tc: extract skip classify bit from tc_verd
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

Packets sent by the IFB device skip subsequent tc classification.
A single bit governs this state. Move it out of tc_verd in
anticipation of removing that __u16 completely.

The new bitfield tc_skip_classify temporarily uses one bit of a
hole, until tc_verd is removed completely in a follow-up patch.

Remove the bit hole comment. It could be 2, 3, 4 or 5 bits long.
With that many options, little value in documenting it.

Introduce a helper function to deduplicate the logic in the two
sites that check this bit.

The field tc_skip_classify is set only in IFB on skbs cloned in
act_mirred, so original packet sources do not have to clear the
bit when reusing packets (notably, pktgen and octeon).

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 drivers/net/ifb.c            |  2 +-
 include/linux/skbuff.h       |  5 ++++-
 include/net/sch_generic.h    | 11 +++++++++++
 include/uapi/linux/pkt_cls.h |  6 ------
 net/core/dev.c               | 10 +++-------
 net/sched/act_api.c          | 11 ++++-------
 6 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 66c0eeafcb5d..4299ac163376 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -81,7 +81,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
 		u32 from = G_TC_FROM(skb->tc_verd);
 
 		skb->tc_verd = 0;
-		skb->tc_verd = SET_TC_NCLS(skb->tc_verd);
+		skb->tc_skip_classify = 1;
 
 		u64_stats_update_begin(&txp->tsync);
 		txp->tx_packets++;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..570f60ec6cb4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -589,6 +589,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
  *	@pkt_type: Packet class
  *	@fclone: skbuff clone status
  *	@ipvs_property: skbuff is owned by ipvs
+ *	@tc_skip_classify: do not classify packet. set by IFB device
  *	@peeked: this packet has been seen already, so stats have been
  *		done for it, don't do them again
  *	@nf_trace: netfilter packet trace flag
@@ -749,7 +750,9 @@ struct sk_buff {
 #ifdef CONFIG_NET_SWITCHDEV
 	__u8			offload_fwd_mark:1;
 #endif
-	/* 2, 4 or 5 bit hole */
+#ifdef CONFIG_NET_CLS_ACT
+	__u8			tc_skip_classify:1;
+#endif
 
 #ifdef CONFIG_NET_SCHED
 	__u16			tc_index;	/* traffic control index */
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 498f81b229a4..857356f2d74b 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -418,6 +418,17 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
 #endif
 }
 
+static inline bool skb_skip_tc_classify(struct sk_buff *skb)
+{
+#ifdef CONFIG_NET_CLS_ACT
+	if (skb->tc_skip_classify) {
+		skb->tc_skip_classify = 0;
+		return true;
+	}
+#endif
+	return false;
+}
+
 /* Reset all TX qdiscs greater then index of a device.  */
 static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
 {
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index bba23dbb3ab6..1eed5d7509bc 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -22,8 +22,6 @@ bit 6,7: Where this packet was last seen
 1: on the Ingress
 2: on the Egress
 
-bit 8: when set --> Request not to classify on ingress. 
-
  *
  * */
 
@@ -36,10 +34,6 @@ bit 8: when set --> Request not to classify on ingress.
 #define AT_INGRESS	0x1
 #define AT_EGRESS	0x2
 
-#define TC_NCLS          _TC_MAKEMASK1(8)
-#define SET_TC_NCLS(v)   ( TC_NCLS | (v & ~TC_NCLS))
-#define CLR_TC_NCLS(v)   ( v & ~TC_NCLS)
-
 #define S_TC_AT          _TC_MAKE32(12)
 #define M_TC_AT          _TC_MAKEMASK(2,S_TC_AT)
 #define G_TC_AT(x)       _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
diff --git a/net/core/dev.c b/net/core/dev.c
index 56818f7eab2b..e39e35d2e082 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4093,12 +4093,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
 			goto out;
 	}
 
-#ifdef CONFIG_NET_CLS_ACT
-	if (skb->tc_verd & TC_NCLS) {
-		skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
-		goto ncls;
-	}
-#endif
+	if (skb_skip_tc_classify(skb))
+		goto skip_classify;
 
 	if (pfmemalloc)
 		goto skip_taps;
@@ -4128,8 +4124,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
 #endif
 #ifdef CONFIG_NET_CLS_ACT
 	skb->tc_verd = 0;
-ncls:
 #endif
+skip_classify:
 	if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
 		goto drop;
 
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 2095c83ce773..f04715a57300 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -426,11 +426,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
 {
 	int ret = -1, i;
 
-	if (skb->tc_verd & TC_NCLS) {
-		skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
-		ret = TC_ACT_OK;
-		goto exec_done;
-	}
+	if (skb_skip_tc_classify(skb))
+		return TC_ACT_OK;
+
 	for (i = 0; i < nr_actions; i++) {
 		const struct tc_action *a = actions[i];
 
@@ -439,9 +437,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
 		if (ret == TC_ACT_REPEAT)
 			goto repeat;	/* we need a ttl - JHS */
 		if (ret != TC_ACT_PIPE)
-			goto exec_done;
+			break;
 	}
-exec_done:
 	return ret;
 }
 EXPORT_SYMBOL(tcf_action_exec);
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* [PATCH net-next 4/6] net-tc: convert tc_verd to integer bitfields
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

Extract the remaining two fields from tc_verd and remove the __u16
completely. TC_AT and TC_FROM are converted to equivalent two-bit
integer fields tc_at and tc_from. Where possible, use existing
helper skb_at_tc_ingress when reading tc_at. Introduce helper
skb_reset_tc to clear fields.

Not documenting tc_from and tc_at, because they will be replaced
with single bit fields in follow-on patches.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 drivers/net/ifb.c                    |  7 +++----
 drivers/staging/octeon/ethernet-tx.c |  5 ++---
 include/linux/skbuff.h               |  6 ++----
 include/net/sch_generic.h            | 10 +++++++++-
 include/uapi/linux/pkt_cls.h         | 31 -------------------------------
 net/core/dev.c                       | 10 ++++------
 net/core/pktgen.c                    |  4 +---
 net/core/skbuff.c                    |  3 ---
 net/sched/act_ife.c                  |  7 +++----
 net/sched/act_mirred.c               |  9 ++++-----
 net/sched/sch_netem.c                |  2 +-
 11 files changed, 29 insertions(+), 65 deletions(-)

diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 4299ac163376..90ad8791bc99 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -78,9 +78,9 @@ static void ifb_ri_tasklet(unsigned long _txp)
 	}
 
 	while ((skb = __skb_dequeue(&txp->tq)) != NULL) {
-		u32 from = G_TC_FROM(skb->tc_verd);
+		u32 from = skb->tc_from;
 
-		skb->tc_verd = 0;
+		skb_reset_tc(skb);
 		skb->tc_skip_classify = 1;
 
 		u64_stats_update_begin(&txp->tsync);
@@ -241,7 +241,6 @@ static void ifb_setup(struct net_device *dev)
 static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct ifb_dev_private *dp = netdev_priv(dev);
-	u32 from = G_TC_FROM(skb->tc_verd);
 	struct ifb_q_private *txp = dp->tx_private + skb_get_queue_mapping(skb);
 
 	u64_stats_update_begin(&txp->rsync);
@@ -249,7 +248,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
 	txp->rx_bytes += skb->len;
 	u64_stats_update_end(&txp->rsync);
 
-	if (!(from & (AT_INGRESS|AT_EGRESS)) || !skb->skb_iif) {
+	if (skb->tc_from == AT_STACK || !skb->skb_iif) {
 		dev_kfree_skb(skb);
 		dev->stats.rx_dropped++;
 		return NETDEV_TX_OK;
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 6b4c20872323..0b8053205091 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -23,6 +23,7 @@
 #endif /* CONFIG_XFRM */
 
 #include <linux/atomic.h>
+#include <net/sch_generic.h>
 
 #include <asm/octeon/octeon.h>
 
@@ -369,9 +370,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 
 #ifdef CONFIG_NET_SCHED
 	skb->tc_index = 0;
-#ifdef CONFIG_NET_CLS_ACT
-	skb->tc_verd = 0;
-#endif /* CONFIG_NET_CLS_ACT */
+	skb_reset_tc(skb);
 #endif /* CONFIG_NET_SCHED */
 #endif /* REUSE_SKBUFFS_WITHOUT_FREE */
 
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 570f60ec6cb4..f738d09947b2 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -599,7 +599,6 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
  *	@nf_bridge: Saved data about a bridged frame - see br_netfilter.c
  *	@skb_iif: ifindex of device we arrived on
  *	@tc_index: Traffic control index
- *	@tc_verd: traffic control verdict
  *	@hash: the packet hash
  *	@queue_mapping: Queue mapping for multiqueue devices
  *	@xmit_more: More SKBs are pending for this queue
@@ -752,13 +751,12 @@ struct sk_buff {
 #endif
 #ifdef CONFIG_NET_CLS_ACT
 	__u8			tc_skip_classify:1;
+	__u8			tc_at:2;
+	__u8			tc_from:2;
 #endif
 
 #ifdef CONFIG_NET_SCHED
 	__u16			tc_index;	/* traffic control index */
-#ifdef CONFIG_NET_CLS_ACT
-	__u16			tc_verd;	/* traffic control verdict */
-#endif
 #endif
 
 	union {
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 857356f2d74b..f80dba516964 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -409,10 +409,18 @@ bool tcf_destroy(struct tcf_proto *tp, bool force);
 void tcf_destroy_chain(struct tcf_proto __rcu **fl);
 int skb_do_redirect(struct sk_buff *);
 
+static inline void skb_reset_tc(struct sk_buff *skb)
+{
+#ifdef CONFIG_NET_CLS_ACT
+	skb->tc_at = 0;
+	skb->tc_from = 0;
+#endif
+}
+
 static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
 {
 #ifdef CONFIG_NET_CLS_ACT
-	return G_TC_AT(skb->tc_verd) & AT_INGRESS;
+	return skb->tc_at & AT_INGRESS;
 #else
 	return false;
 #endif
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 1eed5d7509bc..cee753a7a40c 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -5,40 +5,9 @@
 #include <linux/pkt_sched.h>
 
 #ifdef __KERNEL__
-/* I think i could have done better macros ; for now this is stolen from
- * some arch/mips code - jhs
-*/
-#define _TC_MAKE32(x) ((x))
-
-#define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
-#define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
-#define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
-#define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
-
-/* verdict bit breakdown 
- *
-bit 6,7: Where this packet was last seen 
-0: Above the transmit example at the socket level
-1: on the Ingress
-2: on the Egress
-
- *
- * */
-
-#define S_TC_FROM          _TC_MAKE32(6)
-#define M_TC_FROM          _TC_MAKEMASK(2,S_TC_FROM)
-#define G_TC_FROM(x)       _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
-#define V_TC_FROM(x)       _TC_MAKEVALUE(x,S_TC_FROM)
-#define SET_TC_FROM(v,n)   ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
 #define AT_STACK	0x0
 #define AT_INGRESS	0x1
 #define AT_EGRESS	0x2
-
-#define S_TC_AT          _TC_MAKE32(12)
-#define M_TC_AT          _TC_MAKEMASK(2,S_TC_AT)
-#define G_TC_AT(x)       _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
-#define V_TC_AT(x)       _TC_MAKEVALUE(x,S_TC_AT)
-#define SET_TC_AT(v,n)   ((V_TC_AT(n)) | (v & ~M_TC_AT))
 #endif
 
 /* Action attributes */
diff --git a/net/core/dev.c b/net/core/dev.c
index e39e35d2e082..8b5d6d033473 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3153,7 +3153,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
 	if (!cl)
 		return skb;
 
-	/* skb->tc_verd and qdisc_skb_cb(skb)->pkt_len were already set
+	/* skb->tc_at and qdisc_skb_cb(skb)->pkt_len were already set
 	 * earlier by the caller.
 	 */
 	qdisc_bstats_cpu_update(cl->q, skb);
@@ -3320,7 +3320,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
 
 	qdisc_pkt_len_init(skb);
 #ifdef CONFIG_NET_CLS_ACT
-	skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS);
+	skb->tc_at = AT_EGRESS;
 # ifdef CONFIG_NET_EGRESS
 	if (static_key_false(&egress_needed)) {
 		skb = sch_handle_egress(skb, &rc, dev);
@@ -3920,7 +3920,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
 	}
 
 	qdisc_skb_cb(skb)->pkt_len = skb->len;
-	skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS);
+	skb->tc_at = AT_INGRESS;
 	qdisc_bstats_cpu_update(cl->q, skb);
 
 	switch (tc_classify(skb, cl, &cl_res, false)) {
@@ -4122,9 +4122,7 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
 			goto out;
 	}
 #endif
-#ifdef CONFIG_NET_CLS_ACT
-	skb->tc_verd = 0;
-#endif
+	skb_reset_tc(skb);
 skip_classify:
 	if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
 		goto drop;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8e69ce472236..96947f5d41e4 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3439,9 +3439,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
 			/* skb was 'freed' by stack, so clean few
 			 * bits and reuse it
 			 */
-#ifdef CONFIG_NET_CLS_ACT
-			skb->tc_verd = 0; /* reset reclass/redir ttl */
-#endif
+			skb_reset_tc(skb);
 		} while (--burst > 0);
 		goto out; /* Skips xmit_mode M_START_XMIT */
 	} else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5a03730fbc1a..adec4bf807d8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -878,9 +878,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 #endif
 #ifdef CONFIG_NET_SCHED
 	CHECK_SKB_FIELD(tc_index);
-#ifdef CONFIG_NET_CLS_ACT
-	CHECK_SKB_FIELD(tc_verd);
-#endif
 #endif
 
 }
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 80b848d3f096..921fb20eaa7c 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -736,12 +736,11 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
 	u16 metalen = ife_get_sz(skb, ife);
 	int hdrm = metalen + skb->dev->hard_header_len + IFE_METAHDRLEN;
 	unsigned int skboff = skb->dev->hard_header_len;
-	u32 at = G_TC_AT(skb->tc_verd);
 	int new_len = skb->len + hdrm;
 	bool exceed_mtu = false;
 	int err;
 
-	if (at & AT_EGRESS) {
+	if (!skb_at_tc_ingress(skb)) {
 		if (new_len > skb->dev->mtu)
 			exceed_mtu = true;
 	}
@@ -773,7 +772,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
 		return TC_ACT_SHOT;
 	}
 
-	if (!(at & AT_EGRESS))
+	if (skb_at_tc_ingress(skb))
 		skb_push(skb, skb->dev->hard_header_len);
 
 	iethh = (struct ethhdr *)skb->data;
@@ -816,7 +815,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
 		ether_addr_copy(oethh->h_dest, iethh->h_dest);
 	oethh->h_proto = htons(ife->eth_type);
 
-	if (!(at & AT_EGRESS))
+	if (skb_at_tc_ingress(skb))
 		skb_pull(skb, skb->dev->hard_header_len);
 
 	spin_unlock(&ife->tcf_lock);
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 2d9fa6e0a1b4..8543279bba49 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -170,7 +170,6 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 	int retval, err = 0;
 	int m_eaction;
 	int mac_len;
-	u32 at;
 
 	tcf_lastuse_update(&m->tcf_tm);
 	bstats_cpu_update(this_cpu_ptr(m->common.cpu_bstats), skb);
@@ -191,7 +190,6 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 		goto out;
 	}
 
-	at = G_TC_AT(skb->tc_verd);
 	skb2 = skb_clone(skb, GFP_ATOMIC);
 	if (!skb2)
 		goto out;
@@ -200,8 +198,9 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 	 * and devices expect a mac header on xmit, then mac push/pull is
 	 * needed.
 	 */
-	if (at != tcf_mirred_act_direction(m_eaction) && m_mac_header_xmit) {
-		if (at & AT_EGRESS) {
+	if (skb->tc_at != tcf_mirred_act_direction(m_eaction) &&
+	    m_mac_header_xmit) {
+		if (!skb_at_tc_ingress(skb)) {
 			/* caught at egress, act ingress: pull mac */
 			mac_len = skb_network_header(skb) - skb_mac_header(skb);
 			skb_pull_rcsum(skb2, mac_len);
@@ -213,7 +212,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 
 	/* mirror is always swallowed */
 	if (tcf_mirred_is_act_redirect(m_eaction))
-		skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at);
+		skb2->tc_from = skb2->tc_at;
 
 	skb2->skb_iif = skb->dev->ifindex;
 	skb2->dev = dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index bcfadfdea8e0..bb5c638b6852 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -626,7 +626,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
 			 * If it's at ingress let's pretend the delay is
 			 * from the network (tstamp will be updated).
 			 */
-			if (G_TC_FROM(skb->tc_verd) & AT_INGRESS)
+			if (skb->tc_from & AT_INGRESS)
 				skb->tstamp = 0;
 #endif
 
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* [PATCH net-next 5/6] net-tc: convert tc_at to tc_at_ingress
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

Field tc_at is used only within tc actions to distinguish ingress from
egress processing. A single bit is sufficient for this purpose.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/linux/skbuff.h    |  3 ++-
 include/net/sch_generic.h |  3 +--
 net/core/dev.c            |  8 +++-----
 net/sched/act_mirred.c    | 12 ++++++------
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f738d09947b2..fab3f87e9bd1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -590,6 +590,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
  *	@fclone: skbuff clone status
  *	@ipvs_property: skbuff is owned by ipvs
  *	@tc_skip_classify: do not classify packet. set by IFB device
+ *	@tc_at_ingress: used within tc_classify to distinguish in/egress
  *	@peeked: this packet has been seen already, so stats have been
  *		done for it, don't do them again
  *	@nf_trace: netfilter packet trace flag
@@ -751,7 +752,7 @@ struct sk_buff {
 #endif
 #ifdef CONFIG_NET_CLS_ACT
 	__u8			tc_skip_classify:1;
-	__u8			tc_at:2;
+	__u8			tc_at_ingress:1;
 	__u8			tc_from:2;
 #endif
 
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index f80dba516964..4bd6d5387209 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -412,7 +412,6 @@ int skb_do_redirect(struct sk_buff *);
 static inline void skb_reset_tc(struct sk_buff *skb)
 {
 #ifdef CONFIG_NET_CLS_ACT
-	skb->tc_at = 0;
 	skb->tc_from = 0;
 #endif
 }
@@ -420,7 +419,7 @@ static inline void skb_reset_tc(struct sk_buff *skb)
 static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
 {
 #ifdef CONFIG_NET_CLS_ACT
-	return skb->tc_at & AT_INGRESS;
+	return skb->tc_at_ingress;
 #else
 	return false;
 #endif
diff --git a/net/core/dev.c b/net/core/dev.c
index 8b5d6d033473..c143f1391117 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3153,9 +3153,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
 	if (!cl)
 		return skb;
 
-	/* skb->tc_at and qdisc_skb_cb(skb)->pkt_len were already set
-	 * earlier by the caller.
-	 */
+	/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
 	qdisc_bstats_cpu_update(cl->q, skb);
 
 	switch (tc_classify(skb, cl, &cl_res, false)) {
@@ -3320,7 +3318,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
 
 	qdisc_pkt_len_init(skb);
 #ifdef CONFIG_NET_CLS_ACT
-	skb->tc_at = AT_EGRESS;
+	skb->tc_at_ingress = 0;
 # ifdef CONFIG_NET_EGRESS
 	if (static_key_false(&egress_needed)) {
 		skb = sch_handle_egress(skb, &rc, dev);
@@ -3920,7 +3918,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
 	}
 
 	qdisc_skb_cb(skb)->pkt_len = skb->len;
-	skb->tc_at = AT_INGRESS;
+	skb->tc_at_ingress = 1;
 	qdisc_bstats_cpu_update(cl->q, skb);
 
 	switch (tc_classify(skb, cl, &cl_res, false)) {
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 8543279bba49..e832c62fd705 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -39,15 +39,15 @@ static bool tcf_mirred_is_act_redirect(int action)
 	return action == TCA_EGRESS_REDIR || action == TCA_INGRESS_REDIR;
 }
 
-static u32 tcf_mirred_act_direction(int action)
+static bool tcf_mirred_act_wants_ingress(int action)
 {
 	switch (action) {
 	case TCA_EGRESS_REDIR:
 	case TCA_EGRESS_MIRROR:
-		return AT_EGRESS;
+		return false;
 	case TCA_INGRESS_REDIR:
 	case TCA_INGRESS_MIRROR:
-		return AT_INGRESS;
+		return true;
 	default:
 		BUG();
 	}
@@ -198,7 +198,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 	 * and devices expect a mac header on xmit, then mac push/pull is
 	 * needed.
 	 */
-	if (skb->tc_at != tcf_mirred_act_direction(m_eaction) &&
+	if (skb_at_tc_ingress(skb) != tcf_mirred_act_wants_ingress(m_eaction) &&
 	    m_mac_header_xmit) {
 		if (!skb_at_tc_ingress(skb)) {
 			/* caught at egress, act ingress: pull mac */
@@ -212,11 +212,11 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 
 	/* mirror is always swallowed */
 	if (tcf_mirred_is_act_redirect(m_eaction))
-		skb2->tc_from = skb2->tc_at;
+		skb2->tc_from = skb_at_tc_ingress(skb) ? AT_INGRESS : AT_EGRESS;
 
 	skb2->skb_iif = skb->dev->ifindex;
 	skb2->dev = dev;
-	if (tcf_mirred_act_direction(m_eaction) & AT_EGRESS)
+	if (!tcf_mirred_act_wants_ingress(m_eaction))
 		err = dev_queue_xmit(skb2);
 	else
 		err = netif_receive_skb(skb2);
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* [PATCH net-next 6/6] net-tc: convert tc_from to tc_from_ingress and tc_redirected
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
  To: netdev
  Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
	Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

The tc_from field fulfills two roles. It encodes whether a packet was
redirected by an act_mirred device and, if so, whether act_mirred was
called on ingress or egress. Split it into separate fields.

The information is needed by the special IFB loop, where packets are
taken out of the normal path by act_mirred, forwarded to IFB, then
reinjected at their original location (ingress or egress) by IFB.

The IFB device cannot use skb->tc_at_ingress, because that may have
been overwritten as the packet travels from act_mirred to ifb_xmit,
when it passes through tc_classify on the IFB egress path. Cache this
value in skb->tc_from_ingress.

That field is valid only if a packet arriving at ifb_xmit came from
act_mirred. Other packets can be crafted to reach ifb_xmit. These
must be dropped. Set tc_redirected on redirection and drop all packets
that do not have this bit set.

Both fields are set only on cloned skbs in tc actions, so original
packet sources do not have to clear the bit when reusing packets
(notably, pktgen and octeon).

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 drivers/net/ifb.c            | 13 +++++--------
 include/linux/skbuff.h       |  5 ++++-
 include/net/sch_generic.h    |  2 +-
 include/uapi/linux/pkt_cls.h |  6 ------
 net/sched/act_mirred.c       |  6 ++++--
 net/sched/sch_netem.c        |  2 +-
 6 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 90ad8791bc99..193af7483bb0 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -78,9 +78,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
 	}
 
 	while ((skb = __skb_dequeue(&txp->tq)) != NULL) {
-		u32 from = skb->tc_from;
-
-		skb_reset_tc(skb);
+		skb->tc_redirected = 0;
 		skb->tc_skip_classify = 1;
 
 		u64_stats_update_begin(&txp->tsync);
@@ -101,13 +99,12 @@ static void ifb_ri_tasklet(unsigned long _txp)
 		rcu_read_unlock();
 		skb->skb_iif = txp->dev->ifindex;
 
-		if (from & AT_EGRESS) {
+		if (!skb->tc_from_ingress) {
 			dev_queue_xmit(skb);
-		} else if (from & AT_INGRESS) {
+		} else {
 			skb_pull(skb, skb->mac_len);
 			netif_receive_skb(skb);
-		} else
-			BUG();
+		}
 	}
 
 	if (__netif_tx_trylock(txq)) {
@@ -248,7 +245,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
 	txp->rx_bytes += skb->len;
 	u64_stats_update_end(&txp->rsync);
 
-	if (skb->tc_from == AT_STACK || !skb->skb_iif) {
+	if (!skb->tc_redirected || !skb->skb_iif) {
 		dev_kfree_skb(skb);
 		dev->stats.rx_dropped++;
 		return NETDEV_TX_OK;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index fab3f87e9bd1..3149a88de548 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -591,6 +591,8 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
  *	@ipvs_property: skbuff is owned by ipvs
  *	@tc_skip_classify: do not classify packet. set by IFB device
  *	@tc_at_ingress: used within tc_classify to distinguish in/egress
+ *	@tc_redirected: packet was redirected by a tc action
+ *	@tc_from_ingress: if tc_redirected, tc_at_ingress at time of redirect
  *	@peeked: this packet has been seen already, so stats have been
  *		done for it, don't do them again
  *	@nf_trace: netfilter packet trace flag
@@ -753,7 +755,8 @@ struct sk_buff {
 #ifdef CONFIG_NET_CLS_ACT
 	__u8			tc_skip_classify:1;
 	__u8			tc_at_ingress:1;
-	__u8			tc_from:2;
+	__u8			tc_redirected:1;
+	__u8			tc_from_ingress:1;
 #endif
 
 #ifdef CONFIG_NET_SCHED
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 4bd6d5387209..e2f426f6d62f 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -412,7 +412,7 @@ int skb_do_redirect(struct sk_buff *);
 static inline void skb_reset_tc(struct sk_buff *skb)
 {
 #ifdef CONFIG_NET_CLS_ACT
-	skb->tc_from = 0;
+	skb->tc_redirected = 0;
 #endif
 }
 
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index cee753a7a40c..a081efbd61a2 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -4,12 +4,6 @@
 #include <linux/types.h>
 #include <linux/pkt_sched.h>
 
-#ifdef __KERNEL__
-#define AT_STACK	0x0
-#define AT_INGRESS	0x1
-#define AT_EGRESS	0x2
-#endif
-
 /* Action attributes */
 enum {
 	TCA_ACT_UNSPEC,
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index e832c62fd705..84682f02b611 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -211,8 +211,10 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
 	}
 
 	/* mirror is always swallowed */
-	if (tcf_mirred_is_act_redirect(m_eaction))
-		skb2->tc_from = skb_at_tc_ingress(skb) ? AT_INGRESS : AT_EGRESS;
+	if (tcf_mirred_is_act_redirect(m_eaction)) {
+		skb2->tc_redirected = 1;
+		skb2->tc_from_ingress = skb2->tc_at_ingress;
+	}
 
 	skb2->skb_iif = skb->dev->ifindex;
 	skb2->dev = dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index bb5c638b6852..c8bb62a1e744 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -626,7 +626,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
 			 * If it's at ingress let's pretend the delay is
 			 * from the network (tstamp will be updated).
 			 */
-			if (skb->tc_from & AT_INGRESS)
+			if (skb->tc_redirected && skb->tc_from_ingress)
 				skb->tstamp = 0;
 #endif
 
-- 
2.11.0.390.gc69c2f50cf-goog

^ permalink raw reply related

* Re: [PATCH v2 net-next 3/4] secure_seq: use SipHash in place of MD5
From: Eric Biggers @ 2017-01-07 22:09 UTC (permalink / raw)
  To: David Miller
  Cc: Jason, jeanphilippe.aumasson, gregkh, netdev, linux-kernel, ak,
	David.Laight, tom, hannes, eric.dumazet, luto
In-Reply-To: <20170107.163736.2224609477435674963.davem@davemloft.net>

Hi David,

On Sat, Jan 07, 2017 at 04:37:36PM -0500, David Miller wrote:
> From: "Jason A. Donenfeld" <Jason@zx2c4.com>
> Date: Sat,  7 Jan 2017 15:40:56 +0100
> 
> > This gives a clear speed and security improvement. Siphash is both
> > faster and is more solid crypto than the aging MD5.
[snip]
> 
> This and the next patch are a real shame, performance wise, on cpus
> that have single-instruction SHA1 and MD5 implementations.  Sparc64
> has both, and I believe x86_64 can do SHA1 these days.
> 
> It took so long to get those instructions into real silicon, and then
> have software implemented to make use of them as well.
> 
> Who knows when we'll see SipHash widely deployed in any instruction
> set, if at all, right?  And by that time we'll possibly find out that
> "Oh shit, this SipHash thing has flaws!" and we'll need
> DIPPY_DO_DA_HASH and thus be forced back to a software implementation
> again.
> 
> I understand the reasons why these patches are being proposed, I just
> thought I'd mention the issue of cpus that implement secure hash
> algorithm instructions.

Well, except those instructions aren't actually used in these places.  Although
x86_64 SHA1-NI accelerated SHA-1 is available in the Linux crypto API, it seems
that in kernel code it remains impractical to use these instructions on small
amounts of data because they use XMM registers, which means the overhead of
kernel_fpu_begin()/kernel_fpu_end() must be incurred.  Furthermore,
kernel_fpu_begin() is not allowed in all contexts so there has to be a fallback.

Out of curiosity, is this actually a solvable problem, e.g. by making the code
using the XMM registers responsible for saving and restoring the ones clobbered,
or by optimizing kernel_fpu_begin()/kernel_fpu_end()?  Or does it in fact remain
impractical for such instructions to be used for applications like this one?

Eric

^ permalink raw reply

* [PATCH] net: intel: e100: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2017-01-07 22:18 UTC (permalink / raw)
  To: jeffrey.t.kirsher, davem
  Cc: intel-wired-lan, netdev, linux-kernel, Philippe Reynes

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/net/ethernet/intel/e100.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 25c6dfd..04e9392 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2426,19 +2426,21 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
 #define E100_82552_LED_ON       0x000F /* LEDTX and LED_RX both on */
 #define E100_82552_LED_OFF      0x000A /* LEDTX and LED_RX both off */
 
-static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
+static int e100_get_link_ksettings(struct net_device *netdev,
+				   struct ethtool_link_ksettings *cmd)
 {
 	struct nic *nic = netdev_priv(netdev);
-	return mii_ethtool_gset(&nic->mii, cmd);
+	return mii_ethtool_get_link_ksettings(&nic->mii, cmd);
 }
 
-static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
+static int e100_set_link_ksettings(struct net_device *netdev,
+				   const struct ethtool_link_ksettings *cmd)
 {
 	struct nic *nic = netdev_priv(netdev);
 	int err;
 
 	mdio_write(netdev, nic->mii.phy_id, MII_BMCR, BMCR_RESET);
-	err = mii_ethtool_sset(&nic->mii, cmd);
+	err = mii_ethtool_set_link_ksettings(&nic->mii, cmd);
 	e100_exec_cb(nic, NULL, e100_configure);
 
 	return err;
@@ -2741,8 +2743,6 @@ static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 }
 
 static const struct ethtool_ops e100_ethtool_ops = {
-	.get_settings		= e100_get_settings,
-	.set_settings		= e100_set_settings,
 	.get_drvinfo		= e100_get_drvinfo,
 	.get_regs_len		= e100_get_regs_len,
 	.get_regs		= e100_get_regs,
@@ -2763,6 +2763,8 @@ static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 	.get_ethtool_stats	= e100_get_ethtool_stats,
 	.get_sset_count		= e100_get_sset_count,
 	.get_ts_info		= ethtool_op_get_ts_info,
+	.get_link_ksettings	= e100_get_link_ksettings,
+	.set_link_ksettings	= e100_set_link_ksettings,
 };
 
 static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-- 
1.7.4.4

^ permalink raw reply related

* Re: [RFC PATCH] intel: Use upper_32_bits and lower_32_bits
From: Julia Lawall @ 2017-01-07 22:20 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jeff Kirsher, Julia Lawall, intel-wired-lan, netdev, linux-kernel
In-Reply-To: <7a5cfe63cad3ef4badc30cbc2185a5bfb9250fd8.1483813334.git.joe@perches.com>

On Sat, 7 Jan 2017, Joe Perches wrote:

> Shifting and masking various types can be made a bit
> simpler to read by using the available kernel macros.

It looks much nicer to me, especially in the lower case, where there are
multiple ways to express the same thing.

julia


>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>
> This RFC patch is meant as an example, not necessarily
> to apply, though it does compile to equivalent code.
>
> It does seem a bit simpler for a human to read.
>
> Perhaps this could be automated via a coccinelle script,
> but this was done with grep & sed and some typing.
>
> Treewide, there are many hundred instances of this style code
> that could be converted.
>
> Dunno if it's really worth it though.
>
> Another usage that could be converted is DMA_BIT_MASK(32)
> where it is equivalent to upper_32_bits and lower_32_bits.
>
>  drivers/net/ethernet/intel/e1000/e1000_ethtool.c   |  8 ++++----
>  drivers/net/ethernet/intel/e1000/e1000_main.c      |  8 ++++----
>  drivers/net/ethernet/intel/e1000e/ethtool.c        |  8 ++++----
>  drivers/net/ethernet/intel/fm10k/fm10k_common.c    |  4 ++--
>  drivers/net/ethernet/intel/fm10k/fm10k_pf.c        |  2 +-
>  drivers/net/ethernet/intel/i40e/i40e_common.c      |  4 ++--
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c     |  8 ++++----
>  drivers/net/ethernet/intel/i40e/i40e_main.c        |  4 ++--
>  drivers/net/ethernet/intel/i40e/i40e_ptp.c         | 12 ++++++------
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  9 +++++----
>  drivers/net/ethernet/intel/i40evf/i40evf_main.c    |  4 ++--
>  drivers/net/ethernet/intel/igb/igb_main.c          | 10 ++++------
>  drivers/net/ethernet/intel/igb/igb_ptp.c           |  4 ++--
>  drivers/net/ethernet/intel/ixgb/ixgb_main.c        | 12 ++++++------
>  drivers/net/ethernet/intel/ixgbe/ixgbe_common.h    |  4 ++--
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c   | 12 ++++++------
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c      | 16 ++++++++--------
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c       | 12 ++++++------
>  drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c      |  4 ++--
>  19 files changed, 72 insertions(+), 73 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> index 975eeb885ca2..11ad95f34f4f 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> @@ -1021,8 +1021,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
>  	}
>  	txdr->next_to_use = txdr->next_to_clean = 0;
>
> -	ew32(TDBAL, ((u64)txdr->dma & 0x00000000FFFFFFFF));
> -	ew32(TDBAH, ((u64)txdr->dma >> 32));
> +	ew32(TDBAL, lower_32_bits(txdr->dma));
> +	ew32(TDBAH, upper_32_bits(txdr->dma));
>  	ew32(TDLEN, txdr->count * sizeof(struct e1000_tx_desc));
>  	ew32(TDH, 0);
>  	ew32(TDT, 0);
> @@ -1081,8 +1081,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
>
>  	rctl = er32(RCTL);
>  	ew32(RCTL, rctl & ~E1000_RCTL_EN);
> -	ew32(RDBAL, ((u64)rxdr->dma & 0xFFFFFFFF));
> -	ew32(RDBAH, ((u64)rxdr->dma >> 32));
> +	ew32(RDBAL, lower_32_bits(rxdr->dma));
> +	ew32(RDBAH, upper_32_bits(rxdr->dma));
>  	ew32(RDLEN, rxdr->size);
>  	ew32(RDH, 0);
>  	ew32(RDT, 0);
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
> index 93fc6c67306b..d222f731f280 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
> @@ -1614,8 +1614,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
>  		tdlen = adapter->tx_ring[0].count *
>  			sizeof(struct e1000_tx_desc);
>  		ew32(TDLEN, tdlen);
> -		ew32(TDBAH, (tdba >> 32));
> -		ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
> +		ew32(TDBAH, upper_32_bits(tdba));
> +		ew32(TDBAL, lower_32_bits(tdba));
>  		ew32(TDT, 0);
>  		ew32(TDH, 0);
>  		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ?
> @@ -1896,8 +1896,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
>  	default:
>  		rdba = adapter->rx_ring[0].dma;
>  		ew32(RDLEN, rdlen);
> -		ew32(RDBAH, (rdba >> 32));
> -		ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
> +		ew32(RDBAH, upper_32_bits(rdba));
> +		ew32(RDBAL, lower_32_bits(rdba));
>  		ew32(RDT, 0);
>  		ew32(RDH, 0);
>  		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ?
> diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
> index 7aff68a4a4df..35304b380eaa 100644
> --- a/drivers/net/ethernet/intel/e1000e/ethtool.c
> +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
> @@ -1203,8 +1203,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
>  	tx_ring->next_to_use = 0;
>  	tx_ring->next_to_clean = 0;
>
> -	ew32(TDBAL(0), ((u64)tx_ring->dma & 0x00000000FFFFFFFF));
> -	ew32(TDBAH(0), ((u64)tx_ring->dma >> 32));
> +	ew32(TDBAL(0), lower_32_bits(tx_ring->dma));
> +	ew32(TDBAH(0), upper_32_bits(tx_ring->dma));
>  	ew32(TDLEN(0), tx_ring->count * sizeof(struct e1000_tx_desc));
>  	ew32(TDH(0), 0);
>  	ew32(TDT(0), 0);
> @@ -1266,8 +1266,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
>  	rctl = er32(RCTL);
>  	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
>  		ew32(RCTL, rctl & ~E1000_RCTL_EN);
> -	ew32(RDBAL(0), ((u64)rx_ring->dma & 0xFFFFFFFF));
> -	ew32(RDBAH(0), ((u64)rx_ring->dma >> 32));
> +	ew32(RDBAL(0), lower_32_bits(rx_ring->dma));
> +	ew32(RDBAH(0), upper_32_bits(rx_ring->dma));
>  	ew32(RDLEN(0), rx_ring->size);
>  	ew32(RDH(0), 0);
>  	ew32(RDT(0), 0);
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_common.c b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> index dd95ac4f4c64..72d428f598b3 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> @@ -325,10 +325,10 @@ static void fm10k_update_hw_base_48b(struct fm10k_hw_stat *stat, u64 delta)
>
>  	/* update lower 32 bits */
>  	delta += stat->base_l;
> -	stat->base_l = (u32)delta;
> +	stat->base_l = lower_32_bits(delta);
>
>  	/* update upper 32 bits */
> -	stat->base_h += (u32)(delta >> 32);
> +	stat->base_h += upper_32_bits(delta);
>  }
>
>  /**
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> index 23fb319fd2a0..e0cc9883710b 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> @@ -1548,7 +1548,7 @@ static void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw,
>  static void fm10k_set_dma_mask_pf(struct fm10k_hw *hw, u64 dma_mask)
>  {
>  	/* we need to write the upper 32 bits of DMA mask to PhyAddrSpace */
> -	u32 phyaddr = (u32)(dma_mask >> 32);
> +	u32 phyaddr = upper_32_bits(dma_mask);
>
>  	fm10k_write_reg(hw, FM10K_PHYADDR, phyaddr);
>  }
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
> index 128735975caa..b184487eb49a 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_common.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
> @@ -2984,8 +2984,8 @@ i40e_status i40e_aq_debug_write_register(struct i40e_hw *hw,
>  	i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_write_reg);
>
>  	cmd->address = cpu_to_le32(reg_addr);
> -	cmd->value_high = cpu_to_le32((u32)(reg_val >> 32));
> -	cmd->value_low = cpu_to_le32((u32)(reg_val & 0xFFFFFFFF));
> +	cmd->value_high = cpu_to_le32(upper_32_bits(reg_val));
> +	cmd->value_low = cpu_to_le32(lower_32_bits(reg_val));
>
>  	status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> index cc1465aac2ef..091ac00053bd 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> @@ -2550,14 +2550,14 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
>  					       flow_pctype)) << 32);
>  		i_set = i40e_get_rss_hash_bits(nfc, i_setc);
>  		i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_pctype),
> -				  (u32)i_set);
> +				  lower_32_bits(i_set));
>  		i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_pctype),
> -				  (u32)(i_set >> 32));
> +				  upper_32_bits(i_set));
>  		hena |= BIT_ULL(flow_pctype);
>  	}
>
> -	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
> -	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
> +	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
> +	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
>  	i40e_flush(hw);
>
>  	return 0;
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index ad4cf639430e..219c696411f9 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -8410,8 +8410,8 @@ static int i40e_pf_config_rss(struct i40e_pf *pf)
>  		((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32);
>  	hena |= i40e_pf_get_default_rss_hena(pf);
>
> -	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
> -	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
> +	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
> +	i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
>
>  	/* Determine the RSS table size based on the hardware capabilities */
>  	reg_val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> index 9e49ffafce28..b2566ce83505 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> @@ -88,8 +88,8 @@ static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts)
>  	/* The timer will not update until the high register is written, so
>  	 * write the low register first.
>  	 */
> -	wr32(hw, I40E_PRTTSYN_TIME_L, ns & 0xFFFFFFFF);
> -	wr32(hw, I40E_PRTTSYN_TIME_H, ns >> 32);
> +	wr32(hw, I40E_PRTTSYN_TIME_L, lower_32_bits(ns));
> +	wr32(hw, I40E_PRTTSYN_TIME_H, upper_32_bits(ns));
>  }
>
>  /**
> @@ -141,8 +141,8 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
>  	else
>  		adj += diff;
>
> -	wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF);
> -	wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32);
> +	wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(adj));
> +	wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(adj));
>
>  	return 0;
>  }
> @@ -447,8 +447,8 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
>  	 * hardware will not update the clock until both registers have been
>  	 * written.
>  	 */
> -	wr32(hw, I40E_PRTTSYN_INC_L, incval & 0xFFFFFFFF);
> -	wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
> +	wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(incval));
> +	wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(incval));
>
>  	/* Update the base adjustement value. */
>  	ACCESS_ONCE(pf->ptp_base_adj) = incval;
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 0fb899efbad3..d8cb9aea07a1 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -705,9 +705,9 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
>  				 "Could not allocate VF broadcast filter\n");
>  		spin_unlock_bh(&vsi->mac_filter_hash_lock);
>  		i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id),
> -				  (u32)hena);
> +				  lower_32_bits(hena));
>  		i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id),
> -				  (u32)(hena >> 32));
> +				  upper_32_bits(hena));
>  	}
>
>  	/* program mac filter */
> @@ -2349,9 +2349,10 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
>  		aq_ret = I40E_ERR_PARAM;
>  		goto err;
>  	}
> -	i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)vrh->hena);
> +	i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id),
> +			  lower_32_bits(vrh->hena));
>  	i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(1, vf->vf_id),
> -			  (u32)(vrh->hena >> 32));
> +			  upper_32_bits(vrh->hena));
>
>  	/* send the response to the VF */
>  err:
> diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> index c0fc53361800..089a1e87ced8 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> +++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> @@ -1379,8 +1379,8 @@ static int i40evf_init_rss(struct i40evf_adapter *adapter)
>  		else
>  			adapter->hena = I40E_DEFAULT_RSS_HENA;
>
> -		wr32(hw, I40E_VFQF_HENA(0), (u32)adapter->hena);
> -		wr32(hw, I40E_VFQF_HENA(1), (u32)(adapter->hena >> 32));
> +		wr32(hw, I40E_VFQF_HENA(0), lower_32_bits(adapter->hena));
> +		wr32(hw, I40E_VFQF_HENA(1), upper_32_bits(adapter->hena));
>  	}
>
>  	i40evf_fill_rss_lut(adapter);
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index a761001308dc..a2fd0b6019cf 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3390,9 +3390,8 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,
>
>  	wr32(E1000_TDLEN(reg_idx),
>  	     ring->count * sizeof(union e1000_adv_tx_desc));
> -	wr32(E1000_TDBAL(reg_idx),
> -	     tdba & 0x00000000ffffffffULL);
> -	wr32(E1000_TDBAH(reg_idx), tdba >> 32);
> +	wr32(E1000_TDBAL(reg_idx), lower_32_bits(tdba));
> +	wr32(E1000_TDBAH(reg_idx), upper_32_bits(tdba));
>
>  	ring->tail = hw->hw_addr + E1000_TDT(reg_idx);
>  	wr32(E1000_TDH(reg_idx), 0);
> @@ -3726,9 +3725,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
>  	wr32(E1000_RXDCTL(reg_idx), 0);
>
>  	/* Set DMA base address registers */
> -	wr32(E1000_RDBAL(reg_idx),
> -	     rdba & 0x00000000ffffffffULL);
> -	wr32(E1000_RDBAH(reg_idx), rdba >> 32);
> +	wr32(E1000_RDBAL(reg_idx), lower_32_bits(rdba));
> +	wr32(E1000_RDBAH(reg_idx), upper_32_bits(rdba));
>  	wr32(E1000_RDLEN(reg_idx),
>  	     ring->count * sizeof(union e1000_adv_rx_desc));
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> index c4477552ce9e..67559c73e0e7 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> @@ -188,8 +188,8 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,
>  	case e1000_i211:
>  		memset(hwtstamps, 0, sizeof(*hwtstamps));
>  		/* Upper 32 bits contain s, lower 32 bits contain ns. */
> -		hwtstamps->hwtstamp = ktime_set(systim >> 32,
> -						systim & 0xFFFFFFFF);
> +		hwtstamps->hwtstamp = ktime_set(upper_32_bits(systim),
> +						lower_32_bits(systim));
>  		break;
>  	default:
>  		break;
> diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> index 5826b1ddedcf..a23e99528d5e 100644
> --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> @@ -749,8 +749,8 @@ ixgb_configure_tx(struct ixgb_adapter *adapter)
>  	 * tx_ring.dma can be either a 32 or 64 bit value
>  	 */
>
> -	IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
> -	IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
> +	IXGB_WRITE_REG(hw, TDBAL, lower_32_bits(tdba));
> +	IXGB_WRITE_REG(hw, TDBAH, upper_32_bits(tdba));
>
>  	IXGB_WRITE_REG(hw, TDLEN, tdlen);
>
> @@ -875,8 +875,8 @@ ixgb_configure_rx(struct ixgb_adapter *adapter)
>
>  	/* Setup the Base and Length of the Rx Descriptor Ring */
>
> -	IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
> -	IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
> +	IXGB_WRITE_REG(hw, RDBAL, lower_32_bits(rdba));
> +	IXGB_WRITE_REG(hw, RDBAH, upper_32_bits(rdba));
>
>  	IXGB_WRITE_REG(hw, RDLEN, rdlen);
>
> @@ -1664,8 +1664,8 @@ ixgb_update_stats(struct ixgb_adapter *adapter)
>  		if (multi >= bcast)
>  			multi -= bcast;
>
> -		adapter->stats.mprcl += (multi & 0xFFFFFFFF);
> -		adapter->stats.mprch += (multi >> 32);
> +		adapter->stats.mprcl += lower_32_bits(multi);
> +		adapter->stats.mprch += upper_32_bits(multi);
>  		adapter->stats.bprcl += bcast_l;
>  		adapter->stats.bprch += bcast_h;
>  	} else {
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> index e083732adf64..6237e6c2ed30 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> @@ -173,8 +173,8 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
>  #define writeq writeq
>  static inline void writeq(u64 val, void __iomem *addr)
>  {
> -	writel((u32)val, addr);
> -	writel((u32)(val >> 32), addr + 4);
> +	writel(lower_32_bits(val), addr);
> +	writel(upper_32_bits(val), addr + 4);
>  }
>  #endif
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 17589068da78..0d973e2d0937 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -748,10 +748,10 @@ static void ixgbe_get_regs(struct net_device *netdev,
>  	regs_buff[939] = IXGBE_GET_STAT(adapter, bprc);
>  	regs_buff[940] = IXGBE_GET_STAT(adapter, mprc);
>  	regs_buff[941] = IXGBE_GET_STAT(adapter, gptc);
> -	regs_buff[942] = (u32)IXGBE_GET_STAT(adapter, gorc);
> -	regs_buff[943] = (u32)(IXGBE_GET_STAT(adapter, gorc) >> 32);
> -	regs_buff[944] = (u32)IXGBE_GET_STAT(adapter, gotc);
> -	regs_buff[945] = (u32)(IXGBE_GET_STAT(adapter, gotc) >> 32);
> +	regs_buff[942] = lower_32_bits(IXGBE_GET_STAT(adapter, gorc));
> +	regs_buff[943] = upper_32_bits(IXGBE_GET_STAT(adapter, gorc));
> +	regs_buff[944] = lower_32_bits(IXGBE_GET_STAT(adapter, gotc));
> +	regs_buff[945] = upper_32_bits(IXGBE_GET_STAT(adapter, gotc));
>  	for (i = 0; i < 8; i++)
>  		regs_buff[946 + i] = IXGBE_GET_STAT(adapter, rnbc[i]);
>  	regs_buff[954] = IXGBE_GET_STAT(adapter, ruc);
> @@ -761,8 +761,8 @@ static void ixgbe_get_regs(struct net_device *netdev,
>  	regs_buff[958] = IXGBE_GET_STAT(adapter, mngprc);
>  	regs_buff[959] = IXGBE_GET_STAT(adapter, mngpdc);
>  	regs_buff[960] = IXGBE_GET_STAT(adapter, mngptc);
> -	regs_buff[961] = (u32)IXGBE_GET_STAT(adapter, tor);
> -	regs_buff[962] = (u32)(IXGBE_GET_STAT(adapter, tor) >> 32);
> +	regs_buff[961] = lower_32_bits(IXGBE_GET_STAT(adapter, tor));
> +	regs_buff[962] = upper_32_bits(IXGBE_GET_STAT(adapter, tor));
>  	regs_buff[963] = IXGBE_GET_STAT(adapter, tpr);
>  	regs_buff[964] = IXGBE_GET_STAT(adapter, tpt);
>  	regs_buff[965] = IXGBE_GET_STAT(adapter, ptc64);
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index 0c6eca570791..71d054f6a2aa 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -936,10 +936,10 @@ static inline void ixgbe_irq_rearm_queues(struct ixgbe_adapter *adapter,
>  	case ixgbe_mac_X550:
>  	case ixgbe_mac_X550EM_x:
>  	case ixgbe_mac_x550em_a:
> -		mask = (qmask & 0xFFFFFFFF);
> -		IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask);
> -		mask = (qmask >> 32);
> -		IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask);
> +		IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0),
> +				lower_32_bits(qmask));
> +		IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1),
> +				upper_32_bits(qmask));
>  		break;
>  	default:
>  		break;
> @@ -2650,10 +2650,10 @@ static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter,
>  	case ixgbe_mac_X550:
>  	case ixgbe_mac_X550EM_x:
>  	case ixgbe_mac_x550em_a:
> -		mask = (qmask & 0xFFFFFFFF);
> +		mask = lower_32_bits(qmask);
>  		if (mask)
>  			IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
> -		mask = (qmask >> 32);
> +		mask = upper_32_bits(qmask);
>  		if (mask)
>  			IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
>  		break;
> @@ -2679,10 +2679,10 @@ static inline void ixgbe_irq_disable_queues(struct ixgbe_adapter *adapter,
>  	case ixgbe_mac_X550:
>  	case ixgbe_mac_X550EM_x:
>  	case ixgbe_mac_x550em_a:
> -		mask = (qmask & 0xFFFFFFFF);
> +		mask = lower_32_bits(qmask);
>  		if (mask)
>  			IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), mask);
> -		mask = (qmask >> 32);
> +		mask = upper_32_bits(qmask);
>  		if (mask)
>  			IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), mask);
>  		break;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> index ef0635e0918c..a1cb0b99456c 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> @@ -206,8 +206,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
>  		 IXGBE_TSAUXC_SDP0_INT;
>
>  	/* clock period (or pulse length) */
> -	clktiml = (u32)(IXGBE_PTP_PPS_HALF_SECOND << shift);
> -	clktimh = (u32)((IXGBE_PTP_PPS_HALF_SECOND << shift) >> 32);
> +	clktiml = lower_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
> +	clktimh = upper_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
>
>  	/* Account for the cyclecounter wrap-around value by
>  	 * using the converted ns value of the current time to
> @@ -221,8 +221,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
>  	clock_edge += ((IXGBE_PTP_PPS_HALF_SECOND - (u64)rem) << shift);
>
>  	/* specify the initial clock start time */
> -	trgttiml = (u32)clock_edge;
> -	trgttimh = (u32)(clock_edge >> 32);
> +	trgttiml = lower_32_bits(clock_edge);
> +	trgttimh = upper_32_bits(clock_edge);
>
>  	IXGBE_WRITE_REG(hw, IXGBE_CLKTIML, clktiml);
>  	IXGBE_WRITE_REG(hw, IXGBE_CLKTIMH, clktimh);
> @@ -339,8 +339,8 @@ static void ixgbe_ptp_convert_to_hwtstamp(struct ixgbe_adapter *adapter,
>  		 * correct math even though the units haven't been corrected
>  		 * yet.
>  		 */
> -		systime.tv_sec = timestamp >> 32;
> -		systime.tv_nsec = timestamp & 0xFFFFFFFF;
> +		systime.tv_sec = upper_32_bits(timestamp);
> +		systime.tv_nsec = lower_32_bits(timestamp);
>
>  		timestamp = timespec64_to_ns(&systime);
>  		break;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> index 200f847fd8f3..1d3ca7a5106f 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> @@ -3437,8 +3437,8 @@ static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
>  	else
>  		pfflp &= ~(1ULL << pool);
>
> -	IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
> -	IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
> +	IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, lower_32_bits(pfflp));
> +	IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, upper_32_bits(pfflp));
>  }
>
>  /**
> --
> 2.10.0.rc2.1.g053435c
>
>

^ permalink raw reply

* [PATCH net] ipv6: fix typos
From: Alexander Alemayhu @ 2017-01-07 22:53 UTC (permalink / raw)
  To: netdev; +Cc: Alexander Alemayhu

o s/approriate/appropriate
o s/discouvery/discovery

Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
---
 net/ipv6/route.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8417c41d8ec8..ce5aaf448c54 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1464,7 +1464,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
 	struct fib6_node *fn;
 
 	/* Get the "current" route for this destination and
-	 * check if the redirect has come from approriate router.
+	 * check if the redirect has come from appropriate router.
 	 *
 	 * RFC 4861 specifies that redirects should only be
 	 * accepted if they come from the nexthop to the target.
@@ -2768,7 +2768,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
 	   old MTU is the lowest MTU in the path, update the route PMTU
 	   to reflect the increase. In this case if the other nodes' MTU
 	   also have the lowest MTU, TOO BIG MESSAGE will be lead to
-	   PMTU discouvery.
+	   PMTU discovery.
 	 */
 	if (rt->dst.dev == arg->dev &&
 	    dst_metric_raw(&rt->dst, RTAX_MTU) &&
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH v5] net: stmmac: fix maxmtu assignment to be within valid range
From: Andy Shevchenko @ 2017-01-08  1:06 UTC (permalink / raw)
  To: Kweh, Hock Leong
  Cc: David S. Miller, Joao Pinto, Giuseppe CAVALLARO,
	seraphin.bonnaffe, Jarod Wilson, Alexandre TORGUE,
	Joachim Eastwood, Niklas Cassel, Johan Hovold, Pavel Machek,
	lars.persson, netdev, LKML
In-Reply-To: <1483781523-14334-1-git-send-email-hock.leong.kweh@intel.com>

On Sat, Jan 7, 2017 at 11:32 AM, Kweh, Hock Leong
<hock.leong.kweh@intel.com> wrote:
> From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com>
>
> There is no checking valid value of maxmtu when getting it from
> device tree. This resolution added the checking condition to
> ensure the assignment is made within a valid range.

FWIW:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

>
> Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
> ---
> changelog v5:
> * revert back that plat->maxmtu > ndev->max_mtu is a valid case
>   when ndev->max_mtu assignment is entering to the else statement
> * add comment to enchance clarification
>
> changelog v4:
> * add print warning message when maxmtu > max_mtu as well
> * add maxmtu = JUMBO_LEN into each *_default_data() at stmmac_pci.c
>
> changelog v3:
> * print the warning message only if maxmtu < min_mtu
> * add maxmtu = JUMBO_LEN at stmmac_pci.c to follow stmmac_platform.c
>
> changelog v2:
> * correction of "devicetree" to "device tree" reported by Andy
> * print warning message while maxmtu is not in valid range
>
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   10 +++++++++-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c  |    6 ++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 92ac006..8e56dc4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3345,8 +3345,16 @@ int stmmac_dvr_probe(struct device *device,
>                 ndev->max_mtu = JUMBO_LEN;
>         else
>                 ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
> -       if (priv->plat->maxmtu < ndev->max_mtu)
> +       /* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
> +        * as well as plat->maxmtu < ndev->min_mtu which is a invalid range.
> +        */
> +       if ((priv->plat->maxmtu < ndev->max_mtu) &&
> +           (priv->plat->maxmtu >= ndev->min_mtu))
>                 ndev->max_mtu = priv->plat->maxmtu;
> +       else if (priv->plat->maxmtu < ndev->min_mtu)
> +               netdev_warn(priv->dev,
> +                           "%s: warning: maxmtu having invalid value (%d)\n",
> +                           __func__, priv->plat->maxmtu);
>
>         if (flow_ctrl)
>                 priv->flow_ctrl = FLOW_AUTO;    /* RX/TX pause on */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index a283177..3da4737 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> @@ -89,6 +89,9 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
>
>         /* Set default value for unicast filter entries */
>         plat->unicast_filter_entries = 1;
> +
> +       /* Set the maxmtu to a default of JUMBO_LEN */
> +       plat->maxmtu = JUMBO_LEN;
>  }
>
>  static int quark_default_data(struct plat_stmmacenet_data *plat,
> @@ -126,6 +129,9 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
>         /* Set default value for unicast filter entries */
>         plat->unicast_filter_entries = 1;
>
> +       /* Set the maxmtu to a default of JUMBO_LEN */
> +       plat->maxmtu = JUMBO_LEN;
> +
>         return 0;
>  }
>
> --
> 1.7.9.5
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply

* Re: [PATCH v2 net-next 3/4] secure_seq: use SipHash in place of MD5
From: David Miller @ 2017-01-08  1:42 UTC (permalink / raw)
  To: ebiggers3
  Cc: Jason, jeanphilippe.aumasson, gregkh, netdev, linux-kernel, ak,
	David.Laight, tom, hannes, eric.dumazet, luto
In-Reply-To: <20170107220911.GB8327@zzz>

From: Eric Biggers <ebiggers3@gmail.com>
Date: Sat, 7 Jan 2017 14:09:11 -0800

> Well, except those instructions aren't actually used in these
> places.  Although x86_64 SHA1-NI accelerated SHA-1 is available in
> the Linux crypto API, it seems that in kernel code it remains
> impractical to use these instructions on small amounts of data
> because they use XMM registers, which means the overhead of
> kernel_fpu_begin()/kernel_fpu_end() must be incurred.  Furthermore,
> kernel_fpu_begin() is not allowed in all contexts so there has to be
> a fallback.
> 
> Out of curiosity, is this actually a solvable problem, e.g. by
> making the code using the XMM registers responsible for saving and
> restoring the ones clobbered, or by optimizing
> kernel_fpu_begin()/kernel_fpu_end()?  Or does it in fact remain
> impractical for such instructions to be used for applications like
> this one?

On x86 making the FPU save more tractible in situations like this is
really hard and will make the code significantly more complex.

It's simpler and cheaper on sparc64, and unlike on x86 there aren't
any fundament restrictions on where FPU stuff can be used.  This is
because we don't have "save all the FPU state" instructions and have
to do it all by hand anyways.

However I will note that just like x86, sparc64 doesn't override the
md5_transform() in lib/md5.c like it should.

^ permalink raw reply

* Re: [PATCH v2 0/7] net: ethernet: ti: cpsw: support placing CPDMA descriptors into DDR
From: David Miller @ 2017-01-08  1:48 UTC (permalink / raw)
  To: grygorii.strashko
  Cc: netdev, mugunthanvnm, ivan.khoronzhuk, nsekhar, linux-kernel,
	linux-omap
In-Reply-To: <20170106200735.4210-1-grygorii.strashko@ti.com>

From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Fri, 6 Jan 2017 14:07:28 -0600

> This series intended to add support for placing CPDMA descriptors into DDR by
> introducing new module parameter "descs_pool_size" to specify size of descriptor's
> pool. The "descs_pool_size" defines total number of CPDMA
> CPPI descriptors to be used for both ingress/egress packets
> processing. If not specified - the default value 256 will be used
> which will allow to place descriptor's pool into the internal CPPI
> RAM.
> 
> In addition, added ability to re-split CPDMA pool of descriptors between RX and TX
> path via ethtool '-G' command wich will allow to configure and fix number
> of descriptors used by RX and TX path, which, then, will be split between
> RX/TX channels proportionally depending on number of RX/TX channels and
> its weight. 
> 
> This allows significantly to reduce UDP packets drop rate
> for bandwidth >301 Mbits/sec (am57x).  
> 
> Before enabling this feature, the am437x SoC has to be fixed as it's proved
> that it's not working when CPDMA descriptors placed in DDR.
> So, the patch 1 fixes this issue.

Series applied to net-next, thanks.

^ permalink raw reply

* Re: [PATCH net] net: Fix inconsistent rtnl_lock usage on dev_get_stats().
From: David Miller @ 2017-01-08  2:03 UTC (permalink / raw)
  To: eric.dumazet; +Cc: michael.chan, netdev
In-Reply-To: <1483733603.9712.38.camel@edumazet-glaptop3.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 06 Jan 2017 12:13:23 -0800

> Well, there are cases where RTNL is quite contended, but supervisions
> like to get /proc/net/devices or various sysfs attributes
> (netstat_show() can be called very very often
> for /sys/class/net/*/statistics/*) in a reasonable amount of time.
> 
> I fear that such a change will add drifts, when devices are constantly
> added/removed.

It stands to reason that RTNETLINK could use pure RCU locking for
device and stat dumps, and frankly that would make their usage and
overhead superior to poking files over and over.

^ permalink raw reply

* Re: [net-next v1 0/8] netcp: enhancements and minor fixes
From: David Miller @ 2017-01-08  2:04 UTC (permalink / raw)
  To: m-karicheri2
  Cc: arnd, netdev, linux-kernel, mugunthanvnm, linux-omap,
	grygorii.strashko
In-Reply-To: <1483735066-14632-1-git-send-email-m-karicheri2@ti.com>

From: Murali Karicheri <m-karicheri2@ti.com>
Date: Fri, 6 Jan 2017 15:37:38 -0500

> This series is for net-next. This propagates enhancements and minor
> bug fixes from internal version of the driver to keep the upstream
> in sync. Please review and apply if this looks good.
> 
> Tested on all of K2HK/E/L boards with nfs rootfs.
> Test logs below
> K2HK-EVM: http://pastebin.ubuntu.com/23754106/
> k2L-EVM: http://pastebin.ubuntu.com/23754143/
> K2E-EVM: http://pastebin.ubuntu.com/23754159/
> 
> History:
>   v1 - dropped 1/10 amd 2/10 of v0 based on comments from Rob as
>        it needs more work before submission
>   v0 - Initial version

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH net] be2net: fix unicast list filling
From: David Miller @ 2017-01-08  2:27 UTC (permalink / raw)
  To: cera
  Cc: netdev, sathya.perla, ajit.khaparde, sriharsha.basavapatna,
	somnath.kotur
In-Reply-To: <20170106205930.3996-1-cera@cera.cz>

From: Ivan Vecera <cera@cera.cz>
Date: Fri,  6 Jan 2017 21:59:30 +0100

> The adapter->pmac_id[0] item is used for primary MAC address but
> this is not true for adapter->uc_list[0] as is assumed in
> be_set_uc_list(). There are N UC addresses copied first from net_device
> to adapter->uc_list[1..N] and then N UC addresses from
> adapter->uc_list[0..N-1] are sent to HW. So the last UC address is never
> stored into HW and address 00:00:00:00;00:00 (from uc_list[0]) is used
> instead.
> 
> Cc: Sathya Perla <sathya.perla@broadcom.com>
> Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Cc: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> Cc: Somnath Kotur <somnath.kotur@broadcom.com>
> Fixes: b717241 be2net: replace polling with sleeping in the FW completion path
> Signed-off-by: Ivan Vecera <cera@cera.cz>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH net] tg3: Fix race condition in tg3_get_stats64().
From: David Miller @ 2017-01-08  2:35 UTC (permalink / raw)
  To: michael.chan; +Cc: netdev, wangyufen
In-Reply-To: <1483737533-25059-1-git-send-email-michael.chan@broadcom.com>

From: Michael Chan <michael.chan@broadcom.com>
Date: Fri,  6 Jan 2017 16:18:53 -0500

> The driver's ndo_get_stats64() method is not always called under RTNL.
> So it can race with driver close or ethtool reconfigurations.  Fix the
> race condition by taking tp->lock spinlock in tg3_free_consistent()
> when freeing the tp->hw_stats memory block.  tg3_get_stats64() is
> already taking tp->lock.
> 
> Reported-by: Wang Yufen <wangyufen@huawei.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Applied, thanks Michael.

^ permalink raw reply

* Re: [PATCH net-next] net: dsa: move HWMON support to its own file
From: David Miller @ 2017-01-08  3:42 UTC (permalink / raw)
  To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew
In-Reply-To: <20170106214200.15633-1-vivien.didelot@savoirfairelinux.com>

From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Fri,  6 Jan 2017 16:42:00 -0500

> Isolate the HWMON support in DSA in its own file. Currently only the
> legacy DSA code is concerned.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Applied.

^ permalink raw reply

* [PATCH net-next] net: ipv4: remove disable of bottom half in inet_rtm_getroute
From: David Ahern @ 2017-01-08  4:04 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Nothing about the route lookup requires bottom half to be disabled.
Remove the local_bh_disable ... local_bh_enable around ip_route_input.
This appears to be a vestige of days gone by as it has been there
since the beginning of git time.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 net/ipv4/route.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index f51823dc998b..7144288371cf 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2631,9 +2631,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		skb->protocol	= htons(ETH_P_IP);
 		skb->dev	= dev;
 		skb->mark	= mark;
-		local_bh_disable();
 		err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
-		local_bh_enable();
 
 		rt = skb_rtable(skb);
 		if (err == 0 && rt->dst.error)
-- 
2.1.4

^ permalink raw reply related

* Re: [PATCH net-next] net: ipv6: put autoconf routes into per-interface tables
From: David Ahern @ 2017-01-08  4:24 UTC (permalink / raw)
  To: Lorenzo Colitti, netdev
  Cc: zenczykowski, hannes, ek, hideaki.yoshifuji, davem, drosen
In-Reply-To: <20170106153026.24785-1-lorenzo@google.com>

On 1/6/17 8:30 AM, Lorenzo Colitti wrote:
> This patch adds a per-interface sysctl to have the kernel put
> autoconf routes into different tables. This allows each interface
> to have its own routing table if desired.  Choosing the default
> interface, or using different interfaces at the same time on a
> per-socket or per-packet basis) can be done using policy routing
> mechanisms that use as SO_BINDTODEVICE / IPV6_PKTINFO, mark-based
> routing, or UID-based routing to select specific routing tables.

Why not use the VRF capability then? create a VRF and assign the interface to it. End result is the same -- separate tables and the need to use a bind-to-device API to hit those routes.

^ permalink raw reply

* [PATCH net 0/2] net: dsa: bcm_sf2: Couple fixes
From: Florian Fainelli @ 2017-01-08  5:01 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Hi David,

Here are a couple of fixes for bcm_sf2, please queue these up for -stable
as well, thank you very much!

Florian Fainelli (2):
  net: dsa: bcm_sf2: Do not clobber b53_switch_ops
  net: dsa: bcm_sf2: Utilize nested MDIO read/write

 drivers/net/dsa/bcm_sf2.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

-- 
2.9.3

^ permalink raw reply

* [PATCH net 1/2] net: dsa: bcm_sf2: Do not clobber b53_switch_ops
From: Florian Fainelli @ 2017-01-08  5:01 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli
In-Reply-To: <20170108050157.16302-1-f.fainelli@gmail.com>

We make the bcm_sf2 driver override ds->ops which points to
b53_switch_ops since b53_switch_alloc() did the assignent. This is all
well and good until a second b53 switch comes in, and ends up using the
bcm_sf2 operations. Make a proper local copy, substitute the ds->ops
pointer and then override the operations.

Fixes: f458995b9ad8 ("net: dsa: bcm_sf2: Utilize core B53 driver when possible")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 9ec33b51a0ed..2f9f910c0e40 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -982,6 +982,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 	const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
 	struct device_node *dn = pdev->dev.of_node;
 	struct b53_platform_data *pdata;
+	struct dsa_switch_ops *ops;
 	struct bcm_sf2_priv *priv;
 	struct b53_device *dev;
 	struct dsa_switch *ds;
@@ -995,6 +996,10 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
+	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
 	dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv);
 	if (!dev)
 		return -ENOMEM;
@@ -1014,6 +1019,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 	ds = dev->ds;
 
 	/* Override the parts that are non-standard wrt. normal b53 devices */
+	memcpy(ops, ds->ops, sizeof(*ops));
+	ds->ops = ops;
 	ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol;
 	ds->ops->setup = bcm_sf2_sw_setup;
 	ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags;
-- 
2.9.3

^ permalink raw reply related

* [PATCH net 2/2] net: dsa: bcm_sf2: Utilize nested MDIO read/write
From: Florian Fainelli @ 2017-01-08  5:01 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli
In-Reply-To: <20170108050157.16302-1-f.fainelli@gmail.com>

We are implementing a MDIO bus which is behind another one, so use the
nested version of the accessors to get lockdep annotations correct.

Fixes: 461cd1b03e32 ("net: dsa: bcm_sf2: Register our slave MDIO bus")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 2f9f910c0e40..2ce7ae97ac91 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -393,7 +393,7 @@ static int bcm_sf2_sw_mdio_read(struct mii_bus *bus, int addr, int regnum)
 	if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
 		return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
 	else
-		return mdiobus_read(priv->master_mii_bus, addr, regnum);
+		return mdiobus_read_nested(priv->master_mii_bus, addr, regnum);
 }
 
 static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
@@ -407,7 +407,7 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
 	if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
 		bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
 	else
-		mdiobus_write(priv->master_mii_bus, addr, regnum, val);
+		mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val);
 
 	return 0;
 }
-- 
2.9.3

^ permalink raw reply related

* Re: [for-next 07/10] IB/mlx5: Use blue flame register allocator in mlx5_ib
From: Leon Romanovsky @ 2017-01-08  6:22 UTC (permalink / raw)
  To: David Miller; +Cc: eli, saeedm, dledford, netdev, linux-rdma, eli, matanb
In-Reply-To: <20170106.111131.1775665484264248231.davem@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

On Fri, Jan 06, 2017 at 11:11:31AM -0500, David Miller wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> Date: Fri, 6 Jan 2017 08:06:09 +0200
>
> > On Thu, Jan 05, 2017 at 03:07:31PM -0500, David Miller wrote:
> >> From: Eli Cohen <eli@dev.mellanox.co.il>
> >> Date: Thu, 5 Jan 2017 14:03:18 -0600
> >>
> >> > If necessary I can make sure it builds on 32 bits as well.
> >>
> >> Please do.
> >
> > Dave,
> >
> > I'm failing to understand the benefits of building mlx5 on 32 bits, and
> > see only disadvantages:
> >  * It is actual dead code without test coverage.
> >  * It misleads reviewers/customers by seeing code for 32 bits.
> >  * It adds compilation time for 32 bits platforms and "punishes" them
> >    for not relevant for them driver.
> >
> > Why do you call removing all that as a "regression"?
>
> We have this thing called "CONFIG_COMPILE_TEST", it has tons of value,
> perhaps you've seen it before?

Thanks David,
I see your point.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH net-next V2 0/3] net/sched: act_pedit: Use offset relative to conventional network headers
From: Amir Vadai @ 2017-01-08  8:46 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, jiri, ogerlitz, hadarh
In-Reply-To: <20170106.205109.917848391545129035.davem@davemloft.net>

On Fri, Jan 06, 2017 at 08:51:09PM -0500, David Miller wrote:
> From: Amir Vadai <amir@vadai.me>
> Date: Thu,  5 Jan 2017 11:54:51 +0200
> 
> > Enhancing the UAPI to allow for specifying that would allow the same
> > flows to be set into both SW and HW.
> 
> This is actually not backward compatible.
> 
> When pedit rules are dumped, older tools will not know about the
> type field and therefore will completely misinterpret the rule.
> 
> You must extend this the proper way, which is to add a new attribute
> or something along those lines.  The presense of a new attribute
> is an explicit communication to older tools that somethng they
> might not support and understand is going on.

Sorry, I missed this scenario. Going back to the drawing board.

^ 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