Re: [vbox-dev] Fixes for API changes in kernel 4.20

2018-11-20 Thread Aleksey Ilyushin
Hello Larry,

Thanks a lot for your patch. I do have an issue with it though. I think 
‘get_link_ksettings’ callback is supposed to return the link settings in the 
new format, so ‘vboxNetAdpEthGetSettings’ should allocate the old structure, 
fill it out, then call a function that does the opposite of what 
‘convert_link_ksettings_to_legacy_settings’ does, thus filling the new 
structure provided in the parameters, then free the old structure. Currently 
the patch does not modify the output structure at all. It looks like you had 
’setter’ in mind when implementing this. If you agree I’ll go forward and 
modify the patch, then apply it.

Best regards,
Aleksey

> On 21 Nov 2018, at 04:24, Larry Finger  wrote:
> 
> On 11/20/18 6:37 AM, Michael Thayer wrote:
>> 08.11.18 21:27, Larry Finger wrote:
>>> Hi,
>>> 
>>> There are a number of changes in kernel 4.20 that affect building the VB
>>> modules. These are as follows:
>>> 
>>> 1. In struct ethtool_ops, the get_settings member is renamed
>>> get_link_ksettings, and the callback method is changed. To satisfy the
>>> new method, routine convert_link_ksettings_to_legacy_settings(), which
>>> is not exported by the kernel, had to be duplicated.
>>> 
>>> 2. Routine ktime_get_real_ts() must be replaced by ktime_get_real_ts64()
>>> and there are other places where 64-bit names have to be used.
>>> 
>>> 3. In the drm routines, info->flags no longer accepts
>>> FBINFO_CAN_FORCE_OUTPUT. According to the kernel commit message, this
>>> flag was unused and it can be deleted without any harmful effects.
>>> 
>>> The patch file for these changes is attached.
>> Hello Larry,
>> Still waiting for input from the "owner" of the VBoxNetAdp code, but
>> does this slightly adjusted version (patch against trunk) look alright
>> to you?
>> Index: include/iprt/time.h
>> ===
>> --- include/iprt/time.h  (revision 126767)
>> +++ include/iprt/time.h  (working copy)
>> @@ -428,6 +428,14 @@
>>  {
>>  return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
>> pTimespec->tv_sec), pTimespec->tv_nsec);
>>  }
>> +
>> +
>> +# ifdef _LINUX_TIME64_H
>> +DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime,
>> const struct timespec64 *pTimeval)
>> +{
>> +return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
>> pTimeval->tv_sec), pTimeval->tv_nsec);
>> +}
>> +# endif
>>  #endif /* various ways of detecting struct timespec */
>> Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
>> ===
>> --- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c  (revision 126767)
>> +++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c  (working copy)
>> @@ -171,11 +171,20 @@
>>  {
>>  IPRT_LINUX_SAVE_EFL_AC();
>>  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
>> +/* On Linux 4.20, time.h includes time64.h and we have to use 64-bit
>> times. */
>> +# ifdef _LINUX_TIME64_H
>> +struct timespec64 Ts;
>> +ktime_get_real_ts64();
>> +# else
>>  struct timespec Ts;
>>  ktime_get_real_ts();
>> +# endif
>>  IPRT_LINUX_RESTORE_EFL_AC();
>> +# ifdef _LINUX_TIME64_H
>> +return RTTimeSpecSetTimespec64(pTime, );
>> +#else
>>  return RTTimeSpecSetTimespec(pTime, );
>> -
>> +#endif
>>  #else   /* < 2.6.16 */
>>  struct timeval Tv;
>>  do_gettimeofday();
>> Index: src/VBox/Additions/linux/drm/vbox_fb.c
>> ===
>> --- src/VBox/Additions/linux/drm/vbox_fb.c   (revision 126767)
>> +++ src/VBox/Additions/linux/drm/vbox_fb.c   (working copy)
>> @@ -325,8 +325,7 @@
>>   * The last flag forces a mode set on VT switches even if the kernel
>>   * does not think it is needed.
>>   */
>> -info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT |
>> -  FBINFO_MISC_ALWAYS_SETPAR;
>> +info->flags = FBINFO_DEFAULT | FBINFO_MISC_ALWAYS_SETPAR;
>>  info->fbops = _ops;
>>  /*
>> Index: src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
>> ===
>> --- src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c (revision
>> 126767)
>> +++ src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c (working copy)
>> @@ -84,9 +84,12 @@
>>  #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
>>  static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct
>> ethtool_drvinfo *info);
>> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
>> +static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct
>> ethtool_link_ksettings *link_ksettings);
>> +#else
>>  static int vboxNetAdpEthGetSettings(struct net_device *dev, struct
>> ethtool_cmd *cmd);
>> +#endif
>> -
>>  
>> /*
>>  *   Global Variables
>> 

Re: [vbox-dev] Fixes for API changes in kernel 4.20

2018-11-20 Thread Larry Finger

On 11/20/18 6:37 AM, Michael Thayer wrote:

08.11.18 21:27, Larry Finger wrote:

Hi,

There are a number of changes in kernel 4.20 that affect building the VB
modules. These are as follows:

1. In struct ethtool_ops, the get_settings member is renamed
get_link_ksettings, and the callback method is changed. To satisfy the
new method, routine convert_link_ksettings_to_legacy_settings(), which
is not exported by the kernel, had to be duplicated.

2. Routine ktime_get_real_ts() must be replaced by ktime_get_real_ts64()
and there are other places where 64-bit names have to be used.

3. In the drm routines, info->flags no longer accepts
FBINFO_CAN_FORCE_OUTPUT. According to the kernel commit message, this
flag was unused and it can be deleted without any harmful effects.

The patch file for these changes is attached.


Hello Larry,

Still waiting for input from the "owner" of the VBoxNetAdp code, but
does this slightly adjusted version (patch against trunk) look alright
to you?

Index: include/iprt/time.h
===
--- include/iprt/time.h (revision 126767)
+++ include/iprt/time.h (working copy)
@@ -428,6 +428,14 @@
  {
  return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
pTimespec->tv_sec), pTimespec->tv_nsec);
  }
+
+
+# ifdef _LINUX_TIME64_H
+DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime,
const struct timespec64 *pTimeval)
+{
+return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
pTimeval->tv_sec), pTimeval->tv_nsec);
+}
+# endif
  #endif /* various ways of detecting struct timespec */


Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
===
--- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 126767)
+++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (working copy)
@@ -171,11 +171,20 @@
  {
  IPRT_LINUX_SAVE_EFL_AC();
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
+/* On Linux 4.20, time.h includes time64.h and we have to use 64-bit
times. */
+# ifdef _LINUX_TIME64_H
+struct timespec64 Ts;
+ktime_get_real_ts64();
+# else
  struct timespec Ts;
  ktime_get_real_ts();
+# endif
  IPRT_LINUX_RESTORE_EFL_AC();
+# ifdef _LINUX_TIME64_H
+return RTTimeSpecSetTimespec64(pTime, );
+#else
  return RTTimeSpecSetTimespec(pTime, );
-
+#endif
  #else   /* < 2.6.16 */
  struct timeval Tv;
  do_gettimeofday();
Index: src/VBox/Additions/linux/drm/vbox_fb.c
===
--- src/VBox/Additions/linux/drm/vbox_fb.c  (revision 126767)
+++ src/VBox/Additions/linux/drm/vbox_fb.c  (working copy)
@@ -325,8 +325,7 @@
 * The last flag forces a mode set on VT switches even if the kernel
 * does not think it is needed.
 */
-   info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT |
- FBINFO_MISC_ALWAYS_SETPAR;
+   info->flags = FBINFO_DEFAULT | FBINFO_MISC_ALWAYS_SETPAR;
info->fbops = _ops;

/*
Index: src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
===
--- src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c(revision
126767)
+++ src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c(working copy)
@@ -84,9 +84,12 @@
  #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */

  static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct
ethtool_drvinfo *info);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct
ethtool_link_ksettings *link_ksettings);
+#else
  static int vboxNetAdpEthGetSettings(struct net_device *dev, struct
ethtool_cmd *cmd);
+#endif

-
  
/*
  *   Global Variables
   *
  
*/
@@ -133,7 +136,11 @@
  # endif
  {
  .get_drvinfo= vboxNetAdpEthGetDrvinfo,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+.get_link_ksettings = vboxNetAdpEthGetSettings,
+#else
  .get_settings   = vboxNetAdpEthGetSettings,
+#endif
  .get_link   = ethtool_op_get_link,
  };

@@ -204,10 +211,64 @@
  "N/A");
  }

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static bool
+convert_link_ksettings_to_legacy_settings(
+   struct ethtool_cmd *legacy_settings,
+   const struct ethtool_link_ksettings *link_ksettings)
+{
+   bool retval = true;

+   memset(legacy_settings, 0, sizeof(*legacy_settings));
+   /* this also clears the deprecated fields in legacy structure:
+* __u8 transceiver;
+* __u32maxtxpkt;
+* __u32

Re: [vbox-dev] Fixes for API changes in kernel 4.20

2018-11-20 Thread Michael Thayer
08.11.18 21:27, Larry Finger wrote:
> Hi,
> 
> There are a number of changes in kernel 4.20 that affect building the VB
> modules. These are as follows:
> 
> 1. In struct ethtool_ops, the get_settings member is renamed
> get_link_ksettings, and the callback method is changed. To satisfy the
> new method, routine convert_link_ksettings_to_legacy_settings(), which
> is not exported by the kernel, had to be duplicated.
> 
> 2. Routine ktime_get_real_ts() must be replaced by ktime_get_real_ts64()
> and there are other places where 64-bit names have to be used.
> 
> 3. In the drm routines, info->flags no longer accepts
> FBINFO_CAN_FORCE_OUTPUT. According to the kernel commit message, this
> flag was unused and it can be deleted without any harmful effects.
> 
> The patch file for these changes is attached.

Hello Larry,

Still waiting for input from the "owner" of the VBoxNetAdp code, but
does this slightly adjusted version (patch against trunk) look alright
to you?

Index: include/iprt/time.h
===
--- include/iprt/time.h (revision 126767)
+++ include/iprt/time.h (working copy)
@@ -428,6 +428,14 @@
 {
 return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
pTimespec->tv_sec), pTimespec->tv_nsec);
 }
+
+
+# ifdef _LINUX_TIME64_H
+DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime,
const struct timespec64 *pTimeval)
+{
+return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime,
pTimeval->tv_sec), pTimeval->tv_nsec);
+}
+# endif
 #endif /* various ways of detecting struct timespec */


Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
===
--- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 126767)
+++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (working copy)
@@ -171,11 +171,20 @@
 {
 IPRT_LINUX_SAVE_EFL_AC();
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
+/* On Linux 4.20, time.h includes time64.h and we have to use 64-bit
times. */
+# ifdef _LINUX_TIME64_H
+struct timespec64 Ts;
+ktime_get_real_ts64();
+# else
 struct timespec Ts;
 ktime_get_real_ts();
+# endif
 IPRT_LINUX_RESTORE_EFL_AC();
+# ifdef _LINUX_TIME64_H
+return RTTimeSpecSetTimespec64(pTime, );
+#else
 return RTTimeSpecSetTimespec(pTime, );
-
+#endif
 #else   /* < 2.6.16 */
 struct timeval Tv;
 do_gettimeofday();
Index: src/VBox/Additions/linux/drm/vbox_fb.c
===
--- src/VBox/Additions/linux/drm/vbox_fb.c  (revision 126767)
+++ src/VBox/Additions/linux/drm/vbox_fb.c  (working copy)
@@ -325,8 +325,7 @@
 * The last flag forces a mode set on VT switches even if the kernel
 * does not think it is needed.
 */
-   info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT |
- FBINFO_MISC_ALWAYS_SETPAR;
+   info->flags = FBINFO_DEFAULT | FBINFO_MISC_ALWAYS_SETPAR;
info->fbops = _ops;

/*
Index: src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
===
--- src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c(revision
126767)
+++ src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c(working copy)
@@ -84,9 +84,12 @@
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */

 static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct
ethtool_drvinfo *info);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct
ethtool_link_ksettings *link_ksettings);
+#else
 static int vboxNetAdpEthGetSettings(struct net_device *dev, struct
ethtool_cmd *cmd);
+#endif

-
 
/*
 *   Global Variables
  *
 
*/
@@ -133,7 +136,11 @@
 # endif
 {
 .get_drvinfo= vboxNetAdpEthGetDrvinfo,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+.get_link_ksettings = vboxNetAdpEthGetSettings,
+#else
 .get_settings   = vboxNetAdpEthGetSettings,
+#endif
 .get_link   = ethtool_op_get_link,
 };

@@ -204,10 +211,64 @@
 "N/A");
 }

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static bool
+convert_link_ksettings_to_legacy_settings(
+   struct ethtool_cmd *legacy_settings,
+   const struct ethtool_link_ksettings *link_ksettings)
+{
+   bool retval = true;

+   memset(legacy_settings, 0, sizeof(*legacy_settings));
+   /* this also clears the deprecated fields in legacy structure:
+* __u8 transceiver;
+* __u32maxtxpkt;
+* __u32maxrxpkt;
+*/
+
+   retval &=