Lines Matching refs:port

135 	struct sa_db_port	port[0];
192 static void process_updates(struct sa_db_port *port);
396 static void update_path_db(struct sa_db_port *port,
409 port->update_id += (type == SA_UPDATE_FULL);
416 ret = insert_attr(&port->paths, port->update_id,
426 remove_old_attrs(&port->paths, port->update_id);
429 static struct ib_mad_send_buf *get_sa_msg(struct sa_db_port *port,
435 msg = ib_create_send_mad(port->agent, 1, 0, 0, IB_MGMT_SA_HDR,
441 ah_attr.dlid = port->sm_lid;
442 ah_attr.sl = port->sm_sl;
443 ah_attr.port_num = port->port_num;
445 msg->ah = ib_create_ah(port->agent->qp->pd, &ah_attr);
453 msg->context[0] = port;
465 static void format_path_req(struct sa_db_port *port,
481 path_rec.sgid = port->gid;
492 static int send_query(struct sa_db_port *port,
497 port->msg = get_sa_msg(port, update);
498 if (!port->msg)
501 format_path_req(port, update, port->msg);
503 ret = ib_post_send_mad(port->msg, NULL);
510 ib_destroy_ah(port->msg->ah);
511 ib_free_send_mad(port->msg);
515 static void add_update(struct sa_db_port *port, u8 *gid,
525 list_add(&update->list, &port->update_list);
528 if (port->state == SA_DB_IDLE) {
529 port->state = SA_DB_REFRESH;
530 process_updates(port);
534 static void clean_update_list(struct sa_db_port *port)
538 while (!list_empty(&port->update_list)) {
539 update = list_entry(port->update_list.next,
549 struct sa_db_port *port = info->context;
555 pinfo = &port->in_info;
558 pinfo = &port->out_info;
563 if (port->state == SA_DB_DESTROY || !*pinfo) {
571 add_update(port, gid_data->gid, type);
579 port->state = SA_DB_IDLE;
580 clean_update_list(port);
582 queue_work(sa_wq, &port->work);
588 static int reg_in_info(struct sa_db_port *port)
592 port->in_info = ib_sa_register_inform_info(&sa_client,
593 port->dev->device,
594 port->port_num,
597 port);
598 if (IS_ERR(port->in_info))
599 ret = PTR_ERR(port->in_info);
604 static int reg_out_info(struct sa_db_port *port)
608 port->out_info = ib_sa_register_inform_info(&sa_client,
609 port->dev->device,
610 port->port_num,
613 port);
614 if (IS_ERR(port->out_info))
615 ret = PTR_ERR(port->out_info);
620 static void unsubscribe_port(struct sa_db_port *port)
622 if (port->in_info && !IS_ERR(port->in_info))
623 ib_sa_unregister_inform_info(port->in_info);
625 if (port->out_info && !IS_ERR(port->out_info))
626 ib_sa_unregister_inform_info(port->out_info);
628 port->out_info = NULL;
629 port->in_info = NULL;
633 static void cleanup_port(struct sa_db_port *port)
635 unsubscribe_port(port);
637 clean_update_list(port);
638 remove_all_attrs(&port->paths);
641 static int update_port_info(struct sa_db_port *port)
646 ret = ib_query_port(port->dev->device, port->port_num, &port_attr);
653 port->sm_lid = port_attr.sm_lid;
654 port->sm_sl = port_attr.sm_sl;
658 static void process_updates(struct sa_db_port *port)
664 if (!paths_per_dest || update_port_info(port)) {
665 cleanup_port(port);
671 if (!port->out_info) {
672 ret = reg_out_info(port);
677 if (!port->in_info) {
678 ret = reg_in_info(port);
683 unsubscribe_port(port);
685 while (!list_empty(&port->update_list)) {
686 update = list_entry(port->update_list.next,
691 attr_list = find_attr_list(&port->paths,
694 remove_attr(&port->paths, attr_list);
697 ret = send_query(port, update);
706 port->state = SA_DB_IDLE;
709 static void refresh_port_db(struct sa_db_port *port)
711 if (port->state == SA_DB_DESTROY)
714 if (port->state == SA_DB_REFRESH) {
715 clean_update_list(port);
716 ib_cancel_mad(port->agent, port->msg);
719 add_update(port, NULL, SA_UPDATE_FULL);
727 refresh_port_db(&dev->port[i]);
807 struct sa_db_port *port;
809 port = container_of(work, typeof(*port), work);
811 refresh_port_db(port);
819 struct sa_db_port *port;
822 port = &dev->port[event->element.port_num - dev->start_port];
831 queue_work(sa_wq, &port->work);
847 struct sa_db_port *port;
854 port = &dev->port[port_num - dev->start_port];
857 list = find_attr_list(&port->paths, dgid->raw);
992 * @port_num: port number to send query on
1079 struct sa_db_port *port;
1085 port = msg->context[0];
1089 if (port->state == SA_DB_DESTROY ||
1090 update != list_entry(port->update_list.next,
1106 struct sa_db_port *port;
1111 port = msg->context[0];
1115 if (port->state == SA_DB_DESTROY)
1118 if (update == list_entry(port->update_list.next,
1134 process_updates(port);
1144 struct sa_db_port *port;
1147 port = &dev->port[port_num - dev->start_port];
1148 port->dev = dev;
1149 port->port_num = port_num;
1150 INIT_WORK(&port->work, port_work_handler);
1151 port->paths = RB_ROOT;
1152 INIT_LIST_HEAD(&port->update_list);
1154 ret = ib_get_cached_gid(dev->device, port_num, 0, &port->gid);
1158 port->agent = ib_register_mad_agent(dev->device, port_num, IB_QPT_GSI,
1160 send_handler, recv_handler, port);
1161 if (IS_ERR(port->agent))
1162 ret = PTR_ERR(port->agent);
1167 static void destroy_port(struct sa_db_port *port)
1170 port->state = SA_DB_DESTROY;
1173 ib_unregister_mad_agent(port->agent);
1174 cleanup_port(port);
1181 struct sa_db_port *port;
1194 dev = kzalloc(sizeof *dev + (e - s + 1) * sizeof *port, GFP_KERNEL);
1220 destroy_port(&dev->port[i]);
1237 destroy_port(&dev->port[i]);