From: Andrew Rybchenko Date: Tue, 4 Apr 2017 11:57:36 +0000 (+0100) Subject: net/sfc: remove unnecessary mbuf initialization on Rx X-Git-Tag: spdx-start~3621 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=68de5f6c035a81e22cd992bf7bbd0931eca733ff;p=dpdk.git net/sfc: remove unnecessary mbuf initialization on Rx mbuf next is equal to NULL, nb_segs and reference counter are equal to 1 when mbuf is obtained from mempool. Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c index 2a3bf891f4..1484baba8b 100644 --- a/drivers/net/sfc/sfc_ef10_rx.c +++ b/drivers/net/sfc/sfc_ef10_rx.c @@ -386,9 +386,8 @@ sfc_ef10_rx_process_event(struct sfc_ef10_rxq *rxq, efx_qword_t rx_ev, *rx_pkts++ = m; - *(uint64_t *)(&m->rearm_data) = rxq->rearm_data; - /* rearm_data rewrites ol_flags which is updated below */ - rte_compiler_barrier(); + RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != sizeof(rxq->rearm_data)); + m->rearm_data[0] = rxq->rearm_data; /* Classify packet based on Rx event */ sfc_ef10_rx_ev_to_offloads(rxq, rx_ev, m); @@ -412,7 +411,7 @@ sfc_ef10_rx_process_event(struct sfc_ef10_rxq *rxq, efx_qword_t rx_ev, rte_pktmbuf_data_len(m) = pkt_len; rte_pktmbuf_pkt_len(m) = pkt_len; - m->next = NULL; + SFC_ASSERT(m->next == NULL); /* Remember mbuf to copy offload flags and packet type from */ m0 = m; @@ -426,9 +425,9 @@ sfc_ef10_rx_process_event(struct sfc_ef10_rxq *rxq, efx_qword_t rx_ev, if (ready > rxq->prepared) *rx_pkts++ = m; - *(uint64_t *)(&m->rearm_data) = rxq->rearm_data; - /* rearm_data rewrites ol_flags which is updated below */ - rte_compiler_barrier(); + RTE_BUILD_BUG_ON(sizeof(m->rearm_data[0]) != + sizeof(rxq->rearm_data)); + m->rearm_data[0] = rxq->rearm_data; /* Event-dependent information is the same */ m->ol_flags = m0->ol_flags; @@ -449,7 +448,7 @@ sfc_ef10_rx_process_event(struct sfc_ef10_rxq *rxq, efx_qword_t rx_ev, rte_pktmbuf_data_len(m) = pkt_len; rte_pktmbuf_pkt_len(m) = pkt_len; - m->next = NULL; + SFC_ASSERT(m->next == NULL); } return n_rx_pkts; @@ -560,7 +559,8 @@ sfc_ef10_mk_mbuf_rearm_data(uint16_t port_id, uint16_t prefix_size) /* rearm_data covers structure members filled in above */ rte_compiler_barrier(); - return *(uint64_t *)(&m.rearm_data); + RTE_BUILD_BUG_ON(sizeof(m.rearm_data[0]) != sizeof(uint64_t)); + return m.rearm_data[0]; } static sfc_dp_rx_qcreate_t sfc_ef10_rx_qcreate; diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 56130b2c6f..ddf9217052 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -122,10 +122,10 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq) rxd = &rxq->sw_desc[id]; rxd->mbuf = m; - rte_mbuf_refcnt_set(m, 1); + SFC_ASSERT(rte_mbuf_refcnt_read(m) == 1); m->data_off = RTE_PKTMBUF_HEADROOM; - m->next = NULL; - m->nb_segs = 1; + SFC_ASSERT(m->next == NULL); + SFC_ASSERT(m->nb_segs == 1); m->port = port_id; addr[i] = rte_pktmbuf_mtophys(m);