All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries
@ 2015-06-03 22:56 Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 02/15] fm10k: use correct ethernet driver Tx timestamp function Jacob Keller
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This change fixes an issue with adding an invalid multicast address
using the iproute2 tool (ip maddr add <MADDR> dev <dev>). The iproute2
tool and the kernel do not validate or filter the multicast addresses
when adding them to the multicast list. Thus, when synchronizing this
list with an invalid entry, the action will be aborted with an error
since the fm10k driver currently validates the list. Consequently,
multicast entries beyond the invalid one will not be processed and
communicated with the switch via the mailbox. This change makes it so
that invalid addresses will simply be skipped and allows synchronizing
the full list to proceed.

Signed-off-by: Ngai-Mint Kwan <ngai-mint.kwan@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 2f4f41b7eae7..4c6b51111566 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -923,18 +923,12 @@ static int __fm10k_mc_sync(struct net_device *dev,
 	struct fm10k_intfc *interface = netdev_priv(dev);
 	struct fm10k_hw *hw = &interface->hw;
 	u16 vid, glort = interface->glort;
-	s32 err;
-
-	if (!is_multicast_ether_addr(addr))
-		return -EADDRNOTAVAIL;
 
 	/* update table with current entries */
 	for (vid = hw->mac.default_vid ? fm10k_find_next_vlan(interface, 0) : 0;
 	     vid < VLAN_N_VID;
 	     vid = fm10k_find_next_vlan(interface, vid)) {
-		err = hw->mac.ops.update_mc_addr(hw, glort, addr, vid, sync);
-		if (err)
-			return err;
+		hw->mac.ops.update_mc_addr(hw, glort, addr, vid, sync);
 	}
 
 	return 0;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 02/15] fm10k: use correct ethernet driver Tx timestamp function
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 03/15] fm10k: move setting shinfo inside ts_tx_enqueue Jacob Keller
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

skb_complete_tx_timestamp is intended for use by PHY drivers which
implement a different method of returning timestamps. This method is
intended to be used after a PHY driver accepts a cloned packet via its
phy_driver.txtstamp function. It is not correct to use in the standard
ethernet driver such as fm10k. This patch fixes the following possible
kernel panic.

[ 2744.552896] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W  OE  3.19.3-200.fc21.x86_64 #1
[ 2744.552899] Hardware name: Intel Corporation S2600CO/S2600CO, BIOS SE5C600.86B.02.03.8x23.060520140825 06/05/2014
[ 2744.552901]  0000000000000000 2f4c8b10ea3f9848 ffff88081ee03a38 ffffffff8176e215
[ 2744.552906]  0000000000000000 0000000000000000 ffff88081ee03a78 ffffffff8109bc1a
[ 2744.552910]  ffff88081ee03c50 ffff88080e55fc00 ffff88080e55fc00 ffffffff81647c50
[ 2744.552914] Call Trace:
[ 2744.552917]  <IRQ>  [<ffffffff8176e215>] dump_stack+0x45/0x57
[ 2744.552931]  [<ffffffff8109bc1a>] warn_slowpath_common+0x8a/0xc0
[ 2744.552936]  [<ffffffff81647c50>] ? skb_queue_purge+0x20/0x40
[ 2744.552941]  [<ffffffff8109bd4a>] warn_slowpath_null+0x1a/0x20
[ 2744.552946]  [<ffffffff81646911>] skb_release_head_state+0xe1/0xf0
[ 2744.552950]  [<ffffffff81647b26>] skb_release_all+0x16/0x30
[ 2744.552954]  [<ffffffff81647ba6>] kfree_skb+0x36/0x90
[ 2744.552958]  [<ffffffff81647c50>] skb_queue_purge+0x20/0x40
[ 2744.552964]  [<ffffffff81751f8d>] packet_sock_destruct+0x1d/0x90
[ 2744.552968]  [<ffffffff81642053>] __sk_free+0x23/0x140
[ 2744.552973]  [<ffffffff81642189>] sk_free+0x19/0x20
[ 2744.552977]  [<ffffffff81647d60>] skb_complete_tx_timestamp+0x50/0x60
[ 2744.552988]  [<ffffffffa02eee40>] fm10k_ts_tx_hwtstamp+0xd0/0x100 [fm10k]
[ 2744.552994]  [<ffffffffa02e054e>] fm10k_1588_msg_pf+0x12e/0x140 [fm10k]
[ 2744.553002]  [<ffffffffa02edf1d>] fm10k_tlv_msg_parse+0x8d/0xc0 [fm10k]
[ 2744.553010]  [<ffffffffa02eb2d0>] fm10k_mbx_dequeue_rx+0x60/0xb0 [fm10k]
[ 2744.553016]  [<ffffffffa02ebf98>] fm10k_sm_mbx_process+0x178/0x3c0 [fm10k]
[ 2744.553022]  [<ffffffffa02e09ca>] fm10k_msix_mbx_pf+0xfa/0x360 [fm10k]
[ 2744.553030]  [<ffffffff811030a7>] ? get_next_timer_interrupt+0x1f7/0x270
[ 2744.553036]  [<ffffffff810f2a47>] handle_irq_event_percpu+0x77/0x1a0
[ 2744.553041]  [<ffffffff810f2bab>] handle_irq_event+0x3b/0x60
[ 2744.553045]  [<ffffffff810f5d6e>] handle_edge_irq+0x6e/0x120
[ 2744.553054]  [<ffffffff81017414>] handle_irq+0x74/0x140
[ 2744.553061]  [<ffffffff810bb54a>] ? atomic_notifier_call_chain+0x1a/0x20
[ 2744.553066]  [<ffffffff8177777f>] do_IRQ+0x4f/0xf0
[ 2744.553072]  [<ffffffff8177556d>] common_interrupt+0x6d/0x6d
[ 2744.553074]  <EOI>  [<ffffffff81609b16>] ? cpuidle_enter_state+0x66/0x160
[ 2744.553084]  [<ffffffff81609b01>] ? cpuidle_enter_state+0x51/0x160
[ 2744.553087]  [<ffffffff81609cf7>] cpuidle_enter+0x17/0x20
[ 2744.553092]  [<ffffffff810de101>] cpu_startup_entry+0x321/0x3c0
[ 2744.553098]  [<ffffffff81764497>] rest_init+0x77/0x80
[ 2744.553103]  [<ffffffff81d4f02c>] start_kernel+0x4a4/0x4c5
[ 2744.553107]  [<ffffffff81d4e120>] ? early_idt_handlers+0x120/0x120
[ 2744.553110]  [<ffffffff81d4e4d7>] x86_64_start_reservations+0x2a/0x2c
[ 2744.553114]  [<ffffffff81d4e62b>] x86_64_start_kernel+0x152/0x175

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_ptp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
index 9043633c3e50..bb7d3bfca6ef 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
@@ -103,9 +103,10 @@ void fm10k_ts_tx_hwtstamp(struct fm10k_intfc *interface, __le16 dglort,
 	if (!skb)
 		return;
 
-	/* timestamp the sk_buff and return it to the socket */
+	/* timestamp the sk_buff and free out copy */
 	fm10k_systime_to_hwtstamp(interface, &shhwtstamps, systime);
-	skb_complete_tx_timestamp(skb, &shhwtstamps);
+	skb_tstamp_tx(skb &shhwtstamps);
+	dev_kfree_skb_any(skb);
 }
 
 void fm10k_ts_tx_subtask(struct fm10k_intfc *interface)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 03/15] fm10k: move setting shinfo inside ts_tx_enqueue
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 02/15] fm10k: use correct ethernet driver Tx timestamp function Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 04/15] fm10k: fix incorrect free on skb in ts_tx_enqueue Jacob Keller
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This patch simplifies the code flow for setting the IN_PROGRESS bit of
the shinfo for an skb we will be timestamping.

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_ptp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
index bb7d3bfca6ef..448d60ae98ce 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
@@ -70,16 +70,16 @@ void fm10k_ts_tx_enqueue(struct fm10k_intfc *interface, struct sk_buff *skb)
 	 * if none are present then insert skb in tail of list
 	 */
 	skb = fm10k_ts_tx_skb(interface, FM10K_CB(clone)->fi.w.dglort);
-	if (!skb)
+	if (!skb) {
+		skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
 		__skb_queue_tail(list, clone);
+	}
 
 	spin_unlock_irqrestore(&list->lock, flags);
 
 	/* if list is already has one then we just free the clone */
 	if (skb)
 		kfree_skb(skb);
-	else
-		skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
 }
 
 void fm10k_ts_tx_hwtstamp(struct fm10k_intfc *interface, __le16 dglort,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 04/15] fm10k: fix incorrect free on skb in ts_tx_enqueue
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 02/15] fm10k: use correct ethernet driver Tx timestamp function Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 03/15] fm10k: move setting shinfo inside ts_tx_enqueue Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 05/15] fm10k: add call to fm10k_clean_all_rx_rings in fm10k_down Jacob Keller
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This patch resolves a bug in the ts_tx_enqueue code responsible for a
NULL pointer dereference and invalid access of the skb list. We
incorrectly freed the actual skb we found instead of our copy. Thus the
skb queue is essentially invalidated. Resolve this by freeing our clone
in the cases where we did not add it to the queue. This also avoids the
skb memory leak caused by failure to free the clone.

[  589.719320] BUG: unable to handle kernel NULL pointer dereference at           (null)
[  589.722344] IP: [<ffffffffa0310e60>] fm10k_ts_tx_subtask+0xb0/0x160 [fm10k]
[  589.723796] PGD 0
[  589.725228] Oops: 0000 [#1] SMP

Change-Id: If0ba5033d70f523e624d928bdfc3700ce5e003af
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Change-type: Defect
Complexity: High
Customer-visible: Yes
---
 drivers/net/ethernet/intel/fm10k/fm10k_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
index 448d60ae98ce..f1dcf2e377c7 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
@@ -79,7 +79,7 @@ void fm10k_ts_tx_enqueue(struct fm10k_intfc *interface, struct sk_buff *skb)
 
 	/* if list is already has one then we just free the clone */
 	if (skb)
-		kfree_skb(skb);
+		dev_kfree_skb(clone);
 }
 
 void fm10k_ts_tx_hwtstamp(struct fm10k_intfc *interface, __le16 dglort,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 05/15] fm10k: add call to fm10k_clean_all_rx_rings in fm10k_down
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (2 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 04/15] fm10k: fix incorrect free on skb in ts_tx_enqueue Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 06/15] fm10k: use an unsigned int for i in ethtool_get_strings Jacob Keller
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This prevents a memory leak in fm10k_set_ringparams. The leak occurs
because we go down, change ring parameters, and then come up. However,
fm10k_down on its own is not clearing the Rx rings. Since fm10k_up
assumes the rings are clean we basically drop the buffers and leak a
bunch of memory. Eventually we hit dirty page faults and reboot the
system. This issue does not occur elsewhere because other flows that
involve fm10k_down go through fm10k_close which immediately called
fm10k_free_all_rx_resources which properly cleans the rings.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index df9fda38bdd1..445014a49de7 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -1559,6 +1559,7 @@ void fm10k_down(struct fm10k_intfc *interface)
 
 	/* free any buffers still on the rings */
 	fm10k_clean_all_tx_rings(interface);
+	fm10k_clean_all_rx_rings(interface);
 }
 
 /**
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 06/15] fm10k: use an unsigned int for i in ethtool_get_strings
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (3 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 05/15] fm10k: add call to fm10k_clean_all_rx_rings in fm10k_down Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 07/15] fm10k: remove extraneous NULL check on l2_accel Jacob Keller
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

The value will never be negative, and we use the %i print format, use
unsigned int for the loop counter. Issue found using cppcheck.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
index 4b9d9f88af70..06f0b08d9af5 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
@@ -124,7 +124,7 @@ static void fm10k_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	struct fm10k_intfc *interface = netdev_priv(dev);
 	char *p = (char *)data;
-	int i;
+	unsigned int i;
 
 	switch (stringset) {
 	case ETH_SS_TEST:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 07/15] fm10k: remove extraneous NULL check on l2_accel
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (4 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 06/15] fm10k: use an unsigned int for i in ethtool_get_strings Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 08/15] fm10k: trivial fixup message style to include a colon Jacob Keller
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

l2_accel was checked for NULL at the top of fm10k_dfwd_del_station, and
we return if it is not defined. Due to this, we already know it can't be
null here so a separate check is meaningless. Discovered via cppcheck.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 4c6b51111566..99228bf46c12 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -1333,8 +1333,7 @@ static void fm10k_dfwd_del_station(struct net_device *dev, void *priv)
 	dglort.rss_l = fls(interface->ring_feature[RING_F_RSS].mask);
 	dglort.pc_l = fls(interface->ring_feature[RING_F_QOS].mask);
 	dglort.glort = interface->glort;
-	if (l2_accel)
-		dglort.shared_l = fls(l2_accel->size);
+	dglort.shared_l = fls(l2_accel->size);
 	hw->mac.ops.configure_dglort_map(hw, &dglort);
 
 	/* If table is empty remove it */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 08/15] fm10k: trivial fixup message style to include a colon
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (5 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 07/15] fm10k: remove extraneous NULL check on l2_accel Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 09/15] fm10k: use dma_set_mask_and_coherent in fm10k_probe Jacob Keller
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 445014a49de7..5269b1628ca6 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -1773,7 +1773,7 @@ static int fm10k_probe(struct pci_dev *pdev,
 					   fm10k_driver_name);
 	if (err) {
 		dev_err(&pdev->dev,
-			"pci_request_selected_regions failed 0x%x\n", err);
+			"pci_request_selected_regions failed: 0x%x\n", err);
 		goto err_pci_reg;
 	}
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 09/15] fm10k: use dma_set_mask_and_coherent in fm10k_probe
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (6 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 08/15] fm10k: trivial fixup message style to include a colon Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 10/15] fm10k: force LPORT delete when updating VLAN or MAC address Jacob Keller
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This patch cleans up the use of dma_get_required_mask and uses the
simpler dma_set_mask_and_coherent function instead of doing these as
separate steps.

I removed the dma_get_required_mask call because based on some minimal
testing it appears that either (a) we're not doing the right thing with
the call or (b) we don't need it anyways. If the value returned is
<48bits, we'll end up trying with 48 bits anyways. If it's over 48bits,
fm10k can't support that anyways, and we should try 48bits. If 48bits
fails, we'll fallback to 32bits. This cleans up some very funky code.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 5269b1628ca6..e61f8767429e 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -1741,30 +1741,17 @@ static int fm10k_probe(struct pci_dev *pdev,
 	struct fm10k_intfc *interface;
 	struct fm10k_hw *hw;
 	int err;
-	u64 dma_mask;
 
 	err = pci_enable_device_mem(pdev);
 	if (err)
 		return err;
 
-	/* By default fm10k only supports a 48 bit DMA mask */
-	dma_mask = DMA_BIT_MASK(48) | dma_get_required_mask(&pdev->dev);
-
-	if ((dma_mask <= DMA_BIT_MASK(32)) ||
-	    dma_set_mask_and_coherent(&pdev->dev, dma_mask)) {
-		dma_mask &= DMA_BIT_MASK(32);
-
+	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48));
+	if (err)
 		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
-		err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
-		if (err) {
-			err = dma_set_coherent_mask(&pdev->dev,
-						    DMA_BIT_MASK(32));
-			if (err) {
-				dev_err(&pdev->dev,
-					"No usable DMA configuration, aborting\n");
-				goto err_dma;
-			}
-		}
+	if (err) {
+		dev_err(&pdev->dev,
+			"DMA configuration failed: 0x%x\n", err);
 	}
 
 	err = pci_request_selected_regions(pdev,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 10/15] fm10k: force LPORT delete when updating VLAN or MAC address
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (7 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 09/15] fm10k: use dma_set_mask_and_coherent in fm10k_probe Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 11/15] fm10k: re-map all possible VF queues after a VFLR Jacob Keller
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

Currently, we don't notify the switch at all when the PF
administratively sets a new VLAN or MAC address. This causes the old
addresses to remain valid on the switch table. Since the PF is
overriding any configuration done directly by the VF, we choose to
simply re-create the LPORT for the VF. This does mean that all rules for
the VF will be dropped when we set something directly via the PF, but it
prevents some weird issues where the MAC/VLAN table retains some stale
configuration.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_iov.c | 38 +++++++++++++++++-----------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
index 5b08e6284a3c..94571e6e790c 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
@@ -400,11 +400,31 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs)
 	return num_vfs;
 }
 
+static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface,
+				       struct fm10k_vf_info *vf_info)
+{
+	struct fm10k_hw *hw = &interface->hw;
+
+	/* assigning the MAC address will send a mailbox message */
+	fm10k_mbx_lock(interface);
+
+	/* disable LPORT for this VF which clears switch rules */
+	hw->iov.ops.reset_lport(hw, vf_info);
+
+	/* assign new MAC+VLAN for this VF */
+	hw->iov.ops.assign_default_mac_vlan(hw, vf_info);
+
+	/* re-enable the LPORT for this VF */
+	hw->iov.ops.set_lport(hw, vf_info, vf_info->vf_idx,
+			      FM10K_VF_FLAG_MULTI_CAPABLE);
+
+	fm10k_mbx_unlock(interface);
+}
+
 int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac)
 {
 	struct fm10k_intfc *interface = netdev_priv(netdev);
 	struct fm10k_iov_data *iov_data = interface->iov_data;
-	struct fm10k_hw *hw = &interface->hw;
 	struct fm10k_vf_info *vf_info;
 
 	/* verify SR-IOV is active and that vf idx is valid */
@@ -419,13 +439,7 @@ int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac)
 	vf_info = &iov_data->vf_info[vf_idx];
 	ether_addr_copy(vf_info->mac, mac);
 
-	/* assigning the MAC will send a mailbox message so lock is needed */
-	fm10k_mbx_lock(interface);
-
-	/* assign MAC address to VF */
-	hw->iov.ops.assign_default_mac_vlan(hw, vf_info);
-
-	fm10k_mbx_unlock(interface);
+	fm10k_reset_vf_info(interface, vf_info);
 
 	return 0;
 }
@@ -455,16 +469,10 @@ int fm10k_ndo_set_vf_vlan(struct net_device *netdev, int vf_idx, u16 vid,
 	/* record default VLAN ID for VF */
 	vf_info->pf_vid = vid;
 
-	/* assigning the VLAN will send a mailbox message so lock is needed */
-	fm10k_mbx_lock(interface);
-
 	/* Clear the VLAN table for the VF */
 	hw->mac.ops.update_vlan(hw, FM10K_VLAN_ALL, vf_info->vsi, false);
 
-	/* Update VF assignment and trigger reset */
-	hw->iov.ops.assign_default_mac_vlan(hw, vf_info);
-
-	fm10k_mbx_unlock(interface);
+	fm10k_reset_vf_info(interface, vf_info);
 
 	return 0;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 11/15] fm10k: re-map all possible VF queues after a VFLR
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (8 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 10/15] fm10k: force LPORT delete when updating VLAN or MAC address Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 12/15] fm10k: pack TLV overlay structures Jacob Keller
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

During initialization, the VF counts its rings by walking the TQDLOC
registers. This works only if the TQMAP/RQMAP registers are set to map
all of the out-of-bound rings back to the first one. This allows the VF
to cleanly detect when it has run out of queues. Update the PF code so
that it resets the empty TQMAP/RQMAP registers post-VFLR to prevent
innocent VF drivers from triggering malicious driver events.

Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index 891e21874b2a..3b942061a339 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -1046,6 +1046,12 @@ static s32 fm10k_iov_reset_resources_pf(struct fm10k_hw *hw,
 		fm10k_write_reg(hw, FM10K_RQMAP(qmap_idx + i), vf_q_idx + i);
 	}
 
+	/* repeat the first ring for all the remaining VF rings */
+	for (i = queues_per_pool; i < qmap_stride; i++) {
+		fm10k_write_reg(hw, FM10K_TQMAP(qmap_idx + 1), vf_q_idx);
+		fm10k_write_reg(hw, FM10K_RQMAP(qmap_idx + 1), vf_q_idx);
+	}
+
 	return 0;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 12/15] fm10k: pack TLV overlay structures
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (9 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 11/15] fm10k: re-map all possible VF queues after a VFLR Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 13/15] fm10k: fix incorrect DIR_NEVATIVE bit in 1588 code Jacob Keller
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

This patch adds the __attribute__((packed)) indicator to some structures
which are overlayed onto a TLV message. These structures must be packed
as small as possible in order to correctly align when copied into the
mailbox buffer. Without doing so, the receiving mailbox code incorrectly
parses the values and we get invalid message responses from the switch
manager software.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.h b/drivers/net/ethernet/intel/fm10k/fm10k_pf.h
index 7ab1db4fff32..36791457ae6c 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.h
@@ -81,26 +81,26 @@ struct fm10k_mac_update {
 	__le16	glort;
 	u8	flags;
 	u8	action;
-};
+} __attribute__((packed));
 
 struct fm10k_global_table_data {
 	__le32	used;
 	__le32	avail;
-};
+} __attribute__((packed));
 
 struct fm10k_swapi_error {
 	__le32				status;
 	struct fm10k_global_table_data	mac;
 	struct fm10k_global_table_data	nexthop;
 	struct fm10k_global_table_data	ffu;
-};
+} __attribute__((packed));
 
 struct fm10k_swapi_1588_timestamp {
 	__le64 egress;
 	__le64 ingress;
 	__le16 dglort;
 	__le16 sglort;
-};
+} __attribute__((packed));
 
 s32 fm10k_msg_lport_map_pf(struct fm10k_hw *, u32 **, struct fm10k_mbx_info *);
 extern const struct fm10k_tlv_attr fm10k_lport_map_msg_attr[];
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 13/15] fm10k: fix incorrect DIR_NEVATIVE bit in 1588 code
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (10 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 12/15] fm10k: pack TLV overlay structures Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 14/15] fm10k: remove err_no reference in fm10k_mbx.c Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 15/15] fm10k: fix iov_msg_lport_state_pf issue Jacob Keller
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

The SYSTIME_CFG.Adjust Direction bit is actually supposed to indicate
that the adjustment is positive. Fix the code to align correctly with
hardware and documentation.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c   | 4 ++--
 drivers/net/ethernet/intel/fm10k/fm10k_type.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index 3b942061a339..ab81c00327b2 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -1792,8 +1792,8 @@ static s32 fm10k_adjust_systime_pf(struct fm10k_hw *hw, s32 ppb)
 	if (systime_adjust > FM10K_SW_SYSTIME_ADJUST_MASK)
 		return FM10K_ERR_PARAM;
 
-	if (ppb < 0)
-		systime_adjust |= FM10K_SW_SYSTIME_ADJUST_DIR_NEGATIVE;
+	if (ppb > 0)
+		systime_adjust |= FM10K_SW_SYSTIME_ADJUST_DIR_POSITIVE;
 
 	fm10k_write_sw_reg(hw, FM10K_SW_SYSTIME_ADJUST, (u32)systime_adjust);
 
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_type.h b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
index 4af96686c584..2a17d82fa37d 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_type.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
@@ -369,7 +369,7 @@ struct fm10k_hw;
 /* Registers contained in BAR 4 for Switch management */
 #define FM10K_SW_SYSTIME_ADJUST	0x0224D
 #define FM10K_SW_SYSTIME_ADJUST_MASK		0x3FFFFFFF
-#define FM10K_SW_SYSTIME_ADJUST_DIR_NEGATIVE	0x80000000
+#define FM10K_SW_SYSTIME_ADJUST_DIR_POSITIVE	0x80000000
 #define FM10K_SW_SYSTIME_PULSE(_n)	((_n) + 0x02252)
 
 enum fm10k_int_source {
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 14/15] fm10k: remove err_no reference in fm10k_mbx.c
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (11 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 13/15] fm10k: fix incorrect DIR_NEVATIVE bit in 1588 code Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 15/15] fm10k: fix iov_msg_lport_state_pf issue Jacob Keller
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

The reference to err_no was left around after a previous code refactor.
We never use the value, and it doesn't seem to be used in side a hidden
macro reference. Discovered via cppcheck.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_mbx.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
index 1b2738380518..1a4b52637de9 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
@@ -1259,16 +1259,11 @@ static s32 fm10k_mbx_process_error(struct fm10k_hw *hw,
 				   struct fm10k_mbx_info *mbx)
 {
 	const u32 *hdr = &mbx->mbx_hdr;
-	s32 err_no;
 	u16 head;
 
 	/* we will need to pull all of the fields for verification */
 	head = FM10K_MSG_HDR_FIELD_GET(*hdr, HEAD);
 
-	/* we only have lower 10 bits of error number so add upper bits */
-	err_no = FM10K_MSG_HDR_FIELD_GET(*hdr, ERR_NO);
-	err_no |= ~FM10K_MSG_HDR_MASK(ERR_NO);
-
 	switch (mbx->state) {
 	case FM10K_STATE_OPEN:
 	case FM10K_STATE_DISCONNECT:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Intel-wired-lan] [PATCH 15/15] fm10k: fix iov_msg_lport_state_pf issue
  2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
                   ` (12 preceding siblings ...)
  2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 14/15] fm10k: remove err_no reference in fm10k_mbx.c Jacob Keller
@ 2015-06-03 22:56 ` Jacob Keller
  13 siblings, 0 replies; 15+ messages in thread
From: Jacob Keller @ 2015-06-03 22:56 UTC (permalink / raw)
  To: intel-wired-lan

When a VF issues an LPORT_STATE request to enable a port that is already
enabled, the PF will first disable the VF LPORT. Then it should
re-enable the VF again with the new requested settings. This ensures
that any switch rules are cleared by deleting the LPORT on the switch.
However, the flow is bugged because we actually check if the VF is
enabled at the end, and thus don't re-enable it. Fix the flow so that we
actually clear the enabled flags as part of our removal of the LPORT.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index ab81c00327b2..54d1cd97866f 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -1351,6 +1351,14 @@ s32 fm10k_iov_msg_lport_state_pf(struct fm10k_hw *hw, u32 **results,
 			err = fm10k_update_lport_state_pf(hw, vf_info->glort,
 							  1, false);
 
+		/* we need to clear VF_FLAG_ENABLED flags in order to ensure
+		 * that we actually re-enable the LPORT state below. Note that
+		 * this has no impact if the VF is already disabled, as the
+		 * flags are already cleared.
+		 */
+		if (!err)
+			vf_info->vf_flags = FM10K_VF_FLAG_CAPABLE(vf_info);
+
 		/* when enabling the port we should reset the rate limiters */
 		hw->iov.ops.configure_tc(hw, vf_info->vf_idx, vf_info->rate);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-06-03 22:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 22:56 [Intel-wired-lan] [PATCH 01/15] fm10k: ignore invalid multicast address entries Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 02/15] fm10k: use correct ethernet driver Tx timestamp function Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 03/15] fm10k: move setting shinfo inside ts_tx_enqueue Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 04/15] fm10k: fix incorrect free on skb in ts_tx_enqueue Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 05/15] fm10k: add call to fm10k_clean_all_rx_rings in fm10k_down Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 06/15] fm10k: use an unsigned int for i in ethtool_get_strings Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 07/15] fm10k: remove extraneous NULL check on l2_accel Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 08/15] fm10k: trivial fixup message style to include a colon Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 09/15] fm10k: use dma_set_mask_and_coherent in fm10k_probe Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 10/15] fm10k: force LPORT delete when updating VLAN or MAC address Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 11/15] fm10k: re-map all possible VF queues after a VFLR Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 12/15] fm10k: pack TLV overlay structures Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 13/15] fm10k: fix incorrect DIR_NEVATIVE bit in 1588 code Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 14/15] fm10k: remove err_no reference in fm10k_mbx.c Jacob Keller
2015-06-03 22:56 ` [Intel-wired-lan] [PATCH 15/15] fm10k: fix iov_msg_lport_state_pf issue Jacob Keller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.