This commit includes two small code optimization. 1. use __insn_fetchadd4() instead of rte_atomic32_xxx() in mpipe_dp_enter/mpipe_dp_exit to avoid the nnecessary memory fence. 2. replace the calling of rte_pktmbuf_reset() in mpipe_recv_mbuf() with specific code to avoid some duplicated initializations. --- drivers/net/mpipe/mpipe_tilegx.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c index 5845511..8d006fa 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -451,13 +451,13 @@ static inline void mpipe_dp_enter(struct mpipe_dev_priv *priv) { __insn_mtspr(SPR_DSTREAM_PF, 0); - rte_atomic32_inc(&priv->dp_count); + __insn_fetchadd4(&priv->dp_count, 1); } static inline void mpipe_dp_exit(struct mpipe_dev_priv *priv) { - rte_atomic32_dec(&priv->dp_count); + __insn_fetchadd4(&priv->dp_count, -1); } static inline void @@ -484,12 +484,20 @@ mpipe_recv_mbuf(struct mpipe_dev_priv *priv, gxio_mpipe_idesc_t *idesc, uint16_t size = gxio_mpipe_idesc_get_xfer_size(idesc); struct rte_mbuf *mbuf = RTE_PTR_SUB(va, priv->rx_offset); - rte_pktmbuf_reset(mbuf); mbuf->data_off = (uintptr_t)va - (uintptr_t)mbuf->buf_addr; - mbuf->port = in_port; - mbuf->data_len = size; + mbuf->nb_segs = 1; + mbuf->port = in_port; + mbuf->ol_flags = 0; + if (gxio_mpipe_idesc_get_ethertype(idesc) == ETHER_TYPE_IPv4) + mbuf->packet_type = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L2_ETHER; + else if (gxio_mpipe_idesc_get_ethertype(idesc) == ETHER_TYPE_IPv6) + mbuf->packet_type = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L2_ETHER; + else + mbuf->packet_type = RTE_PTYPE_UNKNOWN; mbuf->pkt_len = size; + mbuf->data_len = size; mbuf->hash.rss = gxio_mpipe_idesc_get_flow_hash(idesc); + mbuf->next = NULL; PMD_DEBUG_RX("%s: RX mbuf %p, buffer %p, buf_addr %p, size %d\n", mpipe_name(priv), mbuf, va, mbuf->buf_addr, size); -- 1.8.3.1