Skip to content

Commit 04c85bf

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 100GbE Intel Wired LAN Driver Updates 2016-04-05 This series contains updates to fm10k only. Bruce provides nearly half of the patches in the series, most of which do general cleanup of the driver. These include semantic cleanups, checkpatch.pl fixes, update driver to use BIT() kernel macro, use BUILD_BUG_ON() where appropriate and use ether_addr_copy() instead of memcpy(). Jake provides the remaining patches in the series, starting with a fix for a possible NULL pointer deference. Next delays initialization of the service timer and service task until late in probe(). If we do not wait, failures in probe do not properly cleanup the service timer or service task items which result in a kernel panic. Added better reporting during error conditions. Fixed another possible kernel panic where we were clearing the interrupt scheme before we freed the mailbox IRQ. Added helper functions for setting strings and data for ethtool stats. Fixed comment mis-spelled words. v2: Dropped patch 3 from the original submission, until a better solution can be worked up based on feedback from Joe Perches and David Miller. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 265bee7 + 0ea7fae commit 04c85bf

File tree

10 files changed

+245
-213
lines changed

10 files changed

+245
-213
lines changed

drivers/net/ethernet/intel/fm10k/fm10k.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ struct fm10k_intfc {
262262
unsigned long state;
263263

264264
u32 flags;
265-
#define FM10K_FLAG_RESET_REQUESTED (u32)(1 << 0)
266-
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(1 << 1)
267-
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(1 << 2)
268-
#define FM10K_FLAG_RX_TS_ENABLED (u32)(1 << 3)
269-
#define FM10K_FLAG_SWPRI_CONFIG (u32)(1 << 4)
270-
#define FM10K_FLAG_DEBUG_STATS (u32)(1 << 5)
265+
#define FM10K_FLAG_RESET_REQUESTED (u32)(BIT(0))
266+
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(BIT(1))
267+
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(BIT(2))
268+
#define FM10K_FLAG_RX_TS_ENABLED (u32)(BIT(3))
269+
#define FM10K_FLAG_SWPRI_CONFIG (u32)(BIT(4))
270+
#define FM10K_FLAG_DEBUG_STATS (u32)(BIT(5))
271271
int xcast_mode;
272272

273273
/* Tx fast path data */
@@ -510,6 +510,8 @@ int fm10k_close(struct net_device *netdev);
510510

511511
/* Ethtool */
512512
void fm10k_set_ethtool_ops(struct net_device *dev);
513+
u32 fm10k_get_reta_size(struct net_device *netdev);
514+
void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir);
513515

514516
/* IOV */
515517
s32 fm10k_iov_event(struct fm10k_intfc *interface);

drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c

Lines changed: 115 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -153,57 +153,51 @@ static const char fm10k_prv_flags[FM10K_PRV_FLAG_LEN][ETH_GSTRING_LEN] = {
153153
"debug-statistics",
154154
};
155155

156+
static void fm10k_add_stat_strings(char **p, const char *prefix,
157+
const struct fm10k_stats stats[],
158+
const unsigned int size)
159+
{
160+
unsigned int i;
161+
162+
for (i = 0; i < size; i++) {
163+
snprintf(*p, ETH_GSTRING_LEN, "%s%s",
164+
prefix, stats[i].stat_string);
165+
*p += ETH_GSTRING_LEN;
166+
}
167+
}
168+
156169
static void fm10k_get_stat_strings(struct net_device *dev, u8 *data)
157170
{
158171
struct fm10k_intfc *interface = netdev_priv(dev);
159172
struct fm10k_iov_data *iov_data = interface->iov_data;
160173
char *p = (char *)data;
161174
unsigned int i;
162-
unsigned int j;
163175

164-
for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
165-
memcpy(p, fm10k_gstrings_net_stats[i].stat_string,
166-
ETH_GSTRING_LEN);
167-
p += ETH_GSTRING_LEN;
168-
}
176+
fm10k_add_stat_strings(&p, "", fm10k_gstrings_net_stats,
177+
FM10K_NETDEV_STATS_LEN);
169178

170-
for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
171-
memcpy(p, fm10k_gstrings_global_stats[i].stat_string,
172-
ETH_GSTRING_LEN);
173-
p += ETH_GSTRING_LEN;
174-
}
179+
fm10k_add_stat_strings(&p, "", fm10k_gstrings_global_stats,
180+
FM10K_GLOBAL_STATS_LEN);
175181

176-
if (interface->flags & FM10K_FLAG_DEBUG_STATS) {
177-
for (i = 0; i < FM10K_DEBUG_STATS_LEN; i++) {
178-
memcpy(p, fm10k_gstrings_debug_stats[i].stat_string,
179-
ETH_GSTRING_LEN);
180-
p += ETH_GSTRING_LEN;
181-
}
182-
}
182+
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
183+
fm10k_add_stat_strings(&p, "", fm10k_gstrings_debug_stats,
184+
FM10K_DEBUG_STATS_LEN);
183185

184-
for (i = 0; i < FM10K_MBX_STATS_LEN; i++) {
185-
memcpy(p, fm10k_gstrings_mbx_stats[i].stat_string,
186-
ETH_GSTRING_LEN);
187-
p += ETH_GSTRING_LEN;
188-
}
186+
fm10k_add_stat_strings(&p, "", fm10k_gstrings_mbx_stats,
187+
FM10K_MBX_STATS_LEN);
189188

190-
if (interface->hw.mac.type != fm10k_mac_vf) {
191-
for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
192-
memcpy(p, fm10k_gstrings_pf_stats[i].stat_string,
193-
ETH_GSTRING_LEN);
194-
p += ETH_GSTRING_LEN;
195-
}
196-
}
189+
if (interface->hw.mac.type != fm10k_mac_vf)
190+
fm10k_add_stat_strings(&p, "", fm10k_gstrings_pf_stats,
191+
FM10K_PF_STATS_LEN);
197192

198193
if ((interface->flags & FM10K_FLAG_DEBUG_STATS) && iov_data) {
199194
for (i = 0; i < iov_data->num_vfs; i++) {
200-
for (j = 0; j < FM10K_MBX_STATS_LEN; j++) {
201-
snprintf(p,
202-
ETH_GSTRING_LEN,
203-
"vf_%u_%s", i,
204-
fm10k_gstrings_mbx_stats[j].stat_string);
205-
p += ETH_GSTRING_LEN;
206-
}
195+
char prefix[ETH_GSTRING_LEN];
196+
197+
snprintf(prefix, ETH_GSTRING_LEN, "vf_%u_", i);
198+
fm10k_add_stat_strings(&p, prefix,
199+
fm10k_gstrings_mbx_stats,
200+
FM10K_MBX_STATS_LEN);
207201
}
208202
}
209203

@@ -271,6 +265,41 @@ static int fm10k_get_sset_count(struct net_device *dev, int sset)
271265
}
272266
}
273267

268+
static void fm10k_add_ethtool_stats(u64 **data, void *pointer,
269+
const struct fm10k_stats stats[],
270+
const unsigned int size)
271+
{
272+
unsigned int i;
273+
char *p;
274+
275+
/* simply skip forward if we were not given a valid pointer */
276+
if (!pointer) {
277+
*data += size;
278+
return;
279+
}
280+
281+
for (i = 0; i < size; i++) {
282+
p = (char *)pointer + stats[i].stat_offset;
283+
284+
switch (stats[i].sizeof_stat) {
285+
case sizeof(u64):
286+
*((*data)++) = *(u64 *)p;
287+
break;
288+
case sizeof(u32):
289+
*((*data)++) = *(u32 *)p;
290+
break;
291+
case sizeof(u16):
292+
*((*data)++) = *(u16 *)p;
293+
break;
294+
case sizeof(u8):
295+
*((*data)++) = *(u8 *)p;
296+
break;
297+
default:
298+
*((*data)++) = 0;
299+
}
300+
}
301+
}
302+
274303
static void fm10k_get_ethtool_stats(struct net_device *netdev,
275304
struct ethtool_stats __always_unused *stats,
276305
u64 *data)
@@ -279,47 +308,29 @@ static void fm10k_get_ethtool_stats(struct net_device *netdev,
279308
struct fm10k_intfc *interface = netdev_priv(netdev);
280309
struct fm10k_iov_data *iov_data = interface->iov_data;
281310
struct net_device_stats *net_stats = &netdev->stats;
282-
char *p;
283311
int i, j;
284312

285313
fm10k_update_stats(interface);
286314

287-
for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
288-
p = (char *)net_stats + fm10k_gstrings_net_stats[i].stat_offset;
289-
*(data++) = (fm10k_gstrings_net_stats[i].sizeof_stat ==
290-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
291-
}
315+
fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats,
316+
FM10K_NETDEV_STATS_LEN);
292317

293-
for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
294-
p = (char *)interface +
295-
fm10k_gstrings_global_stats[i].stat_offset;
296-
*(data++) = (fm10k_gstrings_global_stats[i].sizeof_stat ==
297-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
298-
}
318+
fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats,
319+
FM10K_GLOBAL_STATS_LEN);
299320

300-
if (interface->flags & FM10K_FLAG_DEBUG_STATS) {
301-
for (i = 0; i < FM10K_DEBUG_STATS_LEN; i++) {
302-
p = (char *)interface +
303-
fm10k_gstrings_debug_stats[i].stat_offset;
304-
*(data++) = (fm10k_gstrings_debug_stats[i].sizeof_stat ==
305-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
306-
}
307-
}
321+
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
322+
fm10k_add_ethtool_stats(&data, interface,
323+
fm10k_gstrings_debug_stats,
324+
FM10K_DEBUG_STATS_LEN);
308325

309-
for (i = 0; i < FM10K_MBX_STATS_LEN; i++) {
310-
p = (char *)&interface->hw.mbx +
311-
fm10k_gstrings_mbx_stats[i].stat_offset;
312-
*(data++) = (fm10k_gstrings_mbx_stats[i].sizeof_stat ==
313-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
314-
}
326+
fm10k_add_ethtool_stats(&data, &interface->hw.mbx,
327+
fm10k_gstrings_mbx_stats,
328+
FM10K_MBX_STATS_LEN);
315329

316330
if (interface->hw.mac.type != fm10k_mac_vf) {
317-
for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
318-
p = (char *)interface +
319-
fm10k_gstrings_pf_stats[i].stat_offset;
320-
*(data++) = (fm10k_gstrings_pf_stats[i].sizeof_stat ==
321-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
322-
}
331+
fm10k_add_ethtool_stats(&data, interface,
332+
fm10k_gstrings_pf_stats,
333+
FM10K_PF_STATS_LEN);
323334
}
324335

325336
if ((interface->flags & FM10K_FLAG_DEBUG_STATS) && iov_data) {
@@ -328,18 +339,9 @@ static void fm10k_get_ethtool_stats(struct net_device *netdev,
328339

329340
vf_info = &iov_data->vf_info[i];
330341

331-
/* skip stats if we don't have a vf info */
332-
if (!vf_info) {
333-
data += FM10K_MBX_STATS_LEN;
334-
continue;
335-
}
336-
337-
for (j = 0; j < FM10K_MBX_STATS_LEN; j++) {
338-
p = (char *)&vf_info->mbx +
339-
fm10k_gstrings_mbx_stats[j].stat_offset;
340-
*(data++) = (fm10k_gstrings_mbx_stats[j].sizeof_stat ==
341-
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
342-
}
342+
fm10k_add_ethtool_stats(&data, &vf_info->mbx,
343+
fm10k_gstrings_mbx_stats,
344+
FM10K_MBX_STATS_LEN);
343345
}
344346
}
345347

@@ -425,7 +427,7 @@ static void fm10k_get_regs(struct net_device *netdev,
425427
u32 *buff = p;
426428
u16 i;
427429

428-
regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
430+
regs->version = BIT(24) | (hw->revision_id << 16) | hw->device_id;
429431

430432
switch (hw->mac.type) {
431433
case fm10k_mac_pf:
@@ -935,15 +937,15 @@ static int fm10k_mbx_test(struct fm10k_intfc *interface, u64 *data)
935937
struct fm10k_mbx_info *mbx = &hw->mbx;
936938
u32 attr_flag, test_msg[6];
937939
unsigned long timeout;
938-
int err;
940+
int err = -EINVAL;
939941

940942
/* For now this is a VF only feature */
941943
if (hw->mac.type != fm10k_mac_vf)
942944
return 0;
943945

944946
/* loop through both nested and unnested attribute types */
945-
for (attr_flag = (1 << FM10K_TEST_MSG_UNSET);
946-
attr_flag < (1 << (2 * FM10K_TEST_MSG_NESTED));
947+
for (attr_flag = BIT(FM10K_TEST_MSG_UNSET);
948+
attr_flag < BIT(2 * FM10K_TEST_MSG_NESTED);
947949
attr_flag += attr_flag) {
948950
/* generate message to be tested */
949951
fm10k_tlv_msg_test_create(test_msg, attr_flag);
@@ -1005,7 +1007,7 @@ static u32 fm10k_get_priv_flags(struct net_device *netdev)
10051007
u32 priv_flags = 0;
10061008

10071009
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
1008-
priv_flags |= 1 << FM10K_PRV_FLAG_DEBUG_STATS;
1010+
priv_flags |= BIT(FM10K_PRV_FLAG_DEBUG_STATS);
10091011

10101012
return priv_flags;
10111013
}
@@ -1014,22 +1016,42 @@ static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)
10141016
{
10151017
struct fm10k_intfc *interface = netdev_priv(netdev);
10161018

1017-
if (priv_flags >= (1 << FM10K_PRV_FLAG_LEN))
1019+
if (priv_flags >= BIT(FM10K_PRV_FLAG_LEN))
10181020
return -EINVAL;
10191021

1020-
if (priv_flags & (1 << FM10K_PRV_FLAG_DEBUG_STATS))
1022+
if (priv_flags & BIT(FM10K_PRV_FLAG_DEBUG_STATS))
10211023
interface->flags |= FM10K_FLAG_DEBUG_STATS;
10221024
else
10231025
interface->flags &= ~FM10K_FLAG_DEBUG_STATS;
10241026

10251027
return 0;
10261028
}
10271029

1028-
static u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
1030+
u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
10291031
{
10301032
return FM10K_RETA_SIZE * FM10K_RETA_ENTRIES_PER_REG;
10311033
}
10321034

1035+
void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir)
1036+
{
1037+
struct fm10k_hw *hw = &interface->hw;
1038+
int i;
1039+
1040+
/* record entries to reta table */
1041+
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
1042+
u32 reta = indir[0] |
1043+
(indir[1] << 8) |
1044+
(indir[2] << 16) |
1045+
(indir[3] << 24);
1046+
1047+
if (interface->reta[i] == reta)
1048+
continue;
1049+
1050+
interface->reta[i] = reta;
1051+
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
1052+
}
1053+
}
1054+
10331055
static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
10341056
{
10351057
struct fm10k_intfc *interface = netdev_priv(netdev);
@@ -1053,7 +1075,6 @@ static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
10531075
static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
10541076
{
10551077
struct fm10k_intfc *interface = netdev_priv(netdev);
1056-
struct fm10k_hw *hw = &interface->hw;
10571078
int i;
10581079
u16 rss_i;
10591080

@@ -1068,19 +1089,7 @@ static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
10681089
return -EINVAL;
10691090
}
10701091

1071-
/* record entries to reta table */
1072-
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
1073-
u32 reta = indir[0] |
1074-
(indir[1] << 8) |
1075-
(indir[2] << 16) |
1076-
(indir[3] << 24);
1077-
1078-
if (interface->reta[i] == reta)
1079-
continue;
1080-
1081-
interface->reta[i] = reta;
1082-
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
1083-
}
1092+
fm10k_write_reta(interface, indir);
10841093

10851094
return 0;
10861095
}
@@ -1145,7 +1154,7 @@ static unsigned int fm10k_max_channels(struct net_device *dev)
11451154

11461155
/* For QoS report channels per traffic class */
11471156
if (tcs > 1)
1148-
max_combined = 1 << (fls(max_combined / tcs) - 1);
1157+
max_combined = BIT((fls(max_combined / tcs) - 1));
11491158

11501159
return max_combined;
11511160
}
@@ -1210,11 +1219,9 @@ static int fm10k_get_ts_info(struct net_device *dev,
12101219
else
12111220
info->phc_index = -1;
12121221

1213-
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
1214-
(1 << HWTSTAMP_TX_ON);
1222+
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
12151223

1216-
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
1217-
(1 << HWTSTAMP_FILTER_ALL);
1224+
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
12181225

12191226
return 0;
12201227
}

drivers/net/ethernet/intel/fm10k/fm10k_iov.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ s32 fm10k_iov_event(struct fm10k_intfc *interface)
5050
s64 vflre;
5151
int i;
5252

53-
/* if there is no iov_data then there is no mailboxes to process */
53+
/* if there is no iov_data then there is no mailbox to process */
5454
if (!ACCESS_ONCE(interface->iov_data))
5555
return 0;
5656

@@ -98,7 +98,7 @@ s32 fm10k_iov_mbx(struct fm10k_intfc *interface)
9898
struct fm10k_iov_data *iov_data;
9999
int i;
100100

101-
/* if there is no iov_data then there is no mailboxes to process */
101+
/* if there is no iov_data then there is no mailbox to process */
102102
if (!ACCESS_ONCE(interface->iov_data))
103103
return 0;
104104

0 commit comments

Comments
 (0)