From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F400143B1D; Wed, 14 Feb 2024 03:18:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 840F842E51; Wed, 14 Feb 2024 03:18:35 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 4536D42DF9 for ; Wed, 14 Feb 2024 03:18:33 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4TZMJD1hrpz1Q8yX; Wed, 14 Feb 2024 10:16:28 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id F1DB7140410; Wed, 14 Feb 2024 10:18:30 +0800 (CST) Received: from [10.45.33.178] (10.45.33.178) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 10:18:30 +0800 Content-Type: multipart/alternative; boundary="------------vQBxW63PSCTPdd2rqwQpZSMk" Message-ID: <62462c5d-d685-50fd-5645-6a7293e91c12@huawei.com> Date: Wed, 14 Feb 2024 10:18:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH] drivers: use common container_of macro Content-Language: en-US To: David Marchand , CC: Rahul Lakkireddy , Yuying Zhang , Rosen Xu References: <20240213153741.2133915-1-david.marchand@redhat.com> From: fengchengwen In-Reply-To: <20240213153741.2133915-1-david.marchand@redhat.com> X-Originating-IP: [10.45.33.178] X-ClientProxiedBy: dggpeml500010.china.huawei.com (7.185.36.155) To dggpeml500024.china.huawei.com (7.185.36.10) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --------------vQBxW63PSCTPdd2rqwQpZSMk Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Acked-by: Chengwen Feng On 2024/2/13 23:37, David Marchand wrote: > rte_common.h provides container_of if none is defined. > > The drivers headers touched by this commit either already include > rte_common.h or use some other common macro defined in rte_common.h. > As a consequence, it seems safe to assume that container_of is always > available for includers of those headers. > > Signed-off-by: David Marchand > --- > drivers/net/cxgbe/cxgbe_compat.h | 6 ------ > drivers/net/i40e/i40e_rxtx.h | 5 ----- > drivers/raw/ifpga/base/ifpga_compat.h | 5 ----- > 3 files changed, 16 deletions(-) > > diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h > index 0b02eb62a9..e74d476f6d 100644 > --- a/drivers/net/cxgbe/cxgbe_compat.h > +++ b/drivers/net/cxgbe/cxgbe_compat.h > @@ -135,12 +135,6 @@ typedef uint64_t dma_addr_t; > */ > #define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1)) > > -#ifndef container_of > -#define container_of(ptr, type, member) ({ \ > - typeof(((type *)0)->member)(*__mptr) = (ptr); \ > - (type *)((char *)__mptr - offsetof(type, member)); }) > -#endif > - > #define ARRAY_SIZE(arr) RTE_DIM(arr) > > #define cpu_to_be16(o) rte_cpu_to_be_16(o) > diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h > index b191f23e1f..a3a53ffce4 100644 > --- a/drivers/net/i40e/i40e_rxtx.h > +++ b/drivers/net/i40e/i40e_rxtx.h > @@ -45,11 +45,6 @@ > #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK 0x03 > #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX 0x01 > > -#undef container_of > -#define container_of(ptr, type, member) ({ \ > - typeof(((type *)0)->member)(*__mptr) = (ptr); \ > - (type *)((char *)__mptr - offsetof(type, member)); }) > - > #define I40E_TD_CMD (I40E_TX_DESC_CMD_ICRC |\ > I40E_TX_DESC_CMD_EOP) > > diff --git a/drivers/raw/ifpga/base/ifpga_compat.h b/drivers/raw/ifpga/base/ifpga_compat.h > index cdeca70ca5..8a624d174f 100644 > --- a/drivers/raw/ifpga/base/ifpga_compat.h > +++ b/drivers/raw/ifpga/base/ifpga_compat.h > @@ -7,11 +7,6 @@ > > #include "opae_osdep.h" > > -#undef container_of > -#define container_of(ptr, type, member) ({ \ > - typeof(((type *)0)->member)(*__mptr) = (ptr); \ > - (type *)((char *)__mptr - offsetof(type, member)); }) > - > #define IFPGA_PAGE_SHIFT 12 > #define IFPGA_PAGE_SIZE (1 << IFPGA_PAGE_SHIFT) > #define IFPGA_PAGE_MASK (~(IFPGA_PAGE_SIZE - 1)) --------------vQBxW63PSCTPdd2rqwQpZSMk Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit

Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2024/2/13 23:37, David Marchand wrote:
rte_common.h provides container_of if none is defined.

The drivers headers touched by this commit either already include
rte_common.h or use some other common macro defined in rte_common.h.
As a consequence, it seems safe to assume that container_of is always
available for includers of those headers.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/cxgbe/cxgbe_compat.h      | 6 ------
 drivers/net/i40e/i40e_rxtx.h          | 5 -----
 drivers/raw/ifpga/base/ifpga_compat.h | 5 -----
 3 files changed, 16 deletions(-)

diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h
index 0b02eb62a9..e74d476f6d 100644
--- a/drivers/net/cxgbe/cxgbe_compat.h
+++ b/drivers/net/cxgbe/cxgbe_compat.h
@@ -135,12 +135,6 @@ typedef uint64_t  dma_addr_t;
  */
 #define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1))
 
-#ifndef container_of
-#define container_of(ptr, type, member) ({ \
-		typeof(((type *)0)->member)(*__mptr) = (ptr); \
-		(type *)((char *)__mptr - offsetof(type, member)); })
-#endif
-
 #define ARRAY_SIZE(arr) RTE_DIM(arr)
 
 #define cpu_to_be16(o) rte_cpu_to_be_16(o)
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index b191f23e1f..a3a53ffce4 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -45,11 +45,6 @@
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK   0x03
 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX   0x01
 
-#undef container_of
-#define container_of(ptr, type, member) ({ \
-		typeof(((type *)0)->member)(*__mptr) = (ptr); \
-		(type *)((char *)__mptr - offsetof(type, member)); })
-
 #define I40E_TD_CMD (I40E_TX_DESC_CMD_ICRC |\
 		     I40E_TX_DESC_CMD_EOP)
 
diff --git a/drivers/raw/ifpga/base/ifpga_compat.h b/drivers/raw/ifpga/base/ifpga_compat.h
index cdeca70ca5..8a624d174f 100644
--- a/drivers/raw/ifpga/base/ifpga_compat.h
+++ b/drivers/raw/ifpga/base/ifpga_compat.h
@@ -7,11 +7,6 @@
 
 #include "opae_osdep.h"
 
-#undef container_of
-#define container_of(ptr, type, member) ({ \
-		typeof(((type *)0)->member)(*__mptr) = (ptr); \
-		(type *)((char *)__mptr - offsetof(type, member)); })
-
 #define IFPGA_PAGE_SHIFT       12
 #define IFPGA_PAGE_SIZE        (1 << IFPGA_PAGE_SHIFT)
 #define IFPGA_PAGE_MASK        (~(IFPGA_PAGE_SIZE - 1))
--------------vQBxW63PSCTPdd2rqwQpZSMk--