forked from NetFPGA-NewNIC/linux-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnf10_ethtool.c
89 lines (80 loc) · 2.6 KB
/
nf10_ethtool.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
*
* NetFPGA-10G http://www.netfpga.org
*
* File:
* nf10_ethtool.c
*
* Project:
*
*
* Author:
* Hwanju Kim
*
* Description:
* This module provides the implementation of ethtool.
* It began providing only get/set_msglevel for debugging purpose, and
* a coalescing feature with rx-usecs.
* It will be extended as needed for additional ethtool features.
*
* This code is initially developed for the Network-as-a-Service (NaaS) project.
* (under development in https://github.com/NetFPGA-NewNIC/linux-driver)
*
*
* Copyright notice:
* Copyright (C) 2014 University of Cambridge
*
* Licence:
* This file is part of the NetFPGA 10G development base package.
*
* This file is free code: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as
* published by the Free Software Foundation.
*
* This package is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the NetFPGA source package. If not, see
* http://www.gnu.org/licenses/.
*
*/
#include "nf10.h"
static u32 nf10_get_msglevel(struct net_device *netdev)
{
struct nf10_adapter *adapter = netdev_adapter(netdev);
return adapter->msg_enable;
}
static void nf10_set_msglevel(struct net_device *netdev, u32 data)
{
struct nf10_adapter *adapter = netdev_adapter(netdev);
adapter->msg_enable = data;
}
static int nf10_get_coalesce(struct net_device *netdev,
struct ethtool_coalesce *ec)
{
struct nf10_adapter *adapter = netdev_adapter(netdev);
ec->rx_coalesce_usecs = adapter->irq_period_usecs;
return 0;
}
static int nf10_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *ec)
{
struct nf10_adapter *adapter = netdev_adapter(netdev);
if (!adapter->hw_ops || !adapter->hw_ops->set_irq_period)
return -EOPNOTSUPP;
adapter->irq_period_usecs = ec->rx_coalesce_usecs;
return adapter->hw_ops->set_irq_period(adapter);
}
static const struct ethtool_ops nf10_ethtool_ops = {
.get_msglevel = nf10_get_msglevel,
.set_msglevel = nf10_set_msglevel,
.get_coalesce = nf10_get_coalesce,
.set_coalesce = nf10_set_coalesce,
};
void nf10_set_ethtool_ops(struct net_device *netdev)
{
SET_ETHTOOL_OPS(netdev, &nf10_ethtool_ops);
}