Lines Matching refs:rd
14 static int link_help(struct rd *rd) in link_help() argument
16 pr_out("Usage: %s link show [DEV/PORT_INDEX]\n", rd->filename); in link_help()
59 static void link_print_caps(struct rd *rd, struct nlattr **tb) in link_print_caps() argument
69 if (rd->json_output) { in link_print_caps()
70 jsonw_name(rd->jw, "caps"); in link_print_caps()
71 jsonw_start_array(rd->jw); in link_print_caps()
77 if (rd->json_output) { in link_print_caps()
78 jsonw_string(rd->jw, caps_to_str(idx)); in link_print_caps()
88 if (rd->json_output) in link_print_caps()
89 jsonw_end_array(rd->jw); in link_print_caps()
94 static void link_print_subnet_prefix(struct rd *rd, struct nlattr **tb) in link_print_subnet_prefix() argument
106 if (rd->json_output) in link_print_subnet_prefix()
107 jsonw_string_field(rd->jw, "subnet_prefix", str); in link_print_subnet_prefix()
112 static void link_print_lid(struct rd *rd, struct nlattr **tb) in link_print_lid() argument
120 if (rd->json_output) in link_print_lid()
121 jsonw_uint_field(rd->jw, "lid", lid); in link_print_lid()
126 static void link_print_sm_lid(struct rd *rd, struct nlattr **tb) in link_print_sm_lid() argument
134 if (rd->json_output) in link_print_sm_lid()
135 jsonw_uint_field(rd->jw, "sm_lid", sm_lid); in link_print_sm_lid()
140 static void link_print_lmc(struct rd *rd, struct nlattr **tb) in link_print_lmc() argument
148 if (rd->json_output) in link_print_lmc()
149 jsonw_uint_field(rd->jw, "lmc", lmc); in link_print_lmc()
165 static void link_print_state(struct rd *rd, struct nlattr **tb) in link_print_state() argument
173 if (rd->json_output) in link_print_state()
174 jsonw_string_field(rd->jw, "state", link_state_to_str(state)); in link_print_state()
193 static void link_print_phys_state(struct rd *rd, struct nlattr **tb) in link_print_phys_state() argument
201 if (rd->json_output) in link_print_phys_state()
202 jsonw_string_field(rd->jw, "physical_state", in link_print_phys_state()
211 struct rd *rd = data; in link_parse_cb() local
229 if (rd->json_output) { in link_parse_cb()
230 jsonw_uint_field(rd->jw, "ifindex", idx); in link_parse_cb()
231 jsonw_uint_field(rd->jw, "port", port); in link_parse_cb()
232 jsonw_string_field(rd->jw, "ifname", name); in link_parse_cb()
238 link_print_subnet_prefix(rd, tb); in link_parse_cb()
239 link_print_lid(rd, tb); in link_parse_cb()
240 link_print_sm_lid(rd, tb); in link_parse_cb()
241 link_print_lmc(rd, tb); in link_parse_cb()
242 link_print_state(rd, tb); in link_parse_cb()
243 link_print_phys_state(rd, tb); in link_parse_cb()
244 if (rd->show_details) in link_parse_cb()
245 link_print_caps(rd, tb); in link_parse_cb()
247 if (!rd->json_output) in link_parse_cb()
252 static int link_no_args(struct rd *rd) in link_no_args() argument
257 rd_prepare_msg(rd, RDMA_NLDEV_CMD_PORT_GET, &seq, in link_no_args()
259 mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx); in link_no_args()
260 mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_PORT_INDEX, rd->port_idx); in link_no_args()
261 ret = rd_send_msg(rd); in link_no_args()
265 if (rd->json_output) in link_no_args()
266 jsonw_start_object(rd->jw); in link_no_args()
267 ret = rd_recv_msg(rd, link_parse_cb, rd, seq); in link_no_args()
268 if (rd->json_output) in link_no_args()
269 jsonw_end_object(rd->jw); in link_no_args()
273 static int link_one_show(struct rd *rd) in link_one_show() argument
280 return rd_exec_cmd(rd, cmds, "parameter"); in link_one_show()
283 static int link_show(struct rd *rd) in link_show() argument
289 if (rd->json_output) in link_show()
290 jsonw_start_array(rd->jw); in link_show()
291 if (rd_no_arg(rd)) { in link_show()
292 list_for_each_entry(dev_map, &rd->dev_map_list, list) { in link_show()
293 rd->dev_idx = dev_map->idx; in link_show()
295 rd->port_idx = port; in link_show()
296 ret = link_one_show(rd); in link_show()
303 dev_map = dev_map_lookup(rd, true); in link_show()
304 port = get_port_from_argv(rd); in link_show()
310 rd_arg_inc(rd); in link_show()
311 rd->dev_idx = dev_map->idx; in link_show()
312 rd->port_idx = port ? : 1; in link_show()
313 for (; rd->port_idx < dev_map->num_ports + 1; rd->port_idx++) { in link_show()
314 ret = link_one_show(rd); in link_show()
327 if (rd->json_output) in link_show()
328 jsonw_end_array(rd->jw); in link_show()
332 int cmd_link(struct rd *rd) in cmd_link() argument
342 return rd_exec_cmd(rd, cmds, "link command"); in cmd_link()