aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorYishai Hadas <yishaih@mellanox.com>2015-03-03 09:12:14 -0500
committerDoug Ledford <dledford@redhat.com>2015-04-15 15:51:50 -0400
commitf54796012837687532d0a87a0504de22da7c2503 (patch)
tree0362d329d0d7fe1b38472063177f4db4235bec4c /drivers/infiniband
parent2350f24774627d73fe2e3843172b69db91714cd2 (diff)
IB/mlx4: Change init flow to request alias GUIDs for active VFs
Change the init flow to ask GUIDs only for active VFs. This is done for both SM & HOST modes so that there is no need any more to maintain the ownership record type. In case SM mode is used, the initial value will be 0, ask the SM to assign, for the HOST mode the initial value will be the HOST generated GUID. This will enable out of the box experience for both probed and attached VFs. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/mlx4/alias_GUID.c104
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h8
-rw-r--r--drivers/infiniband/hw/mlx4/sysfs.c17
3 files changed, 50 insertions, 79 deletions
diff --git a/drivers/infiniband/hw/mlx4/alias_GUID.c b/drivers/infiniband/hw/mlx4/alias_GUID.c
index e4edd73f79b9..5b4080740321 100644
--- a/drivers/infiniband/hw/mlx4/alias_GUID.c
+++ b/drivers/infiniband/hw/mlx4/alias_GUID.c
@@ -298,19 +298,17 @@ static void aliasguid_query_handler(int status,
298 */ 298 */
299 if (sm_response == MLX4_NOT_SET_GUID) { 299 if (sm_response == MLX4_NOT_SET_GUID) {
300 if (rec->guids_retry_schedule[i] == 0) 300 if (rec->guids_retry_schedule[i] == 0)
301 mlx4_ib_warn(&dev->ib_dev, "%s:Record num %d in " 301 mlx4_ib_warn(&dev->ib_dev,
302 "block_num: %d was declined by SM, " 302 "%s:Record num %d in block_num: %d was declined by SM\n",
303 "ownership by %d (0 = driver, 1=sysAdmin," 303 __func__, i,
304 " 2=None)\n", __func__, i, 304 guid_rec->block_num);
305 guid_rec->block_num,
306 rec->ownership);
307 goto entry_declined; 305 goto entry_declined;
308 } else { 306 } else {
309 /* properly assigned record. */ 307 /* properly assigned record. */
310 /* We save the GUID we just got from the SM in the 308 /* We save the GUID we just got from the SM in the
311 * admin_guid in order to be persistent, and in the 309 * admin_guid in order to be persistent, and in the
312 * request from the sm the process will ask for the same GUID */ 310 * request from the sm the process will ask for the same GUID */
313 if (rec->ownership == MLX4_GUID_SYSADMIN_ASSIGN && 311 if (required_val &&
314 sm_response != required_val) { 312 sm_response != required_val) {
315 /* Warn only on first retry */ 313 /* Warn only on first retry */
316 if (rec->guids_retry_schedule[i] == 0) 314 if (rec->guids_retry_schedule[i] == 0)
@@ -416,9 +414,7 @@ static void invalidate_guid_record(struct mlx4_ib_dev *dev, u8 port, int index)
416 need to assign GUIDs, then don't put it up for assignment. 414 need to assign GUIDs, then don't put it up for assignment.
417 */ 415 */
418 if (MLX4_GUID_FOR_DELETE_VAL == cur_admin_val || 416 if (MLX4_GUID_FOR_DELETE_VAL == cur_admin_val ||
419 (!index && !i) || 417 (!index && !i))
420 MLX4_GUID_NONE_ASSIGN == dev->sriov.alias_guid.
421 ports_guid[port - 1].all_rec_per_port[index].ownership)
422 continue; 418 continue;
423 comp_mask |= mlx4_ib_get_aguid_comp_mask_from_ix(i); 419 comp_mask |= mlx4_ib_get_aguid_comp_mask_from_ix(i);
424 } 420 }
@@ -526,6 +522,30 @@ out:
526 return err; 522 return err;
527} 523}
528 524
525static void mlx4_ib_guid_port_init(struct mlx4_ib_dev *dev, int port)
526{
527 int j, k, entry;
528 __be64 guid;
529
530 /*Check if the SM doesn't need to assign the GUIDs*/
531 for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
532 for (k = 0; k < NUM_ALIAS_GUID_IN_REC; k++) {
533 entry = j * NUM_ALIAS_GUID_IN_REC + k;
534 /* no request for the 0 entry (hw guid) */
535 if (!entry || entry > dev->dev->persist->num_vfs ||
536 !mlx4_is_slave_active(dev->dev, entry))
537 continue;
538 guid = mlx4_get_admin_guid(dev->dev, entry, port);
539 *(__be64 *)&dev->sriov.alias_guid.ports_guid[port - 1].
540 all_rec_per_port[j].all_recs
541 [GUID_REC_SIZE * k] = guid;
542 pr_debug("guid was set, entry=%d, val=0x%llx, port=%d\n",
543 entry,
544 be64_to_cpu(guid),
545 port);
546 }
547 }
548}
529void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port) 549void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port)
530{ 550{
531 int i; 551 int i;
@@ -535,6 +555,13 @@ void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port)
535 555
536 spin_lock_irqsave(&dev->sriov.going_down_lock, flags); 556 spin_lock_irqsave(&dev->sriov.going_down_lock, flags);
537 spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags1); 557 spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags1);
558
559 if (dev->sriov.alias_guid.ports_guid[port - 1].state_flags &
560 GUID_STATE_NEED_PORT_INIT) {
561 mlx4_ib_guid_port_init(dev, port);
562 dev->sriov.alias_guid.ports_guid[port - 1].state_flags &=
563 (~GUID_STATE_NEED_PORT_INIT);
564 }
538 for (i = 0; i < NUM_ALIAS_GUID_REC_IN_PORT; i++) 565 for (i = 0; i < NUM_ALIAS_GUID_REC_IN_PORT; i++)
539 invalidate_guid_record(dev, port, i); 566 invalidate_guid_record(dev, port, i);
540 567
@@ -657,33 +684,6 @@ out:
657 return ret; 684 return ret;
658} 685}
659 686
660static void set_administratively_guid_record(struct mlx4_ib_dev *dev, int port,
661 int rec_index,
662 struct mlx4_sriov_alias_guid_info_rec_det *rec_det)
663{
664 dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[rec_index].guid_indexes =
665 rec_det->guid_indexes;
666 memcpy(dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[rec_index].all_recs,
667 rec_det->all_recs, NUM_ALIAS_GUID_IN_REC * GUID_REC_SIZE);
668}
669
670static void set_all_slaves_guids(struct mlx4_ib_dev *dev, int port)
671{
672 int j;
673 struct mlx4_sriov_alias_guid_info_rec_det rec_det ;
674
675 for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT ; j++) {
676 memset(rec_det.all_recs, 0, NUM_ALIAS_GUID_IN_REC * GUID_REC_SIZE);
677 rec_det.guid_indexes = (!j ? 0 : IB_SA_GUIDINFO_REC_GID0) |
678 IB_SA_GUIDINFO_REC_GID1 | IB_SA_GUIDINFO_REC_GID2 |
679 IB_SA_GUIDINFO_REC_GID3 | IB_SA_GUIDINFO_REC_GID4 |
680 IB_SA_GUIDINFO_REC_GID5 | IB_SA_GUIDINFO_REC_GID6 |
681 IB_SA_GUIDINFO_REC_GID7;
682 rec_det.status = MLX4_GUID_INFO_STATUS_IDLE;
683 set_administratively_guid_record(dev, port, j, &rec_det);
684 }
685}
686
687static void alias_guid_work(struct work_struct *work) 687static void alias_guid_work(struct work_struct *work)
688{ 688{
689 struct delayed_work *delay = to_delayed_work(work); 689 struct delayed_work *delay = to_delayed_work(work);
@@ -779,7 +779,7 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
779{ 779{
780 char alias_wq_name[15]; 780 char alias_wq_name[15];
781 int ret = 0; 781 int ret = 0;
782 int i, j, k; 782 int i, j;
783 union ib_gid gid; 783 union ib_gid gid;
784 784
785 if (!mlx4_is_master(dev->dev)) 785 if (!mlx4_is_master(dev->dev))
@@ -803,33 +803,25 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
803 for (i = 0 ; i < dev->num_ports; i++) { 803 for (i = 0 ; i < dev->num_ports; i++) {
804 memset(&dev->sriov.alias_guid.ports_guid[i], 0, 804 memset(&dev->sriov.alias_guid.ports_guid[i], 0,
805 sizeof (struct mlx4_sriov_alias_guid_port_rec_det)); 805 sizeof (struct mlx4_sriov_alias_guid_port_rec_det));
806 /*Check if the SM doesn't need to assign the GUIDs*/ 806 dev->sriov.alias_guid.ports_guid[i].state_flags |=
807 GUID_STATE_NEED_PORT_INIT;
807 for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) { 808 for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
808 if (mlx4_ib_sm_guid_assign) { 809 /* mark each val as it was deleted */
809 dev->sriov.alias_guid.ports_guid[i]. 810 memset(dev->sriov.alias_guid.ports_guid[i].
810 all_rec_per_port[j]. 811 all_rec_per_port[j].all_recs, 0xFF,
811 ownership = MLX4_GUID_DRIVER_ASSIGN; 812 sizeof(dev->sriov.alias_guid.ports_guid[i].
812 continue; 813 all_rec_per_port[j].all_recs));
813 }
814 dev->sriov.alias_guid.ports_guid[i].all_rec_per_port[j].
815 ownership = MLX4_GUID_NONE_ASSIGN;
816 /*mark each val as it was deleted,
817 till the sysAdmin will give it valid val*/
818 for (k = 0; k < NUM_ALIAS_GUID_IN_REC; k++) {
819 *(__be64 *)&dev->sriov.alias_guid.ports_guid[i].
820 all_rec_per_port[j].all_recs[GUID_REC_SIZE * k] =
821 cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL);
822 }
823 } 814 }
824 INIT_LIST_HEAD(&dev->sriov.alias_guid.ports_guid[i].cb_list); 815 INIT_LIST_HEAD(&dev->sriov.alias_guid.ports_guid[i].cb_list);
825 /*prepare the records, set them to be allocated by sm*/ 816 /*prepare the records, set them to be allocated by sm*/
817 if (mlx4_ib_sm_guid_assign)
818 for (j = 1; j < NUM_ALIAS_GUID_PER_PORT; j++)
819 mlx4_set_admin_guid(dev->dev, 0, j, i + 1);
826 for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) 820 for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT; j++)
827 invalidate_guid_record(dev, i + 1, j); 821 invalidate_guid_record(dev, i + 1, j);
828 822
829 dev->sriov.alias_guid.ports_guid[i].parent = &dev->sriov.alias_guid; 823 dev->sriov.alias_guid.ports_guid[i].parent = &dev->sriov.alias_guid;
830 dev->sriov.alias_guid.ports_guid[i].port = i; 824 dev->sriov.alias_guid.ports_guid[i].port = i;
831 if (mlx4_ib_sm_guid_assign)
832 set_all_slaves_guids(dev, i);
833 825
834 snprintf(alias_wq_name, sizeof alias_wq_name, "alias_guid%d", i); 826 snprintf(alias_wq_name, sizeof alias_wq_name, "alias_guid%d", i);
835 dev->sriov.alias_guid.ports_guid[i].wq = 827 dev->sriov.alias_guid.ports_guid[i].wq =
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 1cfc2bb7acdf..532a8772b63f 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -344,11 +344,7 @@ enum mlx4_guid_alias_rec_status {
344 MLX4_GUID_INFO_STATUS_SET, 344 MLX4_GUID_INFO_STATUS_SET,
345}; 345};
346 346
347enum mlx4_guid_alias_rec_ownership { 347#define GUID_STATE_NEED_PORT_INIT 0x01
348 MLX4_GUID_DRIVER_ASSIGN,
349 MLX4_GUID_SYSADMIN_ASSIGN,
350 MLX4_GUID_NONE_ASSIGN, /*init state of each record*/
351};
352 348
353enum mlx4_guid_alias_rec_method { 349enum mlx4_guid_alias_rec_method {
354 MLX4_GUID_INFO_RECORD_SET = IB_MGMT_METHOD_SET, 350 MLX4_GUID_INFO_RECORD_SET = IB_MGMT_METHOD_SET,
@@ -359,7 +355,6 @@ struct mlx4_sriov_alias_guid_info_rec_det {
359 u8 all_recs[GUID_REC_SIZE * NUM_ALIAS_GUID_IN_REC]; 355 u8 all_recs[GUID_REC_SIZE * NUM_ALIAS_GUID_IN_REC];
360 ib_sa_comp_mask guid_indexes; /*indicates what from the 8 records are valid*/ 356 ib_sa_comp_mask guid_indexes; /*indicates what from the 8 records are valid*/
361 enum mlx4_guid_alias_rec_status status; /*indicates the administraively status of the record.*/ 357 enum mlx4_guid_alias_rec_status status; /*indicates the administraively status of the record.*/
362 enum mlx4_guid_alias_rec_ownership ownership; /*indicates who assign that alias_guid record*/
363 unsigned int guids_retry_schedule[NUM_ALIAS_GUID_IN_REC]; 358 unsigned int guids_retry_schedule[NUM_ALIAS_GUID_IN_REC];
364 u64 time_to_run; 359 u64 time_to_run;
365}; 360};
@@ -369,6 +364,7 @@ struct mlx4_sriov_alias_guid_port_rec_det {
369 struct workqueue_struct *wq; 364 struct workqueue_struct *wq;
370 struct delayed_work alias_guid_work; 365 struct delayed_work alias_guid_work;
371 u8 port; 366 u8 port;
367 u32 state_flags;
372 struct mlx4_sriov_alias_guid *parent; 368 struct mlx4_sriov_alias_guid *parent;
373 struct list_head cb_list; 369 struct list_head cb_list;
374}; 370};
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index bb1c34a4817e..6797108ce873 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -98,23 +98,6 @@ static ssize_t store_admin_alias_guid(struct device *dev,
98 mlx4_ib_iov_dentry->entry_num, 98 mlx4_ib_iov_dentry->entry_num,
99 port->num); 99 port->num);
100 100
101 switch (sysadmin_ag_val) {
102 case MLX4_GUID_FOR_DELETE_VAL:
103 mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
104 = MLX4_GUID_SYSADMIN_ASSIGN;
105 break;
106 /* The sysadmin requests the SM to re-assign */
107 case MLX4_NOT_SET_GUID:
108 mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
109 = MLX4_GUID_DRIVER_ASSIGN;
110 break;
111 /* The sysadmin requests a specific value.*/
112 default:
113 mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
114 = MLX4_GUID_SYSADMIN_ASSIGN;
115 break;
116 }
117
118 /* set the record index */ 101 /* set the record index */
119 mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].guid_indexes 102 mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].guid_indexes
120 |= mlx4_ib_get_aguid_comp_mask_from_ix(guid_index_in_rec); 103 |= mlx4_ib_get_aguid_comp_mask_from_ix(guid_index_in_rec);