backports: deal with timespec64 changes
cover backports: deal with timespec64 changes
This series adds cocci patches to deal with struct timespec64 changes and also has several other bits to get igb working again. Patches have been tested against next-20150402.
The struct timespec64 patches are not perfect, but they should get us started. There are still some warnings, which we can fix along the way.
Stefan Assmann (4):
backports: handle ndo_gso_check() to ndo_features_check() changes
backports: add passthru_features_check()
backports: deal with struct timespec64 changes
backports: deal with struct struct ptp_clock_info get/settime64
changes
backport/backport-include/linux/netdevice.h | 6 ++ backport/compat/Makefile | 1 + backport/compat/backport-4.1.c | 19 +++++ .../network/0056-ndo_features_check/INFO | 12 ++++ .../0056-ndo_features_check/features_check.cocci | 19 +++++ .../network/0057-timespec64/INFO | 11 +++ .../network/0057-timespec64/igb.patch | 16 +++++ .../network/0057-timespec64/timespec64.cocci | 83 ++++++++++++++++++++++ .../network/0058-ptp_getsettime64/INFO | 11 +++ .../0058-ptp_getsettime64/ptp_getsettime64.cocci | 33 +++++++++ 10 files changed, 211 insertions(+) create mode 100644 backport/compat/backport-4.1.c create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
Signature · 1 line
2.1.0
PATCH 1/4 backports: handle ndo_gso_check() to ndo_features_check() changes
In kernel 3.19 function pointer ndo_gso_check is changed into ndo_features_check in struct net_device_ops.
--- .../network/0056-ndo_features_check/INFO | 12 ++++++++++++ .../0056-ndo_features_check/features_check.cocci | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci
patches/collateral-evolutions/network/0056-ndo_features_check/INFO new file +12 -0
@@ -0,0 +1,12 @@ +In kernel 3.19 function pointer ndo_gso_check is changed into +ndo_features_check in struct net_device_ops. +Address this by putting ifdef around the code. + +commit 5f35227ea34bb616c436d9da47fc325866c428f3 +Author: Jesse Gross <[email protected]> +Date: Tue Dec 23 22:37:26 2014 -0800 + + net: Generalize ndo_gso_check to ndo_features_check + +git describe --contains 5f35227ea34bb616c436d9da47fc325866c428f3 +v3.19-rc3~16^2~7
patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci new file +19 -0
@@ -0,0 +1,19 @@ +@r1@ +identifier s, func; +@@ + +struct net_device_ops s = { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) +.ndo_features_check = func, ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */ +}; + +// ---------------------------------------------------------------------- + +@r2@ +identifier r1.func; +@@ + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) +func(...) { ... } ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
Signature · 1 line
2.1.0
PATCH 2/4 backports: add passthru_features_check()
In reply to Stefan AssmannThis is required by igb and possibly other network drivers.
--- backport/backport-include/linux/netdevice.h | 6 ++++++ backport/compat/Makefile | 1 + backport/compat/backport-4.1.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 backport/compat/backport-4.1.c
backport/backport-include/linux/netdevice.h +6 -0
@@ -254,4 +254,10 @@ static inline struct sk_buff *napi_alloc_skb(struct napi_struct *napi,#define IFF_TX_SKB_SHARING 0#endif +#if LINUX_VERSION_CODE <KERNEL_VERSION (4 ,1 ,0 ) +netdev_features_t passthru_features_check (struct sk_buff *skb, +struct net_device *dev, +netdev_features_t features); +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) */ +#endif /* __BACKPORT_NETDEVICE_H */
backport/compat/Makefile +1 -0
@@ -25,6 +25,7 @@ compat-$(CPTCFG_KERNEL_3_15) += backport-3.15.o compat-$(CPTCFG_KERNEL_3_17) += backport-3.17.o compat-$(CPTCFG_KERNEL_3_18) += backport-3.18.o compat-$(CPTCFG_KERNEL_3_19) += backport-3.19.o +compat-$(CPTCFG_KERNEL_4_1) += backport-4.1.o compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o compat-$(CPTCFG_BPAUTO_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
backport/compat/backport-4.1.c new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (c) 2015 Stefan Assmann <[email protected]> +* +* Backport functionality introduced in Linux 4.1. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/netdevice.h> + +netdev_features_t passthru_features_check (struct sk_buff *skb, +struct net_device *dev, +netdev_features_t features) +{ +return features; +} +EXPORT_SYMBOL (passthru_features_check);
Signature · 1 line
2.1.0
PATCH 3/4 backports: deal with struct timespec64 changes
In reply to Stefan Assmannigb now makes use of struct timespec64. Deal with the required changes via cocci patches where possible. There's one occasion where coccinelle is not able to deal with defining a struct and assigning another struct on the same line.
Example:
struct timespec64 now, then = ns_to_timespec64(delta); Deal with this in a separate patch for now.
--- .../network/0057-timespec64/INFO | 11 +++ .../network/0057-timespec64/igb.patch | 16 +++++ .../network/0057-timespec64/timespec64.cocci | 83 ++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci
patches/collateral-evolutions/network/0057-timespec64/INFO new file +11 -0
@@ -0,0 +1,11 @@ +In kernel 3.17 struct timespec64 was introduced. +Address this with cocci patches where possible. + +commit 361a3bf00582469877f8d18ff20f1efa6b781274 +Author: John Stultz <[email protected]> +Date: Wed Jul 16 21:03:58 2014 +0000 + + time64: Add time64.h header and define struct timespec64 + +git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274 +v3.17-rc1~109^2~62
patches/collateral-evolutions/network/0057-timespec64/igb.patch new file +16 -0
@@ -0,0 +1,16 @@ +diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c +index 060aa75..a660d39 100644 +--- a/drivers/net/ethernet/intel/igb/igb_ptp.c ++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c +@@ -285,7 +285,11 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) + struct igb_adapter *igb = container_of(ptp, struct igb_adapter, + ptp_caps); + unsigned long flags; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + struct timespec64 now, then = ns_to_timespec64(delta); ++#else ++ struct timespec now, then = ns_to_timespec(delta); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + + spin_lock_irqsave(&igb->tmreg_lock, flags); +
patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH 3/4] backports: deal with struct timespec64 changes
Quoted 7 lines · Stefan Assmann
igb now makes use of struct timespec64. Deal with the required changes via cocci patches where possible. There's one occasion where coccinelle is not able to deal with defining a struct and assigning another struct on the same line.
Example:
struct timespec64 now, then =ns_to_timespec64(delta); Deal with this in a separate patch for now.
I think it would be easier if you just replace timespec64 with timespec in the header files.
Like:
#define ns_to_timespec64 ns_to_timespec
#define timespec64 timespec
Then cocci is only needed to replace the settime64 members with settime and so on.
Quoted 139 lines
Signed-off-by Stefan Assmann <[email protected]>--- .../network/0057-timespec64/INFO | 11 +++ .../network/0057-timespec64/igb.patch | 16 +++++ .../network/0057-timespec64/timespec64.cocci | 83 ++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.coccipatches/collateral-evolutions/network/0057-timespec64/INFO new file +11
-0@@ -0,0 +1,11 @@ +In kernel 3.17 struct timespec64 was introduced. +Address this with cocci patches where possible. + +commit 361a3bf00582469877f8d18ff20f1efa6b781274 +Author: John Stultz <[email protected]> +Date: Wed Jul 16 21:03:58 2014 +0000 + + time64: Add time64.h header and define struct timespec64 + +git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274 +v3.17-rc1~109^2~62patches/collateral-evolutions/network/0057-timespec64/igb.patch new file +16
-0@@ -0,0 +1,16 @@ +diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c +index 060aa75..a660d39 100644 +--- a/drivers/net/ethernet/intel/igb/igb_ptp.c ++++ b/drivers/net/ethernet/intel/igb/igb_ptp.c +@@ -285,7 +285,11 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) + struct igb_adapter *igb = container_of(ptp, struct igb_adapter, + ptp_caps); + unsigned long flags; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + struct timespec64 now, then = ns_to_timespec64(delta); ++#else ++ struct timespec now, then = ns_to_timespec(delta); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + + spin_lock_irqsave(&igb->tmreg_lock, flags); +patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci new file +83
-0@@ -0,0 +1,83 @@ +// ---------------------------------------------------------------------------- +// handle struct timespec64 to timespec conversion in prototypes +@r1@ +identifier func, I1; +@@ + func(... ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + ,struct timespec64 *I1 ++#else ++ ,struct timespec *I1 ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + ) {...} + +// ---------------------------------------------------------------------------- +// handle struct timespec64 to timespec conversion in functions +@r2@ +identifier I1; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + struct timespec64 I1; ++#else ++struct timespec I1; ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + +// ---------------------------------------------------------------------------- +// handle struct timespec64 to timespec conversion with assignment +@r3@ +identifier I1; +expression E1; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + struct timespec64 I1 = E1; ++#else ++struct timespec I1 = E1; ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + +// ---------------------------------------------------------------------------- +// handle struct timespec64 to timespec casts +@r4@ +identifier func; +expression E1, E2; +@@ + func(E1 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + ,(const struct timespec64 *) E2 ++#else ++ ,(const struct timespec *) E2 ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + ); + +// ---------------------------------------------------------------------------- +// handle timespec64_add to timespec_add function rename +@r5@ +identifier I1; +expression E1, E2; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + I1 = timespec64_add(E1, E2); ++#else ++I1 = timespec_add(E1, E2); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + +// ---------------------------------------------------------------------------- +// handle ns_to_timespec64 to ns_to_timespec function rename +@r6@ +expression E1, E2; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + E1 = ns_to_timespec64(E2); ++#else ++E1 = ns_to_timespec(E2); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */ + +// ---------------------------------------------------------------------------- +// handle timespec64_to_ns to timespec_to_ns function rename +@r7@ +expression E1, E2; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) + E1 = timespec64_to_ns(E2); ++#else ++E1 = timespec_to_ns(E2); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) */
Re: [PATCH 3/4] backports: deal with struct timespec64 changes
Quoted 12 lines · Hauke Mehrtens
Quoted 7 lines · Stefan Assmann
igb now makes use of struct timespec64. Deal with the required changes via cocci patches where possible. There's one occasion where coccinelle is not able to deal with defining a struct and assigning another struct on the same line.
Example:
struct timespec64 now, then =ns_to_timespec64(delta); Deal with this in a separate patch for now.I think it would be easier if you just replace timespec64 with timespec in the header files.
Quoted 6 lines
Like:
#definens_to_timespec64ns_to_timespec
#define timespec64 timespecThen cocci is only needed to replace the settime64 members with settime and so on.
That seems to work better than I expected. :)
Here's a new patch.
Stefan
Quoted 1 line
From
b4d4d61c80be782f0cffa151e2eab3774c6cb4f9Mon Sep 17 00:00:00 2001
From: Stefan Assmann <[email protected]>
Date: Wed, 22 Apr 2015 10:25:56 -0400
Subject: [PATCH v2] backports: deal with struct timespec64 changes
In kernel 3.17 struct timespec64 was introduced.
commit 361a3bf00582469877f8d18ff20f1efa6b781274
Author: John Stultz <[email protected]> Date: Wed Jul 16 21:03:58 2014 +0000
time64: Add time64.h header and define struct timespec64
git describe --contains 361a3bf00582469877f8d18ff20f1efa6b781274 v3.17-rc1~109^2~62
Deal with the required changes via defines.
--- backport/backport-include/linux/time.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 backport/backport-include/linux/time.h
backport/backport-include/linux/time.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef __BACKPORT_LINUX_TIME_H +#define __BACKPORT_LINUX_TIME_H +#include_next <linux/time.h> + +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,17 ,0 ) +/* Map the ktime_t to timespec conversion to ns_to_timespec function */ +#define ktime_to_timespec (kt) ns_to_timespec((kt).tv64) + +/* Map the ktime_t to timespec conversion to ns_to_timespec function */ +#define ktime_to_timespec64 (kt) ns_to_timespec64((kt).tv64) + +/* Map the ktime_t to timeval conversion to ns_to_timeval function */ +#define ktime_to_timeval (kt) ns_to_timeval((kt).tv64) + +/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */ +#define ktime_to_ns (kt) ((kt).tv64) + +#define timespec64_equal timespec_equal +#define timespec64_compare timespec_compare +#define set_normalized_timespec64 set_normalized_timespec +#define timespec64_add_safe timespec_add_safe +#define timespec64_add timespec_add +#define timespec64_sub timespec_sub +#define timespec64_valid timespec_valid +#define timespec64_valid_strict timespec_valid_strict +#define timespec64_to_ns timespec_to_ns +#define ns_to_timespec64 ns_to_timespec +#define timespec64_add_ns timespec_add_ns +#define timespec64 timespec +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) */ + +#endif /* __BACKPORT_LINUX_TIME_H */
Signature · 1 line
2.1.0
PATCH 4/4 backports: deal with struct struct ptp_clock_info get/settime64 changes
In reply to Stefan AssmannIn kernel 4.1 struct ptp_clock_info changes function pointers gettime, settime to gettime64, settime64.
--- .../network/0058-ptp_getsettime64/INFO | 11 ++++++++ .../0058-ptp_getsettime64/ptp_getsettime64.cocci | 33 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO new file +11 -0
@@ -0,0 +1,11 @@ +In kernel 4.1 struct ptp_clock_info changes function pointers gettime, +settime to gettime64, settime64. + +commit 92f1719407b90475b3be0b7b9c983dec2ff8351e +Author: Richard Cochran <[email protected]> +Date: Sun Mar 29 23:11:51 2015 +0200 + + ptp: introduce get/set time methods with explicit 64 bit seconds. + +git describe --contains 92f1719407b90475b3be0b7b9c983dec2ff8351e +next-20150401~92^2~18^2~22
patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci new file +33 -0
@@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------- +// handle gettime64 to gettime function assignments +@r1@ +expression E1, E2; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) + E1.gettime64 = E2; ++#else ++E1.gettime = E2; ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */ + +// ---------------------------------------------------------------------------- +// handle calls to gettime64 as calls to gettime +@r2@ +expression E1, E2, E3; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) + E1.gettime64(E2, E3); ++#else ++E1.gettime(E2, E3); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */ + +// ---------------------------------------------------------------------------- +// handle settime64 to settime function assignments +@r3@ +expression E1, E2; +@@ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) + E1.settime64 = E2; ++#else ++E1.settime = E2; ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) */ +
Signature · 1 line
2.1.0
Quoted 25 lines · Stefan Assmann
This series adds cocci patches to deal with struct timespec64 changes and also has several other bits to get igb working again. Patches have been tested against next-20150402.
The struct timespec64 patches are not perfect, but they should get us started. There are still some warnings, which we can fix along the way.
Stefan Assmann (4):
backports: handlendo_gso_check()tondo_features_check()changes
backports: addpassthru_features_check()
backports: deal with struct timespec64 changes
backports: deal with struct structptp_clock_infoget/settime64
changesbackport/backport-include/linux/netdevice.h | 6 ++ backport/compat/Makefile | 1 + backport/compat/backport-4.1.c | 19 +++++ .../network/0056-ndo_features_check/INFO | 12 ++++ .../0056-ndo_features_check/features_check.cocci | 19 +++++ .../network/0057-timespec64/INFO | 11 +++ .../network/0057-timespec64/igb.patch | 16 +++++ .../network/0057-timespec64/timespec64.cocci | 83 ++++++++++++++++++++++ .../network/0058-ptp_getsettime64/INFO | 11 +++ .../0058-ptp_getsettime64/ptp_getsettime64.cocci | 33 +++++++++ 10 files changed, 211 insertions(+)
Quoted 9 lines
create mode 100644 backport/compat/backport-4.1.c create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/INFO create mode 100644 patches/collateral-evolutions/network/0056-ndo_features_check/features_check.cocci create mode 100644 patches/collateral-evolutions/network/0057-timespec64/INFO create mode 100644 patches/collateral-evolutions/network/0057-timespec64/igb.patch create mode 100644 patches/collateral-evolutions/network/0057-timespec64/timespec64.cocci create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/INFO create mode 100644 patches/collateral-evolutions/network/0058-ptp_getsettime64/ptp_getsettime64.cocci
Thank you for the patches, I applied and pushed them.
In the patch "backports: add passthru_features_check()" I change the EXPORT_SYMBOL() to a EXPORT_SYMBOL_GPL().
In "backports: deal with struct timespec64 changes" v2 I moved the defines into the header files with the same name as where they are defined in the kernel. If later some code is including time64.h directly this will now work. In addition I removed some ktime_* defines, because they are already in all supported kernel versions.
Hauke