Skip to contentSkip to conversation

enic: Check for DMA mapping error

PATCH In review Govindarajulu Varadarajan 3 participants 7 messages Dec 24, 2014 – Jan 5, 2015

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/3 enic: make vnic_wq_buf doubly linked

In reply to Govindarajulu Varadarajan

This patch makes vnic_wq_buf doubly liked list. This is needed for dma_mapping error check, in case some frag's dma map fails, we need to move back and remove previously queued buffers.

---
 drivers/net/ethernet/cisco/enic/vnic_wq.c | 3 +++
 drivers/net/ethernet/cisco/enic/vnic_wq.h | 1 +
 2 files changed, 4 insertions(+)
drivers/net/ethernet/cisco/enic/vnic_wq.c +3 -0
index 3e6b8d5..b5a1c93 100644
@@ -47,11 +47,14 @@ static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
 				wq->ring.desc_size * buf->index;
 			if (buf->index + 1 == count) {
 				buf->next = wq->bufs[0];
+				buf->next->prev = buf;
 				break;
 			} else if (j + 1 == VNIC_WQ_BUF_BLK_ENTRIES(count)) {
 				buf->next = wq->bufs[i + 1];
+				buf->next->prev = buf;
 			} else {
 				buf->next = buf + 1;
+				buf->next->prev = buf;
 				buf++;
 			}
 		}
drivers/net/ethernet/cisco/enic/vnic_wq.h +1 -0
index 816f1ad..2961543 100644
@@ -62,6 +62,7 @@ struct vnic_wq_buf {
 	uint8_t cq_entry; /* Gets completion event from hw */
 	uint8_t desc_skip_cnt; /* Num descs to occupy */
 	uint8_t compressed_send; /* Both hdr and payload in one desc */
+	struct vnic_wq_buf *prev;
 };
 
 /* Break the vnic_wq_buf allocations into blocks of 32/64 entries */
Signature · 1 line
2.2.1
#3 lore raw

PATCH 2/3 enic: check dma_mapping_error

In reply to Govindarajulu Varadarajan

This patch checks for pci_dma_mapping_error() after dma mapping the data. If the dma mapping fails we remove the previously queued frags and return NETDEV_TX_OK.

---
 drivers/net/ethernet/cisco/enic/enic.h      |  12 +++
 drivers/net/ethernet/cisco/enic/enic_main.c | 152 +++++++++++++++++-----------
 2 files changed, 106 insertions(+), 58 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +12 -0
index 25c4d88..b2ea35a 100644
@@ -242,6 +242,18 @@ static inline unsigned int enic_msix_notify_intr(struct enic *enic)
 	return enic->rq_count + enic->wq_count + 1;
 }
 
+static inline int enic_dma_map_check(struct enic *enic, dma_addr_t dma_addr)
+{
+	if (unlikely(pci_dma_mapping_error(enic->pdev, dma_addr))) {
+		net_warn_ratelimited("%s: PCI dma mapping failed!\n",
+				     enic->netdev->name);
+
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 void enic_reset_addr_lists(struct enic *enic);
 int enic_sriov_enabled(struct enic *enic);
 int enic_is_valid_vf(struct enic *enic, int vf);
drivers/net/ethernet/cisco/enic/enic_main.c +94 -58

238 lines not on this page · raw message

Signature · 1 line
2.2.1
#5 lore raw

PATCH 3/3 enic: add stats for dma mapping error

In reply to Govindarajulu Varadarajan

This patch adds generic statistics for enic. As of now dma_map_error is the only member. dma_map_erro is incremented every time dma maping error happens.

---
 drivers/net/ethernet/cisco/enic/enic.h         |  2 ++
 drivers/net/ethernet/cisco/enic/enic_ethtool.c | 19 ++++++++++++++++++-
 drivers/net/ethernet/cisco/enic/vnic_stats.h   |  5 +++++
 3 files changed, 25 insertions(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic.h +2 -0
index b2ea35a..d2a1035 100644
@@ -188,6 +188,7 @@ struct enic {
 	struct enic_rfs_flw_tbl rfs_h;
 	u32 rx_copybreak;
 	u8 rss_key[ENIC_RSS_LEN];
+	struct vnic_gen_stats gen_stats;
 };
 
 static inline struct device *enic_get_dev(struct enic *enic)
@@ -247,6 +248,7 @@ static inline int enic_dma_map_check(struct enic *enic, dma_addr_t dma_addr)
 	if (unlikely(pci_dma_mapping_error(enic->pdev, dma_addr))) {
 		net_warn_ratelimited("%s: PCI dma mapping failed!\n",
 				     enic->netdev->name);
+		enic->gen_stats.dma_map_error++;
 
 		return -ENOMEM;
 	}
drivers/net/ethernet/cisco/enic/enic_ethtool.c +18 -1
index eba1eb8..0c396c1 100644
@@ -24,6 +24,7 @@
 #include "enic_dev.h"
 #include "enic_clsf.h"
 #include "vnic_rss.h"
+#include "vnic_stats.h"
 
 struct enic_stat {
 	char name[ETH_GSTRING_LEN];
@@ -40,6 +41,11 @@ struct enic_stat {
 	.index = offsetof(struct vnic_rx_stats, stat) / sizeof(u64) \
 }
 
+#define ENIC_GEN_STAT(stat) { \
+	.name = #stat, \
+	.index = offsetof(struct vnic_gen_stats, stat) / sizeof(u64)\
+}
+
 static const struct enic_stat enic_tx_stats[] = {
 	ENIC_TX_STAT(tx_frames_ok),
 	ENIC_TX_STAT(tx_unicast_frames_ok),
@@ -78,8 +84,13 @@ static const struct enic_stat enic_rx_stats[] = {
 	ENIC_RX_STAT(rx_frames_to_max),
 };
 
+static const struct enic_stat enic_gen_stats[] = {
+	ENIC_GEN_STAT(dma_map_error),
+};
+
 static const unsigned int enic_n_tx_stats = ARRAY_SIZE(enic_tx_stats);
 static const unsigned int enic_n_rx_stats = ARRAY_SIZE(enic_rx_stats);
+static const unsigned int enic_n_gen_stats = ARRAY_SIZE(enic_gen_stats);
 
 void enic_intr_coal_set_rx(struct enic *enic, u32 timer)
 {
@@ -146,6 +157,10 @@ static void enic_get_strings(struct net_device *netdev, u32 stringset,
 			memcpy(data, enic_rx_stats[i].name, ETH_GSTRING_LEN);
 			data += ETH_GSTRING_LEN;
 		}
+		for (i = 0; i < enic_n_gen_stats; i++) {
+			memcpy(data, enic_gen_stats[i].name, ETH_GSTRING_LEN);
+			data += ETH_GSTRING_LEN;
+		}
 		break;
 	}
 }
@@ -154,7 +169,7 @@ static int enic_get_sset_count(struct net_device *netdev, int sset)
 {
 	switch (sset) {
 	case ETH_SS_STATS:
-		return enic_n_tx_stats + enic_n_rx_stats;
+		return enic_n_tx_stats + enic_n_rx_stats + enic_n_gen_stats;
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -173,6 +188,8 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
 		*(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].index];
 	for (i = 0; i < enic_n_rx_stats; i++)
 		*(data++) = ((u64 *)&vstats->rx)[enic_rx_stats[i].index];
+	for (i = 0; i < enic_n_gen_stats; i++)
+		*(data++) = ((u64 *)&enic->gen_stats)[enic_gen_stats[i].index];
 }
 
 static u32 enic_get_msglevel(struct net_device *netdev)
drivers/net/ethernet/cisco/enic/vnic_stats.h +5 -0
index 77750ec..74c81ed 100644
@@ -62,6 +62,11 @@ struct vnic_rx_stats {
 	u64 rsvd[16];
 };
 
+/* Generic statistics */
+struct vnic_gen_stats {
+	u64 dma_map_error;
+};
+
 struct vnic_stats {
 	struct vnic_tx_stats tx;
 	struct vnic_rx_stats rx;
Signature · 1 line
2.2.1
#0 lore raw

cover enic: Check for DMA mapping error

After dma mapping the buffers, enic does not call dma_mapping_error() to check if mapping is successful.

This series fixes the issue by checking return value of pci_dma_mapping_error() after pci_map_single().

This is reported by redhat here
https://bugzilla.redhat.com/show_bug.cgi?id=1145016

Govindarajulu Varadarajan (3):
enic: make vnic_wq_buf doubly linked
enic: check dma_mapping_error
enic: add stats for dma mapping error

 drivers/net/ethernet/cisco/enic/enic.h         |  14 +++
 drivers/net/ethernet/cisco/enic/enic_ethtool.c |  19 +++-
 drivers/net/ethernet/cisco/enic/enic_main.c    | 152 +++++++++++++++----------
 drivers/net/ethernet/cisco/enic/vnic_stats.h   |   5 +
 drivers/net/ethernet/cisco/enic/vnic_wq.c      |   3 +
 drivers/net/ethernet/cisco/enic/vnic_wq.h      |   1 +
 6 files changed, 135 insertions(+), 59 deletions(-)
Signature · 1 line
2.2.1
maintainer
#6 lore raw

From: Govindarajulu Varadarajan <[email protected]>
Date: Wed, 24 Dec 2014 15:59:35 +0530

Quoted 8 lines

After dma mapping the buffers, enic does not call dma_mapping_error() to check if mapping is successful.

This series fixes the issue by checking return value of pci_dma_mapping_error() after pci_map_single().

This is reported by redhat here
https://bugzilla.redhat.com/show_bug.cgi?id=1145016

Series applied, thank you.

#2 lore raw

RE: [PATCH net-next 1/3] enic: make vnic_wq_buf doubly linked

In reply to Govindarajulu Varadarajan
Quoted 3 lines

This patch makes vnic_wq_buf doubly liked list. This is needed for dma_mapping error check, in case some frag's dma map fails, we need to move back and remove previously queued buffers.

I can't see any code that keeps the back-pointers valid when items are removed. Maybe they aren't needed, but I'd like to be convinced.

If errors are really unlikely, and the list likely to be short, then just traverse the entire list forwards in the error path.

David

Quoted 45 lines
---
 drivers/net/ethernet/cisco/enic/vnic_wq.c | 3 +++
 drivers/net/ethernet/cisco/enic/vnic_wq.h | 1 +
 2 files changed, 4 insertions(+)
drivers/net/ethernet/cisco/enic/vnic_wq.c +3 -0
index 3e6b8d5..b5a1c93 100644
@@ -47,11 +47,14 @@ static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
 				wq->ring.desc_size * buf->index;
 			if (buf->index + 1 == count) {
 				buf->next = wq->bufs[0];
+				buf->next->prev = buf;
 				break;
 			} else if (j + 1 == VNIC_WQ_BUF_BLK_ENTRIES(count)) {
 				buf->next = wq->bufs[i + 1];
+				buf->next->prev = buf;
 			} else {
 				buf->next = buf + 1;
+				buf->next->prev = buf;
 				buf++;
 			}
 		}
drivers/net/ethernet/cisco/enic/vnic_wq.h +1 -1
index 816f1ad..2961543 100644
@@ -62,6 +62,7 @@ struct vnic_wq_buf {
 	uint8_t cq_entry; /* Gets completion event from hw */
 	uint8_t desc_skip_cnt; /* Num descs to occupy */
 	uint8_t compressed_send; /* Both hdr and payload in one desc */
+	struct vnic_wq_buf *prev;
 };
 
 /* Break the vnic_wq_buf allocations into blocks of 32/64 entries */
--

2.2.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

RE: [PATCH net-next 2/3] enic: check dma_mapping_error

In reply to Govindarajulu Varadarajan
Quoted 3 lines

This patch checks for pci_dma_mapping_error() after dma mapping the data. If the dma mapping fails we remove the previously queued frags and return NETDEV_TX_OK.

This patch contains a lot of whitespace changes that make it very difficult to review.

Split the patch.

David