Skip to contentSkip to conversation

infiniband: possible cleanups

PATCH In review Adrian Bunk 3 participants 7 messages Jan 3, 2005 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband: possible cleanups

The patch below contains the following possible cleanups for the current infiniband code:
- make needlessly global code static
- don't build the completely unused core/fmr_pool.c
- #if 0 the following EXPORT_SYMBOL'ed but unused functions:
- core/device.c: ib_modify_device
- core/device.c: ib_modify_port
- core/mad.c: ib_coalesce_recv_mad
- core/mad.c: ib_process_mad_wc
- core/mad.c: ib_redirect_mad_qp
- core/mad.c: ib_register_mad_snoop
- core/ud_header.c: ib_ud_header_unpack
- core/verbs.c: ib_alloc_mw
- core/verbs.c: ib_dealloc_mw
- core/verbs.c: ib_modify_ah
- core/verbs.c: ib_query_ah
- core/verbs.c: ib_query_mr
- core/verbs.c: ib_query_qp
- core/verbs.c: ib_reg_phys_mr
- core/verbs.c: ib_rereg_phys_mr
- core/verbs.c: ib_resize_cq
- hw/mthca/mthca_cmd.c: mthca_QUERY_QP

If code will be added that uses some of the functions this patch #if 0's it will be trivial to remove the corresponding #if 0's, but as long as this hasn't happened, they only make the kernel needlessly larger for people who use infiniband.

diffstat output:

 drivers/infiniband/core/Makefile               |    2 -
 drivers/infiniband/core/cache.c                |    6 ++---
 drivers/infiniband/core/device.c               |    4 +++
 drivers/infiniband/core/mad.c                  |    8 ++++++
 drivers/infiniband/core/ud_header.c            |    3 ++
 drivers/infiniband/core/verbs.c                |   16 +++++++++++++
 drivers/infiniband/hw/mthca/mthca_cmd.c        |    2 +
 drivers/infiniband/hw/mthca/mthca_cmd.h        |    2 +
 drivers/infiniband/include/ib_mad.h            |    8 ++++++
 drivers/infiniband/include/ib_pack.h           |    3 +-
 drivers/infiniband/include/ib_verbs.h          |   20 +++++++++++++++++
 drivers/infiniband/ulp/ipoib/ipoib_ib.c        |    2 -
 drivers/infiniband/ulp/ipoib/ipoib_main.c      |    2 -
 drivers/infiniband/ulp/ipoib/ipoib_multicast.c |    4 +--
 14 files changed, 73 insertions(+), 9 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_multicast.c renamed from drivers/infiniband/ulp/ipoib/ipoib_multicast.c.old +2 -2
@@ -44,7 +44,7 @@
 #include "ipoib.h"
 
 #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
-int mcast_debug_level;
+static int mcast_debug_level;
 
 module_param(mcast_debug_level, int, 0644);
 MODULE_PARM_DESC(mcast_debug_level,
@@ -621,7 +621,7 @@
 	return 0;
 }
 
-int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
+static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 	struct ib_sa_mcmember_rec rec = {
drivers/infiniband/ulp/ipoib/ipoib_main.c renamed from drivers/infiniband/ulp/ipoib/ipoib_main.c.old +1 -1
@@ -606,7 +606,7 @@
 	return NETDEV_TX_OK;
 }
 
-struct net_device_stats *ipoib_get_stats(struct net_device *dev)
+static struct net_device_stats *ipoib_get_stats(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
drivers/infiniband/ulp/ipoib/ipoib_ib.c renamed from drivers/infiniband/ulp/ipoib/ipoib_ib.c.old +1 -1
@@ -357,7 +357,7 @@
 	}
 }
 
-void __ipoib_reap_ah(struct net_device *dev)
+static void __ipoib_reap_ah(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 	struct ipoib_ah *ah, *tah;
drivers/infiniband/core/cache.c renamed from drivers/infiniband/core/cache.c.old +3 -3
@@ -252,7 +252,7 @@
 	}
 }
 
-void ib_cache_setup_one(struct ib_device *device)
+static void ib_cache_setup_one(struct ib_device *device)
 {
 	int p;
 
@@ -295,7 +295,7 @@
 	kfree(device->cache.gid_cache);
 }
 
-void ib_cache_cleanup_one(struct ib_device *device)
+static void ib_cache_cleanup_one(struct ib_device *device)
 {
 	int p;
 
@@ -311,7 +311,7 @@
 	kfree(device->cache.gid_cache);
 }
 
-struct ib_client cache_client = {
+static struct ib_client cache_client = {
 	.name   = "cache",
 	.add    = ib_cache_setup_one,
 	.remove = ib_cache_cleanup_one
drivers/infiniband/include/ib_verbs.h renamed from drivers/infiniband/include/ib_verbs.h.old +20 -0
@@ -865,6 +865,8 @@
 int ib_query_pkey(struct ib_device *device,
 		  u8 port_num, u16 index, u16 *pkey);
 
+#if 0
+
 int ib_modify_device(struct ib_device *device,
 		     int device_modify_mask,
 		     struct ib_device_modify *device_modify);
@@ -873,6 +875,8 @@
 		   u8 port_num, int port_modify_mask,
 		   struct ib_port_modify *port_modify);
 
+#endif  /*  0  */
+
 /**
  * ib_alloc_pd - Allocates an unused protection domain.
  * @device: The device on which to allocate the protection domain.
@@ -898,6 +902,8 @@
  */
 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
 
+#if 0
+
 /**
  * ib_modify_ah - Modifies the address vector associated with an address
  *   handle.
@@ -916,6 +922,8 @@
  */
 int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
 
+#endif  /*  0  */
+
 /**
  * ib_destroy_ah - Destroys an address handle.
  * @ah: The address handle to destroy.
@@ -955,10 +963,12 @@
  * The qp_attr_mask may be used to limit the query to gathering only the
  * selected attributes.
  */
+#if 0
 int ib_query_qp(struct ib_qp *qp,
 		struct ib_qp_attr *qp_attr,
 		int qp_attr_mask,
 		struct ib_qp_init_attr *qp_init_attr);
+#endif
 
 /**
  * ib_destroy_qp - Destroys the specified QP.
@@ -1021,7 +1031,9 @@
  *
  * Users can examine the cq structure to determine the actual CQ size.
  */
+#if 0
 int ib_resize_cq(struct ib_cq *cq, int cqe);
+#endif
 
 /**
  * ib_destroy_cq - Destroys the specified CQ.
@@ -1094,6 +1106,8 @@
  */
 struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
 
+#if 0
+
 /**
  * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
  *   by an HCA.
@@ -1147,6 +1161,8 @@
  */
 int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
 
+#endif  /*  0  */
+
 /**
  * ib_dereg_mr - Deregisters a memory region and removes it from the
  *   HCA translation table.
@@ -1158,7 +1174,9 @@
  * ib_alloc_mw - Allocates a memory window.
  * @pd: The protection domain associated with the memory window.
  */
+#if 0
 struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
+#endif
 
 /**
  * ib_bind_mw - Posts a work request to the send queue of the specified
@@ -1183,7 +1201,9 @@
  * ib_dealloc_mw - Deallocates a memory window.
  * @mw: The memory window to deallocate.
  */
+#if 0
 int ib_dealloc_mw(struct ib_mw *mw);
+#endif
 
 /**
  * ib_alloc_fmr - Allocates a unmapped fast memory region.
drivers/infiniband/core/device.c renamed from drivers/infiniband/core/device.c.old +4 -0
@@ -549,6 +549,8 @@
 }
 EXPORT_SYMBOL(ib_query_pkey);
 
+#if 0
+
 /**
  * ib_modify_device - Change IB device attributes
  * @device:Device to modify
@@ -587,6 +589,8 @@
 }
 EXPORT_SYMBOL(ib_modify_port);
 
+#endif  /*  0  */
+
 static int __init ib_core_init(void)
 {
 	int ret;
drivers/infiniband/core/Makefile renamed from drivers/infiniband/core/Makefile.old +1 -1
@@ -3,7 +3,7 @@
 obj-$(CONFIG_INFINIBAND) +=	ib_core.o ib_mad.o ib_sa.o ib_umad.o
 
 ib_core-y :=			packer.o ud_header.o verbs.o sysfs.o \
-				device.o fmr_pool.o cache.o
+				device.o cache.o
 
 ib_mad-y :=			mad.o smi.o agent.o
 
drivers/infiniband/include/ib_mad.h renamed from drivers/infiniband/include/ib_mad.h.old +8 -0
@@ -297,6 +297,7 @@
  * @recv_handler: The callback routine invoked for a snooped receive.
  * @context: User specified context associated with the registration.
  */
+#if 0
 struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
 					   u8 port_num,
 					   enum ib_qp_type qp_type,
@@ -304,6 +305,7 @@
 					   ib_mad_snoop_handler snoop_handler,
 					   ib_mad_recv_handler recv_handler,
 					   void *context);
+#endif
 
 /**
  * ib_unregister_mad_agent - Unregisters a client from using MAD services.
@@ -337,8 +339,10 @@
  * This call copies a chain of received RMPP MADs into a single data buffer,
  * removing duplicated headers.
  */
+#if 0
 void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc,
 			  void *buf);
+#endif
 
 /**
  * ib_free_recv_mad - Returns data buffers used to receive a MAD to the
@@ -361,6 +365,8 @@
 void ib_cancel_mad(struct ib_mad_agent *mad_agent,
 		   u64 wr_id);
 
+#if 0
+
 /**
  * ib_redirect_mad_qp - Registers a QP for MAD services.
  * @qp: Reference to a QP that requires MAD services.
@@ -401,4 +407,6 @@
 int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
 		      struct ib_wc *wc);
 
+#endif  /*  0  */
+
 #endif /* IB_MAD_H */
drivers/infiniband/core/mad.c renamed from drivers/infiniband/core/mad.c.old +8 -0
@@ -370,6 +370,8 @@
 		 IB_MAD_SNOOP_RMPP_RECVS*/));
 }
 
+#if 0
+
 static int register_snoop_agent(struct ib_mad_qp_info *qp_info,
 				struct ib_mad_snoop_private *mad_snoop_priv)
 {
@@ -473,6 +475,8 @@
 }
 EXPORT_SYMBOL(ib_register_mad_snoop);
 
+#endif  /*  0  */
+
 static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
 {
 	struct ib_mad_port_private *port_priv;
@@ -892,6 +896,8 @@
 }
 EXPORT_SYMBOL(ib_free_recv_mad);
 
+#if 0
+
 void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc,
 			  void *buf)
 {
@@ -917,6 +923,8 @@
 }
 EXPORT_SYMBOL(ib_process_mad_wc);
 
+#endif  /*  0  */
+
 static int method_in_use(struct ib_mad_mgmt_method_table **method,
 			 struct ib_mad_reg_req *mad_reg_req)
 {
drivers/infiniband/include/ib_pack.h renamed from drivers/infiniband/include/ib_pack.h.old +2 -1
@@ -238,8 +238,9 @@
 
 int ib_ud_header_pack(struct ib_ud_header *header,
 		      void                *buf);
-
+#if 0
 int ib_ud_header_unpack(void                *buf,
 			struct ib_ud_header *header);
+#endif
 
 #endif /* IB_PACK_H */
drivers/infiniband/core/ud_header.c renamed from drivers/infiniband/core/ud_header.c.old +3 -0
@@ -288,6 +288,7 @@
  * ib_ud_header_pack() unpacks the UD header structure @header from wire
  * format in the buffer @buf.
  */
+#if 0
 int ib_ud_header_unpack(void                *buf,
 			struct ib_ud_header *header)
 {
@@ -363,3 +364,5 @@
 	return 0;
 }
 EXPORT_SYMBOL(ib_ud_header_unpack);
+#endif  /*  0  */
+
drivers/infiniband/core/verbs.c renamed from drivers/infiniband/core/verbs.c.old +16 -0
@@ -85,6 +85,8 @@
 }
 EXPORT_SYMBOL(ib_create_ah);
 
+#if 0
+
 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
 {
 	return ah->device->modify_ah ?
@@ -101,6 +103,8 @@
 }
 EXPORT_SYMBOL(ib_query_ah);
 
+#endif  /*  0  */
+
 int ib_destroy_ah(struct ib_ah *ah)
 {
 	struct ib_pd *pd;
@@ -151,6 +155,7 @@
 }
 EXPORT_SYMBOL(ib_modify_qp);
 
+#if 0
 int ib_query_qp(struct ib_qp *qp,
 		struct ib_qp_attr *qp_attr,
 		int qp_attr_mask,
@@ -161,6 +166,7 @@
 		-ENOSYS;
 }
 EXPORT_SYMBOL(ib_query_qp);
+#endif  /*  0  */
 
 int ib_destroy_qp(struct ib_qp *qp)
 {
@@ -219,6 +225,7 @@
 }
 EXPORT_SYMBOL(ib_destroy_cq);
 
+#if 0
 int ib_resize_cq(struct ib_cq *cq,
                  int           cqe)
 {
@@ -234,6 +241,7 @@
 	return ret;
 }
 EXPORT_SYMBOL(ib_resize_cq);
+#endif  /*  0  */
 
 /* Memory regions */
 
@@ -254,6 +262,8 @@
 }
 EXPORT_SYMBOL(ib_get_dma_mr);
 
+#if 0
+
 struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
 			     struct ib_phys_buf *phys_buf_array,
 			     int num_phys_buf,
@@ -315,6 +325,8 @@
 }
 EXPORT_SYMBOL(ib_query_mr);
 
+#endif  /*  0  */
+
 int ib_dereg_mr(struct ib_mr *mr)
 {
 	struct ib_pd *pd;
@@ -334,6 +346,8 @@
 
 /* Memory windows */
 
+#if 0
+
 struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
 {
 	struct ib_mw *mw;
@@ -366,6 +380,8 @@
 }
 EXPORT_SYMBOL(ib_dealloc_mw);
 
+#endif  /*  0  */
+
 /* "Fast" memory regions */
 
 struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
drivers/infiniband/hw/mthca/mthca_cmd.h renamed from drivers/infiniband/hw/mthca/mthca_cmd.h.old +2 -0
@@ -258,8 +258,10 @@
 int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num,
 		    int is_ee, void *qp_context, u32 optmask,
 		    u8 *status);
+#if 0
 int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
 		   void *qp_context, u8 *status);
+#endif
 int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
 			  u8 *status);
 int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port,
drivers/infiniband/hw/mthca/mthca_cmd.c renamed from drivers/infiniband/hw/mthca/mthca_cmd.c.old +2 -0
@@ -1439,6 +1439,7 @@
 	return err;
 }
 
+#if 0
 int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
 		   void *qp_context, u8 *status)
 {
@@ -1460,6 +1461,7 @@
 			 PCI_DMA_FROMDEVICE);
 	return err;
 }
+#endif  /*  0  */
 
 int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
 			  u8 *status)
#1 lore raw

Thanks, I've applied the changes adding "static" to our tree. I'm holding off on the "#if 0" changes since some is code useful for debugging modules and other code is used by modules in development.

Thanks,
Roland

#2 lore raw
Quoted 3 lines · Roland Dreier

Thanks, I've applied the changes adding "static" to our tree. I'm holding off on the "#if 0" changes since some is code useful for debugging modules and other code is used by modules in development.

Is there an ETA when the debugging modules and the modules in development will be merged into the kernel?

Quoted 2 lines

Thanks,
Roland

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw

Hello!
Quoting r. Adrian Bunk ([email protected]) "[openib-general] Re: [2.6 patch] infiniband: possible cleanups":

Quoted 5 lines · Roland Dreier
Quoted 3 lines

Thanks, I've applied the changes adding "static" to our tree. I'm holding off on the "#if 0" changes since some is code useful for debugging modules and other code is used by modules in development.

Quoted 8 lines

Is there an ETA when the debugging modules and the modules in development will be merged into the kernel?

Quoted 2 lines

Thanks,
Roland

cu
Adrian

I saw some bits in Linus bk tree, if thats what you mean by "the kernel".

mst

#4 lore raw
In reply to Adrian Bunk

Adrian> Is there an ETA when the debugging modules and the modules Adrian> in development will be merged into the kernel?

Once they're ready and pass review on lkml.

- R.

#5 lore raw

Hello!
Quoting r. Roland Dreier ([email protected]) "[openib-general] Re: [2.6 patch] infiniband: possible cleanups":

Quoted 6 lines

Adrian> Is there an ETA when the debugging modules and the modules Adrian> in development will be merged into the kernel?

Once they're ready and pass review on lkml.

- R.

By the way, http://linus.bkbits.net:8080/linux-2.5/ChangeSet@-2w?nav=index.html
already has Roland's patches, and I thought that was what Linus uses for kernel releases, right, Roland?

mst

#6 lore raw

Michael> By the way,
Michael> http://linus.bkbits.net:8080/linux-2.5/ChangeSet@-2w?nav=index.html
Michael> already has Roland's patches, and I thought that was what Michael> Linus uses for kernel releases, right, Roland?

Yes, the core kernel drivers are all merged in Linus's kernel already. Adrian and I are talking about modules that use some currently unused APIs, such as Sean's madeye debugging module, the CM, RMPP support, etc.

- Roland