VirtualBox

Changeset 85698 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Aug 11, 2020 5:05:29 PM (4 years ago)
Author:
vboxsync
Message:

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

Location:
trunk/src/VBox/HostDrivers
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r85552 r85698  
    5555
    5656#elif defined(RT_OS_LINUX)
    57 #   include <linux/version.h>
    58 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
     57#   include <iprt/linux/version.h>
     58#   if RTLNX_VER_MIN(2,6,33)
    5959#    include <generated/autoconf.h>
    6060#   else
     
    6565#   if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
    6666#       define MODVERSIONS
    67 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
     67#       if RTLNX_VER_MAX(2,5,71)
    6868#           include <linux/modversions.h>
    6969#       endif
    7070#   endif
    7171#   ifndef KBUILD_STR
    72 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     72#       if RTLNX_VER_MAX(2,6,16)
    7373#            define KBUILD_STR(s) s
    7474#       else
     
    7979#   include <linux/spinlock.h>
    8080#   include <linux/slab.h>
    81 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     81#   if RTLNX_VER_MIN(2,6,27)
    8282#       include <linux/semaphore.h>
    8383#   else /* older kernels */
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r85505 r85698  
    4747
    4848/** @todo figure out the exact version number */
    49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
     49#if RTLNX_VER_MIN(2,6,16)
    5050# include <iprt/power.h>
    5151# define VBOX_WITH_SUSPEND_NOTIFICATION
     
    5757# include <linux/platform_device.h>
    5858#endif
    59 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) && defined(SUPDRV_WITH_MSR_PROBER)
     59#if (RTLNX_VER_MIN(2,6,28)) && defined(SUPDRV_WITH_MSR_PROBER)
    6060# define SUPDRV_LINUX_HAS_SAFE_MSR_API
    6161# include <asm/msr.h>
     
    7272/* check kernel version */
    7373# ifndef SUPDRV_AGNOSTIC
    74 #  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     74#  if RTLNX_VER_MAX(2,6,0)
    7575#   error Unsupported kernel version!
    7676#  endif
     
    112112#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    113113static int  VBoxDrvProbe(struct platform_device *pDev);
    114 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     114# if RTLNX_VER_MIN(2,6,30)
    115115static int  VBoxDrvSuspend(struct device *pDev);
    116116static int  VBoxDrvResume(struct device *pDev);
     
    140140#define DEVICE_NAME_USR     "vboxdrvu"
    141141
    142 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     142#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    143143/**
    144144 * Memory for the executable memory heap (in IPRT).
     
    203203    name:       DEVICE_NAME_SYS,
    204204    fops:       &gFileOpsVBoxDrvSys,
    205 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     205# if RTLNX_VER_MAX(2,6,18)
    206206    devfs_name: DEVICE_NAME_SYS,
    207207# endif
     
    213213    name:       DEVICE_NAME_USR,
    214214    fops:       &gFileOpsVBoxDrvUsr,
    215 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     215# if RTLNX_VER_MAX(2,6,18)
    216216    devfs_name: DEVICE_NAME_USR,
    217217# endif
     
    220220
    221221#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    222 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     222# if RTLNX_VER_MIN(2,6,30)
    223223static struct dev_pm_ops gPlatformPMOps =
    224224{
     
    233233{
    234234    .probe = VBoxDrvProbe,
    235 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
     235# if RTLNX_VER_MAX(2,6,30)
    236236    .suspend = VBoxDrvSuspend,
    237237    .resume  = VBoxDrvResume,
     
    241241    {
    242242        .name = "vboxdrv",
    243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     243# if RTLNX_VER_MIN(2,6,30)
    244244        .pm = &gPlatformPMOps,
    245245# endif
     
    260260DECLINLINE(RTUID) vboxdrvLinuxUid(void)
    261261{
    262 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    263 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     262#if RTLNX_VER_MIN(2,6,29)
     263# if RTLNX_VER_MIN(3,5,0)
    264264    return from_kuid(current_user_ns(), current->cred->uid);
    265265# else
     
    273273DECLINLINE(RTGID) vboxdrvLinuxGid(void)
    274274{
    275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    276 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     275#if RTLNX_VER_MIN(2,6,29)
     276# if RTLNX_VER_MIN(3,5,0)
    277277    return from_kgid(current_user_ns(), current->cred->gid);
    278278# else
     
    286286DECLINLINE(RTUID) vboxdrvLinuxEuid(void)
    287287{
    288 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    289 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     288#if RTLNX_VER_MIN(2,6,29)
     289# if RTLNX_VER_MIN(3,5,0)
    290290    return from_kuid(current_user_ns(), current->cred->euid);
    291291# else
     
    332332        if (RT_SUCCESS(rc))
    333333        {
    334 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     334#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    335335# ifdef VBOX_WITH_TEXT_MODMEM_HACK
    336336            set_memory_x(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE);
     
    516516 *                      Ignored.
    517517 */
    518 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) && !defined(DOXYGEN_RUNNING)
     518# if RTLNX_VER_MIN(2,6,30) && !defined(DOXYGEN_RUNNING)
    519519static int VBoxDrvSuspend(struct device *pDev)
    520520# else
     
    531531 * @param   pDev        Pointer to the platform device.
    532532 */
    533 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     533# if RTLNX_VER_MIN(2,6,30)
    534534static int VBoxDrvResume(struct device *pDev)
    535535# else
     
    757757RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask)
    758758{
    759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     759#if RTLNX_VER_MIN(5,8,0)
    760760    RTCCUINTREG const uOld = __read_cr4();
    761 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     761#elif RTLNX_VER_MIN(3,20,0)
    762762    RTCCUINTREG const uOld = this_cpu_read(cpu_tlbstate.cr4);
    763763#else
     
    767767    if (uNew != uOld)
    768768    {
    769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     769#if RTLNX_VER_MIN(5,8,0)
    770770        ASMSetCR4(uNew);
    771 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     771#elif RTLNX_VER_MIN(3,20,0)
    772772        this_cpu_write(cpu_tlbstate.cr4, uNew);
    773773        __write_cr4(uNew);
     
    11211121
    11221122        /* Nobody waiting and no exit function. */
    1123 #  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
     1123#  if RTLNX_VER_MAX(3,13,0)
    11241124        pMyMod->waiter              = NULL;
    11251125#  endif
     
    11281128        /* References, very important as we must not allow the module
    11291129           to be unloaded using rmmod. */
    1130 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
     1130#  if RTLNX_VER_MIN(3,19,0)
    11311131        atomic_set(&pMyMod->refcnt, 42);
    11321132#  else
     
    12131213        mutex_unlock(&module_mutex);
    12141214
    1215 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     1215# if RTLNX_VER_MAX(3,19,0)
    12161216        free_percpu(pMyMod->refptr);
    12171217# endif
     
    14321432    fFlags |= SUPKERNELFEATURES_GDT_READ_ONLY;
    14331433#endif
    1434 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1434#if RTLNX_VER_MIN(4,12,0)
    14351435    fFlags |= SUPKERNELFEATURES_GDT_NEED_WRITABLE;
    14361436#endif
     
    14471447int VBOXCALL    supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw)
    14481448{
    1449 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1449#if RTLNX_VER_MIN(4,12,0)
    14501450    *pGdtRw = (RTHCUINTPTR)get_current_gdt_rw();
    14511451    return VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv

    r85523 r85698  
    7373    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
    7474    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     75    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    7576    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    7677    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c

    r82968 r85698  
    7676static int VBoxNetAdpLinuxOpen(struct inode *pInode, struct file *pFilp);
    7777static int VBoxNetAdpLinuxClose(struct inode *pInode, struct file *pFilp);
    78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     78#if RTLNX_VER_MAX(2,6,36)
    7979static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp,
    8080                                unsigned int uCmd, unsigned long ulArg);
    81 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     81#else  /* >= 2,6,36 */
    8282static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp,
    8383                                         unsigned int uCmd, unsigned long ulArg);
    84 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     84#endif /* >= 2,6,36 */
    8585
    8686static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
    87 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     87#if RTLNX_VER_MIN(4,20,0)
    8888static int vboxNetAdpEthGetLinkSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *pLinkSettings);
    89 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     89#else  /* < 4,20,0 */
    9090static int vboxNetAdpEthGetSettings(struct net_device *dev, struct ethtool_cmd *cmd);
    91 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     91#endif /* < 4,20,0 */
    9292
    9393
     
    113113    open:       VBoxNetAdpLinuxOpen,
    114114    release:    VBoxNetAdpLinuxClose,
    115 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     115#if RTLNX_VER_MAX(2,6,36)
    116116    ioctl:      VBoxNetAdpLinuxIOCtl,
    117 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     117#else /* RTLNX_VER_MIN(2,6,36) */
    118118    unlocked_ioctl: VBoxNetAdpLinuxIOCtlUnlocked,
    119 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     119#endif /* RTLNX_VER_MIN(2,6,36) */
    120120};
    121121
     
    126126    name:       VBOXNETADP_CTL_DEV_NAME,
    127127    fops:       &gFileOpsVBoxNetAdp,
    128 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     128# if RTLNX_VER_MAX(2,6,18)
    129129    devfs_name: VBOXNETADP_CTL_DEV_NAME
    130130# endif
    131131};
    132132
    133 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     133# if RTLNX_VER_MIN(2,6,19)
    134134static const struct ethtool_ops gEthToolOpsVBoxNetAdp =
    135135# else
     
    138138{
    139139    .get_drvinfo        = vboxNetAdpEthGetDrvinfo,
    140 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     140# if RTLNX_VER_MIN(4,20,0)
    141141    .get_link_ksettings = vboxNetAdpEthGetLinkSettings,
    142 # else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     142# else
    143143    .get_settings       = vboxNetAdpEthGetSettings,
    144 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     144# endif
    145145    .get_link           = ethtool_op_get_link,
    146146};
     
    174174    pPriv->Stats.tx_packets++;
    175175    pPriv->Stats.tx_bytes += pSkb->len;
    176 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
     176#if RTLNX_VER_MAX(2,6,31)
    177177    /* Update transmission time stamp. */
    178178    pNetDev->trans_start = jiffies;
     
    214214
    215215
    216 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     216# if RTLNX_VER_MIN(4,20,0)
    217217/* ethtool_ops::get_link_ksettings */
    218218static int vboxNetAdpEthGetLinkSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *pLinkSettings)
     
    230230    return 0;
    231231}
    232 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     232#else /* RTLNX_VER_MAX(4,20,0) */
    233233/* ethtool_ops::get_settings */
    234234static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_cmd *cmd)
     
    236236    cmd->supported      = 0;
    237237    cmd->advertising    = 0;
    238 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     238#if RTLNX_VER_MIN(2,6,27)
    239239    ethtool_cmd_speed_set(cmd, SPEED_10);
    240240#else
     
    250250    return 0;
    251251}
    252 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
    253 
    254 
    255 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     252#endif /* RTLNX_VER_MAX(4,20,0) */
     253
     254
     255#if RTLNX_VER_MIN(2,6,29)
    256256static const struct net_device_ops vboxNetAdpNetdevOps = {
    257257    .ndo_open               = vboxNetAdpLinuxOpen,
     
    267267
    268268    ether_setup(pNetDev);
    269 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     269#if RTLNX_VER_MIN(2,6,29)
    270270    pNetDev->netdev_ops = &vboxNetAdpNetdevOps;
    271 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     271#else /* RTLNX_VER_MAX(2,6,29) */
    272272    pNetDev->open = vboxNetAdpLinuxOpen;
    273273    pNetDev->stop = vboxNetAdpLinuxStop;
    274274    pNetDev->hard_start_xmit = vboxNetAdpLinuxXmit;
    275275    pNetDev->get_stats = vboxNetAdpLinuxGetStats;
    276 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     276#endif /* RTLNX_VER_MAX(2,6,29) */
    277277
    278278    pNetDev->ethtool_ops = &gEthToolOpsVBoxNetAdp;
     
    291291    pNetDev = alloc_netdev(sizeof(VBOXNETADPPRIV),
    292292                           pThis->szName[0] ? pThis->szName : VBOXNETADP_LINUX_NAME,
    293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
     293#if RTLNX_VER_MIN(3,17,0)
    294294                           NET_NAME_UNKNOWN,
    295295#endif
     
    391391 * @param   ulArg       The argument specified to ioctl().
    392392 */
    393 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     393#if RTLNX_VER_MAX(2,6,36)
    394394static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp,
    395395                                unsigned int uCmd, unsigned long ulArg)
    396 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     396#else /* RTLNX_VER_MIN(2,6,36) */
    397397static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp,
    398398                                         unsigned int uCmd, unsigned long ulArg)
    399 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     399#endif /* RTLNX_VER_MIN(2,6,36) */
    400400{
    401401    VBOXNETADPREQ Req;
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/files_vboxnetadp

    r82968 r85698  
    6666    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
    6767    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     68    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6869    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6970    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r85588 r85698  
    3535#include "revision-generated.h"
    3636#include "product-generated.h"
    37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     37#if RTLNX_VER_MIN(2,6,24)
    3838#include <linux/nsproxy.h>
    3939#endif
     
    4646#include <linux/ip.h>
    4747#include <linux/if_vlan.h>
    48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     48#if RTLNX_VER_MIN(4,5,0)
    4949#include <uapi/linux/pkt_cls.h>
    5050#endif
     
    9090#endif
    9191
    92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     92#if RTLNX_VER_MIN(3,11,0)
    9393# define VBOX_NETDEV_NOTIFIER_INFO_TO_DEV(ptr) netdev_notifier_info_to_dev(ptr)
    9494#else
     
    9696#endif
    9797
    98 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     98#if RTLNX_VER_MIN(3,5,0)
    9999# define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag))
    100100# define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr)
    101101#else
    102 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
     102# if RTLNX_VER_MIN(3,2,0)
    103103#  define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ)
    104104#  define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ)
     
    109109#endif
    110110
    111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
     111#if RTLNX_VER_MIN(2,6,34)
    112112# define VBOX_NETDEV_NAME(dev)              netdev_name(dev)
    113113#else
     
    115115#endif
    116116
    117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     117#if RTLNX_VER_MIN(2,6,25)
    118118# define VBOX_IPV4_IS_LOOPBACK(addr)        ipv4_is_loopback(addr)
    119119# define VBOX_IPV4_IS_LINKLOCAL_169(addr)   ipv4_is_linklocal_169(addr)
     
    123123#endif
    124124
    125 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     125#if RTLNX_VER_MIN(2,6,22)
    126126# define VBOX_SKB_RESET_NETWORK_HDR(skb)    skb_reset_network_header(skb)
    127127# define VBOX_SKB_RESET_MAC_HDR(skb)        skb_reset_mac_header(skb)
     
    133133#endif
    134134
    135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     135#if RTLNX_VER_MIN(2,6,19)
    136136# define VBOX_SKB_CHECKSUM_HELP(skb)        skb_checksum_help(skb)
    137137#else
    138138# define CHECKSUM_PARTIAL                   CHECKSUM_HW
    139 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
     139# if RTLNX_VER_MIN(2,6,10)
    140140#  define VBOX_SKB_CHECKSUM_HELP(skb)       skb_checksum_help(skb, 0)
    141141# else
    142 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 7)
     142#  if RTLNX_VER_MIN(2,6,7)
    143143#   define VBOX_SKB_CHECKSUM_HELP(skb)      skb_checksum_help(&skb, 0)
    144144#  else
     
    151151#endif
    152152
    153 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     153#if RTLNX_VER_MIN(3,20,0)
    154154# define VBOX_HAVE_SKB_VLAN
    155155#else
     
    177177#endif
    178178
    179 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     179#if RTLNX_VER_MIN(2,6,18)
    180180
    181181/** Indicates that the linux kernel may send us GSO frames. */
     
    196196# define VBOXNETFLT_WITH_GSO_RECV           1
    197197
    198 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) */
    199 
    200 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     198#endif /* RTLNX_VER_MIN(2,6,18) */
     199
     200#if RTLNX_VER_MIN(2,6,29)
    201201/** This enables or disables handling of GSO frames coming from the wire (GRO). */
    202202# define VBOXNETFLT_WITH_GRO                1
     
    246246
    247247
    248 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) && defined(LOG_ENABLED)
     248#if RTLNX_VER_MAX(2,6,12) && defined(LOG_ENABLED)
    249249unsigned dev_get_flags(const struct net_device *dev)
    250250{
     
    262262    return flags;
    263263}
    264 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) */
     264#endif /* RTLNX_VER_MAX(2,6,12) */
    265265
    266266
     
    344344#ifdef VBOXNETFLT_WITH_HOST2WIRE_FILTER
    345345
    346 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     346# if RTLNX_VER_MAX(2,6,29)
    347347
    348348# include <linux/ethtool.h>
     
    352352# define OVR_XMIT pfnStartXmit
    353353
    354 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     354# else /* RTLNX_VER_MIN(2,6,29) */
    355355
    356356typedef struct net_device_ops OVR_OPSTYPE;
     
    358358# define OVR_XMIT pOrgOps->ndo_start_xmit
    359359
    360 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     360# endif /* RTLNX_VER_MIN(2,6,29) */
    361361
    362362/**
     
    379379    /** Pointer to the original ops. */
    380380    OVR_OPSTYPE const              *pOrgOps;
    381 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     381# if RTLNX_VER_MAX(2,6,29)
    382382    /** Pointer to the original hard_start_xmit function. */
    383383    int (*pfnStartXmit)(struct sk_buff *pSkb, struct net_device *pDev);
    384 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     384# endif /* RTLNX_VER_MAX(2,6,29) */
    385385    /** Pointer to the net filter instance. */
    386386    PVBOXNETFLTINS                  pVBoxNetFlt;
     
    419419    if (   !VALID_PTR(pOverride)
    420420        || pOverride->u32Magic != VBOXNETDEVICEOPSOVERRIDE_MAGIC
    421 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     421# if RTLNX_VER_MIN(2,6,29)
    422422        || !VALID_PTR(pOverride->pOrgOps)
    423 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     423# endif /* RTLNX_VER_MIN(2,6,29) */
    424424        )
    425425    {
     
    479479    pOverride->pOrgOps              = pDev->OVR_OPS;
    480480    pOverride->Ops                  = *pDev->OVR_OPS;
    481 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     481# if RTLNX_VER_MAX(2,6,29)
    482482    pOverride->pfnStartXmit         = pDev->hard_start_xmit;
    483 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     483# else /* RTLNX_VER_MIN(2,6,29) */
    484484    pOverride->Ops.ndo_start_xmit   = vboxNetFltLinuxStartXmitFilter;
    485 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     485# endif /* RTLNX_VER_MIN(2,6,29) */
    486486    pOverride->u32Magic             = VBOXNETDEVICEOPSOVERRIDE_MAGIC;
    487487    pOverride->cTotal               = 0;
     
    491491    RTSpinlockAcquire(pThis->hSpinlock); /* (this isn't necessary, but so what) */
    492492    ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride);
    493 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     493# if RTLNX_VER_MAX(2,6,29)
    494494    ASMAtomicXchgPtr((void * volatile *)&pDev->hard_start_xmit, vboxNetFltLinuxStartXmitFilter);
    495 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     495# endif /* RTLNX_VER_MAX(2,6,29) */
    496496    RTSpinlockRelease(pThis->hSpinlock);
    497497}
     
    519519           )
    520520        {
    521 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     521# if RTLNX_VER_MAX(2,6,29)
    522522            ASMAtomicWritePtr((void * volatile *)&pDev->hard_start_xmit, pOverride->pfnStartXmit);
    523 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     523# endif /* RTLNX_VER_MAX(2,6,29) */
    524524            ASMAtomicWritePtr((void const * volatile *)&pDev->OVR_OPS, pOverride->pOrgOps);
    525525            ASMAtomicWriteU32(&pOverride->u32Magic, 0);
     
    566566            Log(("vboxNetFltLinuxRetainNetDev: Device %p(%s) retained. ref=%d\n",
    567567                 pDev, pDev->name,
    568 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     568#if RTLNX_VER_MIN(2,6,37)
    569569                 netdev_refcnt_read(pDev)
    570570#else
     
    602602        Log(("vboxNetFltLinuxReleaseNetDev: Device %p(%s) released. ref=%d\n",
    603603             pDev, pDev->name,
    604 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     604#if RTLNX_VER_MIN(2,6,37)
    605605             netdev_refcnt_read(pDev)
    606606#else
     
    773773        Assert(skb_headlen(pPkt) >= pSG->GsoCtx.cbHdrsTotal);
    774774        pPkt->ip_summed  = CHECKSUM_PARTIAL;
    775 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     775# if RTLNX_VER_MIN(2,6,22)
    776776        pPkt->csum_start = skb_headroom(pPkt) + pSG->GsoCtx.offHdr2;
    777777        if (fGsoType & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))
     
    817817DECLINLINE(unsigned) vboxNetFltLinuxGetChecksumStartOffset(struct sk_buff *pBuf)
    818818{
    819 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 21)
     819#if RTLNX_VER_MIN(2,6,38)
     820    return skb_checksum_start_offset(pBuf);
     821#elif RTLNX_VER_MIN(2,6,22)
     822    return pBuf->csum_start - skb_headroom(pBuf);
     823#else
    820824    unsigned char *pTransportHdr = pBuf->h.raw;
    821 #  if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
     825# if RTLNX_VER_MAX(2,6,19)
    822826    /*
    823827     * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9
     
    828832    if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP))
    829833        pTransportHdr = pBuf->nh.raw + pBuf->nh.iph->ihl * 4;
    830 #  endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
     834# endif
    831835    return pTransportHdr - pBuf->data;
    832 # else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 21) */
    833 #  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38)
    834     return pBuf->csum_start - skb_headroom(pBuf);
    835 #  else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */
    836     return skb_checksum_start_offset(pBuf);
    837 #  endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */
    838 # endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 21) */
     836#endif
    839837}
    840838
     
    867865    unsigned cbProduced = 0;
    868866
    869 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     867# if RTLNX_VER_MIN(2,6,27)
    870868    /* Restore VLAN tag stripped by host hardware */
    871869    if (vlan_tx_tag_present(pBuf))
     
    882880        cbProduced += VLAN_ETH_HLEN;
    883881    }
    884 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     882# endif /* RTLNX_VER_MIN(2,6,27) */
    885883
    886884    if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING)
     
    931929    {
    932930        skb_frag_t *pFrag = &skb_shinfo(pBuf)->frags[i];
    933 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) || defined(OPENSUSE_152)
     931# if RTLNX_VER_MIN(5,4,0) || defined(OPENSUSE_152)
    934932        pSG->aSegs[iSeg].cb = pFrag->bv_len;
    935933        pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
     
    952950        {
    953951            skb_frag_t *pFrag = &skb_shinfo(pFragBuf)->frags[i];
    954 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) || defined(OPENSUSE_152)
     952# if RTLNX_VER_MIN(5,4,0) || defined(OPENSUSE_152)
    955953            pSG->aSegs[iSeg].cb = pFrag->bv_len;
    956954            pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
     
    10271025 * @returns 0 or EJUSTRETURN - this is probably copy & pastry and thus wrong.
    10281026 */
    1029 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
     1027#if RTLNX_VER_MIN(2,6,14)
    10301028static int vboxNetFltLinuxPacketHandler(struct sk_buff *pBuf,
    10311029                                        struct net_device *pSkbDev,
     
    10421040    LogFlow(("vboxNetFltLinuxPacketHandler: pBuf=%p pSkbDev=%p pPacketType=%p\n",
    10431041             pBuf, pSkbDev, pPacketType));
    1044 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     1042#if RTLNX_VER_MIN(2,6,18)
    10451043    Log3(("vboxNetFltLinuxPacketHandler: skb len=%u data_len=%u truesize=%u next=%p nr_frags=%u gso_size=%u gso_seqs=%u gso_type=%x frag_list=%p pkt_type=%x\n",
    10461044          pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->gso_size, skb_shinfo(pBuf)->gso_segs, skb_shinfo(pBuf)->gso_type, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1047 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1045# if RTLNX_VER_MIN(2,6,22)
    10481046    Log6(("vboxNetFltLinuxPacketHandler: packet dump follows:\n%.*Rhxd\n", pBuf->len-pBuf->data_len, skb_mac_header(pBuf)));
    10491047# endif
     
    11021100        /* Somehow skb_copy ignores mac_len */
    11031101        pBuf->mac_len = uMacLen;
    1104 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     1102# if RTLNX_VER_MIN(2,6,27)
    11051103        /* Restore VLAN tag stripped by host hardware */
    11061104        if (vlan_tx_tag_present(pBuf) && skb_headroom(pBuf) >= VLAN_ETH_HLEN)
     
    11141112            pBuf->mac_len      += VLAN_HLEN;
    11151113        }
    1116 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    1117 
    1118 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     1114# endif /* RTLNX_VER_MIN(2,6,27) */
     1115
     1116# if RTLNX_VER_MIN(2,6,18)
    11191117        Log3(("vboxNetFltLinuxPacketHandler: skb copy len=%u data_len=%u truesize=%u next=%p nr_frags=%u gso_size=%u gso_seqs=%u gso_type=%x frag_list=%p pkt_type=%x\n",
    11201118              pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->gso_size, skb_shinfo(pBuf)->gso_segs, skb_shinfo(pBuf)->gso_type, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1121 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1119#  if RTLNX_VER_MIN(2,6,22)
    11221120        Log6(("vboxNetFltLinuxPacketHandler: packet dump follows:\n%.*Rhxd\n", pBuf->len-pBuf->data_len, skb_mac_header(pBuf)));
    1123 #  endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) */
    1124 # else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) */
     1121#  endif /* RTLNX_VER_MIN(2,6,22) */
     1122# else /* RTLNX_VER_MAX(2,6,18) */
    11251123        Log3(("vboxNetFltLinuxPacketHandler: skb copy len=%u data_len=%u truesize=%u next=%p nr_frags=%u tso_size=%u tso_seqs=%u frag_list=%p pkt_type=%x\n",
    11261124              pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->tso_size, skb_shinfo(pBuf)->tso_segs, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1127 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) */
     1125# endif /* RTLNX_VER_MAX(2,6,18) */
    11281126    }
    11291127#endif /* !VBOXNETFLT_SG_SUPPORT */
     
    11621160        *pcbTemp = vboxNetFltLinuxGetChecksumStartOffset(pBuf) + VBOX_SKB_CSUM_OFFSET(pBuf) + sizeof(uint16_t);
    11631161    }
    1164 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     1162# if RTLNX_VER_MIN(2,6,27)
    11651163    if (vlan_tx_tag_present(pBuf))
    11661164    {
     
    11701168            *pcbTemp = VLAN_ETH_HLEN;
    11711169    }
    1172 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     1170# endif /* RTLNX_VER_MIN(2,6,27) */
    11731171    if (*pcbTemp)
    11741172        ++cSegs;
     
    15541552             * skb_gso_segment does the following. Do we need to do it as well?
    15551553             */
    1556 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1554# if RTLNX_VER_MIN(2,6,22)
    15571555            skb_reset_mac_header(pBuf);
    15581556            pBuf->mac_len = pBuf->network_header - pBuf->mac_header;
     
    16041602        if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING)
    16051603        {
    1606 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
     1604# if RTLNX_VER_MIN(2,6,19)
     1605            int rc = VBOX_SKB_CHECKSUM_HELP(pBuf);
     1606# else
    16071607            /*
    16081608             * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9
     
    16141614            if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP))
    16151615                pBuf->h.raw = pBuf->nh.raw + pBuf->nh.iph->ihl * 4;
    1616 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
    16171616            int rc = VBOX_SKB_CHECKSUM_HELP(pBuf);
    1618 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
    16191617            /* Restore the original (wrong) pointer. */
    16201618            pBuf->h.raw = tmp;
    1621 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
    1622             if (rc) {
     1619# endif
     1620            if (rc)
     1621            {
    16231622                LogRel(("VBoxNetFlt: Failed to compute checksum, dropping the packet.\n"));
    16241623                return;
     
    16741673 * @param   pWork               The work queue.
    16751674 */
    1676 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     1675# if RTLNX_VER_MIN(2,6,20)
    16771676static void vboxNetFltLinuxXmitTask(struct work_struct *pWork)
    16781677# else
     
    17911790            return true;
    17921791
    1793 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) /* TAP started doing carrier */
     1792#if RTLNX_VER_MIN(2,6,36) /* TAP started doing carrier */
    17941793        return !strncmp(Info.driver,   "tun", 4)
    17951794            && !strncmp(Info.bus_info, "tap", 4);
     
    18001799}
    18011800
    1802 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
     1801#if RTLNX_VER_MAX(2,6,18)
    18031802DECLINLINE(void) netif_tx_lock_bh(struct net_device *pDev)
    18041803{
     
    18531852    Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n",
    18541853          pDev, pDev->name,
    1855 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     1854#if RTLNX_VER_MIN(2,6,37)
    18561855          netdev_refcnt_read(pDev)
    18571856#else
     
    19501949        Log(("vboxNetFltLinuxUnregisterDevice: Device %p(%s) released. ref=%d\n",
    19511950             pDev, pDev->name,
    1952 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     1951#if RTLNX_VER_MIN(2,6,37)
    19531952             netdev_refcnt_read(pDev)
    19541953#else
     
    20612060    if (ulEventType == NETDEV_REGISTER)
    20622061    {
    2063 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) /* cgroups/namespaces introduced */
    2064 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     2062#if RTLNX_VER_MIN(2,6,24) /* cgroups/namespaces introduced */
     2063# if RTLNX_VER_MIN(2,6,26)
    20652064#  define VBOX_DEV_NET(dev)             dev_net(dev)
    20662065#  define VBOX_NET_EQ(n1, n2)           net_eq((n1), (n2))
     
    21332132     * IPv4
    21342133     */
    2135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
     2134#if RTLNX_VER_MIN(2,6,14)
    21362135    in_dev = __in_dev_get_rtnl(dev);
    21372136#else
     
    21682167
    21692168        read_lock_bh(&in6_dev->lock);
    2170 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
     2169#if RTLNX_VER_MIN(2,6,35)
    21712170        list_for_each_entry(ifa, &in6_dev->addr_list, if_list)
    21722171#else
     
    24722471        Log(("vboxNetFltOsDeleteInstance: Device %p(%s) released. ref=%d\n",
    24732472             pDev, pDev->name,
    2474 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     2473#if RTLNX_VER_MIN(2,6,37)
    24752474             netdev_refcnt_read(pDev)
    24762475#else
     
    25742573#ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE
    25752574    skb_queue_head_init(&pThis->u.s.XmitQueue);
    2576 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     2575# if RTLNX_VER_MIN(2,6,20)
    25772576    INIT_WORK(&pThis->u.s.XmitTask, vboxNetFltLinuxXmitTask);
    25782577# else
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/files_vboxnetflt

    r82968 r85698  
    6565    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
    6666    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
     67    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6768    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6869    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h

    r82968 r85698  
    3838#ifdef RT_OS_LINUX
    3939
    40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) && defined(CONFIG_IOMMU_API)
     40#if RTLNX_VER_MIN(2,6,35) && defined(CONFIG_IOMMU_API)
    4141# define VBOX_WITH_IOMMU
    4242#endif
  • trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c

    r83471 r85698  
    4848# include <linux/intel-iommu.h>
    4949# include <linux/pci.h>
    50 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && \
    51      (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 41) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
     50# if RTLNX_VER_MAX(3,1,0) && \
     51     (RTLNX_VER_MAX(2,6,41) || RTLNX_VER_MIN(3,0,0))
    5252#  include <asm/amd_iommu.h>
    5353# else
    5454#  include <linux/amd-iommu.h>
    5555# endif
    56 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
     56# if RTLNX_VER_MAX(3,2,0)
    5757#  define IOMMU_PRESENT()      iommu_found()
    5858#  define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc()
     
    8787
    8888
    89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     89#if RTLNX_VER_MIN(2,6,20)
    9090# define PCI_DEV_GET(v,d,p)            pci_get_device(v,d,p)
    9191# define PCI_DEV_PUT(x)                pci_dev_put(x)
    92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
     92#if RTLNX_VER_MIN(4,17,0)
    9393/* assume the domain number to be zero - exactly the same assumption of
    9494 * pci_get_bus_and_slot()
     
    165165    if (request_module(PCI_STUB_MODULE) == 0)
    166166    {
    167 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     167# if RTLNX_VER_MIN(2,6,30)
    168168        /* find_module() is static before Linux 2.6.30 */
    169169        mutex_lock(&module_mutex);
     
    320320    if (RT_LIKELY(pIns->pPciDev))
    321321    {
    322 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     322#if RTLNX_VER_MIN(2,6,28)
    323323        if (pci_reset_function(pIns->pPciDev))
    324324        {
     
    374374    fs_save = get_fs();
    375375    set_fs(KERNEL_DS);
    376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
     376#if RTLNX_VER_MIN(4,14,0)
    377377    ret = kernel_write(file, data, size, &offset);
    378378#else
     
    448448        int                iCmdLen;
    449449        const int          cMaxBuf = 128;
    450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     450#if RTLNX_VER_MIN(2,6,29)
    451451        const struct cred *pOldCreds;
    452452        struct cred       *pNewCreds;
     
    469469
    470470        /* Somewhat ugly hack - override current credentials */
    471 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     471#if RTLNX_VER_MIN(2,6,29)
    472472        pNewCreds = prepare_creds();
    473473        if (!pNewCreds)
    474474                goto done;
    475475
    476 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     476# if RTLNX_VER_MIN(3,5,0)
    477477        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    478478# else
     
    533533            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    534534
    535 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     535#if RTLNX_VER_MIN(2,6,29)
    536536        revert_creds(pOldCreds);
    537537        put_cred(pNewCreds);
     
    560560        int                iCmdLen;
    561561        const int          cMaxBuf = 128;
    562 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     562#if RTLNX_VER_MIN(2,6,29)
    563563        const struct cred *pOldCreds;
    564564        struct cred       *pNewCreds;
     
    586586
    587587        /* Somewhat ugly hack - override current credentials */
    588 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     588#if RTLNX_VER_MIN(2,6,29)
    589589        pNewCreds = prepare_creds();
    590590        if (!pNewCreds)
    591591            goto done;
    592592
    593 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     593# if RTLNX_VER_MIN(3,5,0)
    594594        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    595595# else
     
    627627            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    628628
    629 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     629#if RTLNX_VER_MIN(2,6,29)
    630630        revert_creds(pOldCreds);
    631631        put_cred(pNewCreds);
     
    670670                vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__);
    671671
    672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     672#if RTLNX_VER_MIN(2,6,1)
    673673                if (pci_enable_msi(pPciDev) == 0)
    674674                    pIns->fMsiUsed = true;
     
    717717        vboxPciLinuxDevUnregisterWithIommu(pIns);
    718718
    719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     719#if RTLNX_VER_MIN(2,6,1)
    720720        if (pIns->fMsiUsed)
    721721            pci_disable_msi(pPciDev);
     
    843843        if (!rcLnx)
    844844        {
    845 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     845#if RTLNX_VER_MIN(2,6,25)
    846846            /*
    847847             * ioremap() defaults to no caching since the 2.6 kernels.
     
    859859            else
    860860            {
    861 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     861#if RTLNX_VER_MIN(2,6,25)
    862862                vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n");
    863863#else
     
    956956 * @param   pRegs           Register set. Removed in 2.6.19.
    957957 */
    958 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
     958#if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING)
    959959static irqreturn_t vboxPciOsIrqHandler(int iIrq, void *pvDevId)
    960960#else
     
    992992#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    993993                     /* Allow interrupts sharing. */
    994 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     994# if RTLNX_VER_MIN(2,6,20)
    995995                     IRQF_SHARED,
    996996# else
     
    10021002                     /* We don't allow interrupts sharing */
    10031003                     /* XXX overhaul */
    1004 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
     1004# if RTLNX_VER_MIN(2,6,20) && RTLNX_VER_MAX(4,1,0)
    10051005                     IRQF_DISABLED, /* keep irqs disabled when calling the action handler */
    10061006# else
  • trunk/src/VBox/HostDrivers/VBoxPci/linux/files_vboxpci

    r82968 r85698  
    6464    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
    6565    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
     66    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6667    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6768    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette