Skip to content

Commit 435c556

Browse files
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates 2016-06-29 This series contains updates and fixes to e1000e, igb, ixgbe and fm10k. A true smorgasbord of changes. Jake cleans up some obscurity by not using the BIT() macro on bitshift operation and also fixed the calculated index when looping through the indir array. Fixes the issue with igb's workqueue item for overflow check from causing a surprise remove event. The ptp_flags variable is added to simplify the work of writing several complex MAC type checks in the PTP code while fixing the workqueue. Alex Duyck fixes the receive buffers alignment which should not be L1 cache aligned, but to 512 bytes instead. Denys Vlasenko prevents a division by zero which was reported under VMWare for e1000e. Amritha fixes an issue where filters in a child hash table must be cleared from the hardware before delete the filter links in ixgbe. Bhaktipriya Shridhar simply replaces the deprecated create_workqueue() with alloc_workqueue() for fm10k. Tony corrects ixgbe ethtool reporting to show x550 supports hardware timestamping of all packets. Emil fixes an issue where MAC-VLANs on the VF fail to pass traffic due to spoofed packets. Andrew Lunn increases performance on some systems where syncing a buffer for DMA is expensive. So rather than sync the whole 2K receive buffer, only synchronize the length of the frame. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents c435e6e + 64f2525 commit 435c556

File tree

11 files changed

+148
-67
lines changed

11 files changed

+148
-67
lines changed

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4363,7 +4363,8 @@ static cycle_t e1000e_cyclecounter_read(const struct cyclecounter *cc)
43634363

43644364
time_delta = systim_next - systim;
43654365
temp = time_delta;
4366-
rem = do_div(temp, incvalue);
4366+
/* VMWare users have seen incvalue of zero, don't div / 0 */
4367+
rem = incvalue ? do_div(temp, incvalue) : (time_delta != 0);
43674368

43684369
systim = systim_next;
43694370

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static inline u16 fm10k_desc_unused(struct fm10k_ring *ring)
406406
(&(((union fm10k_rx_desc *)((R)->desc))[i]))
407407

408408
#define FM10K_MAX_TXD_PWR 14
409-
#define FM10K_MAX_DATA_PER_TXD BIT(FM10K_MAX_TXD_PWR)
409+
#define FM10K_MAX_DATA_PER_TXD (1u << FM10K_MAX_TXD_PWR)
410410

411411
/* Tx Descriptors needed, worst case */
412412
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), FM10K_MAX_DATA_PER_TXD)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,10 @@ void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir)
983983
/* generate a new table if we weren't given one */
984984
for (j = 0; j < 4; j++) {
985985
if (indir)
986-
n = indir[i + j];
986+
n = indir[4 * i + j];
987987
else
988-
n = ethtool_rxfh_indir_default(i + j, rss_i);
988+
n = ethtool_rxfh_indir_default(4 * i + j,
989+
rss_i);
989990

990991
table[j] = n;
991992
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int __init fm10k_init_module(void)
5656
pr_info("%s\n", fm10k_copyright);
5757

5858
/* create driver workqueue */
59-
fm10k_workqueue = create_workqueue("fm10k");
59+
fm10k_workqueue = alloc_workqueue("fm10k", WQ_MEM_RECLAIM, 0);
6060

6161
fm10k_dbg_init();
6262

@@ -77,7 +77,6 @@ static void __exit fm10k_exit_module(void)
7777
fm10k_dbg_exit();
7878

7979
/* destroy driver workqueue */
80-
flush_workqueue(fm10k_workqueue);
8180
destroy_workqueue(fm10k_workqueue);
8281
}
8382
module_exit(fm10k_exit_module);
@@ -272,7 +271,7 @@ static bool fm10k_add_rx_frag(struct fm10k_rx_buffer *rx_buffer,
272271
#if (PAGE_SIZE < 8192)
273272
unsigned int truesize = FM10K_RX_BUFSZ;
274273
#else
275-
unsigned int truesize = SKB_DATA_ALIGN(size);
274+
unsigned int truesize = ALIGN(size, 512);
276275
#endif
277276
unsigned int pull_len;
278277

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ struct igb_adapter {
445445
unsigned long ptp_tx_start;
446446
unsigned long last_rx_ptp_check;
447447
unsigned long last_rx_timestamp;
448+
unsigned int ptp_flags;
448449
spinlock_t tmreg_lock;
449450
struct cyclecounter cc;
450451
struct timecounter tc;
@@ -474,12 +475,15 @@ struct igb_adapter {
474475
u16 eee_advert;
475476
};
476477

478+
/* flags controlling PTP/1588 function */
479+
#define IGB_PTP_ENABLED BIT(0)
480+
#define IGB_PTP_OVERFLOW_CHECK BIT(1)
481+
477482
#define IGB_FLAG_HAS_MSI BIT(0)
478483
#define IGB_FLAG_DCA_ENABLED BIT(1)
479484
#define IGB_FLAG_QUAD_PORT_A BIT(2)
480485
#define IGB_FLAG_QUEUE_PAIRS BIT(3)
481486
#define IGB_FLAG_DMAC BIT(4)
482-
#define IGB_FLAG_PTP BIT(5)
483487
#define IGB_FLAG_RSS_FIELD_IPV4_UDP BIT(6)
484488
#define IGB_FLAG_RSS_FIELD_IPV6_UDP BIT(7)
485489
#define IGB_FLAG_WOL_SUPPORTED BIT(8)
@@ -546,6 +550,7 @@ void igb_set_fw_version(struct igb_adapter *);
546550
void igb_ptp_init(struct igb_adapter *adapter);
547551
void igb_ptp_stop(struct igb_adapter *adapter);
548552
void igb_ptp_reset(struct igb_adapter *adapter);
553+
void igb_ptp_suspend(struct igb_adapter *adapter);
549554
void igb_ptp_rx_hang(struct igb_adapter *adapter);
550555
void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
551556
void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, unsigned char *va,

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,8 @@ void igb_reset(struct igb_adapter *adapter)
20272027
wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
20282028

20292029
/* Re-enable PTP, where applicable. */
2030-
igb_ptp_reset(adapter);
2030+
if (adapter->ptp_flags & IGB_PTP_ENABLED)
2031+
igb_ptp_reset(adapter);
20312032

20322033
igb_get_phy_info(hw);
20332034
}
@@ -6855,12 +6856,12 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer,
68556856
**/
68566857
static bool igb_add_rx_frag(struct igb_ring *rx_ring,
68576858
struct igb_rx_buffer *rx_buffer,
6859+
unsigned int size,
68586860
union e1000_adv_rx_desc *rx_desc,
68596861
struct sk_buff *skb)
68606862
{
68616863
struct page *page = rx_buffer->page;
68626864
unsigned char *va = page_address(page) + rx_buffer->page_offset;
6863-
unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
68646865
#if (PAGE_SIZE < 8192)
68656866
unsigned int truesize = IGB_RX_BUFSZ;
68666867
#else
@@ -6912,6 +6913,7 @@ static struct sk_buff *igb_fetch_rx_buffer(struct igb_ring *rx_ring,
69126913
union e1000_adv_rx_desc *rx_desc,
69136914
struct sk_buff *skb)
69146915
{
6916+
unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);
69156917
struct igb_rx_buffer *rx_buffer;
69166918
struct page *page;
69176919

@@ -6947,11 +6949,11 @@ static struct sk_buff *igb_fetch_rx_buffer(struct igb_ring *rx_ring,
69476949
dma_sync_single_range_for_cpu(rx_ring->dev,
69486950
rx_buffer->dma,
69496951
rx_buffer->page_offset,
6950-
IGB_RX_BUFSZ,
6952+
size,
69516953
DMA_FROM_DEVICE);
69526954

69536955
/* pull page into skb */
6954-
if (igb_add_rx_frag(rx_ring, rx_buffer, rx_desc, skb)) {
6956+
if (igb_add_rx_frag(rx_ring, rx_buffer, size, rx_desc, skb)) {
69556957
/* hand second half of page back to the ring */
69566958
igb_reuse_rx_page(rx_ring, rx_buffer);
69576959
} else {
@@ -7527,6 +7529,8 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
75277529
if (netif_running(netdev))
75287530
__igb_close(netdev, true);
75297531

7532+
igb_ptp_suspend(adapter);
7533+
75307534
igb_clear_interrupt_scheme(adapter);
75317535

75327536
#ifdef CONFIG_PM

drivers/net/ethernet/intel/igb/igb_ptp.c

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter)
684684
u32 tsyncrxctl = rd32(E1000_TSYNCRXCTL);
685685
unsigned long rx_event;
686686

687+
/* Other hardware uses per-packet timestamps */
687688
if (hw->mac.type != e1000_82576)
688689
return;
689690

@@ -1042,6 +1043,13 @@ int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
10421043
-EFAULT : 0;
10431044
}
10441045

1046+
/**
1047+
* igb_ptp_init - Initialize PTP functionality
1048+
* @adapter: Board private structure
1049+
*
1050+
* This function is called at device probe to initialize the PTP
1051+
* functionality.
1052+
*/
10451053
void igb_ptp_init(struct igb_adapter *adapter)
10461054
{
10471055
struct e1000_hw *hw = &adapter->hw;
@@ -1064,8 +1072,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
10641072
adapter->cc.mask = CYCLECOUNTER_MASK(64);
10651073
adapter->cc.mult = 1;
10661074
adapter->cc.shift = IGB_82576_TSYNC_SHIFT;
1067-
/* Dial the nominal frequency. */
1068-
wr32(E1000_TIMINCA, INCPERIOD_82576 | INCVALUE_82576);
1075+
adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK;
10691076
break;
10701077
case e1000_82580:
10711078
case e1000_i354:
@@ -1084,8 +1091,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
10841091
adapter->cc.mask = CYCLECOUNTER_MASK(IGB_NBITS_82580);
10851092
adapter->cc.mult = 1;
10861093
adapter->cc.shift = 0;
1087-
/* Enable the timer functions by clearing bit 31. */
1088-
wr32(E1000_TSAUXC, 0x0);
1094+
adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK;
10891095
break;
10901096
case e1000_i210:
10911097
case e1000_i211:
@@ -1110,44 +1116,24 @@ void igb_ptp_init(struct igb_adapter *adapter)
11101116
adapter->ptp_caps.settime64 = igb_ptp_settime_i210;
11111117
adapter->ptp_caps.enable = igb_ptp_feature_enable_i210;
11121118
adapter->ptp_caps.verify = igb_ptp_verify_pin;
1113-
/* Enable the timer functions by clearing bit 31. */
1114-
wr32(E1000_TSAUXC, 0x0);
11151119
break;
11161120
default:
11171121
adapter->ptp_clock = NULL;
11181122
return;
11191123
}
11201124

1121-
wrfl();
1122-
11231125
spin_lock_init(&adapter->tmreg_lock);
11241126
INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
11251127

1126-
/* Initialize the clock and overflow work for devices that need it. */
1127-
if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) {
1128-
struct timespec64 ts = ktime_to_timespec64(ktime_get_real());
1129-
1130-
igb_ptp_settime_i210(&adapter->ptp_caps, &ts);
1131-
} else {
1132-
timecounter_init(&adapter->tc, &adapter->cc,
1133-
ktime_to_ns(ktime_get_real()));
1134-
1128+
if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
11351129
INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
11361130
igb_ptp_overflow_check);
11371131

1138-
schedule_delayed_work(&adapter->ptp_overflow_work,
1139-
IGB_SYSTIM_OVERFLOW_PERIOD);
1140-
}
1141-
1142-
/* Initialize the time sync interrupts for devices that support it. */
1143-
if (hw->mac.type >= e1000_82580) {
1144-
wr32(E1000_TSIM, TSYNC_INTERRUPTS);
1145-
wr32(E1000_IMS, E1000_IMS_TS);
1146-
}
1147-
11481132
adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
11491133
adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
11501134

1135+
igb_ptp_reset(adapter);
1136+
11511137
adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
11521138
&adapter->pdev->dev);
11531139
if (IS_ERR(adapter->ptp_clock)) {
@@ -1156,45 +1142,48 @@ void igb_ptp_init(struct igb_adapter *adapter)
11561142
} else {
11571143
dev_info(&adapter->pdev->dev, "added PHC on %s\n",
11581144
adapter->netdev->name);
1159-
adapter->flags |= IGB_FLAG_PTP;
1145+
adapter->ptp_flags |= IGB_PTP_ENABLED;
11601146
}
11611147
}
11621148

11631149
/**
1164-
* igb_ptp_stop - Disable PTP device and stop the overflow check.
1165-
* @adapter: Board private structure.
1150+
* igb_ptp_suspend - Disable PTP work items and prepare for suspend
1151+
* @adapter: Board private structure
11661152
*
1167-
* This function stops the PTP support and cancels the delayed work.
1168-
**/
1169-
void igb_ptp_stop(struct igb_adapter *adapter)
1153+
* This function stops the overflow check work and PTP Tx timestamp work, and
1154+
* will prepare the device for OS suspend.
1155+
*/
1156+
void igb_ptp_suspend(struct igb_adapter *adapter)
11701157
{
1171-
switch (adapter->hw.mac.type) {
1172-
case e1000_82576:
1173-
case e1000_82580:
1174-
case e1000_i354:
1175-
case e1000_i350:
1176-
cancel_delayed_work_sync(&adapter->ptp_overflow_work);
1177-
break;
1178-
case e1000_i210:
1179-
case e1000_i211:
1180-
/* No delayed work to cancel. */
1181-
break;
1182-
default:
1158+
if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
11831159
return;
1184-
}
1160+
1161+
if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
1162+
cancel_delayed_work_sync(&adapter->ptp_overflow_work);
11851163

11861164
cancel_work_sync(&adapter->ptp_tx_work);
11871165
if (adapter->ptp_tx_skb) {
11881166
dev_kfree_skb_any(adapter->ptp_tx_skb);
11891167
adapter->ptp_tx_skb = NULL;
11901168
clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state);
11911169
}
1170+
}
1171+
1172+
/**
1173+
* igb_ptp_stop - Disable PTP device and stop the overflow check.
1174+
* @adapter: Board private structure.
1175+
*
1176+
* This function stops the PTP support and cancels the delayed work.
1177+
**/
1178+
void igb_ptp_stop(struct igb_adapter *adapter)
1179+
{
1180+
igb_ptp_suspend(adapter);
11921181

11931182
if (adapter->ptp_clock) {
11941183
ptp_clock_unregister(adapter->ptp_clock);
11951184
dev_info(&adapter->pdev->dev, "removed PHC on %s\n",
11961185
adapter->netdev->name);
1197-
adapter->flags &= ~IGB_FLAG_PTP;
1186+
adapter->ptp_flags &= ~IGB_PTP_ENABLED;
11981187
}
11991188
}
12001189

@@ -1209,9 +1198,6 @@ void igb_ptp_reset(struct igb_adapter *adapter)
12091198
struct e1000_hw *hw = &adapter->hw;
12101199
unsigned long flags;
12111200

1212-
if (!(adapter->flags & IGB_FLAG_PTP))
1213-
return;
1214-
12151201
/* reset the tstamp_config */
12161202
igb_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config);
12171203

@@ -1248,4 +1234,10 @@ void igb_ptp_reset(struct igb_adapter *adapter)
12481234
}
12491235
out:
12501236
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
1237+
1238+
wrfl();
1239+
1240+
if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
1241+
schedule_delayed_work(&adapter->ptp_overflow_work,
1242+
IGB_SYSTIM_OVERFLOW_PERIOD);
12511243
}

drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,10 +2991,15 @@ static int ixgbe_get_ts_info(struct net_device *dev,
29912991
{
29922992
struct ixgbe_adapter *adapter = netdev_priv(dev);
29932993

2994+
/* we always support timestamping disabled */
2995+
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE);
2996+
29942997
switch (adapter->hw.mac.type) {
29952998
case ixgbe_mac_X550:
29962999
case ixgbe_mac_X550EM_x:
29973000
case ixgbe_mac_x550em_a:
3001+
info->rx_filters |= BIT(HWTSTAMP_FILTER_ALL);
3002+
/* fallthrough */
29983003
case ixgbe_mac_X540:
29993004
case ixgbe_mac_82599EB:
30003005
info->so_timestamping =
@@ -3014,8 +3019,7 @@ static int ixgbe_get_ts_info(struct net_device *dev,
30143019
BIT(HWTSTAMP_TX_OFF) |
30153020
BIT(HWTSTAMP_TX_ON);
30163021

3017-
info->rx_filters =
3018-
BIT(HWTSTAMP_FILTER_NONE) |
3022+
info->rx_filters |=
30193023
BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
30203024
BIT(HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
30213025
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);

0 commit comments

Comments
 (0)