Commit 089f97c7 authored by Quan Nguyen's avatar Quan Nguyen Committed by David S. Miller

drivers: net: xgene: Refactor statistics error parsing code

This patch fixes the tx error counters and adds more rx error counters.
Signed-off-by: default avatarQuan Nguyen <qnguyen@apm.com>
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3f5a2ef1
...@@ -205,30 +205,24 @@ static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring) ...@@ -205,30 +205,24 @@ static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring)
} }
void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring, void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
struct xgene_enet_pdata *pdata,
enum xgene_enet_err_code status) enum xgene_enet_err_code status)
{ {
switch (status) { switch (status) {
case INGRESS_CRC: case INGRESS_CRC:
ring->rx_crc_errors++; ring->rx_crc_errors++;
ring->rx_dropped++;
break; break;
case INGRESS_CHECKSUM: case INGRESS_CHECKSUM:
case INGRESS_CHECKSUM_COMPUTE: case INGRESS_CHECKSUM_COMPUTE:
ring->rx_errors++; ring->rx_errors++;
ring->rx_dropped++;
break; break;
case INGRESS_TRUNC_FRAME: case INGRESS_TRUNC_FRAME:
ring->rx_frame_errors++; ring->rx_frame_errors++;
ring->rx_dropped++;
break; break;
case INGRESS_PKT_LEN: case INGRESS_PKT_LEN:
ring->rx_length_errors++; ring->rx_length_errors++;
ring->rx_dropped++;
break; break;
case INGRESS_PKT_UNDER: case INGRESS_PKT_UNDER:
ring->rx_frame_errors++; ring->rx_frame_errors++;
ring->rx_dropped++;
break; break;
case INGRESS_FIFO_OVERRUN: case INGRESS_FIFO_OVERRUN:
ring->rx_fifo_errors++; ring->rx_fifo_errors++;
......
...@@ -380,9 +380,7 @@ static inline u16 xgene_enet_get_numslots(u16 id, u32 size) ...@@ -380,9 +380,7 @@ static inline u16 xgene_enet_get_numslots(u16 id, u32 size)
} }
void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring, void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
struct xgene_enet_pdata *pdata,
enum xgene_enet_err_code status); enum xgene_enet_err_code status);
int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata); int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata); void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
bool xgene_ring_mgr_init(struct xgene_enet_pdata *p); bool xgene_ring_mgr_init(struct xgene_enet_pdata *p);
......
...@@ -246,9 +246,9 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring, ...@@ -246,9 +246,9 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
skb_frag_t *frag; skb_frag_t *frag;
dma_addr_t *frag_dma_addr; dma_addr_t *frag_dma_addr;
u16 skb_index; u16 skb_index;
u8 status;
int i, ret = 0;
u8 mss_index; u8 mss_index;
u8 status;
int i;
skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0)); skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
skb = cp_ring->cp_skb[skb_index]; skb = cp_ring->cp_skb[skb_index];
...@@ -275,19 +275,17 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring, ...@@ -275,19 +275,17 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
/* Checking for error */ /* Checking for error */
status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0)); status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
if (unlikely(status > 2)) { if (unlikely(status > 2)) {
xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev), cp_ring->tx_dropped++;
status); cp_ring->tx_errors++;
ret = -EIO;
} }
if (likely(skb)) { if (likely(skb)) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
} else { } else {
netdev_err(cp_ring->ndev, "completion skb is NULL\n"); netdev_err(cp_ring->ndev, "completion skb is NULL\n");
ret = -EIO;
} }
return ret; return 0;
} }
static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss) static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss)
...@@ -711,7 +709,8 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring, ...@@ -711,7 +709,8 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
if (!xgene_enet_errata_10GE_8(skb, datalen, status)) { if (!xgene_enet_errata_10GE_8(skb, datalen, status)) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
xgene_enet_free_pagepool(page_pool, raw_desc, exp_desc); xgene_enet_free_pagepool(page_pool, raw_desc, exp_desc);
xgene_enet_parse_error(rx_ring, pdata, status); xgene_enet_parse_error(rx_ring, status);
rx_ring->rx_dropped++;
goto out; goto out;
} }
} }
...@@ -1477,6 +1476,8 @@ static void xgene_enet_get_stats64( ...@@ -1477,6 +1476,8 @@ static void xgene_enet_get_stats64(
if (ring) { if (ring) {
stats->tx_packets += ring->tx_packets; stats->tx_packets += ring->tx_packets;
stats->tx_bytes += ring->tx_bytes; stats->tx_bytes += ring->tx_bytes;
stats->tx_dropped += ring->tx_dropped;
stats->tx_errors += ring->tx_errors;
} }
} }
...@@ -1485,11 +1486,16 @@ static void xgene_enet_get_stats64( ...@@ -1485,11 +1486,16 @@ static void xgene_enet_get_stats64(
if (ring) { if (ring) {
stats->rx_packets += ring->rx_packets; stats->rx_packets += ring->rx_packets;
stats->rx_bytes += ring->rx_bytes; stats->rx_bytes += ring->rx_bytes;
stats->rx_errors += ring->rx_length_errors + stats->rx_dropped += ring->rx_dropped;
stats->rx_errors += ring->rx_errors +
ring->rx_length_errors +
ring->rx_crc_errors + ring->rx_crc_errors +
ring->rx_frame_errors + ring->rx_frame_errors +
ring->rx_fifo_errors; ring->rx_fifo_errors;
stats->rx_dropped += ring->rx_dropped; stats->rx_length_errors += ring->rx_length_errors;
stats->rx_crc_errors += ring->rx_crc_errors;
stats->rx_frame_errors += ring->rx_frame_errors;
stats->rx_fifo_errors += ring->rx_fifo_errors;
} }
} }
} }
......
...@@ -138,6 +138,8 @@ struct xgene_enet_desc_ring { ...@@ -138,6 +138,8 @@ struct xgene_enet_desc_ring {
__le64 *exp_bufs; __le64 *exp_bufs;
u64 tx_packets; u64 tx_packets;
u64 tx_bytes; u64 tx_bytes;
u64 tx_dropped;
u64 tx_errors;
u64 rx_packets; u64 rx_packets;
u64 rx_bytes; u64 rx_bytes;
u64 rx_dropped; u64 rx_dropped;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment