~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/mlx4/en_ethtool.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        struct mlx4_en_priv *priv = netdev_priv(dev);
46
46
        struct mlx4_en_dev *mdev = priv->mdev;
47
47
 
48
 
        sprintf(drvinfo->driver, DRV_NAME " (%s)", mdev->dev->board_id);
 
48
        strncpy(drvinfo->driver, DRV_NAME, 32);
49
49
        strncpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", 32);
50
50
        sprintf(drvinfo->fw_version, "%d.%d.%d",
51
51
                (u16) (mdev->dev->caps.fw_ver >> 32),
57
57
        drvinfo->eedump_len = 0;
58
58
}
59
59
 
60
 
static u32 mlx4_en_get_tso(struct net_device *dev)
61
 
{
62
 
        return (dev->features & NETIF_F_TSO) != 0;
63
 
}
64
 
 
65
 
static int mlx4_en_set_tso(struct net_device *dev, u32 data)
66
 
{
67
 
        struct mlx4_en_priv *priv = netdev_priv(dev);
68
 
 
69
 
        if (data) {
70
 
                if (!priv->mdev->LSO_support)
71
 
                        return -EPERM;
72
 
                dev->features |= (NETIF_F_TSO | NETIF_F_TSO6);
73
 
        } else
74
 
                dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
75
 
        return 0;
76
 
}
77
 
 
78
 
static u32 mlx4_en_get_rx_csum(struct net_device *dev)
79
 
{
80
 
        struct mlx4_en_priv *priv = netdev_priv(dev);
81
 
        return priv->rx_csum;
82
 
}
83
 
 
84
 
static int mlx4_en_set_rx_csum(struct net_device *dev, u32 data)
85
 
{
86
 
        struct mlx4_en_priv *priv = netdev_priv(dev);
87
 
        priv->rx_csum = (data != 0);
88
 
        return 0;
89
 
}
90
 
 
91
60
static const char main_strings[][ETH_GSTRING_LEN] = {
92
61
        "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
93
62
        "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
131
100
static void mlx4_en_get_wol(struct net_device *netdev,
132
101
                            struct ethtool_wolinfo *wol)
133
102
{
134
 
        wol->supported = 0;
135
 
        wol->wolopts = 0;
 
103
        struct mlx4_en_priv *priv = netdev_priv(netdev);
 
104
        int err = 0;
 
105
        u64 config = 0;
 
106
 
 
107
        if (!priv->mdev->dev->caps.wol) {
 
108
                wol->supported = 0;
 
109
                wol->wolopts = 0;
 
110
                return;
 
111
        }
 
112
 
 
113
        err = mlx4_wol_read(priv->mdev->dev, &config, priv->port);
 
114
        if (err) {
 
115
                en_err(priv, "Failed to get WoL information\n");
 
116
                return;
 
117
        }
 
118
 
 
119
        if (config & MLX4_EN_WOL_MAGIC)
 
120
                wol->supported = WAKE_MAGIC;
 
121
        else
 
122
                wol->supported = 0;
 
123
 
 
124
        if (config & MLX4_EN_WOL_ENABLED)
 
125
                wol->wolopts = WAKE_MAGIC;
 
126
        else
 
127
                wol->wolopts = 0;
 
128
}
 
129
 
 
130
static int mlx4_en_set_wol(struct net_device *netdev,
 
131
                            struct ethtool_wolinfo *wol)
 
132
{
 
133
        struct mlx4_en_priv *priv = netdev_priv(netdev);
 
134
        u64 config = 0;
 
135
        int err = 0;
 
136
 
 
137
        if (!priv->mdev->dev->caps.wol)
 
138
                return -EOPNOTSUPP;
 
139
 
 
140
        if (wol->supported & ~WAKE_MAGIC)
 
141
                return -EINVAL;
 
142
 
 
143
        err = mlx4_wol_read(priv->mdev->dev, &config, priv->port);
 
144
        if (err) {
 
145
                en_err(priv, "Failed to get WoL info, unable to modify\n");
 
146
                return err;
 
147
        }
 
148
 
 
149
        if (wol->wolopts & WAKE_MAGIC) {
 
150
                config |= MLX4_EN_WOL_DO_MODIFY | MLX4_EN_WOL_ENABLED |
 
151
                                MLX4_EN_WOL_MAGIC;
 
152
        } else {
 
153
                config &= ~(MLX4_EN_WOL_ENABLED | MLX4_EN_WOL_MAGIC);
 
154
                config |= MLX4_EN_WOL_DO_MODIFY;
 
155
        }
 
156
 
 
157
        err = mlx4_wol_write(priv->mdev->dev, config, priv->port);
 
158
        if (err)
 
159
                en_err(priv, "Failed to set WoL information\n");
 
160
 
 
161
        return err;
136
162
}
137
163
 
138
164
static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
239
265
 
240
266
        trans_type = priv->port_state.transciver;
241
267
        if (netif_carrier_ok(dev)) {
242
 
                cmd->speed = priv->port_state.link_speed;
 
268
                ethtool_cmd_speed_set(cmd, priv->port_state.link_speed);
243
269
                cmd->duplex = DUPLEX_FULL;
244
270
        } else {
245
 
                cmd->speed = -1;
 
271
                ethtool_cmd_speed_set(cmd, -1);
246
272
                cmd->duplex = -1;
247
273
        }
248
274
 
266
292
static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
267
293
{
268
294
        if ((cmd->autoneg == AUTONEG_ENABLE) ||
269
 
            (cmd->speed != SPEED_10000) || (cmd->duplex != DUPLEX_FULL))
 
295
            (ethtool_cmd_speed(cmd) != SPEED_10000) ||
 
296
            (cmd->duplex != DUPLEX_FULL))
270
297
                return -EINVAL;
271
298
 
272
299
        /* Nothing to change */
388
415
                mlx4_en_stop_port(dev);
389
416
        }
390
417
 
391
 
        mlx4_en_free_resources(priv);
 
418
        mlx4_en_free_resources(priv, true);
392
419
 
393
420
        priv->prof->tx_ring_size = tx_size;
394
421
        priv->prof->rx_ring_size = rx_size;
426
453
        .get_drvinfo = mlx4_en_get_drvinfo,
427
454
        .get_settings = mlx4_en_get_settings,
428
455
        .set_settings = mlx4_en_set_settings,
429
 
#ifdef NETIF_F_TSO
430
 
        .get_tso = mlx4_en_get_tso,
431
 
        .set_tso = mlx4_en_set_tso,
432
 
#endif
433
 
        .get_sg = ethtool_op_get_sg,
434
 
        .set_sg = ethtool_op_set_sg,
435
456
        .get_link = ethtool_op_get_link,
436
 
        .get_rx_csum = mlx4_en_get_rx_csum,
437
 
        .set_rx_csum = mlx4_en_set_rx_csum,
438
 
        .get_tx_csum = ethtool_op_get_tx_csum,
439
 
        .set_tx_csum = ethtool_op_set_tx_ipv6_csum,
440
457
        .get_strings = mlx4_en_get_strings,
441
458
        .get_sset_count = mlx4_en_get_sset_count,
442
459
        .get_ethtool_stats = mlx4_en_get_ethtool_stats,
443
460
        .self_test = mlx4_en_self_test,
444
461
        .get_wol = mlx4_en_get_wol,
 
462
        .set_wol = mlx4_en_set_wol,
445
463
        .get_msglevel = mlx4_en_get_msglevel,
446
464
        .set_msglevel = mlx4_en_set_msglevel,
447
465
        .get_coalesce = mlx4_en_get_coalesce,
450
468
        .set_pauseparam = mlx4_en_set_pauseparam,
451
469
        .get_ringparam = mlx4_en_get_ringparam,
452
470
        .set_ringparam = mlx4_en_set_ringparam,
453
 
        .get_flags = ethtool_op_get_flags,
454
471
};
455
472
 
456
473