From: Andrew Rybchenko Date: Tue, 29 Nov 2016 16:19:22 +0000 (+0000) Subject: net/sfc: discard scattered packet on Rx correctly X-Git-Tag: spdx-start~5049 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=09a09b6f8be1535f44b091048f95add7efd23d9c;p=dpdk.git net/sfc: discard scattered packet on Rx correctly Since Rx scatter is not supported, all scattered packets are discarded. It is not always possible to disable scatter on Huntington, so we should handle scattered packets correctly in any case. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index d9e84595ea..eed1b523f8 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -91,7 +91,27 @@ sfc_ev_rx(void *arg, __rte_unused uint32_t label, uint32_t id, delta = (stop >= pending_id) ? (stop - pending_id) : (rxq->ptr_mask + 1 - pending_id + stop); - if (unlikely(delta > rxq->batch_max)) { + if (delta == 0) { + /* + * Rx event with no new descriptors done and zero length + * is used to abort scattered packet when there is no room + * for the tail. + */ + if (unlikely(size != 0)) { + evq->exception = B_TRUE; + sfc_err(evq->sa, + "EVQ %u RxQ %u invalid RX abort " + "(id=%#x size=%u flags=%#x); needs restart\n", + evq->evq_index, sfc_rxq_sw_index(rxq), + id, size, flags); + goto done; + } + + /* Add discard flag to the first fragment */ + rxq->sw_desc[pending_id].flags |= EFX_DISCARD; + /* Remove continue flag from the last fragment */ + rxq->sw_desc[id].flags &= ~EFX_PKT_CONT; + } else if (unlikely(delta > rxq->batch_max)) { evq->exception = B_TRUE; sfc_err(evq->sa, diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 5587620817..bd41131a21 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -137,6 +137,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) unsigned int completed; unsigned int prefix_size = rxq->prefix_size; unsigned int done_pkts = 0; + boolean_t discard_next = B_FALSE; if (unlikely((rxq->state & SFC_RXQ_RUNNING) == 0)) return 0; @@ -156,9 +157,15 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) m = rxd->mbuf; desc_flags = rxd->flags; + if (discard_next) + goto discard; + if (desc_flags & (EFX_ADDR_MISMATCH | EFX_DISCARD)) goto discard; + if (desc_flags & EFX_PKT_CONT) + goto discard; + if (desc_flags & EFX_PKT_PREFIX_LEN) { uint16_t tmp_size; int rc __rte_unused; @@ -182,6 +189,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) continue; discard: + discard_next = ((desc_flags & EFX_PKT_CONT) != 0); rte_mempool_put(rxq->refill_mb_pool, m); rxd->mbuf = NULL; }