Merge tag 'gcc-plugins-v4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / ipoib / ethtool.c
1 /*
2  * Copyright (c) 2017, Mellanox Technologies. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32
33 #include "en.h"
34 #include "ipoib.h"
35
36 static void mlx5i_get_drvinfo(struct net_device *dev,
37                               struct ethtool_drvinfo *drvinfo)
38 {
39         struct mlx5e_priv *priv = mlx5i_epriv(dev);
40
41         mlx5e_ethtool_get_drvinfo(priv, drvinfo);
42 }
43
44 static void mlx5i_get_strings(struct net_device *dev,
45                               uint32_t stringset, uint8_t *data)
46 {
47         struct mlx5e_priv *priv  = mlx5i_epriv(dev);
48
49         mlx5e_ethtool_get_strings(priv, stringset, data);
50 }
51
52 static int mlx5i_get_sset_count(struct net_device *dev, int sset)
53 {
54         struct mlx5e_priv *priv = mlx5i_epriv(dev);
55
56         return mlx5e_ethtool_get_sset_count(priv, sset);
57 }
58
59 static void mlx5i_get_ethtool_stats(struct net_device *dev,
60                                     struct ethtool_stats *stats,
61                                     u64 *data)
62 {
63         struct mlx5e_priv *priv = mlx5i_epriv(dev);
64
65         mlx5e_ethtool_get_ethtool_stats(priv, stats, data);
66 }
67
68 static int mlx5i_set_ringparam(struct net_device *dev,
69                                struct ethtool_ringparam *param)
70 {
71         struct mlx5e_priv *priv = mlx5i_epriv(dev);
72
73         return mlx5e_ethtool_set_ringparam(priv, param);
74 }
75
76 static void mlx5i_get_ringparam(struct net_device *dev,
77                                 struct ethtool_ringparam *param)
78 {
79         struct mlx5e_priv *priv = mlx5i_epriv(dev);
80
81         mlx5e_ethtool_get_ringparam(priv, param);
82 }
83
84 static int mlx5i_set_channels(struct net_device *dev,
85                               struct ethtool_channels *ch)
86 {
87         struct mlx5e_priv *priv = mlx5i_epriv(dev);
88
89         return mlx5e_ethtool_set_channels(priv, ch);
90 }
91
92 static void mlx5i_get_channels(struct net_device *dev,
93                                struct ethtool_channels *ch)
94 {
95         struct mlx5e_priv *priv = mlx5i_epriv(dev);
96
97         mlx5e_ethtool_get_channels(priv, ch);
98 }
99
100 static int mlx5i_set_coalesce(struct net_device *netdev,
101                               struct ethtool_coalesce *coal)
102 {
103         struct mlx5e_priv *priv = mlx5i_epriv(netdev);
104
105         return mlx5e_ethtool_set_coalesce(priv, coal);
106 }
107
108 static int mlx5i_get_coalesce(struct net_device *netdev,
109                               struct ethtool_coalesce *coal)
110 {
111         struct mlx5e_priv *priv = mlx5i_epriv(netdev);
112
113         return mlx5e_ethtool_get_coalesce(priv, coal);
114 }
115
116 static int mlx5i_get_ts_info(struct net_device *netdev,
117                              struct ethtool_ts_info *info)
118 {
119         struct mlx5e_priv *priv = mlx5i_epriv(netdev);
120
121         return mlx5e_ethtool_get_ts_info(priv, info);
122 }
123
124 static int mlx5i_flash_device(struct net_device *netdev,
125                               struct ethtool_flash *flash)
126 {
127         struct mlx5e_priv *priv = mlx5i_epriv(netdev);
128
129         return mlx5e_ethtool_flash_device(priv, flash);
130 }
131
132 const struct ethtool_ops mlx5i_ethtool_ops = {
133         .get_drvinfo       = mlx5i_get_drvinfo,
134         .get_strings       = mlx5i_get_strings,
135         .get_sset_count    = mlx5i_get_sset_count,
136         .get_ethtool_stats = mlx5i_get_ethtool_stats,
137         .get_ringparam     = mlx5i_get_ringparam,
138         .set_ringparam     = mlx5i_set_ringparam,
139         .flash_device      = mlx5i_flash_device,
140         .get_channels      = mlx5i_get_channels,
141         .set_channels      = mlx5i_set_channels,
142         .get_coalesce      = mlx5i_get_coalesce,
143         .set_coalesce      = mlx5i_set_coalesce,
144         .get_ts_info       = mlx5i_get_ts_info,
145 };