Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 1 | From 678e5952cf49bb66c2d697581a70dc8c7d703e8f Mon Sep 17 00:00:00 2001 |
| 2 | From: John Daley <johndale@cisco.com> |
| 3 | Date: Thu, 17 Mar 2016 15:57:06 -0700 |
| 4 | Subject: [PATCH 17/22] enic: fix error packets handling |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 5 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 6 | If the packet_error bit in the completion descriptor is set, the |
| 7 | remainder of the descriptor and data are invalid. PKT_RX_MAC_ERR |
| 8 | was set in the mbuf->ol_flags if packet_error was set and used |
| 9 | later to indicate an error packet. But since PKT_RX_MAC_ERR is |
| 10 | defined as 0, mbuf flags and packet types and length were being |
| 11 | misinterpreted. |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 12 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 13 | Make the function enic_cq_rx_to_pkt_err_flags() return true for error |
| 14 | packets and use the return value instead of mbuf->ol_flags to indicate |
| 15 | error packets. Also remove warning for error packets and rely on |
| 16 | rx_error stats. |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 17 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 18 | Fixes: 947d860c821f ("enic: improve Rx performance") |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 19 | |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 20 | Signed-off-by: John Daley <johndale@cisco.com> |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 21 | --- |
| 22 | drivers/net/enic/enic_rx.c | 43 ++++++++++++++++++------------------------- |
| 23 | 1 file changed, 18 insertions(+), 25 deletions(-) |
John Lo | 23650e6 | 2016-03-29 16:14:35 -0400 | [diff] [blame] | 24 | |
| 25 | diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c |
| 26 | index 59ebaa4..817a891 100644 |
| 27 | --- a/drivers/net/enic/enic_rx.c |
| 28 | +++ b/drivers/net/enic/enic_rx.c |
| 29 | @@ -129,13 +129,6 @@ enic_cq_rx_desc_rss_hash(struct cq_enet_rq_desc *cqrd) |
| 30 | return le32_to_cpu(cqrd->rss_hash); |
| 31 | } |
| 32 | |
| 33 | -static inline uint8_t |
| 34 | -enic_cq_rx_desc_fcs_ok(struct cq_enet_rq_desc *cqrd) |
| 35 | -{ |
| 36 | - return ((cqrd->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) == |
| 37 | - CQ_ENET_RQ_DESC_FLAGS_FCS_OK); |
| 38 | -} |
| 39 | - |
| 40 | static inline uint16_t |
| 41 | enic_cq_rx_desc_vlan(struct cq_enet_rq_desc *cqrd) |
| 42 | { |
| 43 | @@ -150,25 +143,21 @@ enic_cq_rx_desc_n_bytes(struct cq_desc *cqd) |
| 44 | CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK; |
| 45 | } |
| 46 | |
| 47 | -static inline uint64_t |
| 48 | -enic_cq_rx_to_pkt_err_flags(struct cq_desc *cqd) |
| 49 | +static inline uint8_t |
| 50 | +enic_cq_rx_to_pkt_err_flags(struct cq_desc *cqd, uint64_t *pkt_err_flags_out) |
| 51 | { |
| 52 | struct cq_enet_rq_desc *cqrd = (struct cq_enet_rq_desc *)cqd; |
| 53 | uint16_t bwflags; |
| 54 | + int ret = 0; |
| 55 | uint64_t pkt_err_flags = 0; |
| 56 | |
| 57 | bwflags = enic_cq_rx_desc_bwflags(cqrd); |
| 58 | - |
| 59 | - /* Check for packet error. Can't be more specific than MAC error */ |
| 60 | - if (enic_cq_rx_desc_packet_error(bwflags)) { |
| 61 | - pkt_err_flags |= PKT_RX_MAC_ERR; |
| 62 | - } |
| 63 | - |
| 64 | - /* Check for bad FCS. MAC error isn't quite, but no other choice */ |
| 65 | - if (!enic_cq_rx_desc_fcs_ok(cqrd)) { |
| 66 | - pkt_err_flags |= PKT_RX_MAC_ERR; |
| 67 | + if (unlikely(enic_cq_rx_desc_packet_error(bwflags))) { |
| 68 | + pkt_err_flags = PKT_RX_MAC_ERR; |
| 69 | + ret = 1; |
| 70 | } |
| 71 | - return pkt_err_flags; |
| 72 | + *pkt_err_flags_out = pkt_err_flags; |
| 73 | + return ret; |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | @@ -282,6 +271,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 78 | dma_addr_t dma_addr; |
| 79 | struct cq_desc cqd; |
| 80 | uint64_t ol_err_flags; |
| 81 | + uint8_t packet_error; |
| 82 | |
| 83 | /* Check for pkts available */ |
| 84 | color = (cqd_ptr->type_color >> CQ_DESC_COLOR_SHIFT) |
| 85 | @@ -303,9 +293,9 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 86 | break; |
| 87 | } |
| 88 | |
| 89 | - /* Check for FCS or packet errors */ |
| 90 | - ol_err_flags = enic_cq_rx_to_pkt_err_flags(&cqd); |
| 91 | - if (ol_err_flags == 0) |
| 92 | + /* A packet error means descriptor and data are untrusted */ |
| 93 | + packet_error = enic_cq_rx_to_pkt_err_flags(&cqd, &ol_err_flags); |
| 94 | + if (!packet_error) |
| 95 | rx_pkt_len = enic_cq_rx_desc_n_bytes(&cqd); |
| 96 | else |
| 97 | rx_pkt_len = 0; |
| 98 | @@ -340,10 +330,13 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 99 | rxmb->pkt_len = rx_pkt_len; |
| 100 | rxmb->data_len = rx_pkt_len; |
| 101 | rxmb->port = enic->port_id; |
| 102 | - rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); |
| 103 | - rxmb->ol_flags = ol_err_flags; |
| 104 | - if (!ol_err_flags) |
| 105 | + if (!packet_error) { |
| 106 | + rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); |
| 107 | enic_cq_rx_to_pkt_flags(&cqd, rxmb); |
| 108 | + } else { |
| 109 | + rxmb->packet_type = 0; |
| 110 | + rxmb->ol_flags = 0; |
| 111 | + } |
| 112 | |
| 113 | /* prefetch mbuf data for caller */ |
| 114 | rte_packet_prefetch(RTE_PTR_ADD(rxmb->buf_addr, |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 115 | -- |
| 116 | 1.9.1 |
| 117 | |