From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D8D98A04E7; Tue, 3 Nov 2020 00:20:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 51CAC378B; Tue, 3 Nov 2020 00:20:54 +0100 (CET) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by dpdk.org (Postfix) with ESMTP id 119A9377E for ; Tue, 3 Nov 2020 00:20:51 +0100 (CET) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2N2v7Z050735; Mon, 2 Nov 2020 18:20:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=C5RyWDp4Kok2HEN1M6y2nwCzVJ1lZr/9QBD0CQ/qa+U=; b=Q/9rzWWomhvA9x2IQOboCkrUSIuUPEsPciE1OhK/TIX8Qd8yWIcHeMaUK4IVFam3HL9L cMlQqGQPvHvDw/8M7RG3nOBBEDBs5+czbVqYZzdjtWjr8ZTzB6U2syGRLO0I2bi5U4HL L1JCS2u7pjhX3l3ojv7Zz1jk30q42mGs+70ZoqA+5SVDyCWti0WquJzmZQA+6Btnz7mo LZcVfSFk5dwt+WdU6VankjG2Xp/WL3R/DNjoY6jbL22jPyzrnILpwZeQ7xKngYN6waAW 7JjtScTstLvRN6wpP1+65p2teffOINXILCxcQn2ApgQXVz0ThSMPAxp/qTkIgR5JmsJk gg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 34jqsa6jwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 18:20:48 -0500 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0A2NHblc103883; Mon, 2 Nov 2020 18:20:47 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 34jqsa6jw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 18:20:47 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2NHnCq023311; Mon, 2 Nov 2020 23:20:47 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04dal.us.ibm.com with ESMTP id 34h02kf4m9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 23:20:47 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2NKeGA38207934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 23:20:40 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3FE5C6057; Mon, 2 Nov 2020 23:20:45 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9154C605B; Mon, 2 Nov 2020 23:20:44 +0000 (GMT) Received: from Davids-MBP.randomparity.org (unknown [9.211.109.119]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 23:20:44 +0000 (GMT) To: Thomas Monjalon , dev@dpdk.org Cc: ferruh.yigit@intel.com, david.marchand@redhat.com, bruce.richardson@intel.com, olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru, jerinj@marvell.com, viacheslavo@nvidia.com, Matan Azrad , Shahaf Shuler , Ruifeng Wang , Konstantin Ananyev References: <20201029092751.3837177-1-thomas@monjalon.net> <20201101180626.2198868-1-thomas@monjalon.net> <20201101180626.2198868-9-thomas@monjalon.net> From: David Christensen Message-ID: <86daad53-a379-ed24-cc2e-8ece87e2f52b@linux.vnet.ibm.com> Date: Mon, 2 Nov 2020 15:20:44 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201101180626.2198868-9-thomas@monjalon.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_15:2020-11-02, 2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1011 priorityscore=1501 mlxscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020171 Subject: Re: [dpdk-dev] [PATCH v2 08/14] net/mlx5: switch timestamp to dynamic mbuf field X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 11/1/20 10:06 AM, Thomas Monjalon wrote: > The mbuf timestamp is moved to a dynamic field > in order to allow removal of the deprecated static field. > The related mbuf flag is also replaced. > > Signed-off-by: Thomas Monjalon > --- > drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++++++++++++++ > drivers/net/mlx5/mlx5_rxtx.c | 4 +-- > drivers/net/mlx5/mlx5_rxtx.h | 19 +++++++++++ > drivers/net/mlx5/mlx5_rxtx_vec_altivec.h | 41 +++++++++++----------- > drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 43 ++++++++++++------------ > drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 35 +++++++++---------- > 6 files changed, 118 insertions(+), 60 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index f1d8373079..877aa24a18 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -1310,6 +1310,39 @@ mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint16_t idx, > priv->max_lro_msg_size * MLX5_LRO_SEG_CHUNK_SIZE); > } > > +/** > + * Lookup mbuf field and flag for Rx timestamp if offload requested. > + * > + * @param rxq_data > + * Datapath struct where field offset and flag mask are stored. > + * > + * @return > + * 0 on success or offload disabled, negative errno otherwise. > + */ > +static int > +mlx5_rx_timestamp_setup(struct mlx5_rxq_data *rxq_data) > +{ > + int timestamp_rx_dynflag_offset; > + > + rxq_data->timestamp_rx_flag = 0; > + if (rxq_data->hw_timestamp == 0) > + return 0; > + rxq_data->timestamp_offset = rte_mbuf_dynfield_lookup( > + RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); > + if (rxq_data->timestamp_offset < 0) { > + DRV_LOG(ERR, "Cannot lookup timestamp field\n"); > + return -rte_errno; > + } > + timestamp_rx_dynflag_offset = rte_mbuf_dynflag_lookup( > + RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME, NULL); > + if (timestamp_rx_dynflag_offset < 0) { > + DRV_LOG(ERR, "Cannot lookup Rx timestamp flag\n"); > + return -rte_errno; > + } > + rxq_data->timestamp_rx_flag = RTE_BIT64(timestamp_rx_dynflag_offset); > + return 0; > +} > + > /** > * Create a DPDK Rx queue. > * > @@ -1492,7 +1525,10 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, > mlx5_max_lro_msg_size_adjust(dev, idx, max_lro_size); > /* Toggle RX checksum offload if hardware supports it. */ > tmpl->rxq.csum = !!(offloads & DEV_RX_OFFLOAD_CHECKSUM); > + /* Configure Rx timestamp. */ > tmpl->rxq.hw_timestamp = !!(offloads & DEV_RX_OFFLOAD_TIMESTAMP); > + if (mlx5_rx_timestamp_setup(&tmpl->rxq) != 0) > + goto error; > /* Configure VLAN stripping. */ > tmpl->rxq.vlan_strip = !!(offloads & DEV_RX_OFFLOAD_VLAN_STRIP); > /* By default, FCS (CRC) is stripped by hardware. */ > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > index e86468b67a..b577aab00b 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.c > +++ b/drivers/net/mlx5/mlx5_rxtx.c > @@ -1287,8 +1287,8 @@ rxq_cq_to_mbuf(struct mlx5_rxq_data *rxq, struct rte_mbuf *pkt, > > if (rxq->rt_timestamp) > ts = mlx5_txpp_convert_rx_ts(rxq->sh, ts); > - pkt->timestamp = ts; > - pkt->ol_flags |= PKT_RX_TIMESTAMP; > + mlx5_timestamp_set(pkt, rxq->timestamp_offset, ts); > + pkt->ol_flags |= rxq->timestamp_rx_flag; > } > } > > diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h > index 674296ee98..e9eca36b40 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -151,6 +151,8 @@ struct mlx5_rxq_data { > /* CQ (UAR) access lock required for 32bit implementations */ > #endif > uint32_t tunnel; /* Tunnel information. */ > + int timestamp_offset; /* Dynamic mbuf field for timestamp. */ > + uint64_t timestamp_rx_flag; /* Dynamic mbuf flag for timestamp. */ > uint64_t flow_meta_mask; > int32_t flow_meta_offset; > } __rte_cache_aligned; > @@ -681,4 +683,21 @@ mlx5_txpp_convert_tx_ts(struct mlx5_dev_ctx_shared *sh, uint64_t mts) > return ci; > } > > +/** > + * Set timestamp in mbuf dynamic field. > + * > + * @param mbuf > + * Structure to write into. > + * @param offset > + * Dynamic field offset in mbuf structure. > + * @param timestamp > + * Value to write. > + */ > +static __rte_always_inline void > +mlx5_timestamp_set(struct rte_mbuf *mbuf, int offset, > + rte_mbuf_timestamp_t timestamp) > +{ > + *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = timestamp; > +} > + > #endif /* RTE_PMD_MLX5_RXTX_H_ */ > diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h > index 6bf0c9b540..171d7bb0f8 100644 > --- a/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h > +++ b/drivers/net/mlx5/mlx5_rxtx_vec_altivec.h > @@ -330,13 +330,13 @@ rxq_cq_to_ptype_oflags_v(struct mlx5_rxq_data *rxq, > vector unsigned char ol_flags = (vector unsigned char) > (vector unsigned int){ > rxq->rss_hash * PKT_RX_RSS_HASH | > - rxq->hw_timestamp * PKT_RX_TIMESTAMP, > + rxq->hw_timestamp * rxq->timestamp_rx_flag, > rxq->rss_hash * PKT_RX_RSS_HASH | > - rxq->hw_timestamp * PKT_RX_TIMESTAMP, > + rxq->hw_timestamp * rxq->timestamp_rx_flag, > rxq->rss_hash * PKT_RX_RSS_HASH | > - rxq->hw_timestamp * PKT_RX_TIMESTAMP, > + rxq->hw_timestamp * rxq->timestamp_rx_flag, > rxq->rss_hash * PKT_RX_RSS_HASH | > - rxq->hw_timestamp * PKT_RX_TIMESTAMP}; > + rxq->hw_timestamp * rxq->timestamp_rx_flag}; > vector unsigned char cv_flags; > const vector unsigned char zero = (vector unsigned char){0}; > const vector unsigned char ptype_mask = > @@ -1025,31 +1025,32 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts, uint16_t pkts_n, > /* 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) { > + int offset = rxq->timestamp_offset; > if (rxq->rt_timestamp) { > struct mlx5_dev_ctx_shared *sh = rxq->sh; > uint64_t ts; > > ts = rte_be_to_cpu_64(cq[pos].timestamp); > - pkts[pos]->timestamp = > - mlx5_txpp_convert_rx_ts(sh, ts); > + mlx5_timestamp_set(pkts[pos], offset, > + mlx5_txpp_convert_rx_ts(sh, ts)); > ts = rte_be_to_cpu_64(cq[pos + p1].timestamp); > - pkts[pos + 1]->timestamp = > - mlx5_txpp_convert_rx_ts(sh, ts); > + mlx5_timestamp_set(pkts[pos + 1], offset, > + mlx5_txpp_convert_rx_ts(sh, ts)); > ts = rte_be_to_cpu_64(cq[pos + p2].timestamp); > - pkts[pos + 2]->timestamp = > - mlx5_txpp_convert_rx_ts(sh, ts); > + mlx5_timestamp_set(pkts[pos + 2], offset, > + mlx5_txpp_convert_rx_ts(sh, ts)); > ts = rte_be_to_cpu_64(cq[pos + p3].timestamp); > - pkts[pos + 3]->timestamp = > - mlx5_txpp_convert_rx_ts(sh, ts); > + mlx5_timestamp_set(pkts[pos + 3], offset, > + mlx5_txpp_convert_rx_ts(sh, ts)); > } else { > - pkts[pos]->timestamp = rte_be_to_cpu_64 > - (cq[pos].timestamp); > - pkts[pos + 1]->timestamp = rte_be_to_cpu_64 > - (cq[pos + p1].timestamp); > - pkts[pos + 2]->timestamp = rte_be_to_cpu_64 > - (cq[pos + p2].timestamp); > - pkts[pos + 3]->timestamp = rte_be_to_cpu_64 > - (cq[pos + p3].timestamp); > + mlx5_timestamp_set(pkts[pos], offset, > + rte_be_to_cpu_64(cq[pos].timestamp)); > + mlx5_timestamp_set(pkts[pos + 1], offset, > + rte_be_to_cpu_64(cq[pos + p1].timestamp)); > + mlx5_timestamp_set(pkts[pos + 2], offset, > + rte_be_to_cpu_64(cq[pos + p2].timestamp)); > + mlx5_timestamp_set(pkts[pos + 3], offset, > + rte_be_to_cpu_64(cq[pos + p3].timestamp)); > } > } > if (rxq->dynf_meta) { Reviewed-by: David Christensen