From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130044.outbound.protection.outlook.com [40.107.13.44]) by dpdk.org (Postfix) with ESMTP id 6A9731B940 for ; Fri, 11 Jan 2019 12:37:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mXNG9d//mQ1hZbGOdEn++J9abdDeKWbpZPpOvJnsuow=; b=cZB2sspjRlPdZFL4LRdpTr2brvRt+09S7GvQOoDcPMrcMXh+vcgJcvIqvfcwIMexo6QwYd3ai42+5A+hSkZTfamJPgK1IRH++QGmh4oq19wcJ+/BrLoeW1J50Srv1VWGclnQqnv7RtF0v6Y/4X79wNfM5DgGzFBdzq1tC1UyUlU= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3945.eurprd05.prod.outlook.com (52.134.65.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.18; Fri, 11 Jan 2019 11:37:52 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1da8:cd09:4e78:111c]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1da8:cd09:4e78:111c%2]) with mapi id 15.20.1516.016; Fri, 11 Jan 2019 11:37:52 +0000 From: Yongseok Koh To: Andrew Rybchenko CC: "olivier.matz@6wind.com" , "david.marchand@redhat.com" , Shahaf Shuler , "dev@dpdk.org" , "roszenrami@gmail.com" Thread-Topic: [dpdk-dev] [PATCH v3 1/2] mbuf: add function returning default buffer address Thread-Index: AQHUqYWxadl71CWdq0WzoYgcamW15KWpYWwAgACJ5ACAAAXPgA== Date: Fri, 11 Jan 2019 11:37:52 +0000 Message-ID: <49ED7E73-6BB0-46DD-AE49-F39B54E18A30@mellanox.com> References: <20190109085426.39965-1-yskoh@mellanox.com> <20190110183528.42503-1-yskoh@mellanox.com> <2934bc73-98e6-643a-0d61-cf7804e1535d@solarflare.com> <20190111110332.GA8355@minint-98vp2qg> <27206464-dcf0-9871-a797-cb0b9f2ff25d@solarflare.com> In-Reply-To: <27206464-dcf0-9871-a797-cb0b9f2ff25d@solarflare.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [69.181.245.183] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3945; 6:AgQIJygh27XrQ8nRNW9czQRvVQtRDPKVElX9T6TpjxU4sWWGiXI8l6uRcvIpRtEVWHvkRn1mbN0KEGEQ1/3iyV9eHI3QkE2sbtk8ETh11ZOoU1s514BOj/6NWRPy3OFQjP8uOKFgcK9sOY5D2ly7RKpEg+2ciLP12ZhIQsLMj9aqyVleCpsgTHYbumYM5//Xp+Nb9qH6JimIzFW5mM1xkrxUAfszYs/IwnQeCJagM8BEQ0hT9j2NMAoCcb+7ioMx3/qHGUnf14l6wGjsEwBDCp6+kKB1zmTShKeBLytd4qIqdV/h44Fxki7ZGLaEgK3XVQhnFVXMZGWpIzaQmhEk4OXYVuAoNgjWTdA6I5GDuHU1qxQSQbThJqx9fN4eGNpAkj8XDaF5Ln+6UF4hPXQRVACAoL9xmrC4YhCZgTV3zwUDANqUvdvkPcvOhw+varf4tbxeft+Pc3i/fhHZ0Vwytg==; 5:QveFuW9fL2Tc4Andaa4NMsQfAm8dKuXEcPYXCnR9Mpt2F+SLNG6Ev/qD+EKlz6wLHZ6QSoNaB6aZDu32VRMQgKSJUS19KHrGDk17xMDi/sVZPX1h6gqYeuDek2iPIZifoWJMVDuaOWkznXSiQ+8VU+kISuv/dNteGgHxg2+PaftWfHRo9AtB3qqu1I7E5zJBqWpbH5r2lRrFpfXXOpwOFg==; 7:70GZkHsgUJPnAynBgdwc3hLbr94YBSBAfFhQruvdOShYbz/AtHb9nukm5xAUYOpvoLUjlNtqRL/4gZ+5HgQTobGhOFcKUPn5rsKx/H5l4iEVi/zNfiV4bGM+ZAcu+SCVKeUAG3O7sBy819eD1cMmbQ== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: d2ad79f8-139e-4bf1-ddbe-08d677b938bd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3945; x-ms-traffictypediagnostic: DB3PR0502MB3945: x-microsoft-antispam-prvs: x-forefront-prvs: 09144DB0F7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(39860400002)(346002)(396003)(376002)(189003)(199004)(71190400001)(71200400001)(83716004)(86362001)(26005)(14444005)(305945005)(6116002)(3846002)(229853002)(54906003)(6506007)(53546011)(102836004)(7736002)(6916009)(256004)(6436002)(68736007)(97736004)(53936002)(76176011)(6486002)(105586002)(6246003)(2906002)(82746002)(11346002)(446003)(106356001)(33656002)(186003)(2616005)(39060400002)(476003)(316002)(478600001)(8936002)(486006)(81166006)(5660300001)(25786009)(81156014)(99286004)(4326008)(8676002)(36756003)(6512007)(66066001)(14454004)(93886005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3945; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: CeJzo/MIG39Vjh0P8zgwUcHSst/W+wE3G0+f87awm0hcXUEWVr7O9kbyzttjPi3VvILnbTzS26/2wX1lqG7VF7fP5/+NrXFg0go4QukUYt5LTkeUkMsWBzmxxUxAvSLVNXABFi2eXSzZ/paEW6HoqXy8roVFwjZpudV8z0XFryunzUcgtCf7Ql6wvhjpaJHSMYRmjhwFx1qBjRSavfNPxuoJVCovga1DTeZA6ZSi8MAOBgjhGILVBX5YwoyaISmYmJhHJNPUh8+Z4y/bXmwJyqdi24qEd9+qH5ia86HrpbrI21CCK9vw7YClirsEB3qrd/0/wRDHiZNFUAxmLkTWEWdEQoBxPZbiCSXds48ESA++8RsOhzFzAQrWZV+ptllBHJAQ459gbvHn9A6D+ZTiiDjgSftTSshwmDwAN+Nwo2s= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <12328FE309B81E40A5DC65C77AB3FE28@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2ad79f8-139e-4bf1-ddbe-08d677b938bd X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2019 11:37:52.3188 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3945 Subject: Re: [dpdk-dev] [PATCH v3 1/2] mbuf: add function returning default buffer address 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: Fri, 11 Jan 2019 11:37:55 -0000 > On Jan 11, 2019, at 3:17 AM, Andrew Rybchenko = wrote: >=20 > Olivier, David, >=20 > could you take a look at naming suggested below and share your thoughts. > My fear is that rte_mbuf_buf_addr() is too generic and true for direct mb= uf > only. That's why I'd like to highlight it in the function name. Like the existing rte_mbuf_to_baddr(), it is to return the buf_addr of the given mbuf. It doesn't matter whether the given mbuf is direct or not. It should be used at user's discretion. Yongseok > On 1/11/19 2:03 PM, Yongseok Koh wrote: >> On Fri, Jan 11, 2019 at 11:14:22AM +0300, Andrew Rybchenko wrote: >>=20 >>> On 1/10/19 9:35 PM, Yongseok Koh wrote: >>>=20 >>>> This patch introduces two new functions - rte_mbuf_buf_addr() and >>>> rte_mbuf_data_addr_default(). >>>>=20 >>>> rte_mbuf_buf_addr() reutrns the default buffer address of given mbuf w= hich >>>> comes after mbuf structure and private data. >>>>=20 >>>> rte_mbuf_data_addr_default() returns the default address of mbuf data >>>> taking the headroom into account. >>>>=20 >>>> Signed-off-by: Yongseok Koh=20 >>>> >>>>=20 >>>> --- >>>>=20 >>>> v3: >>>> * rename functions >>>>=20 >>>> v2: >>>> * initial implementation >>>>=20 >>>> lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++= ++++--- >>>> 1 file changed, 40 insertions(+), 3 deletions(-) >>>>=20 >>>> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h >>>> index bc562dc8a9..486566fc28 100644 >>>> --- a/lib/librte_mbuf/rte_mbuf.h >>>> +++ b/lib/librte_mbuf/rte_mbuf.h >>>> @@ -788,8 +788,47 @@ rte_mbuf_from_indirect(struct rte_mbuf *mi) >>>> } >>>> /** >>>> + * Return the default buffer address of the mbuf. >>>> + * >>>> + * @param mb >>>> + * The pointer to the mbuf. >>>> + * @param mp >>>> + * The pointer to the mempool of the mbuf. >>>> + * @return >>>> + * The pointer of the mbuf buffer. >>>> + */ >>>> +static inline char * __rte_experimental >>>> +rte_mbuf_buf_addr(struct rte_mbuf *mb, struct rte_mempool *mp) >>>>=20 >>> struct rte_mbuf has pool member. So, I don't understand why mp >>> argument is required. I guess there is a reason, but it should be >>> explained in comments. I see motivation in rte_mbuf_to_baddr() >>> description, but rte_mbuf_buf_add() does not explain it. >>>=20 >> Well, I don't like to put same comment here and there but I'll add small= comment >> here. >>=20 >>=20 >>> Also right now the function name looks like simple get accessor for >>> buf_addr and I'd expect to seem one line implementation may be >>> with extra debug checks: return mb->buf_addr. >>>=20 >> This func is suggested by David and Olivier because same code is being r= epeated >> in multiple locations. This can be used to initialize a mbuf when mb->bu= f_addr is >> null. And second use-case (this is my use-case) is to get the buf_addr w= ithout >> accessing the mbuf struct when mempool of mbuf is known, e.g. Rx buffer >> replenishment. It is definitely beneficial for performance, especially R= ISC >> cores. >>=20 >>=20 >>> May be rte_mbuf_direct_buf_addr() ? >>> If so, similar below rte_mbuf_direct_data_addr_default(). >>>=20 >> Regarding naming, people have different tastes. As it is acked by Olivie= r and >> David, I'll keep the names. >>=20 >=20 >> Thanks, >> Yongseok >>=20 >>=20 >>>> +{ >>>> + char *buffer_addr; >>>> + >>>> + buffer_addr =3D (char *)mb + sizeof(*mb) + rte_pktmbuf_priv_size(mp)= ; >>>> + return buffer_addr; >>>> +} >>>> + >>>> + >>>> +/** >>>> + * Return the default address of the beginning of the mbuf data. >>>> + * >>>> + * @param mb >>>> + * The pointer to the mbuf. >>>> + * @return >>>> + * The pointer of the beginning of the mbuf data. >>>> + */ >>>> +static inline char * __rte_experimental >>>> +rte_mbuf_data_addr_default(struct rte_mbuf *mb) >>>> +{ >>>> + return rte_mbuf_buf_addr(mb, mb->pool) + RTE_PKTMBUF_HEADROOM; >>>> +} >>>> + >>>> +/** >>>> * Return the buffer address embedded in the given mbuf. >>>> * >>>> + * Note that accessing mempool pointer of a mbuf is expensive because= the >>>> + * pointer is stored in the 2nd cache line of mbuf. If mempool is kno= wn, it >>>> + * is better not to reference the mempool pointer in mbuf but calling >>>> + * rte_mbuf_buf_addr() would be more efficient. >>>> + * >>>> * @param md >>>> * The pointer to the mbuf. >>>> * @return >>>> @@ -798,9 +837,7 @@ rte_mbuf_from_indirect(struct rte_mbuf *mi) >>>> static inline char * >>>> rte_mbuf_to_baddr(struct rte_mbuf *md) >>>> { >>>> - char *buffer_addr; >>>> - buffer_addr =3D (char *)md + sizeof(*md) + rte_pktmbuf_priv_size(md-= >pool); >>>> - return buffer_addr; >>>> + return rte_mbuf_buf_addr(md, md->pool); >>>> } >>>> /** >>>>=20 >=20