All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014
@ 2014-02-27 12:26 Amir Vadai
  2014-02-27 12:26 ` [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc Amir Vadai
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:26 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Amir Vadai

Hi,

This patchset contains some fixes for small trivial bugs, and
compilation/syntactic parsers warnings

Patchset was applied and tested over commit f7b1260 "rtnl: make ifla_policy
static"

Thanks,
Amir

Amir Vadai (3):
  net/mlx4_en: Fix UP limit in ieee_ets->prio_tc
  net/mlx4_en: Fix selftest failing on non 10G link speed
  net/mlx4_en: Use union for BlueFlame WQE

Eugenia Emantayev (4):
  net/mlx4_en: Verify mlx4_en module parameters
  net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  net/mlx4_en: Move queue stopped/waked counters to be per ring
  net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64()

Eyal Perry (2):
  net/mlx4_core: Fix sparse warning
  net/mlx4_en: Change Connect-X description in kconfig

 drivers/net/ethernet/mellanox/mlx4/Kconfig       |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c   |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_main.c     | 30 ++++++++++++++++++
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c   | 32 ++++++-------------
 drivers/net/ethernet/mellanox/mlx4/en_port.c     |  6 ++++
 drivers/net/ethernet/mellanox/mlx4/en_selftest.c |  6 ++--
 drivers/net/ethernet/mellanox/mlx4/en_tx.c       | 39 +++++++++++-------------
 drivers/net/ethernet/mellanox/mlx4/fw.c          |  3 +-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h     | 12 +++++++-
 include/linux/mlx4/driver.h                      | 15 +++++++++
 include/linux/mlx4/qp.h                          | 11 +++++--
 11 files changed, 106 insertions(+), 52 deletions(-)

-- 
1.8.3.4

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

* [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
@ 2014-02-27 12:26 ` Amir Vadai
  2014-02-27 12:26 ` [PATCH net-next 2/9] net/mlx4_en: Verify mlx4_en module parameters Amir Vadai
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:26 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Amir Vadai, Eugenia Emantayev

User priority limit has to be less than MLX4_EN_NUM_UP.


Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>

---
 drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
index b4881b6..c95ca25 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -62,7 +62,7 @@ static int mlx4_en_ets_validate(struct mlx4_en_priv *priv, struct ieee_ets *ets)
 	int has_ets_tc = 0;
 
 	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
-		if (ets->prio_tc[i] > MLX4_EN_NUM_UP) {
+		if (ets->prio_tc[i] >= MLX4_EN_NUM_UP) {
 			en_err(priv, "Bad priority in UP <=> TC mapping. TC: %d, UP: %d\n",
 					i, ets->prio_tc[i]);
 			return -EINVAL;
-- 
1.8.3.4

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

* [PATCH net-next 2/9] net/mlx4_en: Verify mlx4_en module parameters
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
  2014-02-27 12:26 ` [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc Amir Vadai
@ 2014-02-27 12:26 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes Amir Vadai
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:26 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev, Amir Vadai

From: Eugenia Emantayev <eugenia@mellanox.com>

Verify mlx4_en module parameters.
In case they are out of range - reset to default values.


Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_main.c | 30 ++++++++++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlx4/en_tx.c   | 21 +++++--------------
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h |  9 +++++++++
 3 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_main.c b/drivers/net/ethernet/mellanox/mlx4/en_main.c
index fa2f6e7..3454437 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_main.c
@@ -72,6 +72,12 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]."
 MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]."
 			   " Per priority bit mask");
 
+MLX4_EN_PARM_INT(inline_thold, MAX_INLINE,
+		 "Threshold for using inline data (range: 17-104, default: 104)");
+
+#define MAX_PFC_TX     0xff
+#define MAX_PFC_RX     0xff
+
 int en_print(const char *level, const struct mlx4_en_priv *priv,
 	     const char *format, ...)
 {
@@ -140,6 +146,7 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
 		params->prof[i].tx_ring_num = params->num_tx_rings_p_up *
 			MLX4_EN_NUM_UP;
 		params->prof[i].rss_rings = 0;
+		params->prof[i].inline_thold = inline_thold;
 	}
 
 	return 0;
@@ -325,8 +332,31 @@ static struct mlx4_interface mlx4_en_interface = {
 	.protocol	= MLX4_PROT_ETH,
 };
 
+void mlx4_en_verify_params(void)
+{
+	if (pfctx > MAX_PFC_TX) {
+		pr_warn("mlx4_en: WARNING: illegal module parameter pfctx 0x%x - should be in range 0-0x%x, will be changed to default (0)\n",
+			pfctx, MAX_PFC_TX);
+		pfctx = 0;
+	}
+
+	if (pfcrx > MAX_PFC_RX) {
+		pr_warn("mlx4_en: WARNING: illegal module parameter pfcrx 0x%x - should be in range 0-0x%x, will be changed to default (0)\n",
+			pfcrx, MAX_PFC_RX);
+		pfcrx = 0;
+	}
+
+	if (inline_thold < MIN_PKT_LEN || inline_thold > MAX_INLINE) {
+		pr_warn("mlx4_en: WARNING: illegal module parameter inline_thold %d - should be in range %d-%d, will be changed to default (%d)\n",
+			inline_thold, MIN_PKT_LEN, MAX_INLINE, MAX_INLINE);
+		inline_thold = MAX_INLINE;
+	}
+}
+
 static int __init mlx4_en_init(void)
 {
+	mlx4_en_verify_params();
+
 	return mlx4_register_interface(&mlx4_en_interface);
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 1345703..8dc7637 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -44,16 +44,6 @@
 
 #include "mlx4_en.h"
 
-enum {
-	MAX_INLINE = 104, /* 128 - 16 - 4 - 4 */
-	MAX_BF = 256,
-};
-
-static int inline_thold __read_mostly = MAX_INLINE;
-
-module_param_named(inline_thold, inline_thold, int, 0444);
-MODULE_PARM_DESC(inline_thold, "threshold for using inline data");
-
 int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
 			   struct mlx4_en_tx_ring **pring, int qpn, u32 size,
 			   u16 stride, int node, int queue_index)
@@ -75,8 +65,7 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
 	ring->size = size;
 	ring->size_mask = size - 1;
 	ring->stride = stride;
-
-	inline_thold = min(inline_thold, MAX_INLINE);
+	ring->inline_thold = priv->prof->inline_thold;
 
 	tmp = size * sizeof(struct mlx4_en_tx_info);
 	ring->tx_info = vmalloc_node(tmp, node);
@@ -520,7 +509,7 @@ static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv,
 	return ring->buf + index * TXBB_SIZE;
 }
 
-static int is_inline(struct sk_buff *skb, void **pfrag)
+static int is_inline(int inline_thold, struct sk_buff *skb, void **pfrag)
 {
 	void *ptr;
 
@@ -580,7 +569,7 @@ static int get_real_size(struct sk_buff *skb, struct net_device *dev,
 		}
 	} else {
 		*lso_header_size = 0;
-		if (!is_inline(skb, NULL))
+		if (!is_inline(priv->prof->inline_thold, skb, NULL))
 			real_size = CTRL_SIZE + (skb_shinfo(skb)->nr_frags + 1) * DS_SIZE;
 		else
 			real_size = inline_size(skb);
@@ -747,11 +736,11 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	tx_info->data_offset = (void *)data - (void *)tx_desc;
 
 	tx_info->linear = (lso_header_size < skb_headlen(skb) &&
-			   !is_inline(skb, NULL)) ? 1 : 0;
+			   !is_inline(ring->inline_thold, skb, NULL)) ? 1 : 0;
 
 	data += skb_shinfo(skb)->nr_frags + tx_info->linear - 1;
 
-	if (is_inline(skb, &fragptr)) {
+	if (is_inline(ring->inline_thold, skb, &fragptr)) {
 		tx_info->inl = 1;
 	} else {
 		/* Map fragments */
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 3c25c7b..2610cc5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -187,6 +187,13 @@ enum {
 #define GET_AVG_PERF_COUNTER(cnt)	(0)
 #endif /* MLX4_EN_PERF_STAT */
 
+/* Constants for TX flow */
+enum {
+	MAX_INLINE = 104, /* 128 - 16 - 4 - 4 */
+	MAX_BF = 256,
+	MIN_PKT_LEN = 17,
+};
+
 /*
  * Configurables
  */
@@ -271,6 +278,7 @@ struct mlx4_en_tx_ring {
 	bool bf_enabled;
 	struct netdev_queue *tx_queue;
 	int hwtstamp_tx_type;
+	int inline_thold;
 };
 
 struct mlx4_en_rx_desc {
@@ -346,6 +354,7 @@ struct mlx4_en_port_profile {
 	u8 tx_pause;
 	u8 tx_ppp;
 	int rss_rings;
+	int inline_thold;
 };
 
 struct mlx4_en_profile {
-- 
1.8.3.4

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

* [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
  2014-02-27 12:26 ` [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc Amir Vadai
  2014-02-27 12:26 ` [PATCH net-next 2/9] net/mlx4_en: Verify mlx4_en module parameters Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 13:08   ` David Laight
  2014-02-27 12:27 ` [PATCH net-next 4/9] net/mlx4_en: Move queue stopped/waked counters to be per ring Amir Vadai
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev, Amir Vadai

From: Eugenia Emantayev <eugenia@mellanox.com>

Hardware can't accept packets smaller than 17 bytes. Therefore need to pad with
zeros.


Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 8dc7637..268cc4a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -585,12 +585,19 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
 	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
 
 	if (skb->len <= spc) {
-		inl->byte_count = cpu_to_be32(1 << 31 | skb->len);
+		inl->byte_count = cpu_to_be32(1 << 31 |
+					      max_t(typeof(skb->len),
+						    skb->len,
+						    MIN_PKT_LEN));
 		skb_copy_from_linear_data(skb, inl + 1, skb_headlen(skb));
 		if (skb_shinfo(skb)->nr_frags)
 			memcpy(((void *)(inl + 1)) + skb_headlen(skb), fragptr,
 			       skb_frag_size(&skb_shinfo(skb)->frags[0]));
 
+		if (skb->len < MIN_PKT_LEN)
+			memset(((void *)(inl + 1)) + skb->len, 0,
+			       MIN_PKT_LEN - skb->len);
+
 	} else {
 		inl->byte_count = cpu_to_be32(1 << 31 | spc);
 		if (skb_headlen(skb) <= spc) {
-- 
1.8.3.4

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

* [PATCH net-next 4/9] net/mlx4_en: Move queue stopped/waked counters to be per ring
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (2 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 5/9] net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64() Amir Vadai
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev, Amir Vadai

From: Eugenia Emantayev <eugenia@mellanox.com>

Give accurate counters and avoids cache misses when several rings
update the counters of stop/wake queue.


Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_port.c | 6 ++++++
 drivers/net/ethernet/mellanox/mlx4/en_tx.c   | 6 +++---
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 2 ++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index dae1a1f..c2cfb05 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -148,10 +148,16 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 	stats->tx_packets = 0;
 	stats->tx_bytes = 0;
 	priv->port_stats.tx_chksum_offload = 0;
+	priv->port_stats.queue_stopped = 0;
+	priv->port_stats.wake_queue = 0;
+
 	for (i = 0; i < priv->tx_ring_num; i++) {
 		stats->tx_packets += priv->tx_ring[i]->packets;
 		stats->tx_bytes += priv->tx_ring[i]->bytes;
 		priv->port_stats.tx_chksum_offload += priv->tx_ring[i]->tx_csum;
+		priv->port_stats.queue_stopped +=
+			priv->tx_ring[i]->queue_stopped;
+		priv->port_stats.wake_queue += priv->tx_ring[i]->wake_queue;
 	}
 
 	stats->rx_errors = be64_to_cpu(mlx4_en_stats->PCS) +
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 268cc4a..9730373 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -445,7 +445,7 @@ static int mlx4_en_process_tx_cq(struct net_device *dev,
 	 */
 	if (netif_tx_queue_stopped(ring->tx_queue) && txbbs_skipped > 0) {
 		netif_tx_wake_queue(ring->tx_queue);
-		priv->port_stats.wake_queue++;
+		ring->wake_queue++;
 	}
 	return done;
 }
@@ -692,7 +692,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 		     ring->size - HEADROOM - MAX_DESC_TXBBS)) {
 		/* every full Tx ring stops queue */
 		netif_tx_stop_queue(ring->tx_queue);
-		priv->port_stats.queue_stopped++;
+		ring->queue_stopped++;
 
 		/* If queue was emptied after the if, and before the
 		 * stop_queue - need to wake the queue, or else it will remain
@@ -705,7 +705,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 		if (unlikely(((int)(ring->prod - ring->cons)) <=
 			     ring->size - HEADROOM - MAX_DESC_TXBBS)) {
 			netif_tx_wake_queue(ring->tx_queue);
-			priv->port_stats.wake_queue++;
+			ring->wake_queue++;
 		} else {
 			return NETDEV_TX_BUSY;
 		}
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 2610cc5..c59011d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -274,6 +274,8 @@ struct mlx4_en_tx_ring {
 	unsigned long bytes;
 	unsigned long packets;
 	unsigned long tx_csum;
+	unsigned long queue_stopped;
+	unsigned long wake_queue;
 	struct mlx4_bf bf;
 	bool bf_enabled;
 	struct netdev_queue *tx_queue;
-- 
1.8.3.4

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

* [PATCH net-next 5/9] net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64()
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (3 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 4/9] net/mlx4_en: Move queue stopped/waked counters to be per ring Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 6/9] net/mlx4_en: Fix selftest failing on non 10G link speed Amir Vadai
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev, Amir Vadai

From: Eugenia Emantayev <eugenia@mellanox.com>

Currently, the EN driver uses a private static function
mlx4_en_mac_to_u64(). Move it to a common include file (driver.h)
for mlx4_en and mlx4_ib for further use.


Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 32 ++++++++------------------
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |  1 -
 include/linux/mlx4/driver.h                    | 15 ++++++++++++
 3 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 2c0823b..3db5946 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -603,7 +603,7 @@ static int mlx4_en_get_qp(struct mlx4_en_priv *priv)
 	int err = 0;
 	u64 reg_id;
 	int *qpn = &priv->base_qpn;
-	u64 mac = mlx4_en_mac_to_u64(priv->dev->dev_addr);
+	u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr);
 
 	en_dbg(DRV, priv, "Registering MAC: %pM for adding\n",
 	       priv->dev->dev_addr);
@@ -672,7 +672,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv)
 	u64 mac;
 
 	if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) {
-		mac = mlx4_en_mac_to_u64(priv->dev->dev_addr);
+		mac = mlx4_mac_to_u64(priv->dev->dev_addr);
 		en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n",
 		       priv->dev->dev_addr);
 		mlx4_unregister_mac(dev, priv->port, mac);
@@ -685,7 +685,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv)
 		for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) {
 			bucket = &priv->mac_hash[i];
 			hlist_for_each_entry_safe(entry, tmp, bucket, hlist) {
-				mac = mlx4_en_mac_to_u64(entry->mac);
+				mac = mlx4_mac_to_u64(entry->mac);
 				en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n",
 				       entry->mac);
 				mlx4_en_uc_steer_release(priv, entry->mac,
@@ -715,14 +715,14 @@ static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn,
 	struct mlx4_en_dev *mdev = priv->mdev;
 	struct mlx4_dev *dev = mdev->dev;
 	int err = 0;
-	u64 new_mac_u64 = mlx4_en_mac_to_u64(new_mac);
+	u64 new_mac_u64 = mlx4_mac_to_u64(new_mac);
 
 	if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) {
 		struct hlist_head *bucket;
 		unsigned int mac_hash;
 		struct mlx4_mac_entry *entry;
 		struct hlist_node *tmp;
-		u64 prev_mac_u64 = mlx4_en_mac_to_u64(prev_mac);
+		u64 prev_mac_u64 = mlx4_mac_to_u64(prev_mac);
 
 		bucket = &priv->mac_hash[prev_mac[MLX4_EN_MAC_HASH_IDX]];
 		hlist_for_each_entry_safe(entry, tmp, bucket, hlist) {
@@ -751,18 +751,6 @@ static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn,
 	return __mlx4_replace_mac(dev, priv->port, qpn, new_mac_u64);
 }
 
-u64 mlx4_en_mac_to_u64(u8 *addr)
-{
-	u64 mac = 0;
-	int i;
-
-	for (i = 0; i < ETH_ALEN; i++) {
-		mac <<= 8;
-		mac |= addr[i];
-	}
-	return mac;
-}
-
 static int mlx4_en_do_set_mac(struct mlx4_en_priv *priv)
 {
 	int err = 0;
@@ -1081,7 +1069,7 @@ static void mlx4_en_do_multicast(struct mlx4_en_priv *priv,
 		mlx4_en_cache_mclist(dev);
 		netif_addr_unlock_bh(dev);
 		list_for_each_entry(mclist, &priv->mc_list, list) {
-			mcast_addr = mlx4_en_mac_to_u64(mclist->addr);
+			mcast_addr = mlx4_mac_to_u64(mclist->addr);
 			mlx4_SET_MCAST_FLTR(mdev->dev, priv->port,
 					    mcast_addr, 0, MLX4_MCAST_CONFIG);
 		}
@@ -1173,7 +1161,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
 				found = true;
 
 			if (!found) {
-				mac = mlx4_en_mac_to_u64(entry->mac);
+				mac = mlx4_mac_to_u64(entry->mac);
 				mlx4_en_uc_steer_release(priv, entry->mac,
 							 priv->base_qpn,
 							 entry->reg_id);
@@ -1216,7 +1204,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
 				priv->flags |= MLX4_EN_FLAG_FORCE_PROMISC;
 				break;
 			}
-			mac = mlx4_en_mac_to_u64(ha->addr);
+			mac = mlx4_mac_to_u64(ha->addr);
 			memcpy(entry->mac, ha->addr, ETH_ALEN);
 			err = mlx4_register_mac(mdev->dev, priv->port, mac);
 			if (err < 0) {
@@ -2206,7 +2194,7 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac)
 {
 	struct mlx4_en_priv *en_priv = netdev_priv(dev);
 	struct mlx4_en_dev *mdev = en_priv->mdev;
-	u64 mac_u64 = mlx4_en_mac_to_u64(mac);
+	u64 mac_u64 = mlx4_mac_to_u64(mac);
 
 	if (!is_valid_ether_addr(mac))
 		return -EINVAL;
@@ -2407,7 +2395,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 		if (mlx4_is_slave(priv->mdev->dev)) {
 			eth_hw_addr_random(dev);
 			en_warn(priv, "Assigned random MAC address %pM\n", dev->dev_addr);
-			mac_u64 = mlx4_en_mac_to_u64(dev->dev_addr);
+			mac_u64 = mlx4_mac_to_u64(dev->dev_addr);
 			mdev->dev->caps.def_mac[priv->port] = mac_u64;
 		} else {
 			en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n",
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index c59011d..4ff7da8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -797,7 +797,6 @@ void mlx4_en_cleanup_filters(struct mlx4_en_priv *priv);
 
 #define MLX4_EN_NUM_SELF_TEST	5
 void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf);
-u64 mlx4_en_mac_to_u64(u8 *addr);
 void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev);
 
 /*
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h
index c257e1b..c68b9e4 100644
--- a/include/linux/mlx4/driver.h
+++ b/include/linux/mlx4/driver.h
@@ -64,4 +64,19 @@ void mlx4_unregister_interface(struct mlx4_interface *intf);
 
 void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port);
 
+#ifndef ETH_ALEN
+#define ETH_ALEN       6
+#endif
+static inline u64 mlx4_mac_to_u64(u8 *addr)
+{
+	u64 mac = 0;
+	int i;
+
+	for (i = 0; i < ETH_ALEN; i++) {
+		mac <<= 8;
+		mac |= addr[i];
+	}
+	return mac;
+}
+
 #endif /* MLX4_DRIVER_H */
-- 
1.8.3.4

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

* [PATCH net-next 6/9] net/mlx4_en: Fix selftest failing on non 10G link speed
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (4 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 5/9] net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64() Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 7/9] net/mlx4_core: Fix sparse warning Amir Vadai
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Amir Vadai

Connect-X devices selftest speed test shouldn't fail on 1G and 40G link
speeds.

Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_selftest.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
index c11d063..03e5f6a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
@@ -129,8 +129,10 @@ static int mlx4_en_test_speed(struct mlx4_en_priv *priv)
 	if (mlx4_en_QUERY_PORT(priv->mdev, priv->port))
 		return -ENOMEM;
 
-	/* The device currently only supports 10G speed */
-	if (priv->port_state.link_speed != SPEED_10000)
+	/* The device supports 1G, 10G and 40G speeds */
+	if (priv->port_state.link_speed != 1000 &&
+	    priv->port_state.link_speed != 10000 &&
+	    priv->port_state.link_speed != 40000)
 		return priv->port_state.link_speed;
 	return 0;
 }
-- 
1.8.3.4

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

* [PATCH net-next 7/9] net/mlx4_core: Fix sparse warning
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (5 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 6/9] net/mlx4_en: Fix selftest failing on non 10G link speed Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 9/9] net/mlx4_en: Change Connect-X description in kconfig Amir Vadai
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eyal Perry, Amir Vadai

From: Eyal Perry <eyalpe@mellanox.com>

This patch force conversion to u32 to fix the following sparse warning:
drivers/net/ethernet/mellanox/mlx4/fw.c:1822:53: warning: restricted __be32
degrades to integer

Casting to u32 is safe here, because token will be returned as is
from the hardware without any modification.

Signed-off-by: Eyal Perry <eyalpe@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 91b69ff..9cdf452 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -1890,7 +1890,8 @@ void mlx4_opreq_action(struct work_struct *work)
 			err = EINVAL;
 			break;
 		}
-		err = mlx4_cmd(dev, 0, ((u32) err | cpu_to_be32(token) << 16),
+		err = mlx4_cmd(dev, 0, ((u32) err |
+					(__force u32)cpu_to_be32(token) << 16),
 			       1, MLX4_CMD_GET_OP_REQ, MLX4_CMD_TIME_CLASS_A,
 			       MLX4_CMD_NATIVE);
 		if (err) {
-- 
1.8.3.4

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

* [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (6 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 7/9] net/mlx4_core: Fix sparse warning Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  2014-02-27 12:27 ` [PATCH net-next 9/9] net/mlx4_en: Change Connect-X description in kconfig Amir Vadai
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Amir Vadai, Dan Carpenter

When BlueFlame is turned on, control segment of the TX WQE is changed,
and the second line of it is used for QPN.
Changed code to use a union in the mlx4_wqe_ctrl_seg instead of casting.
This makes the code clearer and solves the static checker warning:

drivers/net/ethernet/mellanox/mlx4/en_tx.c:839 mlx4_en_xmit()
	warn: potential memory corrupting cast 4 vs 2 bytes

CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_tx.c |  3 ++-
 include/linux/mlx4/qp.h                    | 11 ++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 9730373..fda88a8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -877,7 +877,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	skb_tx_timestamp(skb);
 
 	if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tx_tag_present(skb)) {
-		*(__be32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn);
+		tx_desc->ctrl.bf_qpn |= cpu_to_be32(ring->doorbell_qpn);
+
 		op_own |= htonl((bf_index & 0xffff) << 8);
 		/* Ensure new descirptor hits memory
 		* before setting ownership of this descriptor to HW */
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 59f8ba8..b66e761 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -270,9 +270,14 @@ enum {
 
 struct mlx4_wqe_ctrl_seg {
 	__be32			owner_opcode;
-	__be16			vlan_tag;
-	u8			ins_vlan;
-	u8			fence_size;
+	union {
+		struct {
+			__be16			vlan_tag;
+			u8			ins_vlan;
+			u8			fence_size;
+		};
+		__be32			bf_qpn;
+	};
 	/*
 	 * High 24 bits are SRC remote buffer; low 8 bits are flags:
 	 * [7]   SO (strong ordering)
-- 
1.8.3.4

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

* [PATCH net-next 9/9] net/mlx4_en: Change Connect-X description in kconfig
  2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
                   ` (7 preceding siblings ...)
  2014-02-27 12:27 ` [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE Amir Vadai
@ 2014-02-27 12:27 ` Amir Vadai
  8 siblings, 0 replies; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 12:27 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eyal Perry, Amir Vadai

From: Eyal Perry <eyalpe@mellanox.com>

The mlx4_en driver support also 1Gbit and 40Gbit Ethernet devices, changed the
driver description in the menuconfig to reflect that.

Signed-off-by: Eyal Perry <eyalpe@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>

---
 drivers/net/ethernet/mellanox/mlx4/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/Kconfig b/drivers/net/ethernet/mellanox/mlx4/Kconfig
index 563495d..56efd13 100644
--- a/drivers/net/ethernet/mellanox/mlx4/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx4/Kconfig
@@ -3,7 +3,7 @@
 #
 
 config MLX4_EN
-	tristate "Mellanox Technologies 10Gbit Ethernet support"
+	tristate "Mellanox Technologies 1/10/40Gbit Ethernet support"
 	depends on PCI
 	select MLX4_CORE
 	select PTP_1588_CLOCK
-- 
1.8.3.4

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

* RE: [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 12:27 ` [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes Amir Vadai
@ 2014-02-27 13:08   ` David Laight
  2014-02-27 14:02     ` Amir Vadai
  0 siblings, 1 reply; 17+ messages in thread
From: David Laight @ 2014-02-27 13:08 UTC (permalink / raw)
  To: 'Amir Vadai', David S. Miller
  Cc: netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev

From: Amir Vadai
> Hardware can't accept packets smaller than 17 bytes. Therefore need to pad with
> zeros.

Can they actually happen?
A 16 byte packet would only have 2 bytes following the ethertype/length.
The shortest LLC packets have 3 bytes.
It may well be safe to discard them.

...
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> index 8dc7637..268cc4a 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> @@ -585,12 +585,19 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
>  	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
> 
>  	if (skb->len <= spc) {
> -		inl->byte_count = cpu_to_be32(1 << 31 | skb->len);
> +		inl->byte_count = cpu_to_be32(1 << 31 |
> +					      max_t(typeof(skb->len),
> +						    skb->len,
> +						    MIN_PKT_LEN));
>  		skb_copy_from_linear_data(skb, inl + 1, skb_headlen(skb));
>  		if (skb_shinfo(skb)->nr_frags)
>  			memcpy(((void *)(inl + 1)) + skb_headlen(skb), fragptr,
>  			       skb_frag_size(&skb_shinfo(skb)->frags[0]));

Is there guaranteed to be only 1 fragment here?

> +		if (skb->len < MIN_PKT_LEN)
> +			memset(((void *)(inl + 1)) + skb->len, 0,
> +			       MIN_PKT_LEN - skb->len);
> +

In any case you don't want 2 checks for skb->len < MIN_PKT_LEN,
so reassign to inl->byte_count here.
An unlikely() probably wouldn't go amiss either.

	David

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 13:08   ` David Laight
@ 2014-02-27 14:02     ` Amir Vadai
  2014-02-27 14:44       ` Eric Dumazet
  0 siblings, 1 reply; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 14:02 UTC (permalink / raw)
  To: David Laight
  Cc: David S. Miller, netdev, Yevgeny Petrilin, Or Gerlitz, Eugenia Emantayev

On 27/02/14 13:08 +0000, David Laight wrote:
> From: Amir Vadai
> > Hardware can't accept packets smaller than 17 bytes. Therefore need to pad with
> > zeros.
> 
> Can they actually happen?
> A 16 byte packet would only have 2 bytes following the ethertype/length.
> The shortest LLC packets have 3 bytes.
Raw sockets might send such packets and it will put the HW into
unstable state.

> It may well be safe to discard them.
Yep - that another option.

> 
> ...
> > 
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > index 8dc7637..268cc4a 100644
> > --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > @@ -585,12 +585,19 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
> >  	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
> > 
> >  	if (skb->len <= spc) {
> > -		inl->byte_count = cpu_to_be32(1 << 31 | skb->len);
> > +		inl->byte_count = cpu_to_be32(1 << 31 |
> > +					      max_t(typeof(skb->len),
> > +						    skb->len,
> > +						    MIN_PKT_LEN));
> >  		skb_copy_from_linear_data(skb, inl + 1, skb_headlen(skb));
> >  		if (skb_shinfo(skb)->nr_frags)
> >  			memcpy(((void *)(inl + 1)) + skb_headlen(skb), fragptr,
> >  			       skb_frag_size(&skb_shinfo(skb)->frags[0]));
> 
> Is there guaranteed to be only 1 fragment here?
> 
Yes, skb will not be classified as inline-able if nr_frags != 1.
See is_inline()

> > +		if (skb->len < MIN_PKT_LEN)
> > +			memset(((void *)(inl + 1)) + skb->len, 0,
> > +			       MIN_PKT_LEN - skb->len);
> > +
> 
> In any case you don't want 2 checks for skb->len < MIN_PKT_LEN,
> so reassign to inl->byte_count here.
> An unlikely() probably wouldn't go amiss either.
Right - will fix it for V1

> 
> 	David
> 

Thanks,
Amir

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 14:02     ` Amir Vadai
@ 2014-02-27 14:44       ` Eric Dumazet
  2014-02-27 15:46         ` Amir Vadai
  0 siblings, 1 reply; 17+ messages in thread
From: Eric Dumazet @ 2014-02-27 14:44 UTC (permalink / raw)
  To: Amir Vadai
  Cc: David Laight, David S. Miller, netdev, Yevgeny Petrilin,
	Or Gerlitz, Eugenia Emantayev

On Thu, 2014-02-27 at 16:02 +0200, Amir Vadai wrote:
>  
> Yes, skb will not be classified as inline-able if nr_frags != 1.
> See is_inline()

How often this inline stuff ever happens ?

It looks like the length of the frame needs to be shorter than 44 bytes,
right ?

Minimal length for TCP is 54 bytes.

I wonder why you tried to inline stuff that is probably never
seen in real workload.

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 14:44       ` Eric Dumazet
@ 2014-02-27 15:46         ` Amir Vadai
  2014-02-27 20:36           ` David Miller
  0 siblings, 1 reply; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 15:46 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Laight, David S. Miller, netdev, Yevgeny Petrilin,
	Or Gerlitz, Eugenia Emantayev

On 27/02/14 06:44 -0800, Eric Dumazet wrote:
> On Thu, 2014-02-27 at 16:02 +0200, Amir Vadai wrote:
> >  
> > Yes, skb will not be classified as inline-able if nr_frags != 1.
> > See is_inline()

Maybe I wasn't accurate enough. inline-able skb must have:
1. skb->len < inline_thold 
2. nr_frags <= 1

Default value for inline_thold is 104 and it is a module parameter
that can be changed.

> 
> How often this inline stuff ever happens ?
> 
> It looks like the length of the frame needs to be shorter than 44 bytes,
> right ?
It should be shorter than 104 - inline_thold default (and max) value is 104.
I don't understand why you say 44.

> 
> Minimal length for TCP is 54 bytes.
> 
> I wonder why you tried to inline stuff that is probably never
> seen in real workload.
> 

If you mean why did I try to send packets shorter than 17 using inline
- the answer is that it is easy to do it, so why not to?

Amir

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 15:46         ` Amir Vadai
@ 2014-02-27 20:36           ` David Miller
  2014-02-27 21:47             ` Amir Vadai
  0 siblings, 1 reply; 17+ messages in thread
From: David Miller @ 2014-02-27 20:36 UTC (permalink / raw)
  To: amirv; +Cc: eric.dumazet, David.Laight, netdev, yevgenyp, ogerlitz, eugenia

From: Amir Vadai <amirv@mellanox.com>
Date: Thu, 27 Feb 2014 17:46:37 +0200

> On 27/02/14 06:44 -0800, Eric Dumazet wrote:
>> On Thu, 2014-02-27 at 16:02 +0200, Amir Vadai wrote:
>> >  
>> > Yes, skb will not be classified as inline-able if nr_frags != 1.
>> > See is_inline()
> 
> Maybe I wasn't accurate enough. inline-able skb must have:
> 1. skb->len < inline_thold 
> 2. nr_frags <= 1
> 
> Default value for inline_thold is 104 and it is a module parameter
> that can be changed.

BTW, the canonical way to deal with minimum length requirements is to
use skb_padto().

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 20:36           ` David Miller
@ 2014-02-27 21:47             ` Amir Vadai
  2014-02-27 21:58               ` David Miller
  0 siblings, 1 reply; 17+ messages in thread
From: Amir Vadai @ 2014-02-27 21:47 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet, David.Laight, netdev, yevgenyp, ogerlitz, eugenia

On 27/02/14 15:36 -0500, David Miller wrote:
> From: Amir Vadai <amirv@mellanox.com>
> Date: Thu, 27 Feb 2014 17:46:37 +0200
> 
> > On 27/02/14 06:44 -0800, Eric Dumazet wrote:
> >> On Thu, 2014-02-27 at 16:02 +0200, Amir Vadai wrote:
> >> >  
> >> > Yes, skb will not be classified as inline-able if nr_frags != 1.
> >> > See is_inline()
> > 
> > Maybe I wasn't accurate enough. inline-able skb must have:
> > 1. skb->len < inline_thold 
> > 2. nr_frags <= 1
> > 
> > Default value for inline_thold is 104 and it is a module parameter
> > that can be changed.
> 
> BTW, the canonical way to deal with minimum length requirements is to
> use skb_padto().

I think that in this case it will be a bit of an overshoot. It
will add many unnecessary operations because it need to make sure that
there is enough space in the skb linear buffer for the padding. And in
my case the restriction is on the hardware buffer, so IMHO there is no
need to manipulate the skb.

Amir

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

* Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
  2014-02-27 21:47             ` Amir Vadai
@ 2014-02-27 21:58               ` David Miller
  0 siblings, 0 replies; 17+ messages in thread
From: David Miller @ 2014-02-27 21:58 UTC (permalink / raw)
  To: amirv; +Cc: eric.dumazet, David.Laight, netdev, yevgenyp, ogerlitz, eugenia

From: Amir Vadai <amirv@mellanox.com>
Date: Thu, 27 Feb 2014 23:47:54 +0200

> On 27/02/14 15:36 -0500, David Miller wrote:
>> From: Amir Vadai <amirv@mellanox.com>
>> Date: Thu, 27 Feb 2014 17:46:37 +0200
>> 
>> > On 27/02/14 06:44 -0800, Eric Dumazet wrote:
>> >> On Thu, 2014-02-27 at 16:02 +0200, Amir Vadai wrote:
>> >> >  
>> >> > Yes, skb will not be classified as inline-able if nr_frags != 1.
>> >> > See is_inline()
>> > 
>> > Maybe I wasn't accurate enough. inline-able skb must have:
>> > 1. skb->len < inline_thold 
>> > 2. nr_frags <= 1
>> > 
>> > Default value for inline_thold is 104 and it is a module parameter
>> > that can be changed.
>> 
>> BTW, the canonical way to deal with minimum length requirements is to
>> use skb_padto().
> 
> I think that in this case it will be a bit of an overshoot. It
> will add many unnecessary operations because it need to make sure that
> there is enough space in the skb linear buffer for the padding. And in
> my case the restriction is on the hardware buffer, so IMHO there is no
> need to manipulate the skb.

If you're copying the packet into a bounce buffer, yes.  But skb_padto()
is the thing to use if you're DMA'ing directly out of the SKB's buffer
memory.

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

end of thread, other threads:[~2014-02-27 21:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
2014-02-27 12:26 ` [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc Amir Vadai
2014-02-27 12:26 ` [PATCH net-next 2/9] net/mlx4_en: Verify mlx4_en module parameters Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes Amir Vadai
2014-02-27 13:08   ` David Laight
2014-02-27 14:02     ` Amir Vadai
2014-02-27 14:44       ` Eric Dumazet
2014-02-27 15:46         ` Amir Vadai
2014-02-27 20:36           ` David Miller
2014-02-27 21:47             ` Amir Vadai
2014-02-27 21:58               ` David Miller
2014-02-27 12:27 ` [PATCH net-next 4/9] net/mlx4_en: Move queue stopped/waked counters to be per ring Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 5/9] net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64() Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 6/9] net/mlx4_en: Fix selftest failing on non 10G link speed Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 7/9] net/mlx4_core: Fix sparse warning Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 9/9] net/mlx4_en: Change Connect-X description in kconfig Amir Vadai

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.