* [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19
@ 2013-08-21 7:08 Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 1/5] net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc() Amir Vadai
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai
Hi Dave,
This small patchset contains 2 fixes to bad handling of error flows in TX
datapath, and a fix to a bug in mlx4_en_dcbnl_ieee_setpfc() where global pause
frames were enabled whenever PFC was configured.
Also added a patch to reduce the scope of some local variables in the moved
block of code and it's surrounding.
Thanks,
Amir
---
Changes from V1:
- Split coding style fix from logical fix
Changes from V0:
- Missing new lines + typo's
- Fixed frags dma leak
- Use local for ddev
- New patch (4/4), to reduce scope of some locals
Amir Vadai (4):
net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc()
net/mlx4_en: Notify user when TX ring in error state
net/mlx4_en: Fix handling of dma_map failure
net/mlx4_en: Reduce scope of local variables in mlx4_en_xmit
Eugenia Emantayev (1):
net/mlx4_en: Disable global flow control when PFC enabled
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | 15 ++--
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 116 +++++++++++++++++--------
2 files changed, 87 insertions(+), 44 deletions(-)
--
1.8.3.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next V2 1/5] net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc()
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
@ 2013-08-21 7:08 ` Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 2/5] net/mlx4_en: Disable global flow control when PFC enabled Amir Vadai
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai
Fix some coding style issues in this function.
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
index 9d4a1ea..f71fba9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -160,6 +160,7 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
struct ieee_pfc *pfc)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
+ struct mlx4_en_port_profile *prof = priv->prof;
struct mlx4_en_dev *mdev = priv->mdev;
int err;
@@ -169,15 +170,17 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
pfc->mbc,
pfc->delay);
- priv->prof->rx_pause = priv->prof->tx_pause = !!pfc->pfc_en;
- priv->prof->rx_ppp = priv->prof->tx_ppp = pfc->pfc_en;
+ prof->rx_pause = !!pfc->pfc_en;
+ prof->tx_pause = !!pfc->pfc_en;
+ prof->rx_ppp = pfc->pfc_en;
+ prof->tx_ppp = pfc->pfc_en;
err = mlx4_SET_PORT_general(mdev->dev, priv->port,
priv->rx_skb_size + ETH_FCS_LEN,
- priv->prof->tx_pause,
- priv->prof->tx_ppp,
- priv->prof->rx_pause,
- priv->prof->rx_ppp);
+ prof->tx_pause,
+ prof->tx_ppp,
+ prof->rx_pause,
+ prof->rx_ppp);
if (err)
en_err(priv, "Failed setting pause params\n");
--
1.8.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 2/5] net/mlx4_en: Disable global flow control when PFC enabled
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 1/5] net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc() Amir Vadai
@ 2013-08-21 7:08 ` Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 3/5] net/mlx4_en: Notify user when TX ring in error state Amir Vadai
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai, Eugenia Emantayev
From: Eugenia Emantayev <eugenia@mellanox.com>
Fix a bug when FC and PFC are enabled/disabled at the same time.
According to ConnectX-3 Programmer Manual these two features are mutial
exclusive. So make sure when enabling PFC to turn off global FC and
vise versa. Otherwise it hurts the performance.
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
index f71fba9..b4881b6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -170,8 +170,8 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
pfc->mbc,
pfc->delay);
- prof->rx_pause = !!pfc->pfc_en;
- prof->tx_pause = !!pfc->pfc_en;
+ prof->rx_pause = !pfc->pfc_en;
+ prof->tx_pause = !pfc->pfc_en;
prof->rx_ppp = pfc->pfc_en;
prof->tx_ppp = pfc->pfc_en;
--
1.8.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 3/5] net/mlx4_en: Notify user when TX ring in error state
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 1/5] net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc() Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 2/5] net/mlx4_en: Disable global flow control when PFC enabled Amir Vadai
@ 2013-08-21 7:08 ` Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 4/5] net/mlx4_en: Fix handling of dma_map failure Amir Vadai
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai
When hardware gets into error state, must notify user about it.
When QP in error state no traffic will be tx'ed from the attached
tx_ring.
Driver should know how to recover from this unexpected state. I will send later
on the recovery flow, but having the print shouldn't be delayed.
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 6dcca98..0d691e3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -362,6 +362,15 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
*/
rmb();
+ if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
+ MLX4_CQE_OPCODE_ERROR)) {
+ struct mlx4_err_cqe *cqe_err = (struct mlx4_err_cqe *)cqe;
+
+ en_err(priv, "CQE error - vendor syndrome: 0x%x syndrome: 0x%x\n",
+ cqe_err->vendor_err_syndrome,
+ cqe_err->syndrome);
+ }
+
/* Skip over last polled CQE */
new_index = be16_to_cpu(cqe->wqe_index) & size_mask;
--
1.8.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 4/5] net/mlx4_en: Fix handling of dma_map failure
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
` (2 preceding siblings ...)
2013-08-21 7:08 ` [PATCH net-next V2 3/5] net/mlx4_en: Notify user when TX ring in error state Amir Vadai
@ 2013-08-21 7:08 ` Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 5/5] net/mlx4_en: Reduce scope of local variables in mlx4_en_xmit Amir Vadai
2013-08-21 19:20 ` [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai
Result of skb_frag_dma_map() and dma_map_single() wasn't checked.
Added a check and proper handling in case of failure.
Moved the mapping to the beginning of mlx4_en_xmit(), before updating
the ring data structure to make error handling easier.
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 97 +++++++++++++++++++-----------
1 file changed, 62 insertions(+), 35 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 0d691e3..c28868b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -588,6 +588,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
+ struct device *ddev = priv->ddev;
struct mlx4_en_tx_ring *ring;
struct mlx4_en_tx_desc *tx_desc;
struct mlx4_wqe_data_seg *data;
@@ -674,6 +675,56 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
tx_info->skb = skb;
tx_info->nr_txbb = nr_txbb;
+ if (lso_header_size)
+ data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4,
+ DS_SIZE));
+ else
+ data = &tx_desc->data;
+
+ /* valid only for none inline segments */
+ tx_info->data_offset = (void *)data - (void *)tx_desc;
+
+ tx_info->linear = (lso_header_size < skb_headlen(skb) &&
+ !is_inline(skb, NULL)) ? 1 : 0;
+
+ data += skb_shinfo(skb)->nr_frags + tx_info->linear - 1;
+
+ if (is_inline(skb, &fragptr)) {
+ tx_info->inl = 1;
+ } else {
+ /* Map fragments */
+ for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
+ frag = &skb_shinfo(skb)->frags[i];
+ dma = skb_frag_dma_map(ddev, frag,
+ 0, skb_frag_size(frag),
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(ddev, dma))
+ goto tx_drop_unmap;
+
+ data->addr = cpu_to_be64(dma);
+ data->lkey = cpu_to_be32(mdev->mr.key);
+ wmb();
+ data->byte_count = cpu_to_be32(skb_frag_size(frag));
+ --data;
+ }
+
+ /* Map linear part */
+ if (tx_info->linear) {
+ u32 byte_count = skb_headlen(skb) - lso_header_size;
+ dma = dma_map_single(ddev, skb->data +
+ lso_header_size, byte_count,
+ PCI_DMA_TODEVICE);
+ if (dma_mapping_error(ddev, dma))
+ goto tx_drop_unmap;
+
+ data->addr = cpu_to_be64(dma);
+ data->lkey = cpu_to_be32(mdev->mr.key);
+ wmb();
+ data->byte_count = cpu_to_be32(byte_count);
+ }
+ tx_info->inl = 0;
+ }
+
/*
* For timestamping add flag to skb_shinfo and
* set flag for further reference
@@ -720,8 +771,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
/* Copy headers;
* note that we already verified that it is linear */
memcpy(tx_desc->lso.header, skb->data, lso_header_size);
- data = ((void *) &tx_desc->lso +
- ALIGN(lso_header_size + 4, DS_SIZE));
priv->port_stats.tso_packets++;
i = ((skb->len - lso_header_size) / skb_shinfo(skb)->gso_size) +
@@ -733,7 +782,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
op_own = cpu_to_be32(MLX4_OPCODE_SEND) |
((ring->prod & ring->size) ?
cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0);
- data = &tx_desc->data;
tx_info->nr_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
ring->packets++;
@@ -742,38 +790,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
netdev_tx_sent_queue(ring->tx_queue, tx_info->nr_bytes);
AVG_PERF_COUNTER(priv->pstats.tx_pktsz_avg, skb->len);
-
- /* valid only for none inline segments */
- tx_info->data_offset = (void *) data - (void *) tx_desc;
-
- tx_info->linear = (lso_header_size < skb_headlen(skb) && !is_inline(skb, NULL)) ? 1 : 0;
- data += skb_shinfo(skb)->nr_frags + tx_info->linear - 1;
-
- if (!is_inline(skb, &fragptr)) {
- /* Map fragments */
- for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
- frag = &skb_shinfo(skb)->frags[i];
- dma = skb_frag_dma_map(priv->ddev, frag,
- 0, skb_frag_size(frag),
- DMA_TO_DEVICE);
- data->addr = cpu_to_be64(dma);
- data->lkey = cpu_to_be32(mdev->mr.key);
- wmb();
- data->byte_count = cpu_to_be32(skb_frag_size(frag));
- --data;
- }
-
- /* Map linear part */
- if (tx_info->linear) {
- dma = dma_map_single(priv->ddev, skb->data + lso_header_size,
- skb_headlen(skb) - lso_header_size, PCI_DMA_TODEVICE);
- data->addr = cpu_to_be64(dma);
- data->lkey = cpu_to_be32(mdev->mr.key);
- wmb();
- data->byte_count = cpu_to_be32(skb_headlen(skb) - lso_header_size);
- }
- tx_info->inl = 0;
- } else {
+ if (tx_info->inl) {
build_inline_wqe(tx_desc, skb, real_size, &vlan_tag, tx_ind, fragptr);
tx_info->inl = 1;
}
@@ -813,6 +830,16 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
+tx_drop_unmap:
+ en_err(priv, "DMA mapping error\n");
+
+ for (i++; i < skb_shinfo(skb)->nr_frags; i++) {
+ data++;
+ dma_unmap_page(ddev, (dma_addr_t) be64_to_cpu(data->addr),
+ be32_to_cpu(data->byte_count),
+ PCI_DMA_TODEVICE);
+ }
+
tx_drop:
dev_kfree_skb_any(skb);
priv->stats.tx_dropped++;
--
1.8.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next V2 5/5] net/mlx4_en: Reduce scope of local variables in mlx4_en_xmit
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
` (3 preceding siblings ...)
2013-08-21 7:08 ` [PATCH net-next V2 4/5] net/mlx4_en: Fix handling of dma_map failure Amir Vadai
@ 2013-08-21 7:08 ` Amir Vadai
2013-08-21 19:20 ` [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 David Miller
5 siblings, 0 replies; 7+ messages in thread
From: Amir Vadai @ 2013-08-21 7:08 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Amir Vadai
Some variables could have their scope reduced.
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index c28868b..0698c82 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -592,14 +592,11 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
struct mlx4_en_tx_ring *ring;
struct mlx4_en_tx_desc *tx_desc;
struct mlx4_wqe_data_seg *data;
- struct skb_frag_struct *frag;
struct mlx4_en_tx_info *tx_info;
- struct ethhdr *ethh;
int tx_ind = 0;
int nr_txbb;
int desc_size;
int real_size;
- dma_addr_t dma;
u32 index, bf_index;
__be32 op_own;
u16 vlan_tag = 0;
@@ -694,6 +691,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
} else {
/* Map fragments */
for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
+ struct skb_frag_struct *frag;
+ dma_addr_t dma;
+
frag = &skb_shinfo(skb)->frags[i];
dma = skb_frag_dma_map(ddev, frag,
0, skb_frag_size(frag),
@@ -711,6 +711,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
/* Map linear part */
if (tx_info->linear) {
u32 byte_count = skb_headlen(skb) - lso_header_size;
+ dma_addr_t dma;
+
dma = dma_map_single(ddev, skb->data +
lso_header_size, byte_count,
PCI_DMA_TODEVICE);
@@ -749,6 +751,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (priv->flags & MLX4_EN_FLAG_ENABLE_HW_LOOPBACK) {
+ struct ethhdr *ethh;
+
/* Copy dst mac address to wqe. This allows loopback in eSwitch,
* so that VFs and PF can communicate with each other
*/
--
1.8.3.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
` (4 preceding siblings ...)
2013-08-21 7:08 ` [PATCH net-next V2 5/5] net/mlx4_en: Reduce scope of local variables in mlx4_en_xmit Amir Vadai
@ 2013-08-21 19:20 ` David Miller
5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2013-08-21 19:20 UTC (permalink / raw)
To: amirv; +Cc: netdev
From: Amir Vadai <amirv@mellanox.com>
Date: Wed, 21 Aug 2013 10:08:54 +0300
> This small patchset contains 2 fixes to bad handling of error flows in TX
> datapath, and a fix to a bug in mlx4_en_dcbnl_ieee_setpfc() where global pause
> frames were enabled whenever PFC was configured.
> Also added a patch to reduce the scope of some local variables in the moved
> block of code and it's surrounding.
Series applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-08-21 19:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-21 7:08 [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 1/5] net/mlx4_en: Coding style cleanup in mlx4_en_dcbnl_ieee_setpfc() Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 2/5] net/mlx4_en: Disable global flow control when PFC enabled Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 3/5] net/mlx4_en: Notify user when TX ring in error state Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 4/5] net/mlx4_en: Fix handling of dma_map failure Amir Vadai
2013-08-21 7:08 ` [PATCH net-next V2 5/5] net/mlx4_en: Reduce scope of local variables in mlx4_en_xmit Amir Vadai
2013-08-21 19:20 ` [PATCH net-next V2 0/5] Mellanox driver updates 2013-08-19 David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).