diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-03-17 17:05:23 +0000 |
---|---|---|
committer | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-03-31 14:44:15 +0100 |
commit | 86fcde82fdb89610879c10c844b2527b5e973b4a (patch) | |
tree | f4e99692e4481fb07f4df749efa3c60c51b21b9e | |
parent | 5d9c0922918c213e72a3b37723c2faa5d2cfb423 (diff) |
netdev-odp: refactor error handling in netdev_odp_rxq_recv
Refactor how odp_pktio_recv errors handled, including:
- use OVS_(UN)LIKELY
- set *c in error cases
- some code style fix at the definitions
- remove stale printf from the end
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
-rw-r--r-- | lib/netdev-odp.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index a7968dc61..385401f92 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -581,27 +581,28 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, struct netdev_odp *netdev = netdev_odp_cast(rx->up.netdev); int pkts, pkts_ok, ret = 0; size_t rx_bytes = 0; - unsigned long err_cnt = 0; - int i; - odp_packet_t pkt_tbl[NETDEV_MAX_RX_BATCH]; + unsigned long err_cnt = 0; + int i; + odp_packet_t pkt_tbl[NETDEV_MAX_RX_BATCH]; pkts = odp_pktio_recv(netdev->pktio, pkt_tbl, NETDEV_MAX_RX_BATCH); - if (pkts < 0) { - return EINVAL; - } - if (!pkts) { - return EAGAIN; - } - - if (pkts > 0) { + if (OVS_LIKELY(pkts > 0)) { pkts_ok = drop_err_pkts(pkt_tbl, pkts); - if (odp_unlikely(pkts_ok != pkts)) - VLOG_ERR("Dropped frames:%u - err_cnt:%lu\n", + if (OVS_UNLIKELY(pkts_ok != pkts)) + VLOG_ERR_RL(&rl, "Dropped frames:%u - err_cnt:%lu\n", pkts-pkts_ok, ++err_cnt); - if (!pkts_ok) { + if (OVS_UNLIKELY(!pkts_ok)) { + VLOG_ERR_RL(&rl, "ODP: All %d packets dropped!\n", pkts); + *c = 0; ret = EAGAIN; goto out_stats; } + } else { + *c = 0; + if (!pkts) + return EAGAIN; + VLOG_ERR_RL(&rl, "ODP: Packet receive error (%d)\n", pkts); + return EINVAL; } /* Allocate an ofpbuf for each valid packet */ @@ -620,8 +621,6 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, *c = pkts_ok; - printf("ODP: received %d packets\n", pkts_ok); - out_stats: ovs_mutex_lock(&netdev->mutex); netdev->stats.rx_packets += pkts_ok; |