[ofa-general] Re: [PATCH 1/10] libibmad: Clean up "new" interface

Sasha Khapyorsky sashak at voltaire.com
Sat Feb 28 23:00:20 PST 2009


Hi Ira,

On 19:05 Thu 19 Feb     , Ira Weiny wrote:
> From 2774b4ab4608e25bdc365bca3a94c7d51ee19372 Mon Sep 17 00:00:00 2001
> From: Ira Weiny <weiny2 at llnl.gov>
> Date: Wed, 18 Feb 2009 16:37:36 -0800
> Subject: [PATCH] libibmad: Clean up "new" interface

Please don't put email header into commit message body, it breaks tools
like 'git rebase' and similar. At least put '>' before first 'From '
line.

> 
>    type all "void *ibmad_port" and "void *srcport" with struct ibmad_port *

Do you plan to expose 'struct ibmad_port' (I see later in patches that
it is going to some libibmad internal header file)?

>    Create new mad_rpc_portid(struct ibmad_port *srcport) function
>       which mirrors madrpc_portid(void)
>    Mark all "old" functions with __attribute__ ((deprecated))

This generates a lot of warnings right now (even after all patch series
applying it still have deprecated usages in libibmad itself). And this
is not very good. I think our flow should have opposite direction - first
to convert, then mark deprecated functions.

Now as fast workaround I can mask depreciation by macro:

#define DEPRECATED /* __attribute__ ((deprecated)) */

, and we will uncomment this when everything in tree will be converted.

Also after looking over patch series I see that all "original" function
names become deprecated and replaces by its *_via() brothers. How do
you see the next step? Will we remove old names and have almost all API
calls with useless then _via suffix?

Sasha

> 
> Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
> ---
>  libibmad/include/infiniband/mad.h |  139 ++++++++++++++++++++++---------------
>  libibmad/src/gs.c                 |   19 +++---
>  libibmad/src/libibmad.map         |    1 +
>  libibmad/src/resolve.c            |   10 ++-
>  libibmad/src/rpc.c                |   29 ++++----
>  libibmad/src/sa.c                 |    4 +-
>  libibmad/src/smp.c                |    4 +-
>  7 files changed, 118 insertions(+), 88 deletions(-)
> 
> diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
> index 1aaaa1b..80e38be 100644
> --- a/libibmad/include/infiniband/mad.h
> +++ b/libibmad/include/infiniband/mad.h
> @@ -724,100 +724,125 @@ static inline int mad_is_vendor_range2(int mgmt)
>  }
>  
>  /* rpc.c */
> -MAD_EXPORT int madrpc_portid(void);
> -MAD_EXPORT int madrpc_set_retries(int retries);
> -MAD_EXPORT int madrpc_set_timeout(int timeout);
> -void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata);
> -void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
> -		  void *data);
> +MAD_EXPORT int madrpc_portid(void) __attribute__ ((deprecated));
> +void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata)
> +		__attribute__ ((deprecated));
> +void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, void *data)
> +		__attribute__ ((deprecated));
>  MAD_EXPORT void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes,
> -			    int num_classes);
> -void madrpc_save_mad(void *madbuf, int len);
> -MAD_EXPORT void madrpc_show_errors(int set);
> +			    int num_classes) __attribute__ ((deprecated));
> +void madrpc_save_mad(void *madbuf, int len) __attribute__ ((deprecated));
>  
> -void *mad_rpc_open_port(char *dev_name, int dev_port, int *mgmt_classes,
> +/* New interface */
> +MAD_EXPORT void madrpc_show_errors(int set);
> +MAD_EXPORT int madrpc_set_retries(int retries);
> +MAD_EXPORT int madrpc_set_timeout(int timeout);
> +MAD_EXPORT struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port, int *mgmt_classes,
>  			int num_classes);
> -void mad_rpc_close_port(void *ibmad_port);
> -void *mad_rpc(const void *ibmad_port, ib_rpc_t * rpc, ib_portid_t * dport,
> -	      void *payload, void *rcvdata);
> -void *mad_rpc_rmpp(const void *ibmad_port, ib_rpc_t * rpc, ib_portid_t * dport,
> -		   ib_rmpp_hdr_t * rmpp, void *data);
> +MAD_EXPORT void mad_rpc_close_port(struct ibmad_port *srcport);
> +MAD_EXPORT void *mad_rpc(const struct ibmad_port *srcport, ib_rpc_t * rpc, ib_portid_t * dport,
> +			void *payload, void *rcvdata);
> +MAD_EXPORT void *mad_rpc_rmpp(const struct ibmad_port *srcport, ib_rpc_t * rpc, ib_portid_t * dport,
> +			ib_rmpp_hdr_t * rmpp, void *data);
> +MAD_EXPORT int mad_rpc_portid(struct ibmad_port *srcport);
>  
>  /* smp.c */
>  MAD_EXPORT uint8_t *smp_query(void *buf, ib_portid_t * id, unsigned attrid,
> -			      unsigned mod, unsigned timeout);
> +		      unsigned mod, unsigned timeout) __attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid,
> -			    unsigned mod, unsigned timeout);
> +		    unsigned mod, unsigned timeout) __attribute__ ((deprecated));
> +
> +/* smp.c new interface */
>  MAD_EXPORT uint8_t *smp_query_via(void *buf, ib_portid_t * id, unsigned attrid,
> -		       unsigned mod, unsigned timeout, const void *srcport);
> -uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid, unsigned mod,
> -		     unsigned timeout, const void *srcport);
> +		       unsigned mod, unsigned timeout, const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid, unsigned mod,
> +		     unsigned timeout, const struct ibmad_port *srcport);
>  
>  /* sa.c */
>  uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
> -		 unsigned timeout);
> -uint8_t *sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t * portid,
> +		 unsigned timeout) __attribute__ ((deprecated));
> +MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id,
> +		void *buf) __attribute__ ((deprecated));
> +
> +/* sa.c new interface */
> +MAD_EXPORT uint8_t *sa_rpc_call(const struct ibmad_port *srcport, void *rcvbuf, ib_portid_t * portid,
>  		     ib_sa_call_t * sa, unsigned timeout);
> -MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf);	/* returns lid */
> -int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid,
> +MAD_EXPORT int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid,
>  		      ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf);
> +	/* returns lid */
>  
>  /* resolve.c */
> -MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout);
> +MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout)
> +				__attribute__ ((deprecated));
>  MAD_EXPORT int ib_resolve_guid(ib_portid_t * portid, uint64_t * guid,
> -			       ib_portid_t * sm_id, int timeout);
> +			       ib_portid_t * sm_id, int timeout)
> +				__attribute__ ((deprecated));
>  MAD_EXPORT int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
> -				     enum MAD_DEST dest, ib_portid_t * sm_id);
> +				     enum MAD_DEST dest, ib_portid_t * sm_id)
> +				__attribute__ ((deprecated));
>  MAD_EXPORT int ib_resolve_self(ib_portid_t * portid, int *portnum,
> -			       ibmad_gid_t * gid);
> -
> -int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout, const void *srcport);
> -int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
> -			ib_portid_t * sm_id, int timeout, const void *srcport);
> -int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
> +			       ibmad_gid_t * gid)
> +				__attribute__ ((deprecated));
> +
> +/* resolve.c new interface */
> +MAD_EXPORT int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
> +			const struct ibmad_port *srcport);
> +MAD_EXPORT int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
> +			ib_portid_t * sm_id, int timeout,
> +			const struct ibmad_port *srcport);
> +MAD_EXPORT int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
>  			      enum MAD_DEST dest, ib_portid_t * sm_id,
> -			      const void *srcport);
> -int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
> -			const void *srcport);
> +			      const struct ibmad_port *srcport);
> +MAD_EXPORT int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
> +			const struct ibmad_port *srcport);
>  
>  /* gs.c */
>  MAD_EXPORT uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t * dest,
> -					     int port, unsigned timeout);
> +					     int port, unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_performance_query(void *rcvbuf, ib_portid_t * dest,
> -					   int port, unsigned timeout);
> +					   int port, unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t * dest,
>  					   int port, unsigned mask,
> -					   unsigned timeout);
> +					   unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t * dest,
> -					       int port, unsigned timeout);
> +					       int port, unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t * dest,
>  					       int port, unsigned mask,
> -					       unsigned timeout);
> +					       unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t * dest,
> -					       int port, unsigned timeout);
> +					       int port, unsigned timeout)
> +						__attribute__ ((deprecated));
>  MAD_EXPORT uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t * dest,
> -					      int port, unsigned timeout);
> +					      int port, unsigned timeout)
> +						__attribute__ ((deprecated));
>  
> -uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest,
> +/* gs.c new interface */
> +MAD_EXPORT uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest,
>  				      int port, unsigned timeout,
> -				      const void *srcport);
> -uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t * dest, int port,
> -				    unsigned timeout, const void *srcport);
> -uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t * dest, int port,
> +				      const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t * dest, int port,
> +				    unsigned timeout, const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t * dest, int port,
>  				    unsigned mask, unsigned timeout,
> -				    const void *srcport);
> -uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t * dest,
> +				    const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned timeout,
> -					const void *srcport);
> -uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t * dest,
> +					const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned mask,
> -					unsigned timeout, const void *srcport);
> -uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t * dest,
> +					unsigned timeout,
> +					const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned timeout,
> -					const void *srcport);
> -uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t * dest,
> +					const struct ibmad_port *srcport);
> +MAD_EXPORT uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t * dest,
>  				       int port, unsigned timeout,
> -				       const void *srcport);
> +				       const struct ibmad_port *srcport);
>  /* dump.c */
>  MAD_EXPORT ib_mad_dump_fn
>      mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex,
> diff --git a/libibmad/src/gs.c b/libibmad/src/gs.c
> index d2c4574..e302caf 100644
> --- a/libibmad/src/gs.c
> +++ b/libibmad/src/gs.c
> @@ -47,7 +47,7 @@
>  
>  static uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
>  			      unsigned timeout, unsigned id,
> -			      const void *srcport)
> +			      const struct ibmad_port *srcport)
>  {
>  	ib_rpc_t rpc = { 0 };
>  	int lid = dest->lid;
> @@ -89,7 +89,7 @@ uint8_t *pma_query(void *rcvbuf, ib_portid_t * dest, int port, unsigned timeout,
>  
>  uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest,
>  				      int port, unsigned timeout,
> -				      const void *srcport)
> +				      const struct ibmad_port *srcport)
>  {
>  	return pma_query_via(rcvbuf, dest, port, timeout, CLASS_PORT_INFO,
>  			     srcport);
> @@ -102,7 +102,7 @@ uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t * dest, int port,
>  }
>  
>  uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t * dest, int port,
> -				    unsigned timeout, const void *srcport)
> +				    unsigned timeout, const struct ibmad_port *srcport)
>  {
>  	return pma_query_via(rcvbuf, dest, port, timeout,
>  			     IB_GSI_PORT_COUNTERS, srcport);
> @@ -116,7 +116,7 @@ uint8_t *port_performance_query(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  static uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
>  				      int port, unsigned mask, unsigned timeout,
> -				      unsigned id, const void *srcport)
> +				      unsigned id, const struct ibmad_port *srcport)
>  {
>  	ib_rpc_t rpc = { 0 };
>  	int lid = dest->lid;
> @@ -166,7 +166,7 @@ static uint8_t *performance_reset(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t * dest, int port,
>  				    unsigned mask, unsigned timeout,
> -				    const void *srcport)
> +				    const struct ibmad_port *srcport)
>  {
>  	return performance_reset_via(rcvbuf, dest, port, mask, timeout,
>  				     IB_GSI_PORT_COUNTERS, srcport);
> @@ -181,7 +181,7 @@ uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned timeout,
> -					const void *srcport)
> +					const struct ibmad_port *srcport)
>  {
>  	return pma_query_via(rcvbuf, dest, port, timeout,
>  			     IB_GSI_PORT_COUNTERS_EXT, srcport);
> @@ -195,7 +195,8 @@ uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned mask,
> -					unsigned timeout, const void *srcport)
> +					unsigned timeout,
> +					const struct ibmad_port *srcport)
>  {
>  	return performance_reset_via(rcvbuf, dest, port, mask, timeout,
>  				     IB_GSI_PORT_COUNTERS_EXT, srcport);
> @@ -210,7 +211,7 @@ uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t * dest,
>  					int port, unsigned timeout,
> -					const void *srcport)
> +					const struct ibmad_port *srcport)
>  {
>  	return pma_query_via(rcvbuf, dest, port, timeout,
>  			     IB_GSI_PORT_SAMPLES_CONTROL, srcport);
> @@ -225,7 +226,7 @@ uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t * dest, int port,
>  
>  uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t * dest,
>  				       int port, unsigned timeout,
> -				       const void *srcport)
> +				       const struct ibmad_port *srcport)
>  {
>  	return pma_query_via(rcvbuf, dest, port, timeout,
>  			     IB_GSI_PORT_SAMPLES_RESULT, srcport);
> diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map
> index f944d86..94d7762 100644
> --- a/libibmad/src/libibmad.map
> +++ b/libibmad/src/libibmad.map
> @@ -69,6 +69,7 @@ IBMAD_1.3 {
>  		mad_rpc_close_port;
>  		mad_rpc;
>  		mad_rpc_rmpp;
> +		mad_rpc_portid;
>  		madrpc;
>  		madrpc_def_timeout;
>  		madrpc_init;
> diff --git a/libibmad/src/resolve.c b/libibmad/src/resolve.c
> index 553949d..3291f43 100644
> --- a/libibmad/src/resolve.c
> +++ b/libibmad/src/resolve.c
> @@ -45,7 +45,8 @@
>  #undef DEBUG
>  #define DEBUG 	if (ibdebug)	IBWARN
>  
> -int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout, const void *srcport)
> +int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
> +			const struct ibmad_port *srcport)
>  {
>  	ib_portid_t self = { 0 };
>  	uint8_t portinfo[64];
> @@ -67,7 +68,8 @@ int ib_resolve_smlid(ib_portid_t * sm_id, int timeout)
>  }
>  
>  int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
> -			ib_portid_t * sm_id, int timeout, const void *srcport)
> +			ib_portid_t * sm_id, int timeout,
> +			const struct ibmad_port *srcport)
>  {
>  	ib_portid_t sm_portid;
>  	char buf[IB_SA_DATA_SIZE] = { 0 };
> @@ -93,7 +95,7 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
>  
>  int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
>  			      enum MAD_DEST dest_type, ib_portid_t * sm_id,
> -			      const void *srcport)
> +			      const struct ibmad_port *srcport)
>  {
>  	uint64_t guid;
>  	int lid;
> @@ -150,7 +152,7 @@ int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
>  }
>  
>  int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
> -			const void *srcport)
> +			const struct ibmad_port *srcport)
>  {
>  	ib_portid_t self = { 0 };
>  	uint8_t portinfo[64];
> diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
> index e811526..d47873b 100644
> --- a/libibmad/src/rpc.c
> +++ b/libibmad/src/rpc.c
> @@ -100,6 +100,11 @@ int madrpc_portid(void)
>  	return mad_portid;
>  }
>  
> +int mad_rpc_portid(struct ibmad_port *srcport)
> +{
> +	return (srcport->port_id);
> +}
> +
>  static int
>  _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
>  	   int timeout)
> @@ -164,10 +169,9 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
>  	return -1;
>  }
>  
> -void *mad_rpc(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport,
> +void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc, ib_portid_t * dport,
>  	      void *payload, void *rcvdata)
>  {
> -	const struct ibmad_port *p = port_id;
>  	int status, len;
>  	uint8_t sndbuf[1024], rcvbuf[1024], *mad;
>  
> @@ -177,8 +181,8 @@ void *mad_rpc(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport,
>  	if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
>  		return 0;
>  
> -	if ((len = _do_madrpc(p->port_id, sndbuf, rcvbuf,
> -			      p->class_agents[rpc->mgtclass],
> +	if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
> +			      port->class_agents[rpc->mgtclass],
>  			      len, rpc->timeout)) < 0) {
>  		IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
>  		return 0;
> @@ -203,10 +207,9 @@ void *mad_rpc(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport,
>  	return rcvdata;
>  }
>  
> -void *mad_rpc_rmpp(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport,
> +void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc, ib_portid_t * dport,
>  		   ib_rmpp_hdr_t * rmpp, void *data)
>  {
> -	const struct ibmad_port *p = port_id;
>  	int status, len;
>  	uint8_t sndbuf[1024], rcvbuf[1024], *mad;
>  
> @@ -217,8 +220,8 @@ void *mad_rpc_rmpp(const void *port_id, ib_rpc_t * rpc, ib_portid_t * dport,
>  	if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0)
>  		return 0;
>  
> -	if ((len = _do_madrpc(p->port_id, sndbuf, rcvbuf,
> -			      p->class_agents[rpc->mgtclass],
> +	if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
> +			      port->class_agents[rpc->mgtclass],
>  			      len, rpc->timeout)) < 0) {
>  		IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
>  		return 0;
> @@ -303,7 +306,7 @@ madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes)
>  	}
>  }
>  
> -void *mad_rpc_open_port(char *dev_name, int dev_port,
> +struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
>  			int *mgmt_classes, int num_classes)
>  {
>  	struct ibmad_port *p;
> @@ -360,12 +363,10 @@ void *mad_rpc_open_port(char *dev_name, int dev_port,
>  	return p;
>  }
>  
> -void mad_rpc_close_port(void *port_id)
> +void mad_rpc_close_port(struct ibmad_port *port)
>  {
> -	struct ibmad_port *p = port_id;
> -
> -	umad_close_port(p->port_id);
> -	free(p);
> +	umad_close_port(port->port_id);
> +	free(port);
>  }
>  
>  uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
> diff --git a/libibmad/src/sa.c b/libibmad/src/sa.c
> index 7403d4f..ddeb152 100644
> --- a/libibmad/src/sa.c
> +++ b/libibmad/src/sa.c
> @@ -44,7 +44,7 @@
>  #undef DEBUG
>  #define DEBUG 	if (ibdebug)	IBWARN
>  
> -uint8_t *sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t * portid,
> +uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf, ib_portid_t * portid,
>  		     ib_sa_call_t * sa, unsigned timeout)
>  {
>  	ib_rpc_t rpc = { 0 };
> @@ -106,7 +106,7 @@ uint8_t *sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t * portid,
>  			IB_PR_COMPMASK_SGID |\
>  			IB_PR_COMPMASK_NUMBPATH)
>  
> -int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid,
> +int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid,
>  		      ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf)
>  {
>  	int npath;
> diff --git a/libibmad/src/smp.c b/libibmad/src/smp.c
> index fad263c..e5489b3 100644
> --- a/libibmad/src/smp.c
> +++ b/libibmad/src/smp.c
> @@ -45,7 +45,7 @@
>  #define DEBUG 	if (ibdebug)	IBWARN
>  
>  uint8_t *smp_set_via(void *data, ib_portid_t * portid, unsigned attrid,
> -		     unsigned mod, unsigned timeout, const void *srcport)
> +		     unsigned mod, unsigned timeout, const struct ibmad_port *srcport)
>  {
>  	ib_rpc_t rpc = { 0 };
>  
> @@ -81,7 +81,7 @@ uint8_t *smp_set(void *data, ib_portid_t * portid, unsigned attrid,
>  }
>  
>  uint8_t *smp_query_via(void *rcvbuf, ib_portid_t * portid, unsigned attrid,
> -		       unsigned mod, unsigned timeout, const void *srcport)
> +		       unsigned mod, unsigned timeout, const struct ibmad_port *srcport)
>  {
>  	ib_rpc_t rpc = { 0 };
>  
> -- 
> 1.5.4.5
> 



More information about the general mailing list