net/mlx5e: Add ethtool counter for RX buffer allocation failures
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_rx.c
index 5bdcc0b..918b7c7 100644 (file)
@@ -447,9 +447,14 @@ bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
 
        while (!mlx5_wq_ll_is_full(wq)) {
                struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head);
+               int err;
 
-               if (unlikely(rq->alloc_wqe(rq, wqe, wq->head)))
+               err = rq->alloc_wqe(rq, wqe, wq->head);
+               if (unlikely(err)) {
+                       if (err != -EBUSY)
+                               rq->stats.buff_alloc_err++;
                        break;
+               }
 
                mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index));
        }
@@ -573,10 +578,6 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
        if (unlikely(mlx5e_rx_hw_stamp(tstamp)))
                mlx5e_fill_hwstamp(tstamp, get_cqe_ts(cqe), skb_hwtstamps(skb));
 
-       mlx5e_handle_csum(netdev, cqe, rq, skb, !!lro_num_seg);
-
-       skb->protocol = eth_type_trans(skb, netdev);
-
        skb_record_rx_queue(skb, rq->ix);
 
        if (likely(netdev->features & NETIF_F_RXHASH))
@@ -587,6 +588,9 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
                                       be16_to_cpu(cqe->vlan_info));
 
        skb->mark = be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK;
+
+       mlx5e_handle_csum(netdev, cqe, rq, skb, !!lro_num_seg);
+       skb->protocol = eth_type_trans(skb, netdev);
 }
 
 static inline void mlx5e_complete_rx_cqe(struct mlx5e_rq *rq,
@@ -702,8 +706,10 @@ void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
        skb = napi_alloc_skb(rq->cq.napi,
                             ALIGN(MLX5_MPWRQ_SMALL_PACKET_THRESHOLD,
                                   sizeof(long)));
-       if (unlikely(!skb))
+       if (unlikely(!skb)) {
+               rq->stats.buff_alloc_err++;
                goto mpwrq_cqe_out;
+       }
 
        prefetch(skb->data);
        cqe_bcnt = mpwrq_get_cqe_byte_cnt(cqe);