From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 5D2491B1C1 for ; Wed, 24 Jan 2018 16:39:33 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 14D4D226A6; Wed, 24 Jan 2018 10:39:33 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:39:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=kJ7W90eZkJpW1aAv3 DAVC3JIBj3UoltfGDV80LuqUtI=; b=l9ouurtqDBtvC71NxTfEoCHP7rxtoP0lp VdZw5wy0Bf83tiMjaXXvjOZViw7rVvtKIP+Kst9ius7sWwTlrZtlUwsSvrIfPS8D 7h4RYwLE+qTc104+GQ8+nvNpNPsIXai9/oZ5TrX0E4Btj8UvFFNs3FBVmMB6dy25 mpcxNu9dUGoShy+Kil4FUob7xbjGowlJsNUUsoOHu7rSgGzo+quD5berQqREQ1M1 2ToqOXTQpZFUb20Vp51tNTDUq2eLdmkl7VzMpLYo8LpZmJCTw7xKQxHLgb3X1DVQ QpmFoSNstjPY7/0Oj+WGJzBDqYJbJafG9S+LbVhK3SFXGPI81FpQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=kJ7W90eZkJpW1aAv3DAVC3JIBj3UoltfGDV80LuqUtI=; b=aoNONOaB kml2qI6t+hEYVIvomtibIrEV5EnASqbvblXWvUR/uo+MjkjQrwSNOGU8MMs8y00u OhxgA36DyfR8h5dYVa4n04HiTFQOAGA+BC25+SgwmNVOC0b6M+wDL209jiPykjym PJKUaa2j7E0YxuS0Tx67AWSGurAA5PAeoc9yEKAJiEINcOj/wlpnGgQHZsuC2tLc i8PbbW36woUMSBvcBJqxcKBVDdpB+YfyLTjyVQdHpC/y58z4XLb6Kq87tKhOHRjT omTjIPztzvCFTuCVVvG8e3Z1EM/45fFBeFWL21Rw6SxiZsrjhHgAWmnT1xZYL6kV /OZRWebYZ/x8Dw== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 3170C7E3DB; Wed, 24 Jan 2018 10:39:30 -0500 (EST) From: Yuanhan Liu To: Yongseok Koh Cc: dpdk stable Date: Wed, 24 Jan 2018 23:32:29 +0800 Message-Id: <1516808026-25523-81-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/mlx5: fix overwriting bit-fields in SW Rx queue' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:39:33 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 92f916d15846b95e46a2a75b4d0f3e19a50505d0 Mon Sep 17 00:00:00 2001 From: Yongseok Koh Date: Tue, 9 Jan 2018 09:38:50 -0800 Subject: [PATCH] net/mlx5: fix overwriting bit-fields in SW Rx queue [ upstream commit d27fb0de2f2ae072f2dbdb236c1d10bd2b19b28f ] Bit-fields in mlx5_rxq_data can be changed on the fly by a control plane - e.g. rxq->mark. However, vectorized Rx uses a bit-field to mark pending errors. Even if one bit is written, consequence is to write the whole integer and this can cause a synchronization issue - two entities write to a same block without locking. As the pending_err bit is entirely internal use for the datapath, this can be replaced with a local variable. Fixes: 6cb559d67b83 ("net/mlx5: add vectorized Rx/Tx burst for x86") Fixes: 570acdb1da8a ("net/mlx5: add vectorized Rx/Tx burst for ARM") Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5_rxtx.h | 3 +-- drivers/net/mlx5/mlx5_rxtx_vec.c | 6 +++--- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 9 ++++++--- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 8 ++++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index f1a4989..301cd75 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -114,8 +114,7 @@ struct mlx5_rxq_data { unsigned int elts_n:4; /* Log 2 of Mbufs. */ unsigned int rss_hash:1; /* RSS hash result is enabled. */ unsigned int mark:1; /* Marked flow available on the queue. */ - unsigned int pending_err:1; /* CQE error needs to be handled. */ - unsigned int :14; /* Remaining bits. */ + unsigned int :15; /* Remaining bits. */ volatile uint32_t *rq_db; volatile uint32_t *cq_db; uint16_t port_id; diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c index 3aca17c..101aa15 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.c +++ b/drivers/net/mlx5/mlx5_rxtx_vec.c @@ -244,7 +244,6 @@ rxq_handle_pending_error(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, rxq->stats.ipackets -= (pkts_n - n); rxq->stats.ibytes -= err_bytes; #endif - rxq->pending_err = 0; return n; } @@ -266,9 +265,10 @@ mlx5_rx_burst_vec(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) { struct mlx5_rxq_data *rxq = dpdk_rxq; uint16_t nb_rx; + uint64_t err = 0; - nb_rx = rxq_burst_v(rxq, pkts, pkts_n); - if (unlikely(rxq->pending_err)) + nb_rx = rxq_burst_v(rxq, pkts, pkts_n, &err); + if (unlikely(err)) nb_rx = rxq_handle_pending_error(rxq, pkts, nb_rx); return nb_rx; } diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h index 77ce0c3..ce5ad0e 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h @@ -650,12 +650,16 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, * Array to store received packets. * @param pkts_n * Maximum number of packets in array. + * @param[out] err + * Pointer to a flag. Set non-zero value if pkts array has at least one error + * packet to handle. * * @return * Number of packets received including errors (<= pkts_n). */ static inline uint16_t -rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n) +rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, + uint64_t *err) { const uint16_t q_n = 1 << rxq->cqe_n; const uint16_t q_mask = q_n - 1; @@ -955,8 +959,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n) opcode = vceq_u16(resp_err_check, opcode); opcode = vbic_u16(opcode, invalid_mask); /* D.4 mark if any error is set */ - rxq->pending_err |= - !!vget_lane_u64(vreinterpret_u64_u16(opcode), 0); + *err |= vget_lane_u64(vreinterpret_u64_u16(opcode), 0); /* C.4 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v(rxq, ptype_info, flow_tag, opcode, &elts[pos]); diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h index f256811..3e5de62 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h @@ -654,12 +654,16 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, __m128i cqes[4], * Array to store received packets. * @param pkts_n * Maximum number of packets in array. + * @param[out] err + * Pointer to a flag. Set non-zero value if pkts array has at least one error + * packet to handle. * * @return * Number of packets received including errors (<= pkts_n). */ static inline uint16_t -rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n) +rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, + uint64_t *err) { const uint16_t q_n = 1 << rxq->cqe_n; const uint16_t q_mask = q_n - 1; @@ -921,7 +925,7 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n) opcode = _mm_packs_epi32(opcode, zero); opcode = _mm_andnot_si128(invalid_mask, opcode); /* D.4 mark if any error is set */ - rxq->pending_err |= !!_mm_cvtsi128_si64(opcode); + *err |= _mm_cvtsi128_si64(opcode); /* D.5 fill in mbuf - rearm_data and packet_type. */ rxq_cq_to_ptype_oflags_v(rxq, cqes, opcode, &pkts[pos]); if (rxq->hw_timestamp) { -- 2.7.4