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

Ira Weiny weiny2 at llnl.gov
Wed Feb 18 09:27:34 PST 2009


On Wed, 18 Feb 2009 12:07:15 -0500
Hal Rosenstock <hal.rosenstock at gmail.com> wrote:

> On Wed, Feb 18, 2009 at 12:06 AM, Ira Weiny <weiny2 at llnl.gov> wrote:
> >
> > From bac9afe0da7772f97190b3ce758d3e5bfa1fcb65 Mon Sep 17 00:00:00 2001
> > From: weiny2 at llnl.gov <weiny2 at wopri.(none)>
> > Date: Tue, 17 Feb 2009 17:32:15 -0800
> > Subject: [PATCH] Clean up "new" interface
> >
> >   type all "void *ibmad_port" and "void *srcport" with struct ibmad_port *
> >   Create new mad_rpc_portid(struct ibmad_port *srcport) function
> >      which mirrors madrpc_portid(void)
> >
> > Signed-off-by: weiny2 at llnl.gov <weiny2 at wopri.(none)>
> > ---
> >  libibmad/include/infiniband/mad.h |   58 ++++++++++++++++++++++--------------
> >  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, 71 insertions(+), 54 deletions(-)
> >
> > diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
> > index 1aaaa1b..56b87e6 100644
> > --- a/libibmad/include/infiniband/mad.h
> > +++ b/libibmad/include/infiniband/mad.h
> > @@ -724,42 +724,49 @@ static inline int mad_is_vendor_range2(int mgmt)
> >  }
> >
> >  /* rpc.c */
> > +/* Depricated interface */
> 
> typo - Deprecated

Some day I will learn to spell this...  :-(

> 
> >  MAD_EXPORT int madrpc_portid(void);
> > -MAD_EXPORT int madrpc_set_retries(int retries);
> > -MAD_EXPORT int madrpc_set_timeout(int timeout);
> 
> I thought initially we weren't going to remove APIs but move over to
> the new ones ? A subsequent step would be to deprecate the old APIs
> and then eventually remove the old APIs.

They were not removed... [see below]

> 
> -- Hal
> 
> >  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 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);
> >
> > -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);

... but moved down here to indicate they were _not_ deprecated.  We could
deprecate them and make 'retries' and 'timeout' associated with each
ibmad_port but I thought those were pretty global to the instance of the lib.

Ira

> > +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 mad_rpc_close_port(struct ibmad_port *srcport);
> > +void *mad_rpc(const struct ibmad_port *srcport, 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,
> > +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);
> >  MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid,
> >                            unsigned mod, unsigned timeout);
> > +
> > +/* 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);
> > +                      unsigned mod, unsigned timeout, const struct ibmad_port *srcport);
> >  uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid, unsigned mod,
> > -                    unsigned timeout, const void *srcport);
> > +                    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,
> > -                    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,
> > +
> > +/* sa.c new interface */
> > +uint8_t *sa_rpc_call(const struct ibmad_port *srcport, void *rcvbuf, ib_portid_t * portid,
> > +                    ib_sa_call_t * sa, unsigned timeout);
> > +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);
> >
> >  /* resolve.c */
> > @@ -771,14 +778,17 @@ MAD_EXPORT int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
> >  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);
> > +/* resolve.c new interface */
> > +int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
> > +                       const struct ibmad_port *srcport);
> >  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);
> >  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);
> > +                             const struct ibmad_port *srcport);
> >  int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
> > -                       const void *srcport);
> > +                       const struct ibmad_port *srcport);
> >
> >  /* gs.c */
> >  MAD_EXPORT uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t * dest,
> > @@ -798,26 +808,28 @@ MAD_EXPORT uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t * dest,
> >  MAD_EXPORT uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t * dest,
> >                                              int port, unsigned timeout);
> >
> > +/* gs.c new interface */
> >  uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t * dest,
> >                                      int port, unsigned timeout,
> > -                                     const void *srcport);
> > +                                     const struct ibmad_port *srcport);
> >  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);
> >  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);
> >  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);
> >  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);
> >  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);
> >  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
> >
> >


-- 
Ira Weiny <weiny2 at llnl.gov>



More information about the general mailing list