From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7FF721396 for ; Wed, 22 Mar 2017 18:42:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490204540; x=1521740540; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Zg1rLJbeYWytf+d1eaZRyJYctNkK48bCN7knLkZdk6o=; b=pEImeWdBA6E5ZprnlkmKGoyym0uZhGV0uoOPVxfCApxf0yQXOfAaZw7M X960pazy+7Oz/NVA9ZFxwztXVQswrw==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2017 10:42:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,206,1486454400"; d="scan'208";a="1111142829" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga001.jf.intel.com with ESMTP; 22 Mar 2017 10:42:14 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.44]) by irsmsx110.ger.corp.intel.com ([169.254.15.101]) with mapi id 14.03.0248.002; Wed, 22 Mar 2017 17:42:13 +0000 From: "Ananyev, Konstantin" To: Olivier Matz CC: Jan Blunck , "Richardson, Bruce" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC 0/8] mbuf: structure reorganization Thread-Index: AQHSdlXOvL8VQlbyOU+/T85mDKip26FcYNGAgA9pHoCAAD0PgIABJAiAgAAukACAAArJAIAEZh4AgAGZsQCAAGmrAIAAB0CAgAAHcgCAAANakIAAIcgAgAARDkCABE1sgIAF9CCAgAABN2CAAAaegIAADv0QgAAJP4CAAAuoYIAAD6MAgACKxICAAuH6gIAJARjwgBLGuwCAA6/q8A== Date: Wed, 22 Mar 2017 17:42:12 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583FAD3AC3@IRSMSX109.ger.corp.intel.com> References: <1485271173-13408-1-git-send-email-olivier.matz@6wind.com> <2601191342CEEE43887BDE71AB9772583F11B4CC@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772583F11B633@irsmsx105.ger.corp.intel.com> <20170224150053.279e718d@platinum> <2601191342CEEE43887BDE71AB9772583F11E992@irsmsx105.ger.corp.intel.com> <20170228102359.5d601797@platinum> <2601191342CEEE43887BDE71AB9772583F11EA11@irsmsx105.ger.corp.intel.com> <20170228115043.3f78ce52@platinum> <2601191342CEEE43887BDE71AB9772583F11EA96@irsmsx105.ger.corp.intel.com> <20170228132825.37586902@platinum> <2601191342CEEE43887BDE71AB9772583F11EE7A@irsmsx105.ger.corp.intel.com> <20170302174623.268592a7@platinum> <2601191342CEEE43887BDE71AB9772583FACBF10@IRSMSX109.ger.corp.intel.com> <20170320100036.086109e6@platinum> In-Reply-To: <20170320100036.086109e6@platinum> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC 0/8] mbuf: structure reorganization 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: , X-List-Received-Date: Wed, 22 Mar 2017 17:42:21 -0000 Hi Olivier, > > > > > > Another thing that doesn't look very convenient to me here - > > > > > > We can have 2 different values of timestamp (both normalized an= d not) > > > > > > and there is no clear way for the application to know which one= is in > > > > > > use right now. So each app writer would have to come-up with hi= s own > > > > > > solution. > > > > > > > > > > It depends: > > > > > - the solution you describe is to have the application storing th= e > > > > > normalized value in its private metadata. > > > > > - another solution would be to store the normalized value in > > > > > m->timestamp. In this case, we would need a flag to tell if the > > > > > timestamp value is normalized. > > > > > > > > My first thought also was about second flag to specify was timestam= p > > > > already normalized or not. > > > > Though I still in doubt - is it all really worth it: extra ol_flag,= new function in eth_dev API. > > > > My feeling that we trying to overcomplicate things. > > > > > > I don't see what is so complicated. The idea is just to let the > > > application do the normalization if it is required. > > > > I meant 2 ol_flags and special function just to treat properly one of t= he mbuf field > > seems too much. > > Though after second thought might be 2 ol_flags is not a bad idea - > > it gives PMD writer a freedom to choose provide a normalized or raw val= ue > > on return from rx_burst(). >=20 > I don't see a real advantage now, but I think this is something that > could be added once we have the normalization code. >=20 >=20 >=20 > > > If the time is normalized in nanosecond in the PMD, we would still > > > need to normalized the time reference (the 0). And for that we'd need > > > a call to a synchronization code as well. > > > > > > > > > > > > > > The problem pointed out by Jan is that doing the timestamp > > > > > normalization may take some CPU cycles, even if a small part of p= ackets > > > > > requires it. > > > > > > > > I understand that point, but from what I've seen with real example: > > > > http://dpdk.org/ml/archives/dev/2016-October/048810.html > > > > the amount of calculations at RX is pretty small. > > > > I don't think it would affect performance in a noticeable way > > > > (though I don't have any numbers here to prove it). > > > > > > I think we can consider by default that adding code in the data path > > > impacts performance. > > > > > > > > > > From other side, if user doesn't want a timestamp he can always dis= able > > > > that feature anad save cycles, right? > > > > > > > > BTW, you and Jan both mention that not every packet would need a ti= mestamp. > > > > Instead we need sort of a timestamp for the group of packets? > > > > > > I think that for many applications the timestamp should be as precise > > > as possible for each packet. > > > > > > > > > > Is that really the only foreseen usage model? > > > > > > No, but it could be one. > > > > > > > > > > If so, then why not to have a special function that would extract '= latest' timestamp > > > > from the dev? > > > > Or even have tx_burst_extra() that would return a latest timestamp = (extra parameter or so). > > > > Then there is no need to put timestamp into mbuf at all. > > > > > > Doing that will give a poor precision for the timestamp. > > > > > > > > > > > > > Applications that > > > > > > > are doing this are responsible of what they change. > > > > > > > > > > > > > > > > > > > > > > 3. In theory with eth_dev_detach() - mbuf->port value might= be > > > > > > > > not valid at the point when application would decide to do > > > > > > > > normalization. > > > > > > > > > > > > > > > > So to me all that approach with delayed normalization seems > > > > > > > > unnecessary overcomplicated. Original one suggested by Oliv= ier, > > > > > > > > when normalization is done in PMD at RX look much cleaner a= nd > > > > > > > > more manageable. > > > > > > > > > > > > > > Detaching a device requires a synchronization between control= and > > > > > > > data plane, and not only for this use case. > > > > > > > > > > > > Of course it does. > > > > > > But right now it is possible to do: > > > > > > > > > > > > eth_rx_burst(port=3D0, ..., &mbuf, 1); > > > > > > eth_dev_detach(port=3D0, ...); > > > > > > ... > > > > > > /*process previously received mbuf */ > > > > > > > > > > > > With what you are proposing it would be not always possible any= more. > > > > > > > > > > With your example, it does not work even without the timestamp fe= ature, > > > > > since the mbuf input port would reference an invalid port. > > > > > This port is usually used in the application to do a lookup for = an port structure, > > > > > so it is expected that the entry is valid. It would be even worse= if you > > > > > do a detach + attach. > > > > > > > > I am not talking about the mbuf->port value usage. > > > > Right now user can access/interpret all metadata fields set by PMD= RX routines > > > > (vlan, rss hash, ol_flags, ptype, etc.) without need to accessing t= he device data or > > > > calling device functions. > > > > With that change it wouldn't be the case anymore. > > > > > > That's the same for some other functions. If in my application I want > > > to call eth_rx_queue_count(m->port), I will have the same problem. > > > > Yes, but here you are trying to get extra information about device/queu= e based > > on port value stored inside mbuf. > > I am talking about information that already stored inside particular mb= uf itself. > > About m->port itself - as I said before my preference would be to remov= e it at all > > (partly because of that implication - we can't guarantee that m->port i= nformation > > would be valid though all mbuf lifetime). > > But that's probably subject of another discussion. > > > > > > > > I think we also have something quite similar in examples/ptpclient: > > > > > > rte_eth_rx_burst(portid, 0, &m, 1); > > > ... > > > parse_ptp_frames(portid, m); > > > ... > > > ptp_data.portid =3D portid; > > > ... > > > rte_eth_timesync_read_tx_timestamp(ptp_data->portid, ...) > > > > > > > > > So, really, I think it's an application issue: when the app deletes > > > a port, it should ask itself if there are remaining references to > > > it (m->port). > > > > Hmm, and where in the example below do you see the reference to the m->= port? > > As I can see, what that the code above does: > > - it deduces portid value from global variable - not from m->port > > - saves portid info (not from m->port) inside global variable ptp_dat= a.portid > > - later inside same function it used that value to call rte_ethdev fun= ctions > > (via parse_fup or parse_drsp). > > > > So I am not sure how it relates to the topic we are discussing. >=20 > It's similar to what I proposed for the timestamp normalization: for both > functions, you need to call an ethdev function with a port_id as a parame= ter. > Either you get the port from the mbuf (this is my initial suggestion that= you > don't like), either you know it because you retrieved your mbuf with > rte_eth_rx_burst(port_id, ...) (this is what is done in examples/ptpclien= t). >=20 > So, do you still see an issue with having a function to normalize/synchro= nize > the timestamp that takes a port id as a parameter? If it hasn't rely on mbuf->port value, then probably not. >=20 >=20 > > Anyway, to summarize how the proposal looks right now: > > > > 1. m->timestamp value after rx_burst() could be either in raw or normal= ized format. > > 2. validity of m->timesamp and the it's format should be determined by = 2 ol_flags > > (something like: RX_TIMESTAMP, RX_TIMESTAMP_NORM). > > 3. PMD is free to choose what timestamp value to return (raw/normalized= ) >=20 > I think it needs to be raw now, because we don't have any normalization c= ode > at the moment. Maybe we could add a "normalized" flag if it makes sense i= n > the future, once we have decided what normalized means, in a context wher= e several > PMDs/libs can have their own timestamp. >=20 > But once we have a clear definition of what normalized means + an example= of > normalization code, we may have this NORM flag. >=20 > > 4. PMD can provide an optional routine inside devops: > > uint64_t dev_ops->timestamp_normalise(uint64_t timestamps); >=20 > I think (but I'm not sure, it's really out of scope of this patchset), > that the timestamp synchronization API will be more complex than that. >=20 > My current idea: >=20 > - a rte_timestamp library holds the normalization code > - we decide, for instance, that "normalized" means: > - unit: nanosecond > - based on system clock > - reference: 0 =3D time when rte_timestamp_init() was called > - the PMD provides an API to get its clock > - the lib provides something like: > uint64_t rte_timestamp_normalize(unsigned int port_id, uint64_t timesta= mp) >=20 >=20 > > 5. If the user wants to use that function it would be his responsibilit= y to map mbuf > > to the port it was received from. >=20 > Yes, if the application uses a port_id, it's its responsibility to ensure > that this port exists. Ok, so for 17.05 we'll have: - raw timestamp value inside mbuf - ol_flag bit to represenet is mbuf->timestamp value valid or not. That's it, correct? Konstantin