John Lo | 1220afe | 2016-05-27 22:07:44 -0400 | [diff] [blame] | 1 | diff -ur dpdk-16.04.orig/drivers/net/enic/enic.h dpdk-16.04/drivers/net/enic/enic.h |
| 2 | --- dpdk-16.04.orig/drivers/net/enic/enic.h 2016-05-26 16:59:16.531326660 -0700 |
| 3 | +++ dpdk-16.04/drivers/net/enic/enic.h 2016-05-26 16:59:52.689262489 -0700 |
| 4 | @@ -91,6 +91,11 @@ |
| 5 | struct enic_fdir_node *nodes[ENICPMD_FDIR_MAX]; |
| 6 | }; |
| 7 | |
| 8 | +struct enic_soft_stats { |
| 9 | + rte_atomic64_t rx_nombuf; |
| 10 | + rte_atomic64_t rx_packet_errors; |
| 11 | +}; |
| 12 | + |
| 13 | /* Per-instance private data structure */ |
| 14 | struct enic { |
| 15 | struct enic *next; |
| 16 | @@ -133,6 +138,8 @@ |
| 17 | /* interrupt resource */ |
| 18 | struct vnic_intr intr; |
| 19 | unsigned int intr_count; |
| 20 | + |
| 21 | + struct enic_soft_stats soft_stats; |
| 22 | }; |
| 23 | |
| 24 | static inline unsigned int enic_cq_rq(__rte_unused struct enic *enic, unsigned int rq) |
| 25 | diff -ur dpdk-16.04.orig/drivers/net/enic/enic_main.c dpdk-16.04/drivers/net/enic/enic_main.c |
| 26 | --- dpdk-16.04.orig/drivers/net/enic/enic_main.c 2016-05-26 16:59:16.533326822 -0700 |
| 27 | +++ dpdk-16.04/drivers/net/enic/enic_main.c 2016-05-26 17:08:11.768801926 -0700 |
| 28 | @@ -142,22 +142,51 @@ |
| 29 | } |
| 30 | |
| 31 | |
| 32 | +static void enic_clear_soft_stats(struct enic *enic) |
| 33 | +{ |
| 34 | + struct enic_soft_stats *soft_stats = &enic->soft_stats; |
| 35 | + rte_atomic64_clear(&soft_stats->rx_nombuf); |
| 36 | + rte_atomic64_clear(&soft_stats->rx_packet_errors); |
| 37 | +} |
| 38 | + |
| 39 | +static void enic_init_soft_stats(struct enic *enic) |
| 40 | +{ |
| 41 | + struct enic_soft_stats *soft_stats = &enic->soft_stats; |
| 42 | + rte_atomic64_init(&soft_stats->rx_nombuf); |
| 43 | + rte_atomic64_init(&soft_stats->rx_packet_errors); |
| 44 | + enic_clear_soft_stats(enic); |
| 45 | +} |
| 46 | + |
| 47 | void enic_dev_stats_clear(struct enic *enic) |
| 48 | { |
| 49 | if (vnic_dev_stats_clear(enic->vdev)) |
| 50 | dev_err(enic, "Error in clearing stats\n"); |
| 51 | + enic_clear_soft_stats(enic); |
| 52 | } |
| 53 | |
| 54 | void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats) |
| 55 | { |
| 56 | struct vnic_stats *stats; |
| 57 | + struct enic_soft_stats *soft_stats = &enic->soft_stats; |
| 58 | + int64_t rx_truncated; |
| 59 | + uint64_t rx_packet_errors; |
| 60 | |
| 61 | if (vnic_dev_stats_dump(enic->vdev, &stats)) { |
| 62 | dev_err(enic, "Error in getting stats\n"); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | - r_stats->ipackets = stats->rx.rx_frames_ok; |
| 67 | + /* The number of truncated packets can only be calculated by |
| 68 | + * subtracting a hardware counter from error packets received by |
| 69 | + * the driver. Note: this causes transient inaccuracies in the |
| 70 | + * ipackets count. Also, the length of truncated packets are |
| 71 | + * counted in ibytes even though truncated packets are dropped |
| 72 | + * which can make ibytes be slightly higher than it should be. |
| 73 | + */ |
| 74 | + rx_packet_errors = rte_atomic64_read(&soft_stats->rx_packet_errors); |
| 75 | + rx_truncated = rx_packet_errors - stats->rx.rx_errors; |
| 76 | + |
| 77 | + r_stats->ipackets = stats->rx.rx_frames_ok - rx_truncated; |
| 78 | r_stats->opackets = stats->tx.tx_frames_ok; |
| 79 | |
| 80 | r_stats->ibytes = stats->rx.rx_bytes_ok; |
| 81 | @@ -166,10 +195,9 @@ |
| 82 | r_stats->ierrors = stats->rx.rx_errors + stats->rx.rx_drop; |
| 83 | r_stats->oerrors = stats->tx.tx_errors; |
| 84 | |
| 85 | - r_stats->imissed = stats->rx.rx_no_bufs; |
| 86 | + r_stats->imissed = stats->rx.rx_no_bufs + rx_truncated; |
| 87 | |
| 88 | - r_stats->imcasts = stats->rx.rx_multicast_frames_ok; |
| 89 | - r_stats->rx_nombuf = stats->rx.rx_no_bufs; |
| 90 | + r_stats->rx_nombuf = rte_atomic64_read(&soft_stats->rx_nombuf); |
| 91 | } |
| 92 | |
| 93 | void enic_del_mac_address(struct enic *enic) |
| 94 | @@ -755,6 +783,8 @@ |
| 95 | { |
| 96 | int ret; |
| 97 | |
| 98 | + enic_init_soft_stats(enic); |
| 99 | + |
| 100 | ret = enic_set_rss_nic_cfg(enic); |
| 101 | if (ret) { |
| 102 | dev_err(enic, "Failed to config nic, aborting.\n"); |
| 103 | diff -ur dpdk-16.04.orig/drivers/net/enic/enic_rxtx.c dpdk-16.04/drivers/net/enic/enic_rxtx.c |
| 104 | --- dpdk-16.04.orig/drivers/net/enic/enic_rxtx.c 2016-05-26 16:59:16.522325929 -0700 |
| 105 | +++ dpdk-16.04/drivers/net/enic/enic_rxtx.c 2016-05-26 16:59:52.694262896 -0700 |
| 106 | @@ -251,6 +251,7 @@ |
| 107 | struct vnic_cq *cq; |
| 108 | volatile struct cq_desc *cqd_ptr; |
| 109 | uint8_t color; |
| 110 | + uint16_t nb_err = 0; |
| 111 | |
| 112 | cq = &enic->cq[enic_cq_rq(enic, rq->index)]; |
| 113 | rx_id = cq->to_clean; /* index of cqd, rqd, mbuf_table */ |
| 114 | @@ -278,10 +279,7 @@ |
| 115 | /* allocate a new mbuf */ |
| 116 | nmb = rte_rxmbuf_alloc(rq->mp); |
| 117 | if (nmb == NULL) { |
| 118 | - dev_err(enic, "RX mbuf alloc failed port=%u qid=%u", |
| 119 | - enic->port_id, (unsigned)rq->index); |
| 120 | - rte_eth_devices[enic->port_id]. |
| 121 | - data->rx_mbuf_alloc_failed++; |
| 122 | + rte_atomic64_inc(&enic->soft_stats.rx_nombuf); |
| 123 | break; |
| 124 | } |
| 125 | |
| 126 | @@ -323,9 +321,10 @@ |
| 127 | rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); |
| 128 | enic_cq_rx_to_pkt_flags(&cqd, rxmb); |
| 129 | } else { |
| 130 | - rxmb->pkt_len = 0; |
| 131 | - rxmb->packet_type = 0; |
| 132 | - rxmb->ol_flags = 0; |
| 133 | + rte_pktmbuf_free(rxmb); |
| 134 | + rte_atomic64_inc(&enic->soft_stats.rx_packet_errors); |
| 135 | + nb_err++; |
| 136 | + continue; |
| 137 | } |
| 138 | rxmb->data_len = rxmb->pkt_len; |
| 139 | |
| 140 | @@ -337,7 +336,7 @@ |
| 141 | rx_pkts[nb_rx++] = rxmb; |
| 142 | } |
| 143 | |
| 144 | - nb_hold += nb_rx; |
| 145 | + nb_hold += nb_rx + nb_err; |
| 146 | cq->to_clean = rx_id; |
| 147 | |
| 148 | if (nb_hold > rq->rx_free_thresh) { |