* [dpdk-dev] [PATCH 1/3] enic: mbuf->ol_flags could be set incorrectly
2016-03-17 22:57 [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes John Daley
@ 2016-03-17 22:57 ` John Daley
2016-03-17 22:57 ` [dpdk-dev] [PATCH 2/3] enic: handle error packets properly John Daley
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: John Daley @ 2016-03-17 22:57 UTC (permalink / raw)
To: dev; +Cc: John Daley
In the receive path, the function to set mbuf ol_flags used the
mbuf packet_type before it was set.
Fixes: 947d860c821f ("enic: improve Rx performance")
Signed-off-by: John Daley <johndale@cisco.com>
---
drivers/net/enic/enic_rx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c
index 945a60f..59ebaa4 100644
--- a/drivers/net/enic/enic_rx.c
+++ b/drivers/net/enic/enic_rx.c
@@ -210,7 +210,7 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
ciflags = enic_cq_rx_desc_ciflags(cqrd);
bwflags = enic_cq_rx_desc_bwflags(cqrd);
- ASSERT(mbuf->ol_flags == 0);
+ mbuf->ol_flags = 0;
/* flags are meaningless if !EOP */
if (unlikely(!enic_cq_rx_desc_eop(ciflags)))
@@ -340,10 +340,10 @@ 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)
enic_cq_rx_to_pkt_flags(&cqd, rxmb);
- rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd);
/* prefetch mbuf data for caller */
rte_packet_prefetch(RTE_PTR_ADD(rxmb->buf_addr,
--
2.7.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 2/3] enic: handle error packets properly
2016-03-17 22:57 [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes John Daley
2016-03-17 22:57 ` [dpdk-dev] [PATCH 1/3] enic: mbuf->ol_flags could be set incorrectly John Daley
@ 2016-03-17 22:57 ` John Daley
2016-03-17 22:57 ` [dpdk-dev] [PATCH 3/3] enic: small cleanup- remove a packet_error conditional John Daley
2016-03-22 16:55 ` [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes Bruce Richardson
3 siblings, 0 replies; 5+ messages in thread
From: John Daley @ 2016-03-17 22:57 UTC (permalink / raw)
To: dev; +Cc: John Daley
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 <johndale@cisco.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 3/3] enic: small cleanup- remove a packet_error conditional
2016-03-17 22:57 [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes John Daley
2016-03-17 22:57 ` [dpdk-dev] [PATCH 1/3] enic: mbuf->ol_flags could be set incorrectly John Daley
2016-03-17 22:57 ` [dpdk-dev] [PATCH 2/3] enic: handle error packets properly John Daley
@ 2016-03-17 22:57 ` John Daley
2016-03-22 16:55 ` [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes Bruce Richardson
3 siblings, 0 replies; 5+ messages in thread
From: John Daley @ 2016-03-17 22:57 UTC (permalink / raw)
To: dev; +Cc: John Daley
Signed-off-by: John Daley <johndale@cisco.com>
---
drivers/net/enic/enic_rx.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c
index 817a891..232987a 100644
--- a/drivers/net/enic/enic_rx.c
+++ b/drivers/net/enic/enic_rx.c
@@ -266,7 +266,6 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
nb_hold = rq->rx_nb_hold; /* mbufs held by software */
while (nb_rx < nb_pkts) {
- uint16_t rx_pkt_len;
volatile struct rq_enet_desc *rqd_ptr;
dma_addr_t dma_addr;
struct cq_desc cqd;
@@ -295,10 +294,6 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
/* 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;
/* Get the mbuf to return and replace with one just allocated */
rxmb = rq->mbuf_ring[rx_id];
@@ -327,16 +322,17 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
rxmb->data_off = RTE_PKTMBUF_HEADROOM;
rxmb->nb_segs = 1;
rxmb->next = NULL;
- rxmb->pkt_len = rx_pkt_len;
- rxmb->data_len = rx_pkt_len;
rxmb->port = enic->port_id;
if (!packet_error) {
+ rxmb->pkt_len = enic_cq_rx_desc_n_bytes(&cqd);
rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd);
enic_cq_rx_to_pkt_flags(&cqd, rxmb);
} else {
+ rxmb->pkt_len = 0;
rxmb->packet_type = 0;
rxmb->ol_flags = 0;
}
+ rxmb->data_len = rxmb->pkt_len;
/* prefetch mbuf data for caller */
rte_packet_prefetch(RTE_PTR_ADD(rxmb->buf_addr,
--
2.7.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes
2016-03-17 22:57 [dpdk-dev] [PATCH 0/3] enic PMD receive path fixes John Daley
` (2 preceding siblings ...)
2016-03-17 22:57 ` [dpdk-dev] [PATCH 3/3] enic: small cleanup- remove a packet_error conditional John Daley
@ 2016-03-22 16:55 ` Bruce Richardson
3 siblings, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2016-03-22 16:55 UTC (permalink / raw)
To: John Daley; +Cc: dev
On Thu, Mar 17, 2016 at 03:57:04PM -0700, John Daley wrote:
> These patches fix up some bugs in the enic receive path.
>
> John Daley (3):
> enic: mbuf->ol_flags could be set incorrectly
> enic: handle error packets properly
> enic: small cleanup- remove a packet_error conditional
>
> drivers/net/enic/enic_rx.c | 53 ++++++++++++++++++----------------------------
> 1 file changed, 21 insertions(+), 32 deletions(-)
>
> --
> 2.7.0
>
Applied to dpdk-next-net/rel_16_04
/Bruce
^ permalink raw reply [flat|nested] 5+ messages in thread