enic: add stats for dma mapping error
[cascardo/linux.git] / drivers / net / ethernet / cisco / enic / enic.h
index 25c4d88..d2a1035 100644 (file)
@@ -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)
@@ -242,6 +243,19 @@ 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);
+               enic->gen_stats.dma_map_error++;
+
+               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);