VirtualBox

Ignore:
Timestamp:
Oct 13, 2015 4:27:57 PM (9 years ago)
Author:
vboxsync
Message:

VBoxNetAdp/linux: add rudimentary ethtool_ops with a view to use them
in vboxNetFltSetTapLinkState() hook to only report carrier when the
filter is actually attached.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c

    r58207 r58220  
    2323#include "version-generated.h"
    2424#include "product-generated.h"
     25#include <linux/ethtool.h>
    2526#include <linux/netdevice.h>
    2627#include <linux/etherdevice.h>
     
    3334#include <iprt/initterm.h>
    3435#include <iprt/mem.h>
     36#include <iprt/string.h>
    3537
    3638/*
     
    7274#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
    7375
     76static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
     77static int vboxNetAdpEthGetSettings(struct net_device *dev, struct ethtool_cmd *cmd);
     78
    7479
    7580/*********************************************************************************************************************************
     
    112117};
    113118
     119static const struct ethtool_ops gEthToolOpsVBoxNetAdp =
     120{
     121    .get_drvinfo        = vboxNetAdpEthGetDrvinfo,
     122    .get_settings       = vboxNetAdpEthGetSettings,
     123    .get_link           = ethtool_op_get_link,
     124};
     125
     126
    114127struct VBoxNetAdpPriv
    115128{
     
    151164    return &pPriv->Stats;
    152165}
     166
     167
     168/* ethtool_ops::get_drvinfo */
     169static void vboxNetAdpEthGetDrvinfo(struct net_device *pNetDev, struct ethtool_drvinfo *info)
     170{
     171    PVBOXNETADPPRIV pPriv = netdev_priv(pNetDev);
     172
     173    RTStrPrintf(info->driver, sizeof(info->driver),
     174                "%s", VBOXNETADP_NAME);
     175
     176    /*
     177     * Would be nice to include VBOX_SVN_REV, but it's not available
     178     * here.  Use file's svn revision via svn keyword?
     179     */
     180    RTStrPrintf(info->version, sizeof(info->version),
     181                "%s", VBOX_VERSION_STRING);
     182
     183    RTStrPrintf(info->fw_version, sizeof(info->fw_version),
     184                "0x%08X", INTNETTRUNKIFPORT_VERSION);
     185
     186    RTStrPrintf(info->bus_info, sizeof(info->driver),
     187                "N/A");
     188}
     189
     190
     191/* ethtool_ops::get_settings */
     192static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_cmd *cmd)
     193{
     194    cmd->supported      = 0;
     195    cmd->advertising    = 0;
     196    ethtool_cmd_speed_set(cmd, SPEED_10);
     197    cmd->duplex         = DUPLEX_FULL;
     198    cmd->port           = PORT_TP;
     199    cmd->phy_address    = 0;
     200    cmd->transceiver    = XCVR_INTERNAL;
     201    cmd->autoneg        = AUTONEG_DISABLE;
     202    cmd->maxtxpkt       = 0;
     203    cmd->maxrxpkt       = 0;
     204    return 0;
     205}
     206
    153207
    154208#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     
    174228    pNetDev->get_stats = vboxNetAdpLinuxGetStats;
    175229#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     230
     231    pNetDev->ethtool_ops = &gEthToolOpsVBoxNetAdp;
    176232
    177233    pPriv = netdev_priv(pNetDev);
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