All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification
@ 2018-08-20 15:12 Alice Michael
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array Alice Michael
                   ` (12 more replies)
  0 siblings, 13 replies; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Mariusz Stachura <mariusz.stachura@intel.com>

This patch moves saving old link status information after the call to
i40e_get_link_status(). Mentioned function updates both old and the new
link info, so reading it before results in not notifying VF about the
PF link state change.

Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 456c917..969fb93 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8446,14 +8446,9 @@ static void i40e_link_event(struct i40e_pf *pf)
 	i40e_status status;
 	bool new_link, old_link;
 
-	/* save off old link status information */
-	pf->hw.phy.link_info_old = pf->hw.phy.link_info;
-
 	/* set this to force the get_link_status call to refresh state */
 	pf->hw.phy.get_link_info = true;
-
 	old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP);
-
 	status = i40e_get_link_status(&pf->hw, &new_link);
 
 	/* On success, disable temp link polling */
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:16   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h Alice Michael
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Jacob Keller <jacob.e.keller@intel.com>

Use an i40e_stats array to handle the queue stats, instead of coding
similar functionality separately. Because of how the queue stats are
accessed on some kernels, we can't easily use i40e_add_ethtool_stats.

Instead, implement a separate helper, i40e_add_queue_stats, which we'll
use instead. This helper will correctly implement the
u64_stats_fetch_begin_irq logic and allow retries until successful. We
share the most complex code by re-using i40e_add_one_ethtool_stat.

This logic additionally easily supports skipping disabled rings by using
a ternary operator before calling the u64_stats_fetch_begin_irq()
function, so that we correctly zero-out the stats values without having
to perform two separate sections of code.

This significantly reduces the boiler plate code in
i40e_get_ethtool_stats, and helps keep the complex logic contained to as
few functions as possible.

With this patch, we've finally converted all the statistics to use the
helpers and the i40e_stats function.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 148 +++++++++++++++----------
 1 file changed, 89 insertions(+), 59 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 19606a2..9ac41c8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -33,6 +33,8 @@ struct i40e_stats {
 	I40E_STAT(struct i40e_veb, _name, _stat)
 #define I40E_PFC_STAT(_name, _stat) \
 	I40E_STAT(struct i40e_pfc_stats, _name, _stat)
+#define I40E_QUEUE_STAT(_name, _stat) \
+	I40E_STAT(struct i40e_ring, _name, _stat)
 
 static const struct i40e_stats i40e_gstrings_net_stats[] = {
 	I40E_NETDEV_STAT(rx_packets),
@@ -171,20 +173,16 @@ static const struct i40e_stats i40e_gstrings_pfc_stats[] = {
 	I40E_PFC_STAT("port.rx_priority_%u_xon_2_xoff", priority_xon_2_xoff),
 };
 
-/* We use num_tx_queues here as a proxy for the maximum number of queues
- * available because we always allocate queues symmetrically.
- */
-#define I40E_MAX_NUM_QUEUES(n) ((n)->num_tx_queues)
-#define I40E_QUEUE_STATS_LEN(n)                                              \
-	   (I40E_MAX_NUM_QUEUES(n)                                           \
-	    * 2 /* Tx and Rx together */                                     \
-	    * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
-#define I40E_GLOBAL_STATS_LEN	ARRAY_SIZE(i40e_gstrings_stats)
+static const struct i40e_stats i40e_gstrings_queue_stats[] = {
+	I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
+	I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
+};
+
 #define I40E_NETDEV_STATS_LEN	ARRAY_SIZE(i40e_gstrings_net_stats)
+
 #define I40E_MISC_STATS_LEN	ARRAY_SIZE(i40e_gstrings_misc_stats)
-#define I40E_VSI_STATS_LEN(n)	(I40E_NETDEV_STATS_LEN + \
-				 I40E_MISC_STATS_LEN + \
-				 I40E_QUEUE_STATS_LEN((n)))
+
+#define I40E_VSI_STATS_LEN	(I40E_NETDEV_STATS_LEN + I40E_MISC_STATS_LEN)
 
 #define I40E_PFC_STATS_LEN	(ARRAY_SIZE(i40e_gstrings_pfc_stats) * \
 				 I40E_MAX_USER_PRIORITY)
@@ -193,10 +191,15 @@ static const struct i40e_stats i40e_gstrings_pfc_stats[] = {
 				 (ARRAY_SIZE(i40e_gstrings_veb_tc_stats) * \
 				  I40E_MAX_TRAFFIC_CLASS))
 
-#define I40E_PF_STATS_LEN(n)	(I40E_GLOBAL_STATS_LEN + \
+#define I40E_GLOBAL_STATS_LEN	ARRAY_SIZE(i40e_gstrings_stats)
+
+#define I40E_PF_STATS_LEN	(I40E_GLOBAL_STATS_LEN + \
 				 I40E_PFC_STATS_LEN + \
 				 I40E_VEB_STATS_LEN + \
-				 I40E_VSI_STATS_LEN((n)))
+				 I40E_VSI_STATS_LEN)
+
+/* Length of stats for a single queue */
+#define I40E_QUEUE_STATS_LEN	ARRAY_SIZE(i40e_gstrings_queue_stats)
 
 enum i40e_ethtool_test_id {
 	I40E_ETH_TEST_REG = 0,
@@ -1701,11 +1704,30 @@ static int i40e_get_stats_count(struct net_device *netdev)
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
+	int stats_len;
 
 	if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1)
-		return I40E_PF_STATS_LEN(netdev);
+		stats_len = I40E_PF_STATS_LEN;
 	else
-		return I40E_VSI_STATS_LEN(netdev);
+		stats_len = I40E_VSI_STATS_LEN;
+
+	/* The number of stats reported for a given net_device must remain
+	 * constant throughout the life of that device.
+	 *
+	 * This is because the API for obtaining the size, strings, and stats
+	 * is spread out over three separate ethtool ioctls. There is no safe
+	 * way to lock the number of stats across these calls, so we must
+	 * assume that they will never change.
+	 *
+	 * Due to this, we report the maximum number of queues, even if not
+	 * every queue is currently configured. Since we always allocate
+	 * queues in pairs, we'll just use netdev->num_tx_queues * 2. This
+	 * works because the num_tx_queues is set at device creation and never
+	 * changes.
+	 */
+	stats_len += I40E_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues;
+
+	return stats_len;
 }
 
 static int i40e_get_sset_count(struct net_device *netdev, int sset)
@@ -1734,8 +1756,8 @@ static int i40e_get_sset_count(struct net_device *netdev, int sset)
  * @stat: the stat definition
  *
  * Copies the stat data defined by the pointer and stat structure pair into
- * the memory supplied as data. Used to implement i40e_add_ethtool_stats.
- * If the pointer is null, data will be zero'd.
+ * the memory supplied as data. Used to implement i40e_add_ethtool_stats and
+ * i40e_add_queue_stats. If the pointer is null, data will be zero'd.
  */
 static inline void
 i40e_add_one_ethtool_stat(u64 *data, void *pointer,
@@ -1811,6 +1833,45 @@ __i40e_add_ethtool_stats(u64 **data, void *pointer,
 	__i40e_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
 
 /**
+ * i40e_add_queue_stats - copy queue statistics into supplied buffer
+ * @data: ethtool stats buffer
+ * @ring: the ring to copy
+ *
+ * Queue statistics must be copied while protected by
+ * u64_stats_fetch_begin_irq, so we can't directly use i40e_add_ethtool_stats.
+ * Assumes that queue stats are defined in i40e_gstrings_queue_stats. If the
+ * ring pointer is null, zero out the queue stat values and update the data
+ * pointer. Otherwise safely copy the stats from the ring into the supplied
+ * buffer and update the data pointer when finished.
+ *
+ * This function expects to be called while under rcu_read_lock().
+ **/
+static inline void
+i40e_add_queue_stats(u64 **data, struct i40e_ring *ring)
+{
+	const unsigned int size = ARRAY_SIZE(i40e_gstrings_queue_stats);
+	const struct i40e_stats *stats = i40e_gstrings_queue_stats;
+	unsigned int start;
+	unsigned int i;
+
+	/* To avoid invalid statistics values, ensure that we keep retrying
+	 * the copy until we get a consistent value according to
+	 * u64_stats_fetch_retry_irq. But first, make sure our ring is
+	 * non-null before attempting to access its syncp.
+	 */
+	do {
+		start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp);
+		for (i = 0; i < size; i++) {
+			i40e_add_one_ethtool_stat(&(*data)[i], ring,
+						  &stats[i]);
+		}
+	} while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start));
+
+	/* Once we successfully copy the stats in, update the data pointer */
+	data += size;
+}
+
+/**
  * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
  * @pf: the PF device structure
  * @i: the priority value to copy
@@ -1853,12 +1914,10 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 				   struct ethtool_stats *stats, u64 *data)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
-	struct i40e_ring *tx_ring, *rx_ring;
 	struct i40e_vsi *vsi = np->vsi;
 	struct i40e_pf *pf = vsi->back;
 	struct i40e_veb *veb = pf->veb[pf->lan_veb];
 	unsigned int i;
-	unsigned int start;
 	bool veb_stats;
 	u64 *p = data;
 
@@ -1870,38 +1929,12 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 	i40e_add_ethtool_stats(&data, vsi, i40e_gstrings_misc_stats);
 
 	rcu_read_lock();
-	for (i = 0; i < I40E_MAX_NUM_QUEUES(netdev) ; i++) {
-		tx_ring = READ_ONCE(vsi->tx_rings[i]);
-
-		if (!tx_ring) {
-			/* Bump the stat counter to skip these stats, and make
-			 * sure the memory is zero'd
-			 */
-			*(data++) = 0;
-			*(data++) = 0;
-			*(data++) = 0;
-			*(data++) = 0;
-			continue;
-		}
-
-		/* process Tx ring statistics */
-		do {
-			start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
-			data[0] = tx_ring->stats.packets;
-			data[1] = tx_ring->stats.bytes;
-		} while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
-		data += 2;
-
-		/* Rx ring is the 2nd half of the queue pair */
-		rx_ring = &tx_ring[1];
-		do {
-			start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
-			data[0] = rx_ring->stats.packets;
-			data[1] = rx_ring->stats.bytes;
-		} while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
-		data += 2;
+	for (i = 0; i < netdev->num_tx_queues; i++) {
+		i40e_add_queue_stats(&data, READ_ONCE(vsi->tx_rings[i]));
+		i40e_add_queue_stats(&data, READ_ONCE(vsi->rx_rings[i]));
 	}
 	rcu_read_unlock();
+
 	if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
 		goto check_data_pointer;
 
@@ -1990,16 +2023,13 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
 
 	i40e_add_stat_strings(&data, i40e_gstrings_misc_stats);
 
-	for (i = 0; i < I40E_MAX_NUM_QUEUES(netdev); i++) {
-		snprintf(data, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
-		data += ETH_GSTRING_LEN;
-		snprintf(data, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
-		data += ETH_GSTRING_LEN;
-		snprintf(data, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
-		data += ETH_GSTRING_LEN;
-		snprintf(data, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
-		data += ETH_GSTRING_LEN;
+	for (i = 0; i < netdev->num_tx_queues; i++) {
+		i40e_add_stat_strings(&data, i40e_gstrings_queue_stats,
+				      "tx", i);
+		i40e_add_stat_strings(&data, i40e_gstrings_queue_stats,
+				      "rx", i);
 	}
+
 	if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
 		return;
 
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:17   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions Alice Michael
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Jacob Keller <jacob.e.keller@intel.com>

Move the boiler plate structures and helper functions we recently
added into their own header file, so that the complete collection is
located together.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c     | 182 +----------------
 .../net/ethernet/intel/i40e/i40e_ethtool_stats.h   | 221 +++++++++++++++++++++
 2 files changed, 222 insertions(+), 181 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/i40e/i40e_ethtool_stats.h

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 9ac41c8..ecc30524 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -6,25 +6,8 @@
 #include "i40e.h"
 #include "i40e_diag.h"
 
-struct i40e_stats {
-	/* The stat_string is expected to be a format string formatted using
-	 * vsnprintf by i40e_add_stat_strings. Every member of a stats array
-	 * should use the same format specifiers as they will be formatted
-	 * using the same variadic arguments.
-	 */
-	char stat_string[ETH_GSTRING_LEN];
-	int sizeof_stat;
-	int stat_offset;
-};
-
-#define I40E_STAT(_type, _name, _stat) { \
-	.stat_string = _name, \
-	.sizeof_stat = FIELD_SIZEOF(_type, _stat), \
-	.stat_offset = offsetof(_type, _stat) \
-}
+#include "i40e_ethtool_stats.h"
 
-#define I40E_NETDEV_STAT(_net_stat) \
-	I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
 #define I40E_PF_STAT(_name, _stat) \
 	I40E_STAT(struct i40e_pf, _name, _stat)
 #define I40E_VSI_STAT(_name, _stat) \
@@ -173,11 +156,6 @@ static const struct i40e_stats i40e_gstrings_pfc_stats[] = {
 	I40E_PFC_STAT("port.rx_priority_%u_xon_2_xoff", priority_xon_2_xoff),
 };
 
-static const struct i40e_stats i40e_gstrings_queue_stats[] = {
-	I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
-	I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
-};
-
 #define I40E_NETDEV_STATS_LEN	ARRAY_SIZE(i40e_gstrings_net_stats)
 
 #define I40E_MISC_STATS_LEN	ARRAY_SIZE(i40e_gstrings_misc_stats)
@@ -1750,128 +1728,6 @@ static int i40e_get_sset_count(struct net_device *netdev, int sset)
 }
 
 /**
- * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
- * @data: location to store the stat value
- * @pointer: basis for where to copy from
- * @stat: the stat definition
- *
- * Copies the stat data defined by the pointer and stat structure pair into
- * the memory supplied as data. Used to implement i40e_add_ethtool_stats and
- * i40e_add_queue_stats. If the pointer is null, data will be zero'd.
- */
-static inline void
-i40e_add_one_ethtool_stat(u64 *data, void *pointer,
-			  const struct i40e_stats *stat)
-{
-	char *p;
-
-	if (!pointer) {
-		/* ensure that the ethtool data buffer is zero'd for any stats
-		 * which don't have a valid pointer.
-		 */
-		*data = 0;
-		return;
-	}
-
-	p = (char *)pointer + stat->stat_offset;
-	switch (stat->sizeof_stat) {
-	case sizeof(u64):
-		*data = *((u64 *)p);
-		break;
-	case sizeof(u32):
-		*data = *((u32 *)p);
-		break;
-	case sizeof(u16):
-		*data = *((u16 *)p);
-		break;
-	case sizeof(u8):
-		*data = *((u8 *)p);
-		break;
-	default:
-		WARN_ONCE(1, "unexpected stat size for %s",
-			  stat->stat_string);
-		*data = 0;
-	}
-}
-
-/**
- * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
- * @data: ethtool stats buffer
- * @pointer: location to copy stats from
- * @stats: array of stats to copy
- * @size: the size of the stats definition
- *
- * Copy the stats defined by the stats array using the pointer as a base into
- * the data buffer supplied by ethtool. Updates the data pointer to point to
- * the next empty location for successive calls to __i40e_add_ethtool_stats.
- * If pointer is null, set the data values to zero and update the pointer to
- * skip these stats.
- **/
-static inline void
-__i40e_add_ethtool_stats(u64 **data, void *pointer,
-			 const struct i40e_stats stats[],
-			 const unsigned int size)
-{
-	unsigned int i;
-
-	for (i = 0; i < size; i++)
-		i40e_add_one_ethtool_stat((*data)++, pointer, &stats[i]);
-}
-
-/**
- * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
- * @data: ethtool stats buffer
- * @pointer: location where stats are stored
- * @stats: static const array of stat definitions
- *
- * Macro to ease the use of __i40e_add_ethtool_stats by taking a static
- * constant stats array and passing the ARRAY_SIZE(). This avoids typos by
- * ensuring that we pass the size associated with the given stats array.
- * Assumes that stats is an array.
- **/
-#define i40e_add_ethtool_stats(data, pointer, stats) \
-	__i40e_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
-
-/**
- * i40e_add_queue_stats - copy queue statistics into supplied buffer
- * @data: ethtool stats buffer
- * @ring: the ring to copy
- *
- * Queue statistics must be copied while protected by
- * u64_stats_fetch_begin_irq, so we can't directly use i40e_add_ethtool_stats.
- * Assumes that queue stats are defined in i40e_gstrings_queue_stats. If the
- * ring pointer is null, zero out the queue stat values and update the data
- * pointer. Otherwise safely copy the stats from the ring into the supplied
- * buffer and update the data pointer when finished.
- *
- * This function expects to be called while under rcu_read_lock().
- **/
-static inline void
-i40e_add_queue_stats(u64 **data, struct i40e_ring *ring)
-{
-	const unsigned int size = ARRAY_SIZE(i40e_gstrings_queue_stats);
-	const struct i40e_stats *stats = i40e_gstrings_queue_stats;
-	unsigned int start;
-	unsigned int i;
-
-	/* To avoid invalid statistics values, ensure that we keep retrying
-	 * the copy until we get a consistent value according to
-	 * u64_stats_fetch_retry_irq. But first, make sure our ring is
-	 * non-null before attempting to access its syncp.
-	 */
-	do {
-		start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp);
-		for (i = 0; i < size; i++) {
-			i40e_add_one_ethtool_stat(&(*data)[i], ring,
-						  &stats[i]);
-		}
-	} while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start));
-
-	/* Once we successfully copy the stats in, update the data pointer */
-	data += size;
-}
-
-/**
  * i40e_get_pfc_stats - copy HW PFC statistics to formatted structure
  * @pf: the PF device structure
  * @i: the priority value to copy
@@ -1966,42 +1822,6 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 }
 
 /**
- * __i40e_add_stat_strings - copy stat strings into ethtool buffer
- * @p: ethtool supplied buffer
- * @stats: stat definitions array
- * @size: size of the stats array
- *
- * Format and copy the strings described by stats into the buffer pointed at
- * by p.
- **/
-static void __i40e_add_stat_strings(u8 **p, const struct i40e_stats stats[],
-				    const unsigned int size, ...)
-{
-	unsigned int i;
-
-	for (i = 0; i < size; i++) {
-		va_list args;
-
-		va_start(args, size);
-		vsnprintf(*p, ETH_GSTRING_LEN, stats[i].stat_string, args);
-		*p += ETH_GSTRING_LEN;
-		va_end(args);
-	}
-}
-
-/**
- * 40e_add_stat_strings - copy stat strings into ethtool buffer
- * @p: ethtool supplied buffer
- * @stats: stat definitions array
- *
- * Format and copy the strings described by the const static stats value into
- * the buffer pointed@by p. Assumes that stats can have ARRAY_SIZE called
- * for it.
- **/
-#define i40e_add_stat_strings(p, stats, ...) \
-	__i40e_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
-
-/**
  * i40e_get_stat_strings - copy stat strings into supplied buffer
  * @netdev: the netdev to collect strings for
  * @data: supplied buffer to copy strings into
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool_stats.h b/drivers/net/ethernet/intel/i40e/i40e_ethtool_stats.h
new file mode 100644
index 0000000..0290ade
--- /dev/null
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool_stats.h
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2013 - 2018 Intel Corporation. */
+
+/* ethtool statistics helpers */
+
+/**
+ * struct i40e_stats - definition for an ethtool statistic
+ * @stat_string: statistic name to display in ethtool -S output
+ * @sizeof_stat: the sizeof() the stat, must be no greater than sizeof(u64)
+ * @stat_offset: offsetof() the stat from a base pointer
+ *
+ * This structure defines a statistic to be added to the ethtool stats buffer.
+ * It defines a statistic as offset from a common base pointer. Stats should
+ * be defined in constant arrays using the I40E_STAT macro, with every element
+ * of the array using the same _type for calculating the sizeof_stat and
+ * stat_offset.
+ *
+ * The @sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or
+ * sizeof(u64). Other sizes are not expected and will produce a WARN_ONCE from
+ * the i40e_add_ethtool_stat() helper function.
+ *
+ * The @stat_string is interpreted as a format string, allowing formatted
+ * values to be inserted while looping over multiple structures for a given
+ * statistics array. Thus, every statistic string in an array should have the
+ * same type and number of format specifiers, to be formatted by variadic
+ * arguments to the i40e_add_stat_string() helper function.
+ **/
+struct i40e_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
+};
+
+/* Helper macro to define an i40e_stat structure with proper size and type.
+ * Use this when defining constant statistics arrays. Note that @_type expects
+ * only a type name and is used multiple times.
+ */
+#define I40E_STAT(_type, _name, _stat) { \
+	.stat_string = _name, \
+	.sizeof_stat = FIELD_SIZEOF(_type, _stat), \
+	.stat_offset = offsetof(_type, _stat) \
+}
+
+/* Helper macro for defining some statistics directly copied from the netdev
+ * stats structure.
+ */
+#define I40E_NETDEV_STAT(_net_stat) \
+	I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
+
+/* Helper macro for defining some statistics related to queues */
+#define I40E_QUEUE_STAT(_name, _stat) \
+	I40E_STAT(struct i40e_ring, _name, _stat)
+
+/* Stats associated with a Tx or Rx ring */
+static const struct i40e_stats i40e_gstrings_queue_stats[] = {
+	I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
+	I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
+};
+
+/**
+ * i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
+ * @data: location to store the stat value
+ * @pointer: basis for where to copy from
+ * @stat: the stat definition
+ *
+ * Copies the stat data defined by the pointer and stat structure pair into
+ * the memory supplied as data. Used to implement i40e_add_ethtool_stats and
+ * i40e_add_queue_stats. If the pointer is null, data will be zero'd.
+ */
+static inline void
+i40e_add_one_ethtool_stat(u64 *data, void *pointer,
+			  const struct i40e_stats *stat)
+{
+	char *p;
+
+	if (!pointer) {
+		/* ensure that the ethtool data buffer is zero'd for any stats
+		 * which don't have a valid pointer.
+		 */
+		*data = 0;
+		return;
+	}
+
+	p = (char *)pointer + stat->stat_offset;
+	switch (stat->sizeof_stat) {
+	case sizeof(u64):
+		*data = *((u64 *)p);
+		break;
+	case sizeof(u32):
+		*data = *((u32 *)p);
+		break;
+	case sizeof(u16):
+		*data = *((u16 *)p);
+		break;
+	case sizeof(u8):
+		*data = *((u8 *)p);
+		break;
+	default:
+		WARN_ONCE(1, "unexpected stat size for %s",
+			  stat->stat_string);
+		*data = 0;
+	}
+}
+
+/**
+ * __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
+ * @data: ethtool stats buffer
+ * @pointer: location to copy stats from
+ * @stats: array of stats to copy
+ * @size: the size of the stats definition
+ *
+ * Copy the stats defined by the stats array using the pointer as a base into
+ * the data buffer supplied by ethtool. Updates the data pointer to point to
+ * the next empty location for successive calls to __i40e_add_ethtool_stats.
+ * If pointer is null, set the data values to zero and update the pointer to
+ * skip these stats.
+ **/
+static inline void
+__i40e_add_ethtool_stats(u64 **data, void *pointer,
+			 const struct i40e_stats stats[],
+			 const unsigned int size)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; i++)
+		i40e_add_one_ethtool_stat((*data)++, pointer, &stats[i]);
+}
+
+/**
+ * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
+ * @data: ethtool stats buffer
+ * @pointer: location where stats are stored
+ * @stats: static const array of stat definitions
+ *
+ * Macro to ease the use of __i40e_add_ethtool_stats by taking a static
+ * constant stats array and passing the ARRAY_SIZE(). This avoids typos by
+ * ensuring that we pass the size associated with the given stats array.
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided.
+ **/
+#define i40e_add_ethtool_stats(data, pointer, stats) \
+	__i40e_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
+
+/**
+ * i40e_add_queue_stats - copy queue statistics into supplied buffer
+ * @data: ethtool stats buffer
+ * @ring: the ring to copy
+ *
+ * Queue statistics must be copied while protected by
+ * u64_stats_fetch_begin_irq, so we can't directly use i40e_add_ethtool_stats.
+ * Assumes that queue stats are defined in i40e_gstrings_queue_stats. If the
+ * ring pointer is null, zero out the queue stat values and update the data
+ * pointer. Otherwise safely copy the stats from the ring into the supplied
+ * buffer and update the data pointer when finished.
+ *
+ * This function expects to be called while under rcu_read_lock().
+ **/
+static inline void
+i40e_add_queue_stats(u64 **data, struct i40e_ring *ring)
+{
+	const unsigned int size = ARRAY_SIZE(i40e_gstrings_queue_stats);
+	const struct i40e_stats *stats = i40e_gstrings_queue_stats;
+	unsigned int start;
+	unsigned int i;
+
+	/* To avoid invalid statistics values, ensure that we keep retrying
+	 * the copy until we get a consistent value according to
+	 * u64_stats_fetch_retry_irq. But first, make sure our ring is
+	 * non-null before attempting to access its syncp.
+	 */
+	do {
+		start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp);
+		for (i = 0; i < size; i++) {
+			i40e_add_one_ethtool_stat(&(*data)[i], ring,
+						  &stats[i]);
+		}
+	} while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start));
+
+	/* Once we successfully copy the stats in, update the data pointer */
+	*data += size;
+}
+
+/**
+ * __i40e_add_stat_strings - copy stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ * @size: size of the stats array
+ *
+ * Format and copy the strings described by stats into the buffer pointed at
+ * by p.
+ **/
+static void __i40e_add_stat_strings(u8 **p, const struct i40e_stats stats[],
+				    const unsigned int size, ...)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; i++) {
+		va_list args;
+
+		va_start(args, size);
+		vsnprintf(*p, ETH_GSTRING_LEN, stats[i].stat_string, args);
+		*p += ETH_GSTRING_LEN;
+		va_end(args);
+	}
+}
+
+/**
+ * 40e_add_stat_strings - copy stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ *
+ * Format and copy the strings described by the const static stats value into
+ * the buffer pointed@by p.
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided. Additionally, stats must be an array such that
+ * ARRAY_SIZE can be called on it.
+ **/
+#define i40e_add_stat_strings(p, stats, ...) \
+	__i40e_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array Alice Michael
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:19   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver Alice Michael
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Jacob Keller <jacob.e.keller@intel.com>

Fix a bug in the way we handled VF queues, by always showing stats for
the maximum number of queues, even if they aren't allocated. It is not
safe to change the number of strings reported to ethtool, as grabbing
statistics occurs over multiple ethtool ops for which the rtnl_lock()
cannot be held the entire time.

Avoid this by always reporting queue stats for the maximum number of
queues in the netdevice. Share some of the helper functionality for
adding stats with the PF code in i40e_ethtool_stats.h

This should reduce the chance of potential future bugs, and make adding
new statistics easier.

Note for the queue stats, unlike the PF driver we do not keep an array
of queue pointers, but an array of queues, so care must be taken to
avoid accessing queue memory that hasn't yet been allocated.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 .../net/ethernet/intel/i40evf/i40e_ethtool_stats.h | 221 +++++++++++++++++++++
 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 137 +++++++------
 2 files changed, 298 insertions(+), 60 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/i40evf/i40e_ethtool_stats.h

diff --git a/drivers/net/ethernet/intel/i40evf/i40e_ethtool_stats.h b/drivers/net/ethernet/intel/i40evf/i40e_ethtool_stats.h
new file mode 100644
index 0000000..0aa41d4
--- /dev/null
+++ b/drivers/net/ethernet/intel/i40evf/i40e_ethtool_stats.h
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2013 - 2018 Intel Corporation. */
+
+/* ethtool statistics helpers */
+
+/**
+ * struct i40e_stats - definition for an ethtool statistic
+ * @stat_string: statistic name to display in ethtool -S output
+ * @sizeof_stat: the sizeof() the stat, must be no greater than sizeof(u64)
+ * @stat_offset: offsetof() the stat from a base pointer
+ *
+ * This structure defines a statistic to be added to the ethtool stats buffer.
+ * It defines a statistic as offset from a common base pointer. Stats should
+ * be defined in constant arrays using the I40E_STAT macro, with every element
+ * of the array using the same _type for calculating the sizeof_stat and
+ * stat_offset.
+ *
+ * The @sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or
+ * sizeof(u64). Other sizes are not expected and will produce a WARN_ONCE from
+ * the i40e_add_ethtool_stat() helper function.
+ *
+ * The @stat_string is interpreted as a format string, allowing formatted
+ * values to be inserted while looping over multiple structures for a given
+ * statistics array. Thus, every statistic string in an array should have the
+ * same type and number of format specifiers, to be formatted by variadic
+ * arguments to the i40e_add_stat_string() helper function.
+ **/
+struct i40e_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
+};
+
+/* Helper macro to define an i40e_stat structure with proper size and type.
+ * Use this when defining constant statistics arrays. Note that @_type expects
+ * only a type name and is used multiple times.
+ */
+#define I40E_STAT(_type, _name, _stat) { \
+	.stat_string = _name, \
+	.sizeof_stat = FIELD_SIZEOF(_type, _stat), \
+	.stat_offset = offsetof(_type, _stat) \
+}
+
+/* Helper macro for defining some statistics directly copied from the netdev
+ * stats structure.
+ */
+#define I40E_NETDEV_STAT(_net_stat) \
+	I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
+
+/* Helper macro for defining some statistics related to queues */
+#define I40E_QUEUE_STAT(_name, _stat) \
+	I40E_STAT(struct i40e_ring, _name, _stat)
+
+/* Stats associated with a Tx or Rx ring */
+static const struct i40e_stats i40e_gstrings_queue_stats[] = {
+	I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
+	I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
+};
+
+/**
+ * i40evf_add_one_ethtool_stat - copy the stat into the supplied buffer
+ * @data: location to store the stat value
+ * @pointer: basis for where to copy from
+ * @stat: the stat definition
+ *
+ * Copies the stat data defined by the pointer and stat structure pair into
+ * the memory supplied as data. Used to implement i40e_add_ethtool_stats and
+ * i40evf_add_queue_stats. If the pointer is null, data will be zero'd.
+ */
+static inline void
+i40evf_add_one_ethtool_stat(u64 *data, void *pointer,
+			  const struct i40e_stats *stat)
+{
+	char *p;
+
+	if (!pointer) {
+		/* ensure that the ethtool data buffer is zero'd for any stats
+		 * which don't have a valid pointer.
+		 */
+		*data = 0;
+		return;
+	}
+
+	p = (char *)pointer + stat->stat_offset;
+	switch (stat->sizeof_stat) {
+	case sizeof(u64):
+		*data = *((u64 *)p);
+		break;
+	case sizeof(u32):
+		*data = *((u32 *)p);
+		break;
+	case sizeof(u16):
+		*data = *((u16 *)p);
+		break;
+	case sizeof(u8):
+		*data = *((u8 *)p);
+		break;
+	default:
+		WARN_ONCE(1, "unexpected stat size for %s",
+			  stat->stat_string);
+		*data = 0;
+	}
+}
+
+/**
+ * __i40evf_add_ethtool_stats - copy stats into the ethtool supplied buffer
+ * @data: ethtool stats buffer
+ * @pointer: location to copy stats from
+ * @stats: array of stats to copy
+ * @size: the size of the stats definition
+ *
+ * Copy the stats defined by the stats array using the pointer as a base into
+ * the data buffer supplied by ethtool. Updates the data pointer to point to
+ * the next empty location for successive calls to __i40evf_add_ethtool_stats.
+ * If pointer is null, set the data values to zero and update the pointer to
+ * skip these stats.
+ **/
+static inline void
+__i40evf_add_ethtool_stats(u64 **data, void *pointer,
+			 const struct i40e_stats stats[],
+			 const unsigned int size)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; i++)
+		i40evf_add_one_ethtool_stat((*data)++, pointer, &stats[i]);
+}
+
+/**
+ * i40e_add_ethtool_stats - copy stats into ethtool supplied buffer
+ * @data: ethtool stats buffer
+ * @pointer: location where stats are stored
+ * @stats: static const array of stat definitions
+ *
+ * Macro to ease the use of __i40evf_add_ethtool_stats by taking a static
+ * constant stats array and passing the ARRAY_SIZE(). This avoids typos by
+ * ensuring that we pass the size associated with the given stats array.
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided.
+ **/
+#define i40e_add_ethtool_stats(data, pointer, stats) \
+	__i40evf_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
+
+/**
+ * i40evf_add_queue_stats - copy queue statistics into supplied buffer
+ * @data: ethtool stats buffer
+ * @ring: the ring to copy
+ *
+ * Queue statistics must be copied while protected by
+ * u64_stats_fetch_begin_irq, so we can't directly use i40e_add_ethtool_stats.
+ * Assumes that queue stats are defined in i40e_gstrings_queue_stats. If the
+ * ring pointer is null, zero out the queue stat values and update the data
+ * pointer. Otherwise safely copy the stats from the ring into the supplied
+ * buffer and update the data pointer when finished.
+ *
+ * This function expects to be called while under rcu_read_lock().
+ **/
+static inline void
+i40evf_add_queue_stats(u64 **data, struct i40e_ring *ring)
+{
+	const unsigned int size = ARRAY_SIZE(i40e_gstrings_queue_stats);
+	const struct i40e_stats *stats = i40e_gstrings_queue_stats;
+	unsigned int start;
+	unsigned int i;
+
+	/* To avoid invalid statistics values, ensure that we keep retrying
+	 * the copy until we get a consistent value according to
+	 * u64_stats_fetch_retry_irq. But first, make sure our ring is
+	 * non-null before attempting to access its syncp.
+	 */
+	do {
+		start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp);
+		for (i = 0; i < size; i++) {
+			i40evf_add_one_ethtool_stat(&(*data)[i], ring,
+						  &stats[i]);
+		}
+	} while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start));
+
+	/* Once we successfully copy the stats in, update the data pointer */
+	*data += size;
+}
+
+/**
+ * __i40e_add_stat_strings - copy stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ * @size: size of the stats array
+ *
+ * Format and copy the strings described by stats into the buffer pointed at
+ * by p.
+ **/
+static void __i40e_add_stat_strings(u8 **p, const struct i40e_stats stats[],
+				    const unsigned int size, ...)
+{
+	unsigned int i;
+
+	for (i = 0; i < size; i++) {
+		va_list args;
+
+		va_start(args, size);
+		vsnprintf(*p, ETH_GSTRING_LEN, stats[i].stat_string, args);
+		*p += ETH_GSTRING_LEN;
+		va_end(args);
+	}
+}
+
+/**
+ * 40e_add_stat_strings - copy stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ *
+ * Format and copy the strings described by the const static stats value into
+ * the buffer pointed@by p.
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided. Additionally, stats must be an array such that
+ * ARRAY_SIZE can be called on it.
+ **/
+#define i40e_add_stat_strings(p, stats, ...) \
+	__i40e_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
index 69efe0a..9319971 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
@@ -6,18 +6,12 @@
 
 #include <linux/uaccess.h>
 
-struct i40evf_stats {
-	char stat_string[ETH_GSTRING_LEN];
-	int stat_offset;
-};
+#include "i40e_ethtool_stats.h"
 
-#define I40EVF_STAT(_name, _stat) { \
-	.stat_string = _name, \
-	.stat_offset = offsetof(struct i40evf_adapter, _stat) \
-}
+#define I40EVF_STAT(_name, _stat) \
+	I40E_STAT(struct i40evf_adapter, _name, _stat)
 
-/* All stats are u64, so we don't need to track the size of the field. */
-static const struct i40evf_stats i40evf_gstrings_stats[] = {
+static const struct i40e_stats i40evf_gstrings_stats[] = {
 	I40EVF_STAT("rx_bytes", current_stats.rx_bytes),
 	I40EVF_STAT("rx_unicast", current_stats.rx_unicast),
 	I40EVF_STAT("rx_multicast", current_stats.rx_multicast),
@@ -32,13 +26,9 @@ static const struct i40evf_stats i40evf_gstrings_stats[] = {
 	I40EVF_STAT("tx_errors", current_stats.tx_errors),
 };
 
-#define I40EVF_GLOBAL_STATS_LEN ARRAY_SIZE(i40evf_gstrings_stats)
-#define I40EVF_QUEUE_STATS_LEN(_dev) \
-	(((struct i40evf_adapter *)\
-		netdev_priv(_dev))->num_active_queues \
-		  * 2 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
-#define I40EVF_STATS_LEN(_dev) \
-	(I40EVF_GLOBAL_STATS_LEN + I40EVF_QUEUE_STATS_LEN(_dev))
+#define I40EVF_STATS_LEN	ARRAY_SIZE(i40evf_gstrings_stats)
+
+#define I40EVF_QUEUE_STATS_LEN	ARRAY_SIZE(i40e_gstrings_queue_stats)
 
 /* For now we have one and only one private flag and it is only defined
  * when we have support for the SKIP_CPU_SYNC DMA attribute.  Instead
@@ -117,13 +107,13 @@ static int i40evf_get_link_ksettings(struct net_device *netdev,
  * @netdev: network interface device structure
  * @sset: id of string set
  *
- * Reports size of string table. This driver only supports
- * strings for statistics.
+ * Reports size of various string tables.
  **/
 static int i40evf_get_sset_count(struct net_device *netdev, int sset)
 {
 	if (sset == ETH_SS_STATS)
-		return I40EVF_STATS_LEN(netdev);
+		return I40EVF_STATS_LEN +
+			(I40EVF_QUEUE_STATS_LEN * 2 * I40EVF_MAX_REQ_QUEUES);
 	else if (sset == ETH_SS_PRIV_FLAGS)
 		return I40EVF_PRIV_FLAGS_STR_LEN;
 	else
@@ -142,20 +132,66 @@ static void i40evf_get_ethtool_stats(struct net_device *netdev,
 				     struct ethtool_stats *stats, u64 *data)
 {
 	struct i40evf_adapter *adapter = netdev_priv(netdev);
-	unsigned int i, j;
-	char *p;
+	unsigned int i;
+
+	i40e_add_ethtool_stats(&data, adapter, i40evf_gstrings_stats);
+
+	rcu_read_lock();
+	for (i = 0; i < I40EVF_MAX_REQ_QUEUES; i++) {
+		struct i40e_ring *ring;
 
-	for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) {
-		p = (char *)adapter + i40evf_gstrings_stats[i].stat_offset;
-		data[i] =  *(u64 *)p;
+		/* Avoid accessing un-allocated queues */
+		ring = (i < adapter->num_active_queues ?
+			&adapter->tx_rings[i] : NULL);
+		i40evf_add_queue_stats(&data, ring);
+
+		/* Avoid accessing un-allocated queues */
+		ring = (i < adapter->num_active_queues ?
+			&adapter->rx_rings[i] : NULL);
+		i40evf_add_queue_stats(&data, ring);
 	}
-	for (j = 0; j < adapter->num_active_queues; j++) {
-		data[i++] = adapter->tx_rings[j].stats.packets;
-		data[i++] = adapter->tx_rings[j].stats.bytes;
+	rcu_read_unlock();
+}
+
+/**
+ * i40evf_get_priv_flag_strings - Get private flag strings
+ * @netdev: network interface device structure
+ * @data: buffer for string data
+ *
+ * Builds the private flags string table
+ **/
+static void i40evf_get_priv_flag_strings(struct net_device *netdev, u8 *data)
+{
+	unsigned int i;
+
+	for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
+		snprintf(data, ETH_GSTRING_LEN, "%s",
+			 i40evf_gstrings_priv_flags[i].flag_string);
+		data += ETH_GSTRING_LEN;
 	}
-	for (j = 0; j < adapter->num_active_queues; j++) {
-		data[i++] = adapter->rx_rings[j].stats.packets;
-		data[i++] = adapter->rx_rings[j].stats.bytes;
+}
+
+/**
+ * i40evf_get_stat_strings - Get stat strings
+ * @netdev: network interface device structure
+ * @data: buffer for string data
+ *
+ * Builds the statistics string table
+ **/
+static void i40evf_get_stat_strings(struct net_device *netdev, u8 *data)
+{
+	unsigned int i;
+
+	i40e_add_stat_strings(&data, i40evf_gstrings_stats);
+
+	/* Queues are always allocated in pairs, so we just use num_tx_queues
+	 * for both Tx and Rx queues.
+	 */
+	for (i = 0; i < netdev->num_tx_queues; i++) {
+		i40e_add_stat_strings(&data, i40e_gstrings_queue_stats,
+				      "tx", i);
+		i40e_add_stat_strings(&data, i40e_gstrings_queue_stats,
+				      "rx", i);
 	}
 }
 
@@ -165,38 +201,19 @@ static void i40evf_get_ethtool_stats(struct net_device *netdev,
  * @sset: id of string set
  * @data: buffer for string data
  *
- * Builds stats string table.
+ * Builds string tables for various string sets
  **/
 static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
 {
-	struct i40evf_adapter *adapter = netdev_priv(netdev);
-	u8 *p = data;
-	int i;
-
-	if (sset == ETH_SS_STATS) {
-		for (i = 0; i < (int)I40EVF_GLOBAL_STATS_LEN; i++) {
-			memcpy(p, i40evf_gstrings_stats[i].stat_string,
-			       ETH_GSTRING_LEN);
-			p += ETH_GSTRING_LEN;
-		}
-		for (i = 0; i < adapter->num_active_queues; i++) {
-			snprintf(p, ETH_GSTRING_LEN, "tx-%u.packets", i);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "tx-%u.bytes", i);
-			p += ETH_GSTRING_LEN;
-		}
-		for (i = 0; i < adapter->num_active_queues; i++) {
-			snprintf(p, ETH_GSTRING_LEN, "rx-%u.packets", i);
-			p += ETH_GSTRING_LEN;
-			snprintf(p, ETH_GSTRING_LEN, "rx-%u.bytes", i);
-			p += ETH_GSTRING_LEN;
-		}
-	} else if (sset == ETH_SS_PRIV_FLAGS) {
-		for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
-			snprintf(p, ETH_GSTRING_LEN, "%s",
-				 i40evf_gstrings_priv_flags[i].flag_string);
-			p += ETH_GSTRING_LEN;
-		}
+	switch (sset) {
+	case ETH_SS_STATS:
+		i40evf_get_stat_strings(netdev, data);
+		break;
+	case ETH_SS_PRIV_FLAGS:
+		i40evf_get_priv_flag_strings(netdev, data);
+		break;
+	default:
+		break;
 	}
 }
 
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (2 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:29   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings Alice Michael
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Pawe? Jab?o?ski <pawel.jablonski@intel.com> <pawel.jablonski@intel.com>

Add possibility to change a VF mac address from host side
without reloading the VF driver on the guest side. Without
this patch it is not possible to change the VF mac because
executing i40evf_virtchnl_completion function with
VIRTCHNL_OP_GET_VF_RESOURCES opcode resets the VF mac
address to previous value.

Signed-off-by: Pawe? Jab?o?ski <pawel.jablonski@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c  |  8 +++++---
 drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 11 +++++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index c6d24ea..f56c645 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2458,7 +2458,7 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf,
 		    !is_multicast_ether_addr(addr) && vf->pf_set_mac &&
 		    !ether_addr_equal(addr, vf->default_lan_addr.addr)) {
 			dev_err(&pf->pdev->dev,
-				"VF attempting to override administratively set MAC address, reload the VF driver to resume normal operation\n");
+				"VF attempting to override administratively set MAC address, bring down and up the VF interface to resume normal operation\n");
 			return -EPERM;
 		}
 	}
@@ -3873,9 +3873,11 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 			 mac, vf_id);
 	}
 
-	/* Force the VF driver stop so it has to reload with new MAC address */
+	/* Force the VF interface down so it has to bring up with new MAC
+	 * address
+	 */
 	i40e_vc_disable_vf(vf);
-	dev_info(&pf->pdev->dev, "Reload the VF driver to make this change effective.\n");
+	dev_info(&pf->pdev->dev, "Bring down and up the VF interface to make this change effective.\n");
 
 error_param:
 	return ret;
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index 565677d..79b7be8 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -1330,8 +1330,15 @@ void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
 			  sizeof(struct virtchnl_vsi_resource);
 		memcpy(adapter->vf_res, msg, min(msglen, len));
 		i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
-		/* restore current mac address */
-		ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
+		if (is_zero_ether_addr(adapter->hw.mac.addr)) {
+			/* restore current mac address */
+			ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
+		} else {
+			/* refresh current mac address if changed */
+			ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
+			ether_addr_copy(netdev->perm_addr,
+					adapter->hw.mac.addr);
+		}
 		i40evf_process_config(adapter);
 		}
 		break;
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (3 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:36   ` Bowers, AndrewX
  2018-08-24  1:50   ` Mauro Rodrigues
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset Alice Michael
                   ` (7 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Jacob Keller <jacob.e.keller@intel.com>

Commit 9b10df596bd4 ("i40e: use WARN_ONCE to replace the commented
BUG_ON size check") introduced a warning check to make sure
that the size of the stat strings was always the expected value. This
code accidentally inverted the check of the data pointer. Fix this so
that we accurately count the size of the stats we copied in.

This fixes an erroneous WARN kernel splat that occurs when requesting
ethtool statistics.

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

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index ecc30524..3ef9069 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1863,7 +1863,7 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
 	for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
 		i40e_add_stat_strings(&data, i40e_gstrings_pfc_stats, i);
 
-	WARN_ONCE(p - data != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN,
+	WARN_ONCE(data - p != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN,
 		  "stat strings count mismatch!");
 }
 
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (4 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 16:28   ` Shannon Nelson
  2018-08-29 20:53   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends Alice Michael
                   ` (6 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Mariusz Stachura <mariusz.stachura@intel.com>

This patch cleans up promiscuous configuration when a VF reset occurs.
Previously the promiscuous mode settings were still there after the VF
driver removal.

Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 267 ++++++++++++---------
 1 file changed, 157 insertions(+), 110 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index f56c645..ca423be 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -1084,6 +1084,136 @@ static int i40e_quiesce_vf_pci(struct i40e_vf *vf)
 	return -EIO;
 }
 
+static inline int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi);
+
+/**
+ * i40e_config_vf_promiscuous_mode
+ * @vf: pointer to the VF info
+ * @vsi_id: VSI id
+ * @allmulti: set MAC L2 layer multicast promiscuous enable/disable
+ * @alluni: set MAC L2 layer unicast promiscuous enable/disable
+ *
+ * Called from the VF to configure the promiscuous mode of
+ * VF vsis and from the VF reset path to reset promiscuous mode.
+ **/
+static i40e_status i40e_config_vf_promiscuous_mode(struct i40e_vf *vf,
+						   u16 vsi_id,
+						   bool allmulti,
+						   bool alluni)
+{
+	i40e_status aq_ret = 0;
+	struct i40e_pf *pf = vf->pf;
+	struct i40e_hw *hw = &pf->hw;
+	struct i40e_mac_filter *f;
+	struct i40e_vsi *vsi;
+	int bkt;
+
+	vsi = i40e_find_vsi_from_id(pf, vsi_id);
+	if (!i40e_vc_isvalid_vsi_id(vf, vsi_id) || !vsi)
+		return I40E_ERR_PARAM;
+
+	if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
+		dev_err(&pf->pdev->dev,
+			"Unprivileged VF %d is attempting to configure promiscuous mode\n",
+			vf->vf_id);
+		/* Lie to the VF on purpose. */
+		return 0;
+	}
+
+	if (vf->port_vlan_id) {
+		aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, vsi->seid,
+							    allmulti,
+							    vf->port_vlan_id,
+							    NULL);
+		if (aq_ret) {
+			int aq_err = pf->hw.aq.asq_last_status;
+
+			dev_err(&pf->pdev->dev,
+				"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
+				vf->vf_id,
+				i40e_stat_str(&pf->hw, aq_ret),
+				i40e_aq_str(&pf->hw, aq_err));
+			return aq_ret;
+		}
+
+		aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, vsi->seid,
+							    alluni,
+							    vf->port_vlan_id,
+							    NULL);
+		if (aq_ret) {
+			int aq_err = pf->hw.aq.asq_last_status;
+
+			dev_err(&pf->pdev->dev,
+				"VF %d failed to set unicast promiscuous mode err %s aq_err %s\n",
+				vf->vf_id,
+				i40e_stat_str(&pf->hw, aq_ret),
+				i40e_aq_str(&pf->hw, aq_err));
+		}
+		return aq_ret;
+	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
+		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
+			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
+				continue;
+			aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw,
+								    vsi->seid,
+								    allmulti,
+								    f->vlan,
+								    NULL);
+			if (aq_ret) {
+				int aq_err = pf->hw.aq.asq_last_status;
+
+				dev_err(&pf->pdev->dev,
+					"Could not add VLAN %d to multicast promiscuous domain err %s aq_err %s\n",
+					f->vlan,
+					i40e_stat_str(&pf->hw, aq_ret),
+					i40e_aq_str(&pf->hw, aq_err));
+			}
+
+			aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
+								    vsi->seid,
+								    alluni,
+								    f->vlan,
+								    NULL);
+			if (aq_ret) {
+				int aq_err = pf->hw.aq.asq_last_status;
+
+				dev_err(&pf->pdev->dev,
+					"Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n",
+					f->vlan,
+					i40e_stat_str(&pf->hw, aq_ret),
+					i40e_aq_str(&pf->hw, aq_err));
+			}
+		}
+		return aq_ret;
+	}
+	aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, allmulti,
+						       NULL);
+	if (aq_ret) {
+		int aq_err = pf->hw.aq.asq_last_status;
+
+		dev_err(&pf->pdev->dev,
+			"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
+			vf->vf_id,
+			i40e_stat_str(&pf->hw, aq_ret),
+			i40e_aq_str(&pf->hw, aq_err));
+		return aq_ret;
+	}
+
+	aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid, alluni,
+						     NULL, true);
+	if (aq_ret) {
+		int aq_err = pf->hw.aq.asq_last_status;
+
+		dev_err(&pf->pdev->dev,
+			"VF %d failed to set unicast promiscuous mode err %s aq_err %s\n",
+			vf->vf_id,
+			i40e_stat_str(&pf->hw, aq_ret),
+			i40e_aq_str(&pf->hw, aq_err));
+	}
+
+	return aq_ret;
+}
+
 /**
  * i40e_trigger_vf_reset
  * @vf: pointer to the VF structure
@@ -1145,6 +1275,9 @@ static void i40e_cleanup_reset_vf(struct i40e_vf *vf)
 	struct i40e_hw *hw = &pf->hw;
 	u32 reg;
 
+	/* disable promisc modes in case they were enabled */
+	i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, false, false);
+
 	/* free VF resources to begin resetting the VSI state */
 	i40e_free_vf_res(vf);
 
@@ -1851,132 +1984,46 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
 	struct virtchnl_promisc_info *info =
 	    (struct virtchnl_promisc_info *)msg;
 	struct i40e_pf *pf = vf->pf;
-	struct i40e_hw *hw = &pf->hw;
-	struct i40e_mac_filter *f;
 	i40e_status aq_ret = 0;
 	bool allmulti = false;
-	struct i40e_vsi *vsi;
 	bool alluni = false;
-	int aq_err = 0;
-	int bkt;
 
-	vsi = i40e_find_vsi_from_id(pf, info->vsi_id);
-	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
-	    !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) ||
-	    !vsi) {
-		aq_ret = I40E_ERR_PARAM;
-		goto error_param;
-	}
-	if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
-		dev_err(&pf->pdev->dev,
-			"Unprivileged VF %d is attempting to configure promiscuous mode\n",
-			vf->vf_id);
-		/* Lie to the VF on purpose. */
-		aq_ret = 0;
-		goto error_param;
-	}
+	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
+		return I40E_ERR_PARAM;
+
 	/* Multicast promiscuous handling*/
 	if (info->flags & FLAG_VF_MULTICAST_PROMISC)
 		allmulti = true;
 
-	if (vf->port_vlan_id) {
-		aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, vsi->seid,
-							    allmulti,
-							    vf->port_vlan_id,
-							    NULL);
-	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
-		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
-			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
-				continue;
-			aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw,
-								    vsi->seid,
-								    allmulti,
-								    f->vlan,
-								    NULL);
-			aq_err = pf->hw.aq.asq_last_status;
-			if (aq_ret) {
-				dev_err(&pf->pdev->dev,
-					"Could not add VLAN %d to multicast promiscuous domain err %s aq_err %s\n",
-					f->vlan,
-					i40e_stat_str(&pf->hw, aq_ret),
-					i40e_aq_str(&pf->hw, aq_err));
-				break;
-			}
-		}
-	} else {
-		aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid,
-							       allmulti, NULL);
-		aq_err = pf->hw.aq.asq_last_status;
-		if (aq_ret) {
-			dev_err(&pf->pdev->dev,
-				"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
-				vf->vf_id,
-				i40e_stat_str(&pf->hw, aq_ret),
-				i40e_aq_str(&pf->hw, aq_err));
-			goto error_param;
-		}
-	}
-
+	if (info->flags & FLAG_VF_UNICAST_PROMISC)
+		alluni = true;
+	aq_ret = i40e_config_vf_promiscuous_mode(vf, info->vsi_id, allmulti,
+						 alluni);
 	if (!aq_ret) {
-		dev_info(&pf->pdev->dev,
-			 "VF %d successfully set multicast promiscuous mode\n",
-			 vf->vf_id);
-		if (allmulti)
+		if (allmulti) {
+			dev_info(&pf->pdev->dev,
+				 "VF %d successfully set multicast promiscuous mode\n",
+				 vf->vf_id);
 			set_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
-		else
+		} else {
+			dev_info(&pf->pdev->dev,
+				 "VF %d successfully unset multicast promiscuous mode\n",
+				 vf->vf_id);
 			clear_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
-	}
-
-	if (info->flags & FLAG_VF_UNICAST_PROMISC)
-		alluni = true;
-	if (vf->port_vlan_id) {
-		aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, vsi->seid,
-							    alluni,
-							    vf->port_vlan_id,
-							    NULL);
-	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
-		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
-			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
-				continue;
-			aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
-								    vsi->seid,
-								    alluni,
-								    f->vlan,
-								    NULL);
-			aq_err = pf->hw.aq.asq_last_status;
-			if (aq_ret)
-				dev_err(&pf->pdev->dev,
-					"Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n",
-					f->vlan,
-					i40e_stat_str(&pf->hw, aq_ret),
-					i40e_aq_str(&pf->hw, aq_err));
 		}
-	} else {
-		aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
-							     alluni, NULL,
-							     true);
-		aq_err = pf->hw.aq.asq_last_status;
-		if (aq_ret) {
-			dev_err(&pf->pdev->dev,
-				"VF %d failed to set unicast promiscuous mode %8.8x err %s aq_err %s\n",
-				vf->vf_id, info->flags,
-				i40e_stat_str(&pf->hw, aq_ret),
-				i40e_aq_str(&pf->hw, aq_err));
-			goto error_param;
-		}
-	}
-
-	if (!aq_ret) {
-		dev_info(&pf->pdev->dev,
-			 "VF %d successfully set unicast promiscuous mode\n",
-			 vf->vf_id);
-		if (alluni)
+		if (alluni) {
+			dev_info(&pf->pdev->dev,
+				 "VF %d successfully set unicast promiscuous mode\n",
+				 vf->vf_id);
 			set_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
-		else
+		} else {
+			dev_info(&pf->pdev->dev,
+				 "VF %d successfully unset unicast promiscuous mode\n",
+				 vf->vf_id);
 			clear_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
+		}
 	}
 
-error_param:
 	/* send the response to the VF */
 	return i40e_vc_send_resp_to_vf(vf,
 				       VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (5 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-29 20:54   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy Alice Michael
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>

A PF can send any number of queues to the VF and the VF may not
be able to support that many. Check to see that the number of
queues is less than or equal to the max number of queues the
VF can have.

Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
---
 .../net/ethernet/intel/i40evf/i40evf_virtchnl.c    | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index 79b7be8..6579dab 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -154,6 +154,32 @@ int i40evf_send_vf_config_msg(struct i40evf_adapter *adapter)
 }
 
 /**
+ * i40evf_validate_num_queues
+ * @adapter: adapter structure
+ *
+ * Validate that the number of queues the PF has sent in
+ * VIRTCHNL_OP_GET_VF_RESOURCES is not larger than the VF can handle.
+ **/
+static void i40evf_validate_num_queues(struct i40evf_adapter *adapter)
+{
+	if (adapter->vf_res->num_queue_pairs > I40EVF_MAX_REQ_QUEUES) {
+		struct virtchnl_vsi_resource *vsi_res;
+		int i;
+
+		dev_info(&adapter->pdev->dev, "Received %d queues, but can only have a max of %d\n",
+			 adapter->vf_res->num_queue_pairs,
+			 I40EVF_MAX_REQ_QUEUES);
+		dev_info(&adapter->pdev->dev, "Fixing by reducing queues to %d\n",
+			 I40EVF_MAX_REQ_QUEUES);
+		adapter->vf_res->num_queue_pairs = I40EVF_MAX_REQ_QUEUES;
+		for (i = 0; i < adapter->vf_res->num_vsis; i++) {
+			vsi_res = &adapter->vf_res->vsi_res[i];
+			vsi_res->num_queue_pairs = I40EVF_MAX_REQ_QUEUES;
+		}
+	}
+}
+
+/**
  * i40evf_get_vf_config
  * @adapter: private adapter structure
  *
@@ -195,6 +221,11 @@ int i40evf_get_vf_config(struct i40evf_adapter *adapter)
 	err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
 	memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
 
+	/* some PFs send more queues than we should have so validate that
+	 * we aren't getting too many queues
+	 */
+	if (!err)
+		i40evf_validate_num_queues(adapter);
 	i40e_vf_parse_hw_config(hw, adapter->vf_res);
 out_alloc:
 	kfree(event.msg_buf);
@@ -1329,6 +1360,7 @@ void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
 			  I40E_MAX_VF_VSI *
 			  sizeof(struct virtchnl_vsi_resource);
 		memcpy(adapter->vf_res, msg, min(msglen, len));
+		i40evf_validate_num_queues(adapter);
 		i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
 		if (is_zero_ether_addr(adapter->hw.mac.addr)) {
 			/* restore current mac address */
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (6 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 16:28   ` Shannon Nelson
  2018-08-23 16:11   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf Alice Michael
                   ` (4 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Mitch Williams <mitch.a.williams@intel.com>

Caught by gcc 8. When we provide a length for strncpy, we should not
include the terminating null. So we must tell it one less than the size
of the destination buffer.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index 35f2866..1199f05 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -694,7 +694,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
 	if (!IS_ERR_OR_NULL(pf->ptp_clock))
 		return 0;
 
-	strncpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name));
+	strncpy(pf->ptp_caps.name, i40e_driver_name,
+		sizeof(pf->ptp_caps.name) - 1);
 	pf->ptp_caps.owner = THIS_MODULE;
 	pf->ptp_caps.max_adj = 999999999;
 	pf->ptp_caps.n_ext_ts = 0;
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (7 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:41   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct Alice Michael
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Lihong Yang <lihong.yang@intel.com>

Set IFF_UNICAST_FLT flag for the vf to prevent it from entering
promiscuous mode when macvlan is added to the vf.

Signed-off-by: Lihong Yang <lihong.yang@intel.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 5906c1c..07f187b 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -3358,6 +3358,8 @@ int i40evf_process_config(struct i40evf_adapter *adapter)
 	if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)
 		netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 
+	netdev->priv_flags |= IFF_UNICAST_FLT;
+
 	/* Do not turn on offloads when they are requested to be turned off.
 	 * TSO needs minimum 576 bytes to work correctly.
 	 */
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (8 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:41   ` Bowers, AndrewX
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community Alice Michael
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>

The virtchnl_filter struct has a field called field_flags. A previous
commit mistakenly had the type to be a __u8. What we want is for the
field to be an unsigned 8 bit value, so let's just use the existing
kernel type u8 for that.

Signed-off-by: Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>
---
 include/linux/avf/virtchnl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/avf/virtchnl.h b/include/linux/avf/virtchnl.h
index 7cd2290..2c9756b 100644
--- a/include/linux/avf/virtchnl.h
+++ b/include/linux/avf/virtchnl.h
@@ -575,7 +575,7 @@ struct virtchnl_filter {
 	enum	virtchnl_flow_type flow_type;
 	enum	virtchnl_action action;
 	u32	action_meta;
-	__u8	field_flags;
+	u8	field_flags;
 };
 
 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (9 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct Alice Michael
@ 2018-08-20 15:12 ` Alice Michael
  2018-08-21 19:42   ` Bowers, AndrewX
  2018-08-21 16:27 ` [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Shannon Nelson
  2018-08-29 20:53 ` Bowers, AndrewX
  12 siblings, 1 reply; 29+ messages in thread
From: Alice Michael @ 2018-08-20 15:12 UTC (permalink / raw)
  To: intel-wired-lan

From: Martyna Szapar <martyna.szapar@intel.com>

Static analysis tools report a problem from original driver submission.
Removing unnecessary check in condition.

Signed-off-by: Martyna Szapar <martyna.szapar@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 969fb93..e40c023 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -13129,7 +13129,7 @@ struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags,
 	for (vsi_idx = 0; vsi_idx < pf->num_alloc_vsi; vsi_idx++)
 		if (pf->vsi[vsi_idx] && pf->vsi[vsi_idx]->seid == vsi_seid)
 			break;
-	if (vsi_idx >= pf->num_alloc_vsi && vsi_seid != 0) {
+	if (vsi_idx == pf->num_alloc_vsi && vsi_seid != 0) {
 		dev_info(&pf->pdev->dev, "vsi seid %d not found\n",
 			 vsi_seid);
 		return NULL;
-- 
2.9.5


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

* [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (10 preceding siblings ...)
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community Alice Michael
@ 2018-08-21 16:27 ` Shannon Nelson
  2018-08-29 20:53 ` Bowers, AndrewX
  12 siblings, 0 replies; 29+ messages in thread
From: Shannon Nelson @ 2018-08-21 16:27 UTC (permalink / raw)
  To: intel-wired-lan

On 8/20/2018 8:12 AM, Alice Michael wrote:
> From: Mariusz Stachura <mariusz.stachura@intel.com>
> 
> This patch moves saving old link status information after the call to
> i40e_get_link_status(). Mentioned function updates both old and the new
> link info, so reading it before results in not notifying VF about the
> PF link state change.

I see that this is removing one instance of saving the current status, 
not moving it to somewhere else.  I see that i40e_aq_get_link_info() is 
also doing the save, not i40e_get_link_status().  I don't see how this 
affects VF notification.  Can you clean up this description and 
elaborate on how the VF notification is involved?

> 
> Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_main.c | 5 -----
>   1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 456c917..969fb93 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -8446,14 +8446,9 @@ static void i40e_link_event(struct i40e_pf *pf)
>   	i40e_status status;
>   	bool new_link, old_link;
>   
> -	/* save off old link status information */
> -	pf->hw.phy.link_info_old = pf->hw.phy.link_info;
> -
>   	/* set this to force the get_link_status call to refresh state */
>   	pf->hw.phy.get_link_info = true;
> -
>   	old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP);

Since link_info_old has not been refreshed yet by 
i40e_aq_get_link_info(), are you sure you are getting the old_link 
status that you want?

sln

> -
>   	status = i40e_get_link_status(&pf->hw, &new_link);
>   
>   	/* On success, disable temp link polling */
> 

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

* [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy Alice Michael
@ 2018-08-21 16:28   ` Shannon Nelson
  2018-08-23 16:11   ` Bowers, AndrewX
  1 sibling, 0 replies; 29+ messages in thread
From: Shannon Nelson @ 2018-08-21 16:28 UTC (permalink / raw)
  To: intel-wired-lan

On 8/20/2018 8:12 AM, Alice Michael wrote:
> From: Mitch Williams <mitch.a.williams@intel.com>
> 
> Caught by gcc 8. When we provide a length for strncpy, we should not
> include the terminating null. So we must tell it one less than the size
> of the destination buffer.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> index 35f2866..1199f05 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> @@ -694,7 +694,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
>   	if (!IS_ERR_OR_NULL(pf->ptp_clock))
>   		return 0;
>   
> -	strncpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name));
> +	strncpy(pf->ptp_caps.name, i40e_driver_name,
> +		sizeof(pf->ptp_caps.name) - 1);

Is there any need to be sure the rest of the name field is zero'd out? 
It looks like maybe not, not sure.

sln

>   	pf->ptp_caps.owner = THIS_MODULE;
>   	pf->ptp_caps.max_adj = 999999999;
>   	pf->ptp_caps.n_ext_ts = 0;
> 

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

* [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset Alice Michael
@ 2018-08-21 16:28   ` Shannon Nelson
  2018-08-29 20:53   ` Bowers, AndrewX
  1 sibling, 0 replies; 29+ messages in thread
From: Shannon Nelson @ 2018-08-21 16:28 UTC (permalink / raw)
  To: intel-wired-lan

On 8/20/2018 8:12 AM, Alice Michael wrote:
> From: Mariusz Stachura <mariusz.stachura@intel.com>
> 
> This patch cleans up promiscuous configuration when a VF reset occurs.
> Previously the promiscuous mode settings were still there after the VF
> driver removal.
> 
> Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 267 ++++++++++++---------
>   1 file changed, 157 insertions(+), 110 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index f56c645..ca423be 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -1084,6 +1084,136 @@ static int i40e_quiesce_vf_pci(struct i40e_vf *vf)
>   	return -EIO;
>   }
>   
> +static inline int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi);
> +
> +/**
> + * i40e_config_vf_promiscuous_mode
> + * @vf: pointer to the VF info
> + * @vsi_id: VSI id
> + * @allmulti: set MAC L2 layer multicast promiscuous enable/disable
> + * @alluni: set MAC L2 layer unicast promiscuous enable/disable
> + *
> + * Called from the VF to configure the promiscuous mode of
> + * VF vsis and from the VF reset path to reset promiscuous mode.
> + **/
> +static i40e_status i40e_config_vf_promiscuous_mode(struct i40e_vf *vf,
> +						   u16 vsi_id,
> +						   bool allmulti,
> +						   bool alluni)
> +{
> +	i40e_status aq_ret = 0;
> +	struct i40e_pf *pf = vf->pf;
> +	struct i40e_hw *hw = &pf->hw;
> +	struct i40e_mac_filter *f;
> +	struct i40e_vsi *vsi;
> +	int bkt;
> +
> +	vsi = i40e_find_vsi_from_id(pf, vsi_id);
> +	if (!i40e_vc_isvalid_vsi_id(vf, vsi_id) || !vsi)
> +		return I40E_ERR_PARAM;
> +
> +	if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
> +		dev_err(&pf->pdev->dev,
> +			"Unprivileged VF %d is attempting to configure promiscuous mode\n",
> +			vf->vf_id);
> +		/* Lie to the VF on purpose. */

Can you explain why in the comment?

> +		return 0;
> +	}
> +
> +	if (vf->port_vlan_id) {
> +		aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, vsi->seid,
> +							    allmulti,
> +							    vf->port_vlan_id,
> +							    NULL);
> +		if (aq_ret) {
> +			int aq_err = pf->hw.aq.asq_last_status;
> +
> +			dev_err(&pf->pdev->dev,
> +				"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
> +				vf->vf_id,
> +				i40e_stat_str(&pf->hw, aq_ret),
> +				i40e_aq_str(&pf->hw, aq_err));
> +			return aq_ret;
> +		}
> +
> +		aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, vsi->seid,
> +							    alluni,
> +							    vf->port_vlan_id,
> +							    NULL);
> +		if (aq_ret) {
> +			int aq_err = pf->hw.aq.asq_last_status;
> +
> +			dev_err(&pf->pdev->dev,
> +				"VF %d failed to set unicast promiscuous mode err %s aq_err %s\n",
> +				vf->vf_id,
> +				i40e_stat_str(&pf->hw, aq_ret),
> +				i40e_aq_str(&pf->hw, aq_err));

If uc_promisc fails, perhaps you should undo the mc_promisc change?  Of 
course, you might need to find out what it was before you set it to see 
if there was a change requested.

> +		}
> +		return aq_ret;
> +	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
> +		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
> +			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
> +				continue;
> +			aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw,
> +								    vsi->seid,
> +								    allmulti,
> +								    f->vlan,
> +								    NULL);
> +			if (aq_ret) {
> +				int aq_err = pf->hw.aq.asq_last_status;
> +
> +				dev_err(&pf->pdev->dev,
> +					"Could not add VLAN %d to multicast promiscuous domain err %s aq_err %s\n",
> +					f->vlan,
> +					i40e_stat_str(&pf->hw, aq_ret),
> +					i40e_aq_str(&pf->hw, aq_err));
> +			}
> +
> +			aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
> +								    vsi->seid,
> +								    alluni,
> +								    f->vlan,
> +								    NULL);
> +			if (aq_ret) {
> +				int aq_err = pf->hw.aq.asq_last_status;
> +
> +				dev_err(&pf->pdev->dev,
> +					"Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n",
> +					f->vlan,
> +					i40e_stat_str(&pf->hw, aq_ret),
> +					i40e_aq_str(&pf->hw, aq_err));

Undo the mc_promisc change?

> +			}
> +		}
> +		return aq_ret;
> +	}
> +	aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, allmulti,
> +						       NULL);
> +	if (aq_ret) {
> +		int aq_err = pf->hw.aq.asq_last_status;
> +
> +		dev_err(&pf->pdev->dev,
> +			"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
> +			vf->vf_id,
> +			i40e_stat_str(&pf->hw, aq_ret),
> +			i40e_aq_str(&pf->hw, aq_err));
> +		return aq_ret;
> +	}
> +
> +	aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid, alluni,
> +						     NULL, true);
> +	if (aq_ret) {
> +		int aq_err = pf->hw.aq.asq_last_status;
> +
> +		dev_err(&pf->pdev->dev,
> +			"VF %d failed to set unicast promiscuous mode err %s aq_err %s\n",
> +			vf->vf_id,
> +			i40e_stat_str(&pf->hw, aq_ret),
> +			i40e_aq_str(&pf->hw, aq_err));

Undo the mc_promisc change?

> +	}
> +
> +	return aq_ret;
> +}
> +
>   /**
>    * i40e_trigger_vf_reset
>    * @vf: pointer to the VF structure
> @@ -1145,6 +1275,9 @@ static void i40e_cleanup_reset_vf(struct i40e_vf *vf)
>   	struct i40e_hw *hw = &pf->hw;
>   	u32 reg;
>   
> +	/* disable promisc modes in case they were enabled */
> +	i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, false, false);
> +
>   	/* free VF resources to begin resetting the VSI state */
>   	i40e_free_vf_res(vf);
>   
> @@ -1851,132 +1984,46 @@ static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf,
>   	struct virtchnl_promisc_info *info =
>   	    (struct virtchnl_promisc_info *)msg;
>   	struct i40e_pf *pf = vf->pf;
> -	struct i40e_hw *hw = &pf->hw;
> -	struct i40e_mac_filter *f;
>   	i40e_status aq_ret = 0;
>   	bool allmulti = false;
> -	struct i40e_vsi *vsi;
>   	bool alluni = false;
> -	int aq_err = 0;
> -	int bkt;
>   
> -	vsi = i40e_find_vsi_from_id(pf, info->vsi_id);
> -	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
> -	    !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) ||
> -	    !vsi) {
> -		aq_ret = I40E_ERR_PARAM;
> -		goto error_param;
> -	}
> -	if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
> -		dev_err(&pf->pdev->dev,
> -			"Unprivileged VF %d is attempting to configure promiscuous mode\n",
> -			vf->vf_id);
> -		/* Lie to the VF on purpose. */
> -		aq_ret = 0;
> -		goto error_param;
> -	}
> +	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states))
> +		return I40E_ERR_PARAM;
> +
>   	/* Multicast promiscuous handling*/
>   	if (info->flags & FLAG_VF_MULTICAST_PROMISC)
>   		allmulti = true;
>   
> -	if (vf->port_vlan_id) {
> -		aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, vsi->seid,
> -							    allmulti,
> -							    vf->port_vlan_id,
> -							    NULL);
> -	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
> -		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
> -			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
> -				continue;
> -			aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw,
> -								    vsi->seid,
> -								    allmulti,
> -								    f->vlan,
> -								    NULL);
> -			aq_err = pf->hw.aq.asq_last_status;
> -			if (aq_ret) {
> -				dev_err(&pf->pdev->dev,
> -					"Could not add VLAN %d to multicast promiscuous domain err %s aq_err %s\n",
> -					f->vlan,
> -					i40e_stat_str(&pf->hw, aq_ret),
> -					i40e_aq_str(&pf->hw, aq_err));
> -				break;
> -			}
> -		}
> -	} else {
> -		aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid,
> -							       allmulti, NULL);
> -		aq_err = pf->hw.aq.asq_last_status;
> -		if (aq_ret) {
> -			dev_err(&pf->pdev->dev,
> -				"VF %d failed to set multicast promiscuous mode err %s aq_err %s\n",
> -				vf->vf_id,
> -				i40e_stat_str(&pf->hw, aq_ret),
> -				i40e_aq_str(&pf->hw, aq_err));
> -			goto error_param;
> -		}
> -	}
> -
> +	if (info->flags & FLAG_VF_UNICAST_PROMISC)
> +		alluni = true;
> +	aq_ret = i40e_config_vf_promiscuous_mode(vf, info->vsi_id, allmulti,
> +						 alluni);
>   	if (!aq_ret) {
> -		dev_info(&pf->pdev->dev,
> -			 "VF %d successfully set multicast promiscuous mode\n",
> -			 vf->vf_id);
> -		if (allmulti)
> +		if (allmulti) {
> +			dev_info(&pf->pdev->dev,
> +				 "VF %d successfully set multicast promiscuous mode\n",
> +				 vf->vf_id);
>   			set_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
> -		else
> +		} else {
> +			dev_info(&pf->pdev->dev,
> +				 "VF %d successfully unset multicast promiscuous mode\n",
> +				 vf->vf_id);
>   			clear_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states);
> -	}
> -
> -	if (info->flags & FLAG_VF_UNICAST_PROMISC)
> -		alluni = true;
> -	if (vf->port_vlan_id) {
> -		aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, vsi->seid,
> -							    alluni,
> -							    vf->port_vlan_id,
> -							    NULL);
> -	} else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) {
> -		hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
> -			if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID)
> -				continue;
> -			aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw,
> -								    vsi->seid,
> -								    alluni,
> -								    f->vlan,
> -								    NULL);
> -			aq_err = pf->hw.aq.asq_last_status;
> -			if (aq_ret)
> -				dev_err(&pf->pdev->dev,
> -					"Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n",
> -					f->vlan,
> -					i40e_stat_str(&pf->hw, aq_ret),
> -					i40e_aq_str(&pf->hw, aq_err));
>   		}
> -	} else {
> -		aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
> -							     alluni, NULL,
> -							     true);
> -		aq_err = pf->hw.aq.asq_last_status;
> -		if (aq_ret) {
> -			dev_err(&pf->pdev->dev,
> -				"VF %d failed to set unicast promiscuous mode %8.8x err %s aq_err %s\n",
> -				vf->vf_id, info->flags,
> -				i40e_stat_str(&pf->hw, aq_ret),
> -				i40e_aq_str(&pf->hw, aq_err));
> -			goto error_param;
> -		}
> -	}
> -
> -	if (!aq_ret) {
> -		dev_info(&pf->pdev->dev,
> -			 "VF %d successfully set unicast promiscuous mode\n",
> -			 vf->vf_id);
> -		if (alluni)
> +		if (alluni) {
> +			dev_info(&pf->pdev->dev,
> +				 "VF %d successfully set unicast promiscuous mode\n",
> +				 vf->vf_id);
>   			set_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
> -		else
> +		} else {
> +			dev_info(&pf->pdev->dev,
> +				 "VF %d successfully unset unicast promiscuous mode\n",
> +				 vf->vf_id);

It looks to me that all these status messages are getting printed 
whether there actually was a change or not.  In other words, if the 
unicast promisc was already on, and the VF again calls for it to be set, 
this will be printed again, even though there was no change in state. 
Is this what you intended?

sln

>   			clear_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states);
> +		}
>   	}
>   
> -error_param:
>   	/* send the response to the VF */
>   	return i40e_vc_send_resp_to_vf(vf,
>   				       VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
> 

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

* [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array Alice Michael
@ 2018-08-21 19:16   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:16 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats
> to i40e_stats array
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> Use an i40e_stats array to handle the queue stats, instead of coding similar
> functionality separately. Because of how the queue stats are accessed on
> some kernels, we can't easily use i40e_add_ethtool_stats.
> 
> Instead, implement a separate helper, i40e_add_queue_stats, which we'll
> use instead. This helper will correctly implement the
> u64_stats_fetch_begin_irq logic and allow retries until successful. We share
> the most complex code by re-using i40e_add_one_ethtool_stat.
> 
> This logic additionally easily supports skipping disabled rings by using a
> ternary operator before calling the u64_stats_fetch_begin_irq() function, so
> that we correctly zero-out the stats values without having to perform two
> separate sections of code.
> 
> This significantly reduces the boiler plate code in i40e_get_ethtool_stats, and
> helps keep the complex logic contained to as few functions as possible.
> 
> With this patch, we've finally converted all the statistics to use the helpers
> and the i40e_stats function.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 148 +++++++++++++++----
> ------
>  1 file changed, 89 insertions(+), 59 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h Alice Michael
@ 2018-08-21 19:17   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:17 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats
> boiler plate code to i40e_ethtool_stats.h
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> Move the boiler plate structures and helper functions we recently added into
> their own header file, so that the complete collection is located together.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c     | 182 +----------------
>  .../net/ethernet/intel/i40e/i40e_ethtool_stats.h   | 221
> +++++++++++++++++++++
>  2 files changed, 222 insertions(+), 181 deletions(-)  create mode 100644
> drivers/net/ethernet/intel/i40e/i40e_ethtool_stats.h

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions Alice Michael
@ 2018-08-21 19:19   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:19 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool
> stats code and use helper functions
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> Fix a bug in the way we handled VF queues, by always showing stats for the
> maximum number of queues, even if they aren't allocated. It is not safe to
> change the number of strings reported to ethtool, as grabbing statistics
> occurs over multiple ethtool ops for which the rtnl_lock() cannot be held the
> entire time.
> 
> Avoid this by always reporting queue stats for the maximum number of
> queues in the netdevice. Share some of the helper functionality for adding
> stats with the PF code in i40e_ethtool_stats.h
> 
> This should reduce the chance of potential future bugs, and make adding
> new statistics easier.
> 
> Note for the queue stats, unlike the PF driver we do not keep an array of
> queue pointers, but an array of queues, so care must be taken to avoid
> accessing queue memory that hasn't yet been allocated.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  .../net/ethernet/intel/i40evf/i40e_ethtool_stats.h | 221
> +++++++++++++++++++++
> drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 137 +++++++------
>  2 files changed, 298 insertions(+), 60 deletions(-)  create mode 100644
> drivers/net/ethernet/intel/i40evf/i40e_ethtool_stats.h

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver Alice Michael
@ 2018-08-21 19:29   ` Bowers, AndrewX
  2018-08-29 16:34     ` Bowers, AndrewX
  0 siblings, 1 reply; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:29 UTC (permalink / raw)
  To: intel-wired-lan

Setting the VF mac to something arbitrary works, however setting it back to 00:00:00:00:00:00 does NOT set it back to all zeroes, nor does it trigger random MAC generation (dmesg shows "removing MAC on VF 0" and the message to bring the interface down and back up, however dmesg does not report "invalid MAC address, using random" and "ip ad show"
 still shows the 00:11:22:33:44:55 MAC that was set. 

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Pawe? Jab?o?ski
> <"pawel.jablonski@intel.compawel.jablonski"@intel.com>; Pawe? Jab?o?ski
> <pawel.jablonski@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac
> without reloading the VF driver
> 
> From: Pawe? Jab?o?ski <pawel.jablonski@intel.com>
> <pawel.jablonski@intel.com>
> 
> Add possibility to change a VF mac address from host side without reloading
> the VF driver on the guest side. Without this patch it is not possible to change
> the VF mac because executing i40evf_virtchnl_completion function with
> VIRTCHNL_OP_GET_VF_RESOURCES opcode resets the VF mac address to
> previous value.
> 
> Signed-off-by: Pawe? Jab?o?ski <pawel.jablonski@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c  |  8 +++++---
> drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 11 +++++++++--
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index c6d24ea..f56c645 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -2458,7 +2458,7 @@ static inline int i40e_check_vf_permission(struct
> i40e_vf *vf,
>  		    !is_multicast_ether_addr(addr) && vf->pf_set_mac &&
>  		    !ether_addr_equal(addr, vf->default_lan_addr.addr)) {
>  			dev_err(&pf->pdev->dev,
> -				"VF attempting to override administratively
> set MAC address, reload the VF driver to resume normal operation\n");
> +				"VF attempting to override administratively
> set MAC address, bring
> +down and up the VF interface to resume normal operation\n");
>  			return -EPERM;
>  		}
>  	}
> @@ -3873,9 +3873,11 @@ int i40e_ndo_set_vf_mac(struct net_device
> *netdev, int vf_id, u8 *mac)
>  			 mac, vf_id);
>  	}
> 
> -	/* Force the VF driver stop so it has to reload with new MAC address
> */
> +	/* Force the VF interface down so it has to bring up with new MAC
> +	 * address
> +	 */
>  	i40e_vc_disable_vf(vf);
> -	dev_info(&pf->pdev->dev, "Reload the VF driver to make this
> change effective.\n");
> +	dev_info(&pf->pdev->dev, "Bring down and up the VF interface to
> make
> +this change effective.\n");
> 
>  error_param:
>  	return ret;
> diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
> b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
> index 565677d..79b7be8 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
> @@ -1330,8 +1330,15 @@ void i40evf_virtchnl_completion(struct
> i40evf_adapter *adapter,
>  			  sizeof(struct virtchnl_vsi_resource);
>  		memcpy(adapter->vf_res, msg, min(msglen, len));
>  		i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
> -		/* restore current mac address */
> -		ether_addr_copy(adapter->hw.mac.addr, netdev-
> >dev_addr);
> +		if (is_zero_ether_addr(adapter->hw.mac.addr)) {
> +			/* restore current mac address */
> +			ether_addr_copy(adapter->hw.mac.addr, netdev-
> >dev_addr);
> +		} else {
> +			/* refresh current mac address if changed */
> +			ether_addr_copy(netdev->dev_addr, adapter-
> >hw.mac.addr);
> +			ether_addr_copy(netdev->perm_addr,
> +					adapter->hw.mac.addr);
> +		}
>  		i40evf_process_config(adapter);
>  		}
>  		break;
> --
> 2.9.5
> 
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan at osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings Alice Michael
@ 2018-08-21 19:36   ` Bowers, AndrewX
  2018-08-24  1:50   ` Mauro Rodrigues
  1 sibling, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:36 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of
> WARN_ONCE for stat strings
> 
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> Commit 9b10df596bd4 ("i40e: use WARN_ONCE to replace the commented
> BUG_ON size check") introduced a warning check to make sure that the size
> of the stat strings was always the expected value. This code accidentally
> inverted the check of the data pointer. Fix this so that we accurately count
> the size of the stats we copied in.
> 
> This fixes an erroneous WARN kernel splat that occurs when requesting
> ethtool statistics.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf Alice Michael
@ 2018-08-21 19:41   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:41 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:13 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set
> IFF_UNICAST_FLT flag for the vf
> 
> From: Lihong Yang <lihong.yang@intel.com>
> 
> Set IFF_UNICAST_FLT flag for the vf to prevent it from entering promiscuous
> mode when macvlan is added to the vf.
> 
> Signed-off-by: Lihong Yang <lihong.yang@intel.com>
> ---
>  drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 ++
>  1 file changed, 2 insertions(+)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct Alice Michael
@ 2018-08-21 19:41   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:41 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:13 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a
> field in the virtchnl_filter struct
> 
> From: Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>
> 
> The virtchnl_filter struct has a field called field_flags. A previous commit
> mistakenly had the type to be a __u8. What we want is for the field to be an
> unsigned 8 bit value, so let's just use the existing kernel type u8 for that.
> 
> Signed-off-by: Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>
> ---
>  include/linux/avf/virtchnl.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community Alice Michael
@ 2018-08-21 19:42   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-21 19:42 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:13 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Szapar, Martyna <martyna.szapar@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report
> from community
> 
> From: Martyna Szapar <martyna.szapar@intel.com>
> 
> Static analysis tools report a problem from original driver submission.
> Removing unnecessary check in condition.
> 
> Signed-off-by: Martyna Szapar <martyna.szapar@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy Alice Michael
  2018-08-21 16:28   ` Shannon Nelson
@ 2018-08-23 16:11   ` Bowers, AndrewX
  1 sibling, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-23 16:11 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:13 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for
> strncpy
> 
> From: Mitch Williams <mitch.a.williams@intel.com>
> 
> Caught by gcc 8. When we provide a length for strncpy, we should not
> include the terminating null. So we must tell it one less than the size of the
> destination buffer.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings Alice Michael
  2018-08-21 19:36   ` Bowers, AndrewX
@ 2018-08-24  1:50   ` Mauro Rodrigues
  1 sibling, 0 replies; 29+ messages in thread
From: Mauro Rodrigues @ 2018-08-24  1:50 UTC (permalink / raw)
  To: intel-wired-lan

On Mon, Aug 20, 2018 at 08:12:27AM -0700, Alice Michael wrote:
> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> Commit 9b10df596bd4 ("i40e: use WARN_ONCE to replace the commented
> BUG_ON size check") introduced a warning check to make sure
> that the size of the stat strings was always the expected value. This
> code accidentally inverted the check of the data pointer. Fix this so
> that we accurately count the size of the stats we copied in.
> 
> This fixes an erroneous WARN kernel splat that occurs when requesting
> ethtool statistics.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Tested-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>


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

* [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver
  2018-08-21 19:29   ` Bowers, AndrewX
@ 2018-08-29 16:34     ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-29 16:34 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Bowers, AndrewX
> Sent: Tuesday, August 21, 2018 12:29 PM
> To: Michael, Alice <alice.michael@intel.com>; Michael, Alice
> <alice.michael@intel.com>; intel-wired-lan at lists.osuosl.org
> Cc: Pawel Jablonski
> <"pawel.jablonski@intel.compawel.jablonski"@intel.com>; Pawel Jablonski
> <pawel.jablonski@intel.com>
> Subject: Re: [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF
> mac without reloading the VF driver
> 
> Setting the VF mac to something arbitrary works, however setting it back to
> 00:00:00:00:00:00 does NOT set it back to all zeroes, nor does it trigger
> random MAC generation (dmesg shows "removing MAC on VF 0" and the
> message to bring the interface down and back up, however dmesg does not
> report "invalid MAC address, using random" and "ip ad show"
>  still shows the 00:11:22:33:44:55 MAC that was set.
> 
> > -----Original Message-----
> > From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> > Behalf Of Alice Michael
> > Sent: Monday, August 20, 2018 8:12 AM
> > To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> > lan at lists.osuosl.org
> > Cc: Pawe? Jab?o?ski
> > <"pawel.jablonski@intel.compawel.jablonski"@intel.com>; Pawe?
> > Jab?o?ski <pawel.jablonski@intel.com>
> > Subject: [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF
> > mac without reloading the VF driver
> >
> > From: Pawe? Jab?o?ski <pawel.jablonski@intel.com>
> > <pawel.jablonski@intel.com>
> >
> > Add possibility to change a VF mac address from host side without
> > reloading the VF driver on the guest side. Without this patch it is
> > not possible to change the VF mac because executing
> > i40evf_virtchnl_completion function with
> VIRTCHNL_OP_GET_VF_RESOURCES
> > opcode resets the VF mac address to previous value.
> >
> > Signed-off-by: Pawe? Jab?o?ski <pawel.jablonski@intel.com>
> > ---
> >  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c  |  8 +++++---
> > drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 11 +++++++++--
> >  2 files changed, 14 insertions(+), 5 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification
  2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
                   ` (11 preceding siblings ...)
  2018-08-21 16:27 ` [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Shannon Nelson
@ 2018-08-29 20:53 ` Bowers, AndrewX
  12 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-29 20:53 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state
> notification
> 
> From: Mariusz Stachura <mariusz.stachura@intel.com>
> 
> This patch moves saving old link status information after the call to
> i40e_get_link_status(). Mentioned function updates both old and the new
> link info, so reading it before results in not notifying VF about the PF link
> state change.
> 
> Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 5 -----
>  1 file changed, 5 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset Alice Michael
  2018-08-21 16:28   ` Shannon Nelson
@ 2018-08-29 20:53   ` Bowers, AndrewX
  1 sibling, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-29 20:53 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous
> settings on VF reset
> 
> From: Mariusz Stachura <mariusz.stachura@intel.com>
> 
> This patch cleans up promiscuous configuration when a VF reset occurs.
> Previously the promiscuous mode settings were still there after the VF driver
> removal.
> 
> Signed-off-by: Mariusz Stachura <mariusz.stachura@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 267 ++++++++++++-----
> ----
>  1 file changed, 157 insertions(+), 110 deletions(-)> 

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



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

* [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends
  2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends Alice Michael
@ 2018-08-29 20:54   ` Bowers, AndrewX
  0 siblings, 0 replies; 29+ messages in thread
From: Bowers, AndrewX @ 2018-08-29 20:54 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Alice Michael
> Sent: Monday, August 20, 2018 8:12 AM
> To: Michael, Alice <alice.michael@intel.com>; intel-wired-
> lan at lists.osuosl.org
> Cc: Stillwell Jr, Paul M <paul.m.stillwell.jr@intel.com>
> Subject: [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the
> number of queues a PF sends
> 
> From: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
> 
> A PF can send any number of queues to the VF and the VF may not be able
> to support that many. Check to see that the number of queues is less than or
> equal to the max number of queues the VF can have.
> 
> Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
> ---
>  .../net/ethernet/intel/i40evf/i40evf_virtchnl.c    | 32
> ++++++++++++++++++++++
>  1 file changed, 32 insertions(+)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>

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

end of thread, other threads:[~2018-08-29 20:54 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20 15:12 [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Alice Michael
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 02/12] i40e: convert queue stats to i40e_stats array Alice Michael
2018-08-21 19:16   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 03/12] i40e: move ethtool stats boiler plate code to i40e_ethtool_stats.h Alice Michael
2018-08-21 19:17   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 04/12] i40evf: update ethtool stats code and use helper functions Alice Michael
2018-08-21 19:19   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 05/12] i40evf: Change a VF mac without reloading the VF driver Alice Michael
2018-08-21 19:29   ` Bowers, AndrewX
2018-08-29 16:34     ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 06/12] i40e: fix condition of WARN_ONCE for stat strings Alice Michael
2018-08-21 19:36   ` Bowers, AndrewX
2018-08-24  1:50   ` Mauro Rodrigues
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 07/12] i40e: Unset promiscuous settings on VF reset Alice Michael
2018-08-21 16:28   ` Shannon Nelson
2018-08-29 20:53   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 08/12] i40evf: Validate the number of queues a PF sends Alice Michael
2018-08-29 20:54   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 09/12] i40e: use correct length for strncpy Alice Michael
2018-08-21 16:28   ` Shannon Nelson
2018-08-23 16:11   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 10/12] i40evf: set IFF_UNICAST_FLT flag for the vf Alice Michael
2018-08-21 19:41   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 11/12] virtchnl: use u8 type for a field in the virtchnl_filter struct Alice Michael
2018-08-21 19:41   ` Bowers, AndrewX
2018-08-20 15:12 ` [Intel-wired-lan] [next PATCH S95 12/12] i40e: static analysis report from community Alice Michael
2018-08-21 19:42   ` Bowers, AndrewX
2018-08-21 16:27 ` [Intel-wired-lan] [next PATCH S95 01/12] i40e: Fix VF's link state notification Shannon Nelson
2018-08-29 20:53 ` Bowers, AndrewX

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.