Skip to content

Commit 7d0bf49

Browse files
committed
eth: fbnic: reorder ethtool code
Define ethtool callback handlers in order in which they are defined in the ops struct. It doesn't really matter what the order is, but it's good to have an order. Reviewed-by: Larysa Zaremba <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f6f1795 commit 7d0bf49

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,6 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
4040
#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)
4141
#define FBNIC_HW_STATS_LEN FBNIC_HW_FIXED_STATS_LEN
4242

43-
static int
44-
fbnic_get_ts_info(struct net_device *netdev,
45-
struct kernel_ethtool_ts_info *tsinfo)
46-
{
47-
struct fbnic_net *fbn = netdev_priv(netdev);
48-
49-
tsinfo->phc_index = ptp_clock_index(fbn->fbd->ptp);
50-
51-
tsinfo->so_timestamping =
52-
SOF_TIMESTAMPING_TX_SOFTWARE |
53-
SOF_TIMESTAMPING_TX_HARDWARE |
54-
SOF_TIMESTAMPING_RX_HARDWARE |
55-
SOF_TIMESTAMPING_RAW_HARDWARE;
56-
57-
tsinfo->tx_types =
58-
BIT(HWTSTAMP_TX_OFF) |
59-
BIT(HWTSTAMP_TX_ON);
60-
61-
tsinfo->rx_filters =
62-
BIT(HWTSTAMP_FILTER_NONE) |
63-
BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
64-
BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
65-
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
66-
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |
67-
BIT(HWTSTAMP_FILTER_ALL);
68-
69-
return 0;
70-
}
71-
7243
static void
7344
fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
7445
{
@@ -79,10 +50,19 @@ fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
7950
sizeof(drvinfo->fw_version));
8051
}
8152

82-
static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter)
53+
static int fbnic_get_regs_len(struct net_device *netdev)
8354
{
84-
if (counter->reported)
85-
*stat = counter->value;
55+
struct fbnic_net *fbn = netdev_priv(netdev);
56+
57+
return fbnic_csr_regs_len(fbn->fbd) * sizeof(u32);
58+
}
59+
60+
static void fbnic_get_regs(struct net_device *netdev,
61+
struct ethtool_regs *regs, void *data)
62+
{
63+
struct fbnic_net *fbn = netdev_priv(netdev);
64+
65+
fbnic_csr_get_regs(fbn->fbd, data, &regs->version);
8666
}
8767

8868
static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
@@ -97,6 +77,21 @@ static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
9777
}
9878
}
9979

80+
static void fbnic_get_ethtool_stats(struct net_device *dev,
81+
struct ethtool_stats *stats, u64 *data)
82+
{
83+
struct fbnic_net *fbn = netdev_priv(dev);
84+
const struct fbnic_stat *stat;
85+
int i;
86+
87+
fbnic_get_hw_stats(fbn->fbd);
88+
89+
for (i = 0; i < FBNIC_HW_STATS_LEN; i++) {
90+
stat = &fbnic_gstrings_hw_stats[i];
91+
data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset);
92+
}
93+
}
94+
10095
static int fbnic_get_sset_count(struct net_device *dev, int sset)
10196
{
10297
switch (sset) {
@@ -107,21 +102,64 @@ static int fbnic_get_sset_count(struct net_device *dev, int sset)
107102
}
108103
}
109104

110-
static void fbnic_get_ethtool_stats(struct net_device *dev,
111-
struct ethtool_stats *stats, u64 *data)
105+
static int
106+
fbnic_get_ts_info(struct net_device *netdev,
107+
struct kernel_ethtool_ts_info *tsinfo)
112108
{
113-
struct fbnic_net *fbn = netdev_priv(dev);
114-
const struct fbnic_stat *stat;
115-
int i;
109+
struct fbnic_net *fbn = netdev_priv(netdev);
116110

117-
fbnic_get_hw_stats(fbn->fbd);
111+
tsinfo->phc_index = ptp_clock_index(fbn->fbd->ptp);
118112

119-
for (i = 0; i < FBNIC_HW_STATS_LEN; i++) {
120-
stat = &fbnic_gstrings_hw_stats[i];
121-
data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset);
113+
tsinfo->so_timestamping =
114+
SOF_TIMESTAMPING_TX_SOFTWARE |
115+
SOF_TIMESTAMPING_TX_HARDWARE |
116+
SOF_TIMESTAMPING_RX_HARDWARE |
117+
SOF_TIMESTAMPING_RAW_HARDWARE;
118+
119+
tsinfo->tx_types =
120+
BIT(HWTSTAMP_TX_OFF) |
121+
BIT(HWTSTAMP_TX_ON);
122+
123+
tsinfo->rx_filters =
124+
BIT(HWTSTAMP_FILTER_NONE) |
125+
BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
126+
BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
127+
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
128+
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT) |
129+
BIT(HWTSTAMP_FILTER_ALL);
130+
131+
return 0;
132+
}
133+
134+
static void fbnic_get_ts_stats(struct net_device *netdev,
135+
struct ethtool_ts_stats *ts_stats)
136+
{
137+
struct fbnic_net *fbn = netdev_priv(netdev);
138+
u64 ts_packets, ts_lost;
139+
struct fbnic_ring *ring;
140+
unsigned int start;
141+
int i;
142+
143+
ts_stats->pkts = fbn->tx_stats.ts_packets;
144+
ts_stats->lost = fbn->tx_stats.ts_lost;
145+
for (i = 0; i < fbn->num_tx_queues; i++) {
146+
ring = fbn->tx[i];
147+
do {
148+
start = u64_stats_fetch_begin(&ring->stats.syncp);
149+
ts_packets = ring->stats.ts_packets;
150+
ts_lost = ring->stats.ts_lost;
151+
} while (u64_stats_fetch_retry(&ring->stats.syncp, start));
152+
ts_stats->pkts += ts_packets;
153+
ts_stats->lost += ts_lost;
122154
}
123155
}
124156

157+
static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter)
158+
{
159+
if (counter->reported)
160+
*stat = counter->value;
161+
}
162+
125163
static void
126164
fbnic_get_eth_mac_stats(struct net_device *netdev,
127165
struct ethtool_eth_mac_stats *eth_mac_stats)
@@ -164,44 +202,6 @@ fbnic_get_eth_mac_stats(struct net_device *netdev,
164202
&mac_stats->eth_mac.FrameTooLongErrors);
165203
}
166204

167-
static void fbnic_get_ts_stats(struct net_device *netdev,
168-
struct ethtool_ts_stats *ts_stats)
169-
{
170-
struct fbnic_net *fbn = netdev_priv(netdev);
171-
u64 ts_packets, ts_lost;
172-
struct fbnic_ring *ring;
173-
unsigned int start;
174-
int i;
175-
176-
ts_stats->pkts = fbn->tx_stats.ts_packets;
177-
ts_stats->lost = fbn->tx_stats.ts_lost;
178-
for (i = 0; i < fbn->num_tx_queues; i++) {
179-
ring = fbn->tx[i];
180-
do {
181-
start = u64_stats_fetch_begin(&ring->stats.syncp);
182-
ts_packets = ring->stats.ts_packets;
183-
ts_lost = ring->stats.ts_lost;
184-
} while (u64_stats_fetch_retry(&ring->stats.syncp, start));
185-
ts_stats->pkts += ts_packets;
186-
ts_stats->lost += ts_lost;
187-
}
188-
}
189-
190-
static void fbnic_get_regs(struct net_device *netdev,
191-
struct ethtool_regs *regs, void *data)
192-
{
193-
struct fbnic_net *fbn = netdev_priv(netdev);
194-
195-
fbnic_csr_get_regs(fbn->fbd, data, &regs->version);
196-
}
197-
198-
static int fbnic_get_regs_len(struct net_device *netdev)
199-
{
200-
struct fbnic_net *fbn = netdev_priv(netdev);
201-
202-
return fbnic_csr_regs_len(fbn->fbd) * sizeof(u32);
203-
}
204-
205205
static const struct ethtool_ops fbnic_ethtool_ops = {
206206
.get_drvinfo = fbnic_get_drvinfo,
207207
.get_regs_len = fbnic_get_regs_len,

0 commit comments

Comments
 (0)