Lines Matching refs:rd
14 static int rd_argc(struct rd *rd) in rd_argc() argument
16 return rd->argc; in rd_argc()
19 char *rd_argv(struct rd *rd) in rd_argv() argument
21 if (!rd_argc(rd)) in rd_argv()
23 return *rd->argv; in rd_argv()
33 static bool rd_argv_match(struct rd *rd, const char *pattern) in rd_argv_match() argument
35 if (!rd_argc(rd)) in rd_argv_match()
37 return strcmpx(rd_argv(rd), pattern) == 0; in rd_argv_match()
40 void rd_arg_inc(struct rd *rd) in rd_arg_inc() argument
42 if (!rd_argc(rd)) in rd_arg_inc()
44 rd->argc--; in rd_arg_inc()
45 rd->argv++; in rd_arg_inc()
48 bool rd_no_arg(struct rd *rd) in rd_no_arg() argument
50 return rd_argc(rd) == 0; in rd_no_arg()
53 uint32_t get_port_from_argv(struct rd *rd) in get_port_from_argv() argument
57 slash = strchr(rd_argv(rd), '/'); in get_port_from_argv()
83 static void dev_map_cleanup(struct rd *rd) in dev_map_cleanup() argument
88 &rd->dev_map_list, list) { in dev_map_cleanup()
131 struct rd *rd = data; in rd_dev_init_cb() local
148 list_add_tail(&dev_map->list, &rd->dev_map_list); in rd_dev_init_cb()
155 void rd_free_devmap(struct rd *rd) in rd_free_devmap() argument
157 if (!rd) in rd_free_devmap()
159 dev_map_cleanup(rd); in rd_free_devmap()
162 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *cmds, const char *str) in rd_exec_cmd() argument
167 if (rd_no_arg(rd)) in rd_exec_cmd()
168 return cmds->func(rd); in rd_exec_cmd()
171 if (rd_argv_match(rd, c->cmd)) { in rd_exec_cmd()
173 rd_arg_inc(rd); in rd_exec_cmd()
174 return c->func(rd); in rd_exec_cmd()
178 pr_err("Unknown %s '%s'.\n", str, rd_argv(rd)); in rd_exec_cmd()
182 void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags) in rd_prepare_msg() argument
186 rd->nlh = mnl_nlmsg_put_header(rd->buff); in rd_prepare_msg()
187 rd->nlh->nlmsg_type = RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, cmd); in rd_prepare_msg()
188 rd->nlh->nlmsg_seq = *seq; in rd_prepare_msg()
189 rd->nlh->nlmsg_flags = flags; in rd_prepare_msg()
192 int rd_send_msg(struct rd *rd) in rd_send_msg() argument
196 rd->nl = mnl_socket_open(NETLINK_RDMA); in rd_send_msg()
197 if (!rd->nl) { in rd_send_msg()
202 ret = mnl_socket_bind(rd->nl, 0, MNL_SOCKET_AUTOPID); in rd_send_msg()
208 ret = mnl_socket_sendto(rd->nl, rd->nlh, rd->nlh->nlmsg_len); in rd_send_msg()
216 mnl_socket_close(rd->nl); in rd_send_msg()
220 int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, unsigned int seq) in rd_recv_msg() argument
226 portid = mnl_socket_get_portid(rd->nl); in rd_recv_msg()
228 ret = mnl_socket_recvfrom(rd->nl, buf, sizeof(buf)); in rd_recv_msg()
235 mnl_socket_close(rd->nl); in rd_recv_msg()
239 struct dev_map *_dev_map_lookup(struct rd *rd, const char *dev_name) in _dev_map_lookup() argument
243 list_for_each_entry(dev_map, &rd->dev_map_list, list) in _dev_map_lookup()
250 struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index) in dev_map_lookup() argument
256 dev_name = strdup(rd_argv(rd)); in dev_map_lookup()
263 dev_map = _dev_map_lookup(rd, dev_name); in dev_map_lookup()