ibacm cleanups
This series fixed various sparse issues in ibacm, makes it use the common list helpers and removes various cruft.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org
PATCH 1/13 ibacm: remove HAVE_NETLINK
We now always require netlink support
--- buildlib/config.h.in | 3 --- ibacm/src/acm.c | 25 +------------------------ 2 files changed, 1 insertion(+), 27 deletions(-)
buildlib/config.h.in +0 -3
@@ -6,9 +6,6 @@ #define HAVE_TYPEOF 1 #define HAVE_ISBLANK 1 -// FIXME: Remove this, we provide the netlink kernel headers ibacm needs -#define HAVE_NETLINK 1 - // FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support #define STREAM_CLOEXEC "e"
ibacm/src/acm.c +1 -24
@@ -44,10 +44,8 @@#include <infiniband/acm_prov.h> #include <infiniband/umad.h> #include <infiniband/verbs.h> -#ifdef HAVE_NETLINK #include <infiniband/umad_types.h> #include <infiniband/umad_sa.h> -#endif #include <dlist.h> #include <dlfcn.h> #include <search.h>
@@ -57,19 +55,15 @@#include <netinet/in.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> -#ifdef HAVE_NETLINK #include <rdma/rdma_netlink.h> #include <rdma/ib_user_sa.h> -#endif #include <poll.h> #include <inttypes.h> #include "acm_mad.h" #include "acm_util.h" -#ifdef HAVE_NETLINK #if !defined(RDMA_NL_LS_F_ERR )#include "acm_netlink.h" #endif -#endif #define src_out data[0]#define src_index data[1]
@@ -78,9 +72,7 @@#define MAX_EP_ADDR 4#define NL_MSG_BUF_SIZE 4096#define ACM_PROV_NAME_SIZE 64 -#ifdef HAVE_NETLINK #define NL_CLIENT_INDEX 0 -#endif struct acmc_subnet {DLIST_ENTRY entry;
@@ -167,7 +159,6 @@ struct acmc_sa_req {struct acm_sa_mad mad; }; -#ifdef HAVE_NETLINKstruct acm_nl_path {struct nlattr attr_hdr;struct ib_path_rec_data rec;
@@ -182,7 +173,6 @@ struct acm_nl_msg {struct acm_nl_path path[0 ]; }; }; -#endif static char def_prov_name[ACM_PROV_NAME_SIZE ] ="ibacmp" ;static DLIST_ENTRY provider_list;
@@ -205,9 +195,7 @@ static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey);static int acm_ep_insert_addr (struct acmc_ep *ep,const char *name,uint8_t *addr,size_t addr_len,uint8_t addr_type);static void acm_event_handler (struct acmc_device *dev); -#ifdef HAVE_NETLINK static int acm_nl_send (SOCKET sock,struct acm_msg *msg); -#endif static struct sa_data { int timeout;
@@ -502,11 +490,9 @@ int acm_resolve_response(uint64_t id, struct acm_msg *msg) goto release; } -#ifdef HAVE_NETLINK if (id ==NL_CLIENT_INDEX ) ret =acm_nl_send (client->sock, msg);else -#endif ret =send (client->sock, (char *) msg, msg->hdr.length,0 );if (ret != msg->hdr.length)
@@ -639,10 +625,8 @@ static void acm_svr_accept(void) }for (i =0 ; i <FD_SETSIZE -1 ; i++) { -#ifdef HAVE_NETLINK if (i ==NL_CLIENT_INDEX )continue ; -#endif if (!atomic_get (&client_array[i].refcnt))break ; }
@@ -1392,7 +1376,6 @@ static void acm_ipnl_handler(void) } } -#ifdef HAVE_NETLINK static int acm_nl_send (SOCKET sock,struct acm_msg *msg) {struct sockaddr_nl dst_addr;
@@ -1714,7 +1697,6 @@ static int acm_init_nl(void) client_array[NL_CLIENT_INDEX ].sock = nl_rcv_socket;return 0 ; } -#endif static void acm_server (void ) {
@@ -1730,11 +1712,10 @@ static void acm_server(void)acm_log (0 ,"ERROR - server listen failed\n" );return ; } -#ifdef HAVE_NETLINK + ret =acm_init_nl ();if (ret)acm_log (1 ,"Warn - Netlink init failed\n" ); -#endif while (1 ) { n = (int ) listen_socket;
@@ -1773,11 +1754,9 @@ static void acm_server(void)if (client_array[i].sock !=INVALID_SOCKET &&FD_ISSET (client_array[i].sock, &readfds)) {acm_log (2 ,"receiving from client %d\n" , i); -#ifdef HAVE_NETLINK if (i ==NL_CLIENT_INDEX )acm_nl_receive (&client_array[i]);else -#endif acm_svr_receive (&client_array[i]); } }
@@ -3143,10 +3122,8 @@ int CDECL_FUNC main(int argc, char **argv)acm_server ();acm_log (0 ,"shutting down\n" ); -#ifdef HAVE_NETLINK if (client_array[NL_CLIENT_INDEX ].sock !=INVALID_SOCKET )close (client_array[NL_CLIENT_INDEX ].sock); -#endif acm_close_providers ();acm_stop_sa_handler ();umad_done ();
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/13 ibacm: use pthread_mutex_t directly
In reply to a message not in the archive--- ibacm/linux/libacm_linux.c | 4 +- ibacm/linux/osd.h | 5 -- ibacm/prov/acmp/src/acmp.c | 132 ++++++++++++++++++++++----------------------- ibacm/src/acm.c | 42 +++++++-------- ibacm/src/libacm.c | 22 ++++---- 5 files changed, 100 insertions(+), 105 deletions(-)
ibacm/linux/libacm_linux.c +2 -2
@@ -29,9 +29,9 @@#include <osd.h> -lock_t lock; +pthread_mutex_t lock;static void __attribute__((constructor))lib_init (void ) { -lock_init (&lock); +pthread_mutex_init (&lock,NULL ); }
ibacm/linux/osd.h +0 -5
@@ -115,11 +115,6 @@ static inline int event_wait(event_t *e, int timeout)return ret; } -#define lock_t pthread_mutex_t -#define lock_init (x) pthread_mutex_init(x, NULL) -#define lock_acquire pthread_mutex_lock -#define lock_release pthread_mutex_unlock -#define osd_init () 0#define osd_close ()
ibacm/prov/acmp/src/acmp.c +66 -66
424 lines not on this page · raw message
ibacm/src/acm.c +21 -21
157 lines not on this page · raw message
ibacm/src/libacm.c +11 -11
@@ -38,7 +38,7 @@#include <netdb.h> #include <arpa/inet.h> -extern lock_t lock; +extern pthread_mutex_t lock;static SOCKET sock =INVALID_SOCKET ;static short server_port =6125 ;
@@ -212,7 +212,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,struct acm_msg msg;int ret, cnt =0 ; -lock_acquire (&lock); +pthread_mutex_lock (&lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_RESOLVE ;
@@ -246,7 +246,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type, ret =acm_format_resp (&msg, paths, count, print); out: -lock_release (&lock); +pthread_mutex_unlock (&lock);return ret; }
@@ -275,7 +275,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)struct acm_ep_addr_data *data;int ret; -lock_acquire (&lock); +pthread_mutex_lock (&lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_RESOLVE ;
@@ -299,7 +299,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags) *path = data->info.path; out: -lock_release (&lock); +pthread_mutex_unlock (&lock);return ret; }
@@ -308,7 +308,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)struct acm_msg msg;int ret, i; -lock_acquire (&lock); +pthread_mutex_lock (&lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_PERF_QUERY ;
@@ -341,7 +341,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count) (*counters)[i] =ntohll (msg.perf_data[i]); ret =0 ; out: -lock_release (&lock); +pthread_mutex_unlock (&lock);return ret; }
@@ -353,7 +353,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)int cnt;struct acm_ep_config_data *edata; -lock_acquire (&lock); +pthread_mutex_lock (&lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_EP_QUERY ;
@@ -391,7 +391,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) *data = edata; ret =0 ; out: -lock_release (&lock); +pthread_mutex_unlock (&lock);return ret; }
@@ -404,7 +404,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,if (!src)return -1 ; -lock_acquire (&lock); +pthread_mutex_lock (&lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_PERF_QUERY ;
@@ -444,7 +444,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type, ret =0 ; out: -lock_release (&lock); +pthread_mutex_unlock (&lock);return ret; }
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/13 ibacm: use __thread directly
In reply to a message not in the archive--- ibacm/linux/osd.h | 1 - ibacm/prov/acmp/src/acmp.c | 2 +- ibacm/src/acm.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
ibacm/linux/osd.h +0 -1
@@ -136,7 +136,6 @@ static inline uint64_t time_stamp_us(void)#define time_stamp_sec () (time_stamp_ms() / (uint64_t) 1000)#define time_stamp_min () (time_stamp_sec() / (uint64_t) 60) -#define PER_THREAD __threadstatic inline int beginthread (void (*func)(void *),void *arg) {pthread_t thread;
ibacm/prov/acmp/src/acmp.c +1 -1
@@ -259,7 +259,7 @@ static atomic_t wait_cnt;static pthread_t retry_thread_id;static int retry_thread_started =0 ; -PER_THREAD char log_data[ACM_MAX_ADDRESS]; +__threadchar log_data[ACM_MAX_ADDRESS ];/* * Service options - may be set through ibacm_opts.cfg file.
ibacm/src/acm.c +1 -1
@@ -186,7 +186,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1];static FILE *flog;static pthread_mutex_t log_lock; -PER_THREAD char log_data[ACM_MAX_ADDRESS]; +__threadchar log_data[ACM_MAX_ADDRESS ];static atomic_t counter[ACM_MAX_COUNTER ]; static struct acmc_device *
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/13 ibacm: use the unix socket API directly
In reply to a message not in the archive--- ibacm/linux/osd.h | 6 ----- ibacm/src/acm.c | 66 +++++++++++++++++++++++++++--------------------------- ibacm/src/libacm.c | 16 ++++++------- 3 files changed, 41 insertions(+), 47 deletions(-)
ibacm/linux/osd.h +0 -6
@@ -118,12 +118,6 @@ static inline int event_wait(event_t *e, int timeout)#define osd_init () 0#define osd_close () -#define SOCKET int -#define SOCKET_ERROR -1 -#define INVALID_SOCKET -1 -#define socket_errno () errno -#define closesocket close -static inline uint64_t time_stamp_us (void ) {struct timeval curtime;
ibacm/src/acm.c +33 -33
213 lines not on this page · raw message
ibacm/src/libacm.c +8 -8
@@ -39,7 +39,7 @@#include <arpa/inet.h> extern pthread_mutex_t lock; -static SOCKET sock =INVALID_SOCKET ; +static int sock =-1 ;static short server_port =6125 ;static void acm_set_server_port (void )
@@ -67,8 +67,8 @@ int ib_acm_connect(char *dest)return ret; sock =socket (res->ai_family, res->ai_socktype, res->ai_protocol); -if (sock ==INVALID_SOCKET ) { - ret =socket_errno (); +if (sock ==-1 ) { + ret = errno; goto err1; }
@@ -81,8 +81,8 @@ int ib_acm_connect(char *dest)return 0 ; err2: -closesocket (sock); - sock =INVALID_SOCKET ; +close (sock); + sock =-1 ; err1:freeaddrinfo (res);return ret;
@@ -90,10 +90,10 @@ err1:void ib_acm_disconnect (void ) { -if (sock !=INVALID_SOCKET ) { +if (sock !=-1 ) {shutdown (sock,SHUT_RDWR ); -closesocket (sock); - sock =INVALID_SOCKET ; +close (sock); + sock =-1 ; } }
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/13 ibacm: remove unused helper beginthread
In reply to a message not in the archive--- ibacm/linux/osd.h | 6 ------ 1 file changed, 6 deletions(-)
ibacm/linux/osd.h +0 -6
@@ -130,10 +130,4 @@ static inline uint64_t time_stamp_us(void)#define time_stamp_sec () (time_stamp_ms() / (uint64_t) 1000)#define time_stamp_min () (time_stamp_sec() / (uint64_t) 60) -static inline int beginthread (void (*func)(void *),void *arg) -{ -pthread_t thread; -return pthread_create (&thread,NULL , (void *(*)(void *)) func, arg); -} -#endif /* OSD_H */
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/13 ibacm: remove unused LIB_DESTRUCTOR define
In reply to a message not in the archive--- ibacm/linux/osd.h | 1 - 1 file changed, 1 deletion(-)
ibacm/linux/osd.h +0 -1
@@ -53,7 +53,6 @@#define ACM_ADDR_FILE "ibacm_addr.cfg"#define ACM_OPTS_FILE "ibacm_opts.cfg" -#define LIB_DESTRUCTOR __attribute__((destructor))#define CDECL_FUNC #if DEFINE_ATOMICS
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/13 ibacm: remove CDECL_FUNC
In reply to a message not in the archive--- ibacm/linux/osd.h | 2 -- ibacm/src/acm.c | 2 +- ibacm/src/acme.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-)
ibacm/linux/osd.h +0 -2
@@ -53,8 +53,6 @@#define ACM_ADDR_FILE "ibacm_addr.cfg"#define ACM_OPTS_FILE "ibacm_opts.cfg" -#define CDECL_FUNC -#if DEFINE_ATOMICS typedef struct {pthread_mutex_t mut;int val; }atomic_t ;static inline int atomic_inc (atomic_t *atomic)
ibacm/src/acm.c +1 -1
@@ -3049,7 +3049,7 @@ static void show_usage(char *program)printf (" (default %s/%s)\n" ,ACM_CONF_DIR ,ACM_OPTS_FILE ); } -int CDECL_FUNC main(int argc, char **argv) +int main (int argc,char **argv) {int i, op, daemon =1 ;
ibacm/src/acme.c +1 -1
@@ -983,7 +983,7 @@ static void parse_perf_arg(char *arg) } } -int CDECL_FUNC main(int argc, char **argv) +int main (int argc,char **argv) {int op, ret;int make_addr =0 ;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/13 ibacm: remove no-op osd_init/osd_close macros
In reply to a message not in the archive--- ibacm/linux/osd.h | 3 --- ibacm/prov/acmp/src/acmp.c | 3 --- ibacm/src/acm.c | 3 --- ibacm/src/acme.c | 8 +------- 4 files changed, 1 insertion(+), 16 deletions(-)
ibacm/linux/osd.h +0 -3
@@ -112,9 +112,6 @@ static inline int event_wait(event_t *e, int timeout)return ret; } -#define osd_init () 0 -#define osd_close () -static inline uint64_t time_stamp_us (void ) {struct timeval curtime;
ibacm/prov/acmp/src/acmp.c +0 -3
@@ -2941,9 +2941,6 @@ static void acmp_log_options(void)static void __attribute__((constructor))acmp_init (void ) { -if (osd_init ()) -return ; -acmp_set_options ();acmp_log_options ();
ibacm/src/acm.c +0 -3
@@ -3076,9 +3076,6 @@ int main(int argc, char **argv)if (daemon)daemonize (); -if (osd_init ()) -return -1 ; -acm_set_options ();if (acm_open_lock_file ())return -1 ;
ibacm/src/acme.c +1 -7
@@ -985,14 +985,10 @@ static void parse_perf_arg(char *arg)int main (int argc,char **argv) { -int op, ret; +int op, ret =0 ;int make_addr =0 ;int make_opts =0 ; - ret =osd_init (); -if (ret) - goto out; -while ((op =getopt (argc, argv,"e::f:s:d:vcA::O::D:P::S:C:V" )) !=-1 ) {switch (op) {case 'e' :
@@ -1068,8 +1064,6 @@ int main(int argc, char **argv)if (!ret && make_opts) ret =gen_opts (); -osd_close (); -out:if (verbose || !(make_addr || make_opts) || ret)printf ("return status 0x%x\n" , ret);return ret;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/13 ibacm: remove e stricmp and strnicmp
In reply to a message not in the archive--- ibacm/linux/osd.h | 3 --- ibacm/prov/acmp/src/acmp.c | 50 +++++++++++++++++++++++----------------------- ibacm/src/acm.c | 30 ++++++++++++++-------------- ibacm/src/acme.c | 4 ++-- 4 files changed, 42 insertions(+), 45 deletions(-)
ibacm/linux/osd.h +0 -3
@@ -87,9 +87,6 @@ typedef struct { volatile int val; } atomic_t;#define atomic_get (v) ((v)->val)#define atomic_set (v, s) ((v)->val = s) -#define stricmp strcasecmp -#define strnicmp strncasecmp -typedef struct {pthread_cond_t cond;pthread_mutex_t mutex; }event_t ;static inline void event_init (event_t *e) {
ibacm/prov/acmp/src/acmp.c +25 -25
112 lines not on this page · raw message
ibacm/src/acm.c +15 -15
@@ -388,7 +388,7 @@ static void acm_mark_addr_invalid(struct acmc_ep *ep,continue ;if ((data->type ==ACM_ADDRESS_NAME && - !strnicmp ((char *) ep->addr_info[i].addr.info.name, + !strncasecmp ((char *) ep->addr_info[i].addr.info.name, (char *) data->info.addr,ACM_MAX_ADDRESS )) || !memcmp (ep->addr_info[i].addr.info.addr, data->info.addr,ACM_MAX_ADDRESS )) {
@@ -410,7 +410,7 @@ acm_addr_lookup(const struct acm_endpoint *endpoint, uint8_t *addr, uint8_t addrcontinue ;if ((addr_type ==ACM_ADDRESS_NAME && - !strnicmp ((char *) ep->addr_info[i].addr.info.name, + !strncasecmp ((char *) ep->addr_info[i].addr.info.name, (char *) addr,ACM_MAX_ADDRESS )) || !memcmp (ep->addr_info[i].addr.info.addr, addr,ACM_MAX_ADDRESS ))return &ep->addr_info[i].addr;
@@ -2004,7 +2004,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep)memcpy (addr, name, addr_len); } -if (stricmp (pkey_str,"default" )) { +if (strcasecmp (pkey_str,"default" )) {if (sscanf (pkey_str,"%hx" , &pkey) !=1 ) {acm_log (0 ,"ERROR - bad pkey format %s\n" , pkey_str);continue ;
@@ -2013,7 +2013,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep) pkey = ep->port->def_acm_pkey; } -if (!stricmp (dev_name, dev) && +if (!strcasecmp (dev_name, dev) && (ep->port->port.port_num == (uint8_t ) port) && (ep->endpoint.pkey == pkey)) {acm_log (1 ,"assigning %s\n" , name);
@@ -2939,23 +2939,23 @@ static void acm_set_options(void)if (sscanf (s,"%32s%256s" , opt, value) !=2 )continue ; -if (!stricmp ("log_file" , opt)) +if (!strcasecmp ("log_file" , opt))strcpy (log_file, value); -else if (!stricmp ("log_level" , opt)) +else if (!strcasecmp ("log_level" , opt)) log_level =atoi (value); -else if (!stricmp ("lock_file" , opt)) +else if (!strcasecmp ("lock_file" , opt))strcpy (lock_file, value); -else if (!stricmp ("server_port" , opt)) +else if (!strcasecmp ("server_port" , opt)) server_port = (short )atoi (value); -else if (!stricmp ("provider_lib_path" , opt)) +else if (!strcasecmp ("provider_lib_path" , opt))strcpy (prov_lib_path, value); -else if (!stricmp ("support_ips_in_addr_cfg" , opt)) +else if (!strcasecmp ("support_ips_in_addr_cfg" , opt)) support_ips_in_addr_cfg =atoi (value); -else if (!stricmp ("timeout" , opt)) +else if (!strcasecmp ("timeout" , opt)) sa.timeout =atoi (value); -else if (!stricmp ("retries" , opt)) +else if (!strcasecmp ("retries" , opt)) sa.retries =atoi (value); -else if (!stricmp ("sa_depth" , opt)) +else if (!strcasecmp ("sa_depth" , opt)) sa.depth =atoi (value); }
@@ -2981,10 +2981,10 @@ static FILE *acm_open_log(void) {FILE *f; -if (!stricmp (log_file,"stdout" )) +if (!strcasecmp (log_file,"stdout" ))return stdout; -if (!stricmp (log_file,"stderr" )) +if (!strcasecmp (log_file,"stderr" ))return stderr;if (!(f =fopen (log_file,"w" )))
ibacm/src/acme.c +2 -2
@@ -968,9 +968,9 @@ static char *opt_arg(int argc, char **argv)static void parse_perf_arg (char *arg) { -if (!strnicmp ("col" , arg,3 )) { +if (!strncasecmp ("col" , arg,3 )) { perf_query =PERF_QUERY_COL ; - }else if (!strnicmp ("all" , arg,3 )) { + }else if (!strncasecmp ("all" , arg,3 )) { perf_query =PERF_QUERY_EP_ALL ; }else if (!strcmp ("s" , arg)) { perf_query =PERF_QUERY_EP_ADDR ;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/13 ibacm: cleanup "lock"
In reply to a message not in the archiveMake it static to libacm.c, give it a more reasonable name and initialize it at compile time.
Note tha the critical sections for this lock could be reduced easily, but that's a different project if someone cares enough..
--- ibacm/CMakeLists.txt | 1 - ibacm/linux/libacm_linux.c | 37 ------------------------------------- ibacm/src/libacm.c | 22 +++++++++++----------- 3 files changed, 11 insertions(+), 49 deletions(-) delete mode 100644 ibacm/linux/libacm_linux.c
ibacm/CMakeLists.txt +0 -1
@@ -38,7 +38,6 @@ set_target_properties(ibacmp PROPERTIES install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}") rdma_executable(ib_acme - linux/libacm_linux.c src/acme.c src/libacm.c src/parse.c
ibacm/linux/libacm_linux.c deleted +0 -37
@@ -1,37 +0,0 @@ -/* -* Copyright (c) 2009 Intel Corporation. All rights reserved. -* -* This software is available to you under the OpenIB.org BSD license -* below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#include <osd.h> - -pthread_mutex_t lock; - -static void __attribute__((constructor))lib_init (void ) -{ -pthread_mutex_init (&lock,NULL ); -}
ibacm/src/libacm.c +11 -11
@@ -38,7 +38,7 @@#include <netdb.h> #include <arpa/inet.h> -extern pthread_mutex_t lock; +static pthread_mutex_t acm_lock =PTHREAD_MUTEX_INITIALIZER ;static int sock =-1 ;static short server_port =6125 ;
@@ -212,7 +212,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,struct acm_msg msg;int ret, cnt =0 ; -pthread_mutex_lock (&lock); +pthread_mutex_lock (&acm_lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_RESOLVE ;
@@ -246,7 +246,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type, ret =acm_format_resp (&msg, paths, count, print); out: -pthread_mutex_unlock (&lock); +pthread_mutex_unlock (&acm_lock);return ret; }
@@ -275,7 +275,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)struct acm_ep_addr_data *data;int ret; -pthread_mutex_lock (&lock); +pthread_mutex_lock (&acm_lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_RESOLVE ;
@@ -299,7 +299,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags) *path = data->info.path; out: -pthread_mutex_unlock (&lock); +pthread_mutex_unlock (&acm_lock);return ret; }
@@ -308,7 +308,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)struct acm_msg msg;int ret, i; -pthread_mutex_lock (&lock); +pthread_mutex_lock (&acm_lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_PERF_QUERY ;
@@ -341,7 +341,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count) (*counters)[i] =ntohll (msg.perf_data[i]); ret =0 ; out: -pthread_mutex_unlock (&lock); +pthread_mutex_unlock (&acm_lock);return ret; }
@@ -353,7 +353,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)int cnt;struct acm_ep_config_data *edata; -pthread_mutex_lock (&lock); +pthread_mutex_lock (&acm_lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_EP_QUERY ;
@@ -391,7 +391,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data) *data = edata; ret =0 ; out: -pthread_mutex_unlock (&lock); +pthread_mutex_unlock (&acm_lock);return ret; }
@@ -404,7 +404,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,if (!src)return -1 ; -pthread_mutex_lock (&lock); +pthread_mutex_lock (&acm_lock);memset (&msg,0 ,sizeof msg); msg.hdr.version =ACM_VERSION ; msg.hdr.opcode =ACM_OP_PERF_QUERY ;
@@ -444,7 +444,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type, ret =0 ; out: -pthread_mutex_unlock (&lock); +pthread_mutex_unlock (&acm_lock);return ret; }
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/13 ibacm: use ccan/list.h
In reply to a message not in the archiveTrivial conversion, aided by the additional type safety and helpers.
--- ibacm/linux/dlist.h | 80 ------------------ ibacm/prov/acmp/src/acmp.c | 141 +++++++++++-------------------- ibacm/src/acm.c | 206 ++++++++++++++------------------------------- 3 files changed, 112 insertions(+), 315 deletions(-) delete mode 100644 ibacm/linux/dlist.h
ibacm/linux/dlist.h deleted +0 -80
@@ -1,80 +0,0 @@ -/* -* Copyright (c) 2009 Intel Corporation. All rights reserved. -* -* This software is available to you under the OpenIB.org BSD license -* below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#ifndef _DLIST_H_ -#define _DLIST_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _DLIST_ENTRY { -struct _DLIST_ENTRY *Next; -struct _DLIST_ENTRY *Prev; - -}DLIST_ENTRY ; - -static void DListInit (DLIST_ENTRY *pHead) -{ - pHead->Next = pHead; - pHead->Prev = pHead; -} - -static int DListEmpty (DLIST_ENTRY *pHead) -{ -return pHead->Next == pHead; -} - -static void DListInsertAfter (DLIST_ENTRY *pNew,DLIST_ENTRY *pHead) -{ - pNew->Next = pHead->Next; - pNew->Prev = pHead; - pHead->Next->Prev = pNew; - pHead->Next = pNew; -} - -static void DListInsertBefore (DLIST_ENTRY *pNew,DLIST_ENTRY *pHead) -{ -DListInsertAfter (pNew, pHead->Prev); -} - -#define DListInsertHead DListInsertAfter -#define DListInsertTail DListInsertBefore - -static void DListRemove (DLIST_ENTRY *pEntry) -{ - pEntry->Prev->Next = pEntry->Next; - pEntry->Next->Prev = pEntry->Prev; -} - -#ifdef __cplusplus -} -#endif - -#endif // _DLIST_H_
ibacm/prov/acmp/src/acmp.c +50 -91
403 lines not on this page · raw message
ibacm/src/acm.c +62 -144
547 lines not on this page · raw message
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/13 ibacm: mark symbols static where possible
In reply to a message not in the archive--- ibacm/prov/acmp/src/acmp.c | 2 +- ibacm/src/acm.c | 2 +- ibacm/src/acme.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
ibacm/prov/acmp/src/acmp.c +1 -1
@@ -259,7 +259,7 @@ static atomic_t wait_cnt;static pthread_t retry_thread_id;static int retry_thread_started =0 ; -__threadchar log_data[ACM_MAX_ADDRESS ]; +static __threadchar log_data[ACM_MAX_ADDRESS ];/* * Service options - may be set through ibacm_opts.cfg file.
ibacm/src/acm.c +1 -1
@@ -186,7 +186,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1];static FILE *flog;static pthread_mutex_t log_lock; -__threadchar log_data[ACM_MAX_ADDRESS ]; +static __threadchar log_data[ACM_MAX_ADDRESS ];static atomic_t counter[ACM_MAX_COUNTER ]; static struct acmc_device *
ibacm/src/acme.c +3 -3
@@ -69,10 +69,10 @@ enum perf_query_output { PERF_QUERY_EP_ADDR };static enum perf_query_output perf_query; -int verbose; +static int verbose; -struct ibv_context **verbs; -int dev_cnt; +static struct ibv_context **verbs; +static int dev_cnt;#define VPRINT (format, ...) do { if (verbose) printf(format, ## __VA_ARGS__ ); } while (0)
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 13/13 ibacm: mark large integer constant as unsigned long long
In reply to a message not in the archive--- ibacm/src/acm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ibacm/src/acm.c +1 -1
@@ -2772,7 +2772,7 @@ static void acmc_recv_mad(struct acmc_port *port)pthread_mutex_lock (&port->lock);list_for_each (&port->sa_pending, req, entry) {/* The lower 32-bit of the tid is used for agentid in umad */ -if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid &0xFFFFFFFF00000000 )) { +if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid &0xFFFFFFFF00000000ULL )) { found =1 ;list_del (&req->entry); port->sa_credits++;
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hefty, Sean
Acked-byQuoted 2 lines
This series fixed various sparse issues in ibacm, makes it use the common list helpers and removes various cruft.
Thanks - series looks good to me.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Leon Romanovsky
AppliedQuoted 2 lines · Christoph Hellwig
This series fixed various sparse issues in ibacm, makes it use the common list helpers and removes various cruft.
Thanks, applied
https://github.com/linux-rdma/rdma-core/pull/21
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html