Skip to content

Commit b404127

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 2017-04-05 This series contains updates to fm10k only. Phil Turnbull from Oracle fixes an issue where the argument provided to FM10K_REMOVED macro was not what was expecting. Jake modifies the driver to replace the bitwise operators and defines with a BITMAP and enumeration values to avoid race conditions. Also future proof the driver so that developers do not have to remember to re-size the bitmaps when adding new values. Fixed the wording of a code comment to avoid stating that we return a value for a void function. Ngai-Mint makes sure that when configuring the receive ring, we make sure the receive queue is disabled. Fixed an issue where interfaces were resetting because the transmit mailbox FIFO was becoming full since the host was not ready, so ensure the host is ready before queueing up mailbox messages. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 6d2d34a + 7d4fe0d commit b404127

File tree

5 files changed

+239
-133
lines changed

5 files changed

+239
-133
lines changed

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

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Intel(R) Ethernet Switch Host Interface Driver
2-
* Copyright(c) 2013 - 2016 Intel Corporation.
2+
* Copyright(c) 2013 - 2017 Intel Corporation.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms and conditions of the GNU General Public License,
@@ -65,14 +65,16 @@ enum fm10k_ring_state_t {
6565
__FM10K_TX_DETECT_HANG,
6666
__FM10K_HANG_CHECK_ARMED,
6767
__FM10K_TX_XPS_INIT_DONE,
68+
/* This must be last and is used to calculate BITMAP size */
69+
__FM10K_TX_STATE_SIZE__,
6870
};
6971

7072
#define check_for_tx_hang(ring) \
71-
test_bit(__FM10K_TX_DETECT_HANG, &(ring)->state)
73+
test_bit(__FM10K_TX_DETECT_HANG, (ring)->state)
7274
#define set_check_for_tx_hang(ring) \
73-
set_bit(__FM10K_TX_DETECT_HANG, &(ring)->state)
75+
set_bit(__FM10K_TX_DETECT_HANG, (ring)->state)
7476
#define clear_check_for_tx_hang(ring) \
75-
clear_bit(__FM10K_TX_DETECT_HANG, &(ring)->state)
77+
clear_bit(__FM10K_TX_DETECT_HANG, (ring)->state)
7678

7779
struct fm10k_tx_buffer {
7880
struct fm10k_tx_desc *next_to_watch;
@@ -126,7 +128,7 @@ struct fm10k_ring {
126128
struct fm10k_rx_buffer *rx_buffer;
127129
};
128130
u32 __iomem *tail;
129-
unsigned long state;
131+
DECLARE_BITMAP(state, __FM10K_TX_STATE_SIZE__);
130132
dma_addr_t dma; /* phys. address of descriptor ring */
131133
unsigned int size; /* length in bytes */
132134

@@ -249,18 +251,46 @@ struct fm10k_udp_port {
249251
/* one work queue for entire driver */
250252
extern struct workqueue_struct *fm10k_workqueue;
251253

254+
/* The following enumeration contains flags which indicate or enable modified
255+
* driver behaviors. To avoid race conditions, the flags are stored in
256+
* a BITMAP in the fm10k_intfc structure. The BITMAP should be accessed using
257+
* atomic *_bit() operations.
258+
*/
259+
enum fm10k_flags_t {
260+
FM10K_FLAG_RESET_REQUESTED,
261+
FM10K_FLAG_RSS_FIELD_IPV4_UDP,
262+
FM10K_FLAG_RSS_FIELD_IPV6_UDP,
263+
FM10K_FLAG_SWPRI_CONFIG,
264+
/* __FM10K_FLAGS_SIZE__ is used to calculate the size of
265+
* interface->flags and must be the last value in this
266+
* enumeration.
267+
*/
268+
__FM10K_FLAGS_SIZE__
269+
};
270+
271+
enum fm10k_state_t {
272+
__FM10K_RESETTING,
273+
__FM10K_DOWN,
274+
__FM10K_SERVICE_SCHED,
275+
__FM10K_SERVICE_REQUEST,
276+
__FM10K_SERVICE_DISABLE,
277+
__FM10K_MBX_LOCK,
278+
__FM10K_LINK_DOWN,
279+
__FM10K_UPDATING_STATS,
280+
/* This value must be last and determines the BITMAP size */
281+
__FM10K_STATE_SIZE__,
282+
};
283+
252284
struct fm10k_intfc {
253285
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
254286
struct net_device *netdev;
255287
struct fm10k_l2_accel *l2_accel; /* pointer to L2 acceleration list */
256288
struct pci_dev *pdev;
257-
unsigned long state;
289+
DECLARE_BITMAP(state, __FM10K_STATE_SIZE__);
290+
291+
/* Access flag values using atomic *_bit() operations */
292+
DECLARE_BITMAP(flags, __FM10K_FLAGS_SIZE__);
258293

259-
u32 flags;
260-
#define FM10K_FLAG_RESET_REQUESTED (u32)(BIT(0))
261-
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(BIT(1))
262-
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(BIT(2))
263-
#define FM10K_FLAG_SWPRI_CONFIG (u32)(BIT(3))
264294
int xcast_mode;
265295

266296
/* Tx fast path data */
@@ -352,35 +382,25 @@ struct fm10k_intfc {
352382
u16 vid;
353383
};
354384

355-
enum fm10k_state_t {
356-
__FM10K_RESETTING,
357-
__FM10K_DOWN,
358-
__FM10K_SERVICE_SCHED,
359-
__FM10K_SERVICE_DISABLE,
360-
__FM10K_MBX_LOCK,
361-
__FM10K_LINK_DOWN,
362-
__FM10K_UPDATING_STATS,
363-
};
364-
365385
static inline void fm10k_mbx_lock(struct fm10k_intfc *interface)
366386
{
367387
/* busy loop if we cannot obtain the lock as some calls
368388
* such as ndo_set_rx_mode may be made in atomic context
369389
*/
370-
while (test_and_set_bit(__FM10K_MBX_LOCK, &interface->state))
390+
while (test_and_set_bit(__FM10K_MBX_LOCK, interface->state))
371391
udelay(20);
372392
}
373393

374394
static inline void fm10k_mbx_unlock(struct fm10k_intfc *interface)
375395
{
376396
/* flush memory to make sure state is correct */
377397
smp_mb__before_atomic();
378-
clear_bit(__FM10K_MBX_LOCK, &interface->state);
398+
clear_bit(__FM10K_MBX_LOCK, interface->state);
379399
}
380400

381401
static inline int fm10k_mbx_trylock(struct fm10k_intfc *interface)
382402
{
383-
return !test_and_set_bit(__FM10K_MBX_LOCK, &interface->state);
403+
return !test_and_set_bit(__FM10K_MBX_LOCK, interface->state);
384404
}
385405

386406
/* fm10k_test_staterr - test bits in Rx descriptor status and error fields */

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

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Intel(R) Ethernet Switch Host Interface Driver
2-
* Copyright(c) 2013 - 2016 Intel Corporation.
2+
* Copyright(c) 2013 - 2017 Intel Corporation.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms and conditions of the GNU General Public License,
@@ -562,7 +562,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
562562
return 0;
563563
}
564564

565-
while (test_and_set_bit(__FM10K_RESETTING, &interface->state))
565+
while (test_and_set_bit(__FM10K_RESETTING, interface->state))
566566
usleep_range(1000, 2000);
567567

568568
if (!netif_running(interface->netdev)) {
@@ -648,7 +648,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
648648
fm10k_up(interface);
649649
vfree(temp_ring);
650650
clear_reset:
651-
clear_bit(__FM10K_RESETTING, &interface->state);
651+
clear_bit(__FM10K_RESETTING, interface->state);
652652
return err;
653653
}
654654

@@ -716,7 +716,8 @@ static int fm10k_get_rss_hash_opts(struct fm10k_intfc *interface,
716716
cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
717717
/* fall through */
718718
case UDP_V4_FLOW:
719-
if (interface->flags & FM10K_FLAG_RSS_FIELD_IPV4_UDP)
719+
if (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
720+
interface->flags))
720721
cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
721722
/* fall through */
722723
case SCTP_V4_FLOW:
@@ -732,7 +733,8 @@ static int fm10k_get_rss_hash_opts(struct fm10k_intfc *interface,
732733
cmd->data |= RXH_IP_SRC | RXH_IP_DST;
733734
break;
734735
case UDP_V6_FLOW:
735-
if (interface->flags & FM10K_FLAG_RSS_FIELD_IPV6_UDP)
736+
if (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
737+
interface->flags))
736738
cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
737739
cmd->data |= RXH_IP_SRC | RXH_IP_DST;
738740
break;
@@ -764,12 +766,13 @@ static int fm10k_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
764766
return ret;
765767
}
766768

767-
#define UDP_RSS_FLAGS (FM10K_FLAG_RSS_FIELD_IPV4_UDP | \
768-
FM10K_FLAG_RSS_FIELD_IPV6_UDP)
769769
static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,
770770
struct ethtool_rxnfc *nfc)
771771
{
772-
u32 flags = interface->flags;
772+
int rss_ipv4_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
773+
interface->flags);
774+
int rss_ipv6_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
775+
interface->flags);
773776

774777
/* RSS does not support anything other than hashing
775778
* to queues on src and dst IPs and ports
@@ -793,10 +796,12 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,
793796
return -EINVAL;
794797
switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
795798
case 0:
796-
flags &= ~FM10K_FLAG_RSS_FIELD_IPV4_UDP;
799+
clear_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
800+
interface->flags);
797801
break;
798802
case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
799-
flags |= FM10K_FLAG_RSS_FIELD_IPV4_UDP;
803+
set_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
804+
interface->flags);
800805
break;
801806
default:
802807
return -EINVAL;
@@ -808,10 +813,12 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,
808813
return -EINVAL;
809814
switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
810815
case 0:
811-
flags &= ~FM10K_FLAG_RSS_FIELD_IPV6_UDP;
816+
clear_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
817+
interface->flags);
812818
break;
813819
case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
814-
flags |= FM10K_FLAG_RSS_FIELD_IPV6_UDP;
820+
set_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
821+
interface->flags);
815822
break;
816823
default:
817824
return -EINVAL;
@@ -835,28 +842,41 @@ static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,
835842
return -EINVAL;
836843
}
837844

838-
/* if we changed something we need to update flags */
839-
if (flags != interface->flags) {
845+
/* If something changed we need to update the MRQC register. Note that
846+
* test_bit() is guaranteed to return strictly 0 or 1, so testing for
847+
* equality is safe.
848+
*/
849+
if ((rss_ipv4_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
850+
interface->flags)) ||
851+
(rss_ipv6_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
852+
interface->flags))) {
840853
struct fm10k_hw *hw = &interface->hw;
854+
bool warn = false;
841855
u32 mrqc;
842856

843-
if ((flags & UDP_RSS_FLAGS) &&
844-
!(interface->flags & UDP_RSS_FLAGS))
845-
netif_warn(interface, drv, interface->netdev,
846-
"enabling UDP RSS: fragmented packets may arrive out of order to the stack above\n");
847-
848-
interface->flags = flags;
849-
850857
/* Perform hash on these packet types */
851858
mrqc = FM10K_MRQC_IPV4 |
852859
FM10K_MRQC_TCP_IPV4 |
853860
FM10K_MRQC_IPV6 |
854861
FM10K_MRQC_TCP_IPV6;
855862

856-
if (flags & FM10K_FLAG_RSS_FIELD_IPV4_UDP)
863+
if (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
864+
interface->flags)) {
857865
mrqc |= FM10K_MRQC_UDP_IPV4;
858-
if (flags & FM10K_FLAG_RSS_FIELD_IPV6_UDP)
866+
warn = true;
867+
}
868+
if (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
869+
interface->flags)) {
859870
mrqc |= FM10K_MRQC_UDP_IPV6;
871+
warn = true;
872+
}
873+
874+
/* If we enable UDP RSS display a warning that this may cause
875+
* fragmented UDP packets to arrive out of order.
876+
*/
877+
if (warn)
878+
netif_warn(interface, drv, interface->netdev,
879+
"enabling UDP RSS: fragmented packets may arrive out of order to the stack above\n");
860880

861881
fm10k_write_reg(hw, FM10K_MRQC(0), mrqc);
862882
}
@@ -939,7 +959,7 @@ static void fm10k_self_test(struct net_device *dev,
939959

940960
memset(data, 0, sizeof(*data) * FM10K_TEST_LEN);
941961

942-
if (FM10K_REMOVED(hw)) {
962+
if (FM10K_REMOVED(hw->hw_addr)) {
943963
netif_err(interface, drv, dev,
944964
"Interface removed - test blocked\n");
945965
eth_test->flags |= ETH_TEST_FL_FAILED;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Intel(R) Ethernet Switch Host Interface Driver
2-
* Copyright(c) 2013 - 2016 Intel Corporation.
2+
* Copyright(c) 2013 - 2017 Intel Corporation.
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms and conditions of the GNU General Public License,
@@ -34,7 +34,7 @@ const char fm10k_driver_version[] = DRV_VERSION;
3434
char fm10k_driver_name[] = "fm10k";
3535
static const char fm10k_driver_string[] = DRV_SUMMARY;
3636
static const char fm10k_copyright[] =
37-
"Copyright (c) 2013 - 2016 Intel Corporation.";
37+
"Copyright(c) 2013 - 2017 Intel Corporation.";
3838

3939
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
4040
MODULE_DESCRIPTION(DRV_SUMMARY);
@@ -1175,13 +1175,13 @@ bool fm10k_check_tx_hang(struct fm10k_ring *tx_ring)
11751175
/* update completed stats and continue */
11761176
tx_ring->tx_stats.tx_done_old = tx_done;
11771177
/* reset the countdown */
1178-
clear_bit(__FM10K_HANG_CHECK_ARMED, &tx_ring->state);
1178+
clear_bit(__FM10K_HANG_CHECK_ARMED, tx_ring->state);
11791179

11801180
return false;
11811181
}
11821182

11831183
/* make sure it is true for two checks in a row */
1184-
return test_and_set_bit(__FM10K_HANG_CHECK_ARMED, &tx_ring->state);
1184+
return test_and_set_bit(__FM10K_HANG_CHECK_ARMED, tx_ring->state);
11851185
}
11861186

11871187
/**
@@ -1191,9 +1191,9 @@ bool fm10k_check_tx_hang(struct fm10k_ring *tx_ring)
11911191
void fm10k_tx_timeout_reset(struct fm10k_intfc *interface)
11921192
{
11931193
/* Do the reset outside of interrupt context */
1194-
if (!test_bit(__FM10K_DOWN, &interface->state)) {
1194+
if (!test_bit(__FM10K_DOWN, interface->state)) {
11951195
interface->tx_timeout_count++;
1196-
interface->flags |= FM10K_FLAG_RESET_REQUESTED;
1196+
set_bit(FM10K_FLAG_RESET_REQUESTED, interface->flags);
11971197
fm10k_service_event_schedule(interface);
11981198
}
11991199
}
@@ -1214,7 +1214,7 @@ static bool fm10k_clean_tx_irq(struct fm10k_q_vector *q_vector,
12141214
unsigned int budget = q_vector->tx.work_limit;
12151215
unsigned int i = tx_ring->next_to_clean;
12161216

1217-
if (test_bit(__FM10K_DOWN, &interface->state))
1217+
if (test_bit(__FM10K_DOWN, interface->state))
12181218
return true;
12191219

12201220
tx_buffer = &tx_ring->tx_buffer[i];
@@ -1344,7 +1344,7 @@ static bool fm10k_clean_tx_irq(struct fm10k_q_vector *q_vector,
13441344
smp_mb();
13451345
if (__netif_subqueue_stopped(tx_ring->netdev,
13461346
tx_ring->queue_index) &&
1347-
!test_bit(__FM10K_DOWN, &interface->state)) {
1347+
!test_bit(__FM10K_DOWN, interface->state)) {
13481348
netif_wake_subqueue(tx_ring->netdev,
13491349
tx_ring->queue_index);
13501350
++tx_ring->tx_stats.restart_queue;

0 commit comments

Comments
 (0)