From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-5.cisco.com (alln-iport-5.cisco.com [173.37.142.92]) by dpdk.org (Postfix) with ESMTP id 417092C59 for ; Thu, 17 Mar 2016 23:57:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3705; q=dns/txt; s=iport; t=1458255436; x=1459465036; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=4iie7eNMJKIefqrIYMq8pmndjQjUkDedv41uwFJew8s=; b=BiudJD2j0qA89QPJV35b5vUbPnEYQ6nnoMvPSGFV5LCv4d9kSS2R0VVI 464+UlXGvCkuWXBf46YrgrMRwxKNxas9GFQWyL7OHYfxurDtZoqdCtbUV IazCzUZbKXd8fItLuGU9DzfObyAkcrT8twMn0rZ30TQVmDKrlnW72OjHo Y=; X-IronPort-AV: E=Sophos;i="5.24,351,1454976000"; d="scan'208";a="248851425" Received: from alln-core-2.cisco.com ([173.36.13.135]) by alln-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Mar 2016 22:57:15 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id u2HMvFjQ010709; Thu, 17 Mar 2016 22:57:15 GMT Received: by cisco.com (Postfix, from userid 392789) id 41FE73FAADAE; Thu, 17 Mar 2016 15:57:15 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: John Daley Date: Thu, 17 Mar 2016 15:57:06 -0700 Message-Id: <1458255427-12371-3-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458255427-12371-1-git-send-email-johndale@cisco.com> References: <1458255427-12371-1-git-send-email-johndale@cisco.com> Subject: [dpdk-dev] [PATCH 2/3] enic: handle error packets properly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2016 22:57:16 -0000 If the packet_error bit in the completion descriptor is set, the remainder of the descriptor and data are invalid. PKT_RX_MAC_ERR was set in the mbuf->ol_flags if packet_error was set and used later to indicate an error packet. But since PKT_RX_MAC_ERR is defined as 0, mbuf flags and packet types and length were being misinterpreted. Make the function enic_cq_rx_to_pkt_err_flags() return true for error packets and use the return value instead of mbuf->ol_flags to indicate error packets. Also remove warning for error packets and rely on rx_error stats. Fixes: 947d860c821f ("enic: improve Rx performance") Signed-off-by: John Daley --- drivers/net/enic/enic_rx.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c index 59ebaa4..817a891 100644 --- a/drivers/net/enic/enic_rx.c +++ b/drivers/net/enic/enic_rx.c @@ -129,13 +129,6 @@ enic_cq_rx_desc_rss_hash(struct cq_enet_rq_desc *cqrd) return le32_to_cpu(cqrd->rss_hash); } -static inline uint8_t -enic_cq_rx_desc_fcs_ok(struct cq_enet_rq_desc *cqrd) -{ - return ((cqrd->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) == - CQ_ENET_RQ_DESC_FLAGS_FCS_OK); -} - static inline uint16_t enic_cq_rx_desc_vlan(struct cq_enet_rq_desc *cqrd) { @@ -150,25 +143,21 @@ enic_cq_rx_desc_n_bytes(struct cq_desc *cqd) CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK; } -static inline uint64_t -enic_cq_rx_to_pkt_err_flags(struct cq_desc *cqd) +static inline uint8_t +enic_cq_rx_to_pkt_err_flags(struct cq_desc *cqd, uint64_t *pkt_err_flags_out) { struct cq_enet_rq_desc *cqrd = (struct cq_enet_rq_desc *)cqd; uint16_t bwflags; + int ret = 0; uint64_t pkt_err_flags = 0; bwflags = enic_cq_rx_desc_bwflags(cqrd); - - /* Check for packet error. Can't be more specific than MAC error */ - if (enic_cq_rx_desc_packet_error(bwflags)) { - pkt_err_flags |= PKT_RX_MAC_ERR; - } - - /* Check for bad FCS. MAC error isn't quite, but no other choice */ - if (!enic_cq_rx_desc_fcs_ok(cqrd)) { - pkt_err_flags |= PKT_RX_MAC_ERR; + if (unlikely(enic_cq_rx_desc_packet_error(bwflags))) { + pkt_err_flags = PKT_RX_MAC_ERR; + ret = 1; } - return pkt_err_flags; + *pkt_err_flags_out = pkt_err_flags; + return ret; } /* @@ -282,6 +271,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, dma_addr_t dma_addr; struct cq_desc cqd; uint64_t ol_err_flags; + uint8_t packet_error; /* Check for pkts available */ color = (cqd_ptr->type_color >> CQ_DESC_COLOR_SHIFT) @@ -303,9 +293,9 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, break; } - /* Check for FCS or packet errors */ - ol_err_flags = enic_cq_rx_to_pkt_err_flags(&cqd); - if (ol_err_flags == 0) + /* A packet error means descriptor and data are untrusted */ + packet_error = enic_cq_rx_to_pkt_err_flags(&cqd, &ol_err_flags); + if (!packet_error) rx_pkt_len = enic_cq_rx_desc_n_bytes(&cqd); else rx_pkt_len = 0; @@ -340,10 +330,13 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxmb->pkt_len = rx_pkt_len; rxmb->data_len = rx_pkt_len; rxmb->port = enic->port_id; - rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); - rxmb->ol_flags = ol_err_flags; - if (!ol_err_flags) + if (!packet_error) { + rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); enic_cq_rx_to_pkt_flags(&cqd, rxmb); + } else { + rxmb->packet_type = 0; + rxmb->ol_flags = 0; + } /* prefetch mbuf data for caller */ rte_packet_prefetch(RTE_PTR_ADD(rxmb->buf_addr, -- 2.7.0