diff mbox series

[for-next,4/5] RDMA/efa: Move type conversion helpers to efa.h

Message ID 20240624160918.27060-5-mrgolin@amazon.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/efa: Cleanups and minor improvements | expand

Commit Message

Margolin, Michael June 24, 2024, 4:09 p.m. UTC
Move ib_ to efa_ types conversion functions to have them near the types
definitions and to reduce code in efa_verbs.c.

Reviewed-by: Firas Jahjah <firasj@amazon.com>
Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
Signed-off-by: Michael Margolin <mrgolin@amazon.com>
---
 drivers/infiniband/hw/efa/efa.h       | 35 +++++++++++++++++++++++++++
 drivers/infiniband/hw/efa/efa_verbs.c | 35 ---------------------------
 2 files changed, 35 insertions(+), 35 deletions(-)

Comments

Gal Pressman June 25, 2024, 6:33 a.m. UTC | #1
On 24/06/2024 19:09, Michael Margolin wrote:
> Move ib_ to efa_ types conversion functions to have them near the types
> definitions and to reduce code in efa_verbs.c.
> 
> Reviewed-by: Firas Jahjah <firasj@amazon.com>
> Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
> Signed-off-by: Michael Margolin <mrgolin@amazon.com>

The idea was to not expose these functions in the h file as they are not
used outside of efa_verbs.c.
Margolin, Michael June 25, 2024, 11:21 a.m. UTC | #2
On 6/25/2024 9:33 AM, Gal Pressman wrote

> On 24/06/2024 19:09, Michael Margolin wrote:
>> Move ib_ to efa_ types conversion functions to have them near the types
>> definitions and to reduce code in efa_verbs.c.
>>
>> Reviewed-by: Firas Jahjah <firasj@amazon.com>
>> Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
>> Signed-off-by: Michael Margolin <mrgolin@amazon.com>
> The idea was to not expose these functions in the h file as they are not
> used outside of efa_verbs.c.

I know but it's a driver internal header and it also makes sense to have 
the cast from the base type near the definition.

Michael
Leon Romanovsky June 25, 2024, 2:19 p.m. UTC | #3
On Tue, Jun 25, 2024 at 02:21:39PM +0300, Margolin, Michael wrote:
> On 6/25/2024 9:33 AM, Gal Pressman wrote
> 
> > On 24/06/2024 19:09, Michael Margolin wrote:
> > > Move ib_ to efa_ types conversion functions to have them near the types
> > > definitions and to reduce code in efa_verbs.c.
> > > 
> > > Reviewed-by: Firas Jahjah <firasj@amazon.com>
> > > Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
> > > Signed-off-by: Michael Margolin <mrgolin@amazon.com>
> > The idea was to not expose these functions in the h file as they are not
> > used outside of efa_verbs.c.
> 
> I know but it's a driver internal header and it also makes sense to have the
> cast from the base type near the definition.

We put in header file things which are used in multiple files. It is not
the case here. Let's try to avoid code churn without real gain behind it.

Thanks

> 
> Michael
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/efa/efa.h b/drivers/infiniband/hw/efa/efa.h
index 926f9ff1f60f..f1020bf85b78 100644
--- a/drivers/infiniband/hw/efa/efa.h
+++ b/drivers/infiniband/hw/efa/efa.h
@@ -142,6 +142,41 @@  struct efa_eq {
 	struct efa_irq irq;
 };
 
+static inline struct efa_dev *to_edev(struct ib_device *ibdev)
+{
+	return container_of(ibdev, struct efa_dev, ibdev);
+}
+
+static inline struct efa_ucontext *to_eucontext(struct ib_ucontext *ibucontext)
+{
+	return container_of(ibucontext, struct efa_ucontext, ibucontext);
+}
+
+static inline struct efa_pd *to_epd(struct ib_pd *ibpd)
+{
+	return container_of(ibpd, struct efa_pd, ibpd);
+}
+
+static inline struct efa_mr *to_emr(struct ib_mr *ibmr)
+{
+	return container_of(ibmr, struct efa_mr, ibmr);
+}
+
+static inline struct efa_qp *to_eqp(struct ib_qp *ibqp)
+{
+	return container_of(ibqp, struct efa_qp, ibqp);
+}
+
+static inline struct efa_cq *to_ecq(struct ib_cq *ibcq)
+{
+	return container_of(ibcq, struct efa_cq, ibcq);
+}
+
+static inline struct efa_ah *to_eah(struct ib_ah *ibah)
+{
+	return container_of(ibah, struct efa_ah, ibah);
+}
+
 int efa_query_device(struct ib_device *ibdev,
 		     struct ib_device_attr *props,
 		     struct ib_udata *udata);
diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index 9c3e476e3f9c..34a9f86af9bd 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -127,41 +127,6 @@  struct pbl_context {
 	u8 physically_continuous;
 };
 
-static inline struct efa_dev *to_edev(struct ib_device *ibdev)
-{
-	return container_of(ibdev, struct efa_dev, ibdev);
-}
-
-static inline struct efa_ucontext *to_eucontext(struct ib_ucontext *ibucontext)
-{
-	return container_of(ibucontext, struct efa_ucontext, ibucontext);
-}
-
-static inline struct efa_pd *to_epd(struct ib_pd *ibpd)
-{
-	return container_of(ibpd, struct efa_pd, ibpd);
-}
-
-static inline struct efa_mr *to_emr(struct ib_mr *ibmr)
-{
-	return container_of(ibmr, struct efa_mr, ibmr);
-}
-
-static inline struct efa_qp *to_eqp(struct ib_qp *ibqp)
-{
-	return container_of(ibqp, struct efa_qp, ibqp);
-}
-
-static inline struct efa_cq *to_ecq(struct ib_cq *ibcq)
-{
-	return container_of(ibcq, struct efa_cq, ibcq);
-}
-
-static inline struct efa_ah *to_eah(struct ib_ah *ibah)
-{
-	return container_of(ibah, struct efa_ah, ibah);
-}
-
 static inline struct efa_user_mmap_entry *
 to_emmap(struct rdma_user_mmap_entry *rdma_entry)
 {