Lines Matching +full:primary +full:- +full:bond
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
66 mutex_init(&table->mutex); in mlx4_init_mac_table()
68 table->entries[i] = 0; in mlx4_init_mac_table()
69 table->refs[i] = 0; in mlx4_init_mac_table()
70 table->is_dup[i] = false; in mlx4_init_mac_table()
72 table->max = 1 << dev->caps.log_num_macs; in mlx4_init_mac_table()
73 table->total = 0; in mlx4_init_mac_table()
80 mutex_init(&table->mutex); in mlx4_init_vlan_table()
82 table->entries[i] = 0; in mlx4_init_vlan_table()
83 table->refs[i] = 0; in mlx4_init_vlan_table()
84 table->is_dup[i] = false; in mlx4_init_vlan_table()
86 table->max = (1 << dev->caps.log_num_vlans) - MLX4_VLAN_REGULAR; in mlx4_init_vlan_table()
87 table->total = 0; in mlx4_init_vlan_table()
95 mutex_init(&table->mutex); in mlx4_init_roce_gid_table()
97 memset(table->roce_gids[i].raw, 0, MLX4_ROCE_GID_ENTRY_SIZE); in mlx4_init_roce_gid_table()
105 if (index < 0 || index >= table->max || !table->entries[index]) { in validate_index()
107 err = -EINVAL; in validate_index()
118 if (table->refs[i] && in find_index()
120 (MLX4_MAC_MASK & be64_to_cpu(table->entries[i]))) in find_index()
124 return -EINVAL; in find_index()
138 memcpy(mailbox->buf, entries, MLX4_MAC_TABLE_SIZE); in mlx4_set_port_mac_table()
142 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_set_port_mac_table()
152 struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; in mlx4_find_cached_mac()
153 struct mlx4_mac_table *table = &info->mac_table; in mlx4_find_cached_mac()
157 if (!table->refs[i]) in mlx4_find_cached_mac()
160 if (mac == (MLX4_MAC_MASK & be64_to_cpu(table->entries[i]))) { in mlx4_find_cached_mac()
166 return -ENOENT; in mlx4_find_cached_mac()
184 struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; in __mlx4_register_mac()
185 struct mlx4_mac_table *table = &info->mac_table; in __mlx4_register_mac()
187 int free = -1; in __mlx4_register_mac()
188 int free_for_dup = -1; in __mlx4_register_mac()
191 struct mlx4_mac_table *dup_table = &mlx4_priv(dev)->port[dup_port].mac_table; in __mlx4_register_mac()
201 mutex_lock(&table->mutex); in __mlx4_register_mac()
202 mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_register_mac()
204 mutex_lock(&dup_table->mutex); in __mlx4_register_mac()
205 mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_register_mac()
208 mutex_lock(&table->mutex); in __mlx4_register_mac()
212 int index_at_port = -1; in __mlx4_register_mac()
213 int index_at_dup_port = -1; in __mlx4_register_mac()
216 if (((MLX4_MAC_MASK & mac) == (MLX4_MAC_MASK & be64_to_cpu(table->entries[i])))) in __mlx4_register_mac()
218 if (((MLX4_MAC_MASK & mac) == (MLX4_MAC_MASK & be64_to_cpu(dup_table->entries[i])))) in __mlx4_register_mac()
228 /* If the mac is already in the primary table, the slot must be in __mlx4_register_mac()
232 dup_table->refs[index_at_port]) { in __mlx4_register_mac()
236 * corresponding index is not occupied in the primary table, or in __mlx4_register_mac()
237 * the primary table already contains the mac at the same index. in __mlx4_register_mac()
238 * Otherwise, you cannot bond (primary contains a different mac in __mlx4_register_mac()
242 if (!table->refs[index_at_dup_port] || in __mlx4_register_mac()
243 ((MLX4_MAC_MASK & mac) == (MLX4_MAC_MASK & be64_to_cpu(table->entries[index_at_dup_port])))) in __mlx4_register_mac()
251 if (!table->refs[i]) { in __mlx4_register_mac()
255 if (!dup_table->refs[i]) in __mlx4_register_mac()
262 (MLX4_MAC_MASK & be64_to_cpu(table->entries[i]))) { in __mlx4_register_mac()
265 ++table->refs[i]; in __mlx4_register_mac()
267 u64 dup_mac = MLX4_MAC_MASK & be64_to_cpu(dup_table->entries[i]); in __mlx4_register_mac()
269 if (dup_mac != mac || !dup_table->is_dup[i]) { in __mlx4_register_mac()
292 if (table->total == table->max) { in __mlx4_register_mac()
294 err = -ENOSPC; in __mlx4_register_mac()
299 table->entries[free] = cpu_to_be64(mac | MLX4_MAC_VALID); in __mlx4_register_mac()
301 err = mlx4_set_port_mac_table(dev, port, table->entries); in __mlx4_register_mac()
305 table->entries[free] = 0; in __mlx4_register_mac()
308 table->refs[free] = 1; in __mlx4_register_mac()
309 table->is_dup[free] = false; in __mlx4_register_mac()
310 ++table->total; in __mlx4_register_mac()
312 dup_table->refs[free] = 0; in __mlx4_register_mac()
313 dup_table->is_dup[free] = true; in __mlx4_register_mac()
314 dup_table->entries[free] = cpu_to_be64(mac | MLX4_MAC_VALID); in __mlx4_register_mac()
316 err = mlx4_set_port_mac_table(dev, dup_port, dup_table->entries); in __mlx4_register_mac()
319 dup_table->is_dup[free] = false; in __mlx4_register_mac()
320 dup_table->entries[free] = 0; in __mlx4_register_mac()
323 ++dup_table->total; in __mlx4_register_mac()
329 mutex_unlock(&table->mutex); in __mlx4_register_mac()
330 mutex_unlock(&dup_table->mutex); in __mlx4_register_mac()
332 mutex_unlock(&dup_table->mutex); in __mlx4_register_mac()
333 mutex_unlock(&table->mutex); in __mlx4_register_mac()
336 mutex_unlock(&table->mutex); in __mlx4_register_mac()
345 int err = -EINVAL; in mlx4_register_mac()
348 if (!(dev->flags & MLX4_FLAG_OLD_REG_MAC)) { in mlx4_register_mac()
354 if (err && err == -EINVAL && mlx4_is_slave(dev)) { in mlx4_register_mac()
361 dev->flags |= MLX4_FLAG_OLD_REG_MAC; in mlx4_register_mac()
374 return dev->caps.reserved_qps_base[MLX4_QP_REGION_ETH_ADDR] + in mlx4_get_base_qpn()
375 (port - 1) * (1 << dev->caps.log_num_macs); in mlx4_get_base_qpn()
386 struct mlx4_mac_table *dup_table = &mlx4_priv(dev)->port[dup_port].mac_table; in __mlx4_unregister_mac()
388 if (port < 1 || port > dev->caps.num_ports) { in __mlx4_unregister_mac()
392 info = &mlx4_priv(dev)->port[port]; in __mlx4_unregister_mac()
393 table = &info->mac_table; in __mlx4_unregister_mac()
397 mutex_lock(&table->mutex); in __mlx4_unregister_mac()
398 mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_unregister_mac()
400 mutex_lock(&dup_table->mutex); in __mlx4_unregister_mac()
401 mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_unregister_mac()
404 mutex_lock(&table->mutex); in __mlx4_unregister_mac()
412 if (--table->refs[index] || table->is_dup[index]) { in __mlx4_unregister_mac()
415 if (!table->refs[index]) in __mlx4_unregister_mac()
416 dup_table->is_dup[index] = false; in __mlx4_unregister_mac()
420 table->entries[index] = 0; in __mlx4_unregister_mac()
421 if (mlx4_set_port_mac_table(dev, port, table->entries)) in __mlx4_unregister_mac()
423 --table->total; in __mlx4_unregister_mac()
426 dup_table->is_dup[index] = false; in __mlx4_unregister_mac()
427 if (dup_table->refs[index]) in __mlx4_unregister_mac()
429 dup_table->entries[index] = 0; in __mlx4_unregister_mac()
430 if (mlx4_set_port_mac_table(dev, dup_port, dup_table->entries)) in __mlx4_unregister_mac()
433 --table->total; in __mlx4_unregister_mac()
438 mutex_unlock(&table->mutex); in __mlx4_unregister_mac()
439 mutex_unlock(&dup_table->mutex); in __mlx4_unregister_mac()
441 mutex_unlock(&dup_table->mutex); in __mlx4_unregister_mac()
442 mutex_unlock(&table->mutex); in __mlx4_unregister_mac()
445 mutex_unlock(&table->mutex); in __mlx4_unregister_mac()
455 if (!(dev->flags & MLX4_FLAG_OLD_REG_MAC)) { in mlx4_unregister_mac()
476 struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; in __mlx4_replace_mac()
477 struct mlx4_mac_table *table = &info->mac_table; in __mlx4_replace_mac()
478 int index = qpn - info->base_qpn; in __mlx4_replace_mac()
482 struct mlx4_mac_table *dup_table = &mlx4_priv(dev)->port[dup_port].mac_table; in __mlx4_replace_mac()
484 /* CX1 doesn't support multi-functions */ in __mlx4_replace_mac()
487 mutex_lock(&table->mutex); in __mlx4_replace_mac()
488 mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_replace_mac()
490 mutex_lock(&dup_table->mutex); in __mlx4_replace_mac()
491 mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_replace_mac()
494 mutex_lock(&table->mutex); in __mlx4_replace_mac()
501 table->entries[index] = cpu_to_be64(new_mac | MLX4_MAC_VALID); in __mlx4_replace_mac()
503 err = mlx4_set_port_mac_table(dev, port, table->entries); in __mlx4_replace_mac()
507 table->entries[index] = 0; in __mlx4_replace_mac()
510 dup_table->entries[index] = cpu_to_be64(new_mac | MLX4_MAC_VALID); in __mlx4_replace_mac()
512 err = mlx4_set_port_mac_table(dev, dup_port, dup_table->entries); in __mlx4_replace_mac()
516 dup_table->entries[index] = 0; in __mlx4_replace_mac()
523 mutex_unlock(&table->mutex); in __mlx4_replace_mac()
524 mutex_unlock(&dup_table->mutex); in __mlx4_replace_mac()
526 mutex_unlock(&dup_table->mutex); in __mlx4_replace_mac()
527 mutex_unlock(&table->mutex); in __mlx4_replace_mac()
530 mutex_unlock(&table->mutex); in __mlx4_replace_mac()
547 memcpy(mailbox->buf, entries, MLX4_VLAN_TABLE_SIZE); in mlx4_set_port_vlan_table()
549 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_set_port_vlan_table()
560 struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table; in mlx4_find_cached_vlan()
564 if (table->refs[i] && in mlx4_find_cached_vlan()
566 be32_to_cpu(table->entries[i])))) { in mlx4_find_cached_vlan()
573 return -ENOENT; in mlx4_find_cached_vlan()
580 struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table; in __mlx4_register_vlan()
582 int free = -1; in __mlx4_register_vlan()
583 int free_for_dup = -1; in __mlx4_register_vlan()
586 struct mlx4_vlan_table *dup_table = &mlx4_priv(dev)->port[dup_port].vlan_table; in __mlx4_register_vlan()
596 mutex_lock(&table->mutex); in __mlx4_register_vlan()
597 mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_register_vlan()
599 mutex_lock(&dup_table->mutex); in __mlx4_register_vlan()
600 mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_register_vlan()
603 mutex_lock(&table->mutex); in __mlx4_register_vlan()
606 if (table->total == table->max) { in __mlx4_register_vlan()
608 err = -ENOSPC; in __mlx4_register_vlan()
613 int index_at_port = -1; in __mlx4_register_vlan()
614 int index_at_dup_port = -1; in __mlx4_register_vlan()
617 if (vlan == (MLX4_VLAN_MASK & be32_to_cpu(table->entries[i]))) in __mlx4_register_vlan()
619 if (vlan == (MLX4_VLAN_MASK & be32_to_cpu(dup_table->entries[i]))) in __mlx4_register_vlan()
628 /* If the vlan is already in the primary table, the slot must be in __mlx4_register_vlan()
632 dup_table->refs[index_at_port]) { in __mlx4_register_vlan()
636 * corresponding index is not occupied in the primary table, or in __mlx4_register_vlan()
637 * the primary table already contains the vlan at the same index. in __mlx4_register_vlan()
638 * Otherwise, you cannot bond (primary contains a different vlan in __mlx4_register_vlan()
642 if (!table->refs[index_at_dup_port] || in __mlx4_register_vlan()
643 (vlan == (MLX4_VLAN_MASK & be32_to_cpu(dup_table->entries[index_at_dup_port])))) in __mlx4_register_vlan()
651 if (!table->refs[i]) { in __mlx4_register_vlan()
655 if (!dup_table->refs[i]) in __mlx4_register_vlan()
660 if ((table->refs[i] || table->is_dup[i]) && in __mlx4_register_vlan()
662 be32_to_cpu(table->entries[i])))) { in __mlx4_register_vlan()
666 ++table->refs[i]; in __mlx4_register_vlan()
668 u16 dup_vlan = MLX4_VLAN_MASK & be32_to_cpu(dup_table->entries[i]); in __mlx4_register_vlan()
670 if (dup_vlan != vlan || !dup_table->is_dup[i]) { in __mlx4_register_vlan()
692 err = -ENOMEM; in __mlx4_register_vlan()
697 table->refs[free] = 1; in __mlx4_register_vlan()
698 table->is_dup[free] = false; in __mlx4_register_vlan()
699 table->entries[free] = cpu_to_be32(vlan | MLX4_VLAN_VALID); in __mlx4_register_vlan()
701 err = mlx4_set_port_vlan_table(dev, port, table->entries); in __mlx4_register_vlan()
704 table->refs[free] = 0; in __mlx4_register_vlan()
705 table->entries[free] = 0; in __mlx4_register_vlan()
708 ++table->total; in __mlx4_register_vlan()
710 dup_table->refs[free] = 0; in __mlx4_register_vlan()
711 dup_table->is_dup[free] = true; in __mlx4_register_vlan()
712 dup_table->entries[free] = cpu_to_be32(vlan | MLX4_VLAN_VALID); in __mlx4_register_vlan()
714 err = mlx4_set_port_vlan_table(dev, dup_port, dup_table->entries); in __mlx4_register_vlan()
717 dup_table->is_dup[free] = false; in __mlx4_register_vlan()
718 dup_table->entries[free] = 0; in __mlx4_register_vlan()
721 ++dup_table->total; in __mlx4_register_vlan()
728 mutex_unlock(&table->mutex); in __mlx4_register_vlan()
729 mutex_unlock(&dup_table->mutex); in __mlx4_register_vlan()
731 mutex_unlock(&dup_table->mutex); in __mlx4_register_vlan()
732 mutex_unlock(&table->mutex); in __mlx4_register_vlan()
735 mutex_unlock(&table->mutex); in __mlx4_register_vlan()
746 return -EINVAL; in mlx4_register_vlan()
764 struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table; in __mlx4_unregister_vlan()
768 struct mlx4_vlan_table *dup_table = &mlx4_priv(dev)->port[dup_port].vlan_table; in __mlx4_unregister_vlan()
772 mutex_lock(&table->mutex); in __mlx4_unregister_vlan()
773 mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_unregister_vlan()
775 mutex_lock(&dup_table->mutex); in __mlx4_unregister_vlan()
776 mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING); in __mlx4_unregister_vlan()
779 mutex_lock(&table->mutex); in __mlx4_unregister_vlan()
792 if (--table->refs[index] || table->is_dup[index]) { in __mlx4_unregister_vlan()
794 table->refs[index], index); in __mlx4_unregister_vlan()
795 if (!table->refs[index]) in __mlx4_unregister_vlan()
796 dup_table->is_dup[index] = false; in __mlx4_unregister_vlan()
799 table->entries[index] = 0; in __mlx4_unregister_vlan()
800 if (mlx4_set_port_vlan_table(dev, port, table->entries)) in __mlx4_unregister_vlan()
802 --table->total; in __mlx4_unregister_vlan()
804 dup_table->is_dup[index] = false; in __mlx4_unregister_vlan()
805 if (dup_table->refs[index]) in __mlx4_unregister_vlan()
807 dup_table->entries[index] = 0; in __mlx4_unregister_vlan()
808 if (mlx4_set_port_vlan_table(dev, dup_port, dup_table->entries)) in __mlx4_unregister_vlan()
810 --dup_table->total; in __mlx4_unregister_vlan()
815 mutex_unlock(&table->mutex); in __mlx4_unregister_vlan()
816 mutex_unlock(&dup_table->mutex); in __mlx4_unregister_vlan()
818 mutex_unlock(&dup_table->mutex); in __mlx4_unregister_vlan()
819 mutex_unlock(&table->mutex); in __mlx4_unregister_vlan()
822 mutex_unlock(&table->mutex); in __mlx4_unregister_vlan()
844 struct mlx4_mac_table *t1 = &mlx4_priv(dev)->port[1].mac_table; in mlx4_bond_mac_table()
845 struct mlx4_mac_table *t2 = &mlx4_priv(dev)->port[2].mac_table; in mlx4_bond_mac_table()
851 mutex_lock(&t1->mutex); in mlx4_bond_mac_table()
852 mutex_lock(&t2->mutex); in mlx4_bond_mac_table()
854 if ((t1->entries[i] != t2->entries[i]) && in mlx4_bond_mac_table()
855 t1->entries[i] && t2->entries[i]) { in mlx4_bond_mac_table()
857 ret = -EINVAL; in mlx4_bond_mac_table()
863 if (t1->entries[i] && !t2->entries[i]) { in mlx4_bond_mac_table()
864 t2->entries[i] = t1->entries[i]; in mlx4_bond_mac_table()
865 t2->is_dup[i] = true; in mlx4_bond_mac_table()
867 } else if (!t1->entries[i] && t2->entries[i]) { in mlx4_bond_mac_table()
868 t1->entries[i] = t2->entries[i]; in mlx4_bond_mac_table()
869 t1->is_dup[i] = true; in mlx4_bond_mac_table()
871 } else if (t1->entries[i] && t2->entries[i]) { in mlx4_bond_mac_table()
872 t1->is_dup[i] = true; in mlx4_bond_mac_table()
873 t2->is_dup[i] = true; in mlx4_bond_mac_table()
878 ret = mlx4_set_port_mac_table(dev, 1, t1->entries); in mlx4_bond_mac_table()
883 ret = mlx4_set_port_mac_table(dev, 2, t2->entries); in mlx4_bond_mac_table()
891 mutex_unlock(&t2->mutex); in mlx4_bond_mac_table()
892 mutex_unlock(&t1->mutex); in mlx4_bond_mac_table()
898 struct mlx4_mac_table *t1 = &mlx4_priv(dev)->port[1].mac_table; in mlx4_unbond_mac_table()
899 struct mlx4_mac_table *t2 = &mlx4_priv(dev)->port[2].mac_table; in mlx4_unbond_mac_table()
906 mutex_lock(&t1->mutex); in mlx4_unbond_mac_table()
907 mutex_lock(&t2->mutex); in mlx4_unbond_mac_table()
909 if (t1->entries[i] != t2->entries[i]) { in mlx4_unbond_mac_table()
911 ret = -EINVAL; in mlx4_unbond_mac_table()
917 if (!t1->entries[i]) in mlx4_unbond_mac_table()
919 t1->is_dup[i] = false; in mlx4_unbond_mac_table()
920 if (!t1->refs[i]) { in mlx4_unbond_mac_table()
921 t1->entries[i] = 0; in mlx4_unbond_mac_table()
924 t2->is_dup[i] = false; in mlx4_unbond_mac_table()
925 if (!t2->refs[i]) { in mlx4_unbond_mac_table()
926 t2->entries[i] = 0; in mlx4_unbond_mac_table()
932 ret = mlx4_set_port_mac_table(dev, 1, t1->entries); in mlx4_unbond_mac_table()
937 ret1 = mlx4_set_port_mac_table(dev, 2, t2->entries); in mlx4_unbond_mac_table()
944 mutex_unlock(&t2->mutex); in mlx4_unbond_mac_table()
945 mutex_unlock(&t1->mutex); in mlx4_unbond_mac_table()
951 struct mlx4_vlan_table *t1 = &mlx4_priv(dev)->port[1].vlan_table; in mlx4_bond_vlan_table()
952 struct mlx4_vlan_table *t2 = &mlx4_priv(dev)->port[2].vlan_table; in mlx4_bond_vlan_table()
958 mutex_lock(&t1->mutex); in mlx4_bond_vlan_table()
959 mutex_lock(&t2->mutex); in mlx4_bond_vlan_table()
961 if ((t1->entries[i] != t2->entries[i]) && in mlx4_bond_vlan_table()
962 t1->entries[i] && t2->entries[i]) { in mlx4_bond_vlan_table()
964 ret = -EINVAL; in mlx4_bond_vlan_table()
970 if (t1->entries[i] && !t2->entries[i]) { in mlx4_bond_vlan_table()
971 t2->entries[i] = t1->entries[i]; in mlx4_bond_vlan_table()
972 t2->is_dup[i] = true; in mlx4_bond_vlan_table()
974 } else if (!t1->entries[i] && t2->entries[i]) { in mlx4_bond_vlan_table()
975 t1->entries[i] = t2->entries[i]; in mlx4_bond_vlan_table()
976 t1->is_dup[i] = true; in mlx4_bond_vlan_table()
978 } else if (t1->entries[i] && t2->entries[i]) { in mlx4_bond_vlan_table()
979 t1->is_dup[i] = true; in mlx4_bond_vlan_table()
980 t2->is_dup[i] = true; in mlx4_bond_vlan_table()
985 ret = mlx4_set_port_vlan_table(dev, 1, t1->entries); in mlx4_bond_vlan_table()
990 ret = mlx4_set_port_vlan_table(dev, 2, t2->entries); in mlx4_bond_vlan_table()
998 mutex_unlock(&t2->mutex); in mlx4_bond_vlan_table()
999 mutex_unlock(&t1->mutex); in mlx4_bond_vlan_table()
1005 struct mlx4_vlan_table *t1 = &mlx4_priv(dev)->port[1].vlan_table; in mlx4_unbond_vlan_table()
1006 struct mlx4_vlan_table *t2 = &mlx4_priv(dev)->port[2].vlan_table; in mlx4_unbond_vlan_table()
1013 mutex_lock(&t1->mutex); in mlx4_unbond_vlan_table()
1014 mutex_lock(&t2->mutex); in mlx4_unbond_vlan_table()
1016 if (t1->entries[i] != t2->entries[i]) { in mlx4_unbond_vlan_table()
1018 ret = -EINVAL; in mlx4_unbond_vlan_table()
1024 if (!t1->entries[i]) in mlx4_unbond_vlan_table()
1026 t1->is_dup[i] = false; in mlx4_unbond_vlan_table()
1027 if (!t1->refs[i]) { in mlx4_unbond_vlan_table()
1028 t1->entries[i] = 0; in mlx4_unbond_vlan_table()
1031 t2->is_dup[i] = false; in mlx4_unbond_vlan_table()
1032 if (!t2->refs[i]) { in mlx4_unbond_vlan_table()
1033 t2->entries[i] = 0; in mlx4_unbond_vlan_table()
1039 ret = mlx4_set_port_vlan_table(dev, 1, t1->entries); in mlx4_unbond_vlan_table()
1044 ret1 = mlx4_set_port_vlan_table(dev, 2, t2->entries); in mlx4_unbond_vlan_table()
1051 mutex_unlock(&t2->mutex); in mlx4_unbond_vlan_table()
1052 mutex_unlock(&t1->mutex); in mlx4_unbond_vlan_table()
1072 inbuf = inmailbox->buf; in mlx4_get_port_ib_caps()
1073 outbuf = outmailbox->buf; in mlx4_get_port_ib_caps()
1081 err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3, in mlx4_get_port_ib_caps()
1107 max_port_p_one = find_first_bit(actv_ports.ports, dev->caps.num_ports) + in mlx4_get_slave_num_gids()
1108 bitmap_weight(actv_ports.ports, dev->caps.num_ports) + 1; in mlx4_get_slave_num_gids()
1113 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); in mlx4_get_slave_num_gids()
1114 set_bit(i - 1, exclusive_ports.ports); in mlx4_get_slave_num_gids()
1119 slave_gid -= bitmap_weight(slaves_pport_actv.slaves, in mlx4_get_slave_num_gids()
1120 dev->persist->num_vfs + 1); in mlx4_get_slave_num_gids()
1122 vfs = bitmap_weight(slaves_pport.slaves, dev->persist->num_vfs + 1) - 1; in mlx4_get_slave_num_gids()
1123 if (slave_gid <= ((MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS) % vfs)) in mlx4_get_slave_num_gids()
1124 return ((MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS) / vfs) + 1; in mlx4_get_slave_num_gids()
1125 return (MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS) / vfs; in mlx4_get_slave_num_gids()
1144 max_port_p_one = find_first_bit(actv_ports.ports, dev->caps.num_ports) + in mlx4_get_base_gid_ix()
1145 bitmap_weight(actv_ports.ports, dev->caps.num_ports) + 1; in mlx4_get_base_gid_ix()
1150 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); in mlx4_get_base_gid_ix()
1151 set_bit(i - 1, exclusive_ports.ports); in mlx4_get_base_gid_ix()
1156 slave_gid -= bitmap_weight(slaves_pport_actv.slaves, in mlx4_get_base_gid_ix()
1157 dev->persist->num_vfs + 1); in mlx4_get_base_gid_ix()
1159 gids = MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS; in mlx4_get_base_gid_ix()
1160 vfs = bitmap_weight(slaves_pport.slaves, dev->persist->num_vfs + 1) - 1; in mlx4_get_base_gid_ix()
1162 return MLX4_ROCE_PF_GIDS + ((gids / vfs) + 1) * (slave_gid - 1); in mlx4_get_base_gid_ix()
1165 ((gids / vfs) * (slave_gid - 1)); in mlx4_get_base_gid_ix()
1180 memset(mailbox->buf, 0, MLX4_MAILBOX_SIZE); in mlx4_reset_roce_port_gids()
1182 mutex_lock(&(priv->port[port].gid_table.mutex)); in mlx4_reset_roce_port_gids()
1183 /* Zero-out gids belonging to that slave in the port GID table */ in mlx4_reset_roce_port_gids()
1185 memcpy(priv->port[port].gid_table.roce_gids[offset].raw, in mlx4_reset_roce_port_gids()
1189 gid_entry_mbox = (struct mlx4_roce_gid_entry *)mailbox->buf; in mlx4_reset_roce_port_gids()
1191 memcpy(gid_entry_mbox->raw, in mlx4_reset_roce_port_gids()
1192 priv->port[port].gid_table.roce_gids[i].raw, in mlx4_reset_roce_port_gids()
1195 err = mlx4_cmd(dev, mailbox->dma, in mlx4_reset_roce_port_gids()
1199 mutex_unlock(&(priv->port[port].gid_table.mutex)); in mlx4_reset_roce_port_gids()
1211 if (slave < 0 || slave > dev->persist->num_vfs) in mlx4_reset_roce_gids()
1216 for (i = 0, num_eth_ports = 0; i < dev->caps.num_ports; i++) { in mlx4_reset_roce_gids()
1218 if (dev->caps.port_type[i + 1] != MLX4_PORT_TYPE_ETH) in mlx4_reset_roce_gids()
1232 for (i = 0; i < dev->caps.num_ports; i++) { in mlx4_reset_roce_gids()
1234 if (dev->caps.port_type[i + 1] != MLX4_PORT_TYPE_ETH) in mlx4_reset_roce_gids()
1252 struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master; in mlx4_en_set_port_mtu()
1253 struct mlx4_slave_state *slave_st = &master->slave_state[slave]; in mlx4_en_set_port_mtu()
1259 mtu = be16_to_cpu(gen_context->mtu); in mlx4_en_set_port_mtu()
1260 mtu = min_t(int, mtu, dev->caps.eth_mtu_cap[port] + in mlx4_en_set_port_mtu()
1262 prev_mtu = slave_st->mtu[port]; in mlx4_en_set_port_mtu()
1263 slave_st->mtu[port] = mtu; in mlx4_en_set_port_mtu()
1264 if (mtu > master->max_mtu[port]) in mlx4_en_set_port_mtu()
1265 master->max_mtu[port] = mtu; in mlx4_en_set_port_mtu()
1266 if (mtu < prev_mtu && prev_mtu == master->max_mtu[port]) { in mlx4_en_set_port_mtu()
1269 slave_st->mtu[port] = mtu; in mlx4_en_set_port_mtu()
1270 master->max_mtu[port] = mtu; in mlx4_en_set_port_mtu()
1271 for (i = 0; i < dev->num_slaves; i++) in mlx4_en_set_port_mtu()
1272 master->max_mtu[port] = in mlx4_en_set_port_mtu()
1273 max_t(u16, master->max_mtu[port], in mlx4_en_set_port_mtu()
1274 master->slave_state[i].mtu[port]); in mlx4_en_set_port_mtu()
1276 gen_context->mtu = cpu_to_be16(master->max_mtu[port]); in mlx4_en_set_port_mtu()
1284 struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master; in mlx4_en_set_port_user_mtu()
1285 struct mlx4_slave_state *slave_st = &master->slave_state[slave]; in mlx4_en_set_port_user_mtu()
1291 user_mtu = be16_to_cpu(gen_context->user_mtu); in mlx4_en_set_port_user_mtu()
1292 user_mtu = min_t(int, user_mtu, dev->caps.eth_mtu_cap[port]); in mlx4_en_set_port_user_mtu()
1293 prev_user_mtu = slave_st->user_mtu[port]; in mlx4_en_set_port_user_mtu()
1294 slave_st->user_mtu[port] = user_mtu; in mlx4_en_set_port_user_mtu()
1295 if (user_mtu > master->max_user_mtu[port]) in mlx4_en_set_port_user_mtu()
1296 master->max_user_mtu[port] = user_mtu; in mlx4_en_set_port_user_mtu()
1298 prev_user_mtu == master->max_user_mtu[port]) { in mlx4_en_set_port_user_mtu()
1301 slave_st->user_mtu[port] = user_mtu; in mlx4_en_set_port_user_mtu()
1302 master->max_user_mtu[port] = user_mtu; in mlx4_en_set_port_user_mtu()
1303 for (i = 0; i < dev->num_slaves; i++) in mlx4_en_set_port_user_mtu()
1304 master->max_user_mtu[port] = in mlx4_en_set_port_user_mtu()
1305 max_t(u16, master->max_user_mtu[port], in mlx4_en_set_port_user_mtu()
1306 master->slave_state[i].user_mtu[port]); in mlx4_en_set_port_user_mtu()
1308 gen_context->user_mtu = cpu_to_be16(master->max_user_mtu[port]); in mlx4_en_set_port_user_mtu()
1316 struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master; in mlx4_en_set_port_global_pause()
1320 (gen_context->pptx != master->pptx || in mlx4_en_set_port_global_pause()
1321 gen_context->pprx != master->pprx)) { in mlx4_en_set_port_global_pause()
1322 gen_context->pptx = master->pptx; in mlx4_en_set_port_global_pause()
1323 gen_context->pprx = master->pprx; in mlx4_en_set_port_global_pause()
1327 master->pptx = gen_context->pptx; in mlx4_en_set_port_global_pause()
1328 master->pprx = gen_context->pprx; in mlx4_en_set_port_global_pause()
1357 port_info = &priv->port[port]; in mlx4_common_set_port()
1363 if (slave != dev->caps.function && in mlx4_common_set_port()
1368 return -EINVAL; in mlx4_common_set_port()
1372 qpn_context = inbox->buf; in mlx4_common_set_port()
1373 qpn_context->base_qpn = in mlx4_common_set_port()
1374 cpu_to_be32(port_info->base_qpn); in mlx4_common_set_port()
1375 qpn_context->n_mac = 0x7; in mlx4_common_set_port()
1376 promisc = be32_to_cpu(qpn_context->promisc) >> in mlx4_common_set_port()
1378 qpn_context->promisc = cpu_to_be32( in mlx4_common_set_port()
1380 port_info->base_qpn); in mlx4_common_set_port()
1381 promisc = be32_to_cpu(qpn_context->mcast) >> in mlx4_common_set_port()
1383 qpn_context->mcast = cpu_to_be32( in mlx4_common_set_port()
1385 port_info->base_qpn); in mlx4_common_set_port()
1388 gen_context = inbox->buf; in mlx4_common_set_port()
1390 if (gen_context->flags & MLX4_FLAG_V_MTU_MASK) in mlx4_common_set_port()
1394 if (gen_context->flags2 & MLX4_FLAG2_V_USER_MTU_MASK) in mlx4_common_set_port()
1398 if (gen_context->flags & in mlx4_common_set_port()
1406 * need a FOR-loop here over number of gids the guest has. in mlx4_common_set_port()
1411 gid_entry_mbox = (struct mlx4_roce_gid_entry *)(inbox->buf); in mlx4_common_set_port()
1413 if (!memcmp(gid_entry_mbox->raw, zgid_entry.raw, in mlx4_common_set_port()
1418 if (!memcmp(gid_entry_mb1->raw, in mlx4_common_set_port()
1421 if (!memcmp(gid_entry_mb1->raw, gid_entry_mbox->raw, in mlx4_common_set_port()
1422 sizeof(gid_entry_mbox->raw))) { in mlx4_common_set_port()
1424 return -EINVAL; in mlx4_common_set_port()
1433 mutex_lock(&(priv->port[port].gid_table.mutex)); in mlx4_common_set_port()
1437 gid_entry_tbl = &priv->port[port].gid_table.roce_gids[i]; in mlx4_common_set_port()
1438 if (!memcmp(gid_entry_tbl->raw, zgid_entry.raw, sizeof(zgid_entry))) in mlx4_common_set_port()
1440 gid_entry_mbox = (struct mlx4_roce_gid_entry *)(inbox->buf); in mlx4_common_set_port()
1442 if (!memcmp(gid_entry_mbox->raw, zgid_entry.raw, in mlx4_common_set_port()
1445 if (!memcmp(gid_entry_mbox->raw, gid_entry_tbl->raw, in mlx4_common_set_port()
1446 sizeof(gid_entry_tbl->raw))) { in mlx4_common_set_port()
1450 mutex_unlock(&(priv->port[port].gid_table.mutex)); in mlx4_common_set_port()
1451 return -EINVAL; in mlx4_common_set_port()
1457 gid_entry_mbox = (struct mlx4_roce_gid_entry *)(inbox->buf); in mlx4_common_set_port()
1459 memcpy(priv->port[port].gid_table.roce_gids[offset].raw, in mlx4_common_set_port()
1460 gid_entry_mbox->raw, MLX4_ROCE_GID_ENTRY_SIZE); in mlx4_common_set_port()
1463 gid_entry_mbox = (struct mlx4_roce_gid_entry *)(inbox->buf); in mlx4_common_set_port()
1465 memcpy(gid_entry_mbox->raw, in mlx4_common_set_port()
1466 priv->port[port].gid_table.roce_gids[i].raw, in mlx4_common_set_port()
1469 err = mlx4_cmd(dev, inbox->dma, in_mod & 0xffff, op_mod, in mlx4_common_set_port()
1472 mutex_unlock(&(priv->port[port].gid_table.mutex)); in mlx4_common_set_port()
1476 return mlx4_cmd(dev, inbox->dma, in_mod & 0xffff, op_mod, in mlx4_common_set_port()
1484 return -EPERM; in mlx4_common_set_port()
1488 * - The capability mask, which is set to the aggregate of all in mlx4_common_set_port()
1490 * - The QKey violatin counter - reset according to each request. in mlx4_common_set_port()
1493 if (dev->flags & MLX4_FLAG_OLD_PORT_CMDS) { in mlx4_common_set_port()
1494 reset_qkey_viols = (*(u8 *) inbox->buf) & 0x40; in mlx4_common_set_port()
1495 new_cap_mask = ((__be32 *) inbox->buf)[2]; in mlx4_common_set_port()
1497 reset_qkey_viols = ((u8 *) inbox->buf)[3] & 0x1; in mlx4_common_set_port()
1498 new_cap_mask = ((__be32 *) inbox->buf)[1]; in mlx4_common_set_port()
1504 return -EINVAL; in mlx4_common_set_port()
1509 return -EINVAL; in mlx4_common_set_port()
1513 priv->mfunc.master.slave_state[slave].ib_cap_mask[port]; in mlx4_common_set_port()
1514 priv->mfunc.master.slave_state[slave].ib_cap_mask[port] = new_cap_mask; in mlx4_common_set_port()
1515 for (i = 0; i < dev->num_slaves; i++) in mlx4_common_set_port()
1517 priv->mfunc.master.slave_state[i].ib_cap_mask[port]; in mlx4_common_set_port()
1522 if (slave != dev->caps.function) in mlx4_common_set_port()
1523 memset(inbox->buf, 0, 256); in mlx4_common_set_port()
1524 if (dev->flags & MLX4_FLAG_OLD_PORT_CMDS) { in mlx4_common_set_port()
1525 *(u8 *) inbox->buf |= !!reset_qkey_viols << 6; in mlx4_common_set_port()
1526 ((__be32 *) inbox->buf)[2] = agg_cap_mask; in mlx4_common_set_port()
1528 ((u8 *) inbox->buf)[3] |= !!reset_qkey_viols; in mlx4_common_set_port()
1529 ((__be32 *) inbox->buf)[1] = agg_cap_mask; in mlx4_common_set_port()
1532 err = mlx4_cmd(dev, inbox->dma, port, is_eth, MLX4_CMD_SET_PORT, in mlx4_common_set_port()
1535 priv->mfunc.master.slave_state[slave].ib_cap_mask[port] = in mlx4_common_set_port()
1547 dev, slave, vhcr->in_modifier & 0xFF); in mlx4_SET_PORT_wrapper()
1550 return -EINVAL; in mlx4_SET_PORT_wrapper()
1552 vhcr->in_modifier = (vhcr->in_modifier & ~0xFF) | in mlx4_SET_PORT_wrapper()
1555 return mlx4_common_set_port(dev, slave, vhcr->in_modifier, in mlx4_SET_PORT_wrapper()
1556 vhcr->op_modifier, inbox); in mlx4_SET_PORT_wrapper()
1573 if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH) in mlx4_SET_PORT()
1580 ((__be32 *) mailbox->buf)[1] = dev->caps.ib_port_def_cap[port]; in mlx4_SET_PORT()
1584 ((__be16 *) mailbox->buf)[20] = cpu_to_be16(pkey_tbl_sz); in mlx4_SET_PORT()
1589 ((__be32 *) mailbox->buf)[0] = cpu_to_be32( in mlx4_SET_PORT()
1593 (dev->caps.port_ib_mtu[port] << MLX4_SET_PORT_MTU_CAP) | in mlx4_SET_PORT()
1595 err = mlx4_cmd(dev, mailbox->dma, port, in mlx4_SET_PORT()
1598 if (err != -ENOMEM) in mlx4_SET_PORT()
1619 context = mailbox->buf; in mlx4_SET_PORT_general()
1620 context->flags = SET_PORT_GEN_ALL_VALID; in mlx4_SET_PORT_general()
1621 context->mtu = cpu_to_be16(mtu); in mlx4_SET_PORT_general()
1622 context->pptx = (pptx * (!pfctx)) << 7; in mlx4_SET_PORT_general()
1623 context->pfctx = pfctx; in mlx4_SET_PORT_general()
1624 context->pprx = (pprx * (!pfcrx)) << 7; in mlx4_SET_PORT_general()
1625 context->pfcrx = pfcrx; in mlx4_SET_PORT_general()
1627 if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) { in mlx4_SET_PORT_general()
1628 context->flags |= SET_PORT_ROCE_2_FLAGS; in mlx4_SET_PORT_general()
1629 context->roce_mode |= in mlx4_SET_PORT_general()
1633 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_SET_PORT_general()
1649 u32 m_promisc = (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) ? in mlx4_SET_PORT_qpn_calc()
1652 if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) in mlx4_SET_PORT_qpn_calc()
1658 context = mailbox->buf; in mlx4_SET_PORT_qpn_calc()
1659 context->base_qpn = cpu_to_be32(base_qpn); in mlx4_SET_PORT_qpn_calc()
1660 context->n_mac = dev->caps.log_num_macs; in mlx4_SET_PORT_qpn_calc()
1661 context->promisc = cpu_to_be32(promisc << SET_PORT_PROMISC_SHIFT | in mlx4_SET_PORT_qpn_calc()
1663 context->mcast = cpu_to_be32(m_promisc << SET_PORT_MC_PROMISC_SHIFT | in mlx4_SET_PORT_qpn_calc()
1665 context->intra_no_vlan = 0; in mlx4_SET_PORT_qpn_calc()
1666 context->no_vlan = MLX4_NO_VLAN_IDX; in mlx4_SET_PORT_qpn_calc()
1667 context->intra_vlan_miss = 0; in mlx4_SET_PORT_qpn_calc()
1668 context->vlan_miss = MLX4_VLAN_MISS_IDX; in mlx4_SET_PORT_qpn_calc()
1671 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_SET_PORT_qpn_calc()
1690 context = mailbox->buf; in mlx4_SET_PORT_user_mtu()
1691 context->flags2 |= MLX4_FLAG2_V_USER_MTU_MASK; in mlx4_SET_PORT_user_mtu()
1692 context->user_mtu = cpu_to_be16(user_mtu); in mlx4_SET_PORT_user_mtu()
1695 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_SET_PORT_user_mtu()
1714 context = mailbox->buf; in mlx4_SET_PORT_user_mac()
1715 context->flags2 |= MLX4_FLAG2_V_USER_MAC_MASK; in mlx4_SET_PORT_user_mac()
1716 memcpy(context->user_mac, user_mac, sizeof(context->user_mac)); in mlx4_SET_PORT_user_mac()
1719 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_SET_PORT_user_mac()
1738 context = mailbox->buf; in mlx4_SET_PORT_fcs_check()
1739 context->flags2 |= MLX4_FLAG2_V_IGNORE_FCS_MASK; in mlx4_SET_PORT_fcs_check()
1741 context->ignore_fcs |= MLX4_IGNORE_FCS_MASK; in mlx4_SET_PORT_fcs_check()
1743 context->ignore_fcs &= ~MLX4_IGNORE_FCS_MASK; in mlx4_SET_PORT_fcs_check()
1746 err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT, in mlx4_SET_PORT_fcs_check()
1779 context = mailbox->buf; in mlx4_SET_PORT_VXLAN()
1782 context->modify_flags = VXLAN_ENABLE_MODIFY | VXLAN_STEERING_MODIFY; in mlx4_SET_PORT_VXLAN()
1784 context->enable_flags = VXLAN_ENABLE; in mlx4_SET_PORT_VXLAN()
1785 context->steering = steering; in mlx4_SET_PORT_VXLAN()
1788 err = mlx4_cmd(dev, mailbox->dma, in_mod, MLX4_SET_PORT_ETH_OPCODE, in mlx4_SET_PORT_VXLAN()
1806 *((__be32 *)mailbox->buf) = cpu_to_be32(time); in mlx4_SET_PORT_BEACON()
1808 err = mlx4_cmd(dev, mailbox->dma, port, MLX4_SET_PORT_BEACON_OPCODE, in mlx4_SET_PORT_BEACON()
1861 int i, found_ix = -1; in mlx4_get_slave_from_roce_gid()
1862 int vf_gids = MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS; in mlx4_get_slave_from_roce_gid()
1868 return -EINVAL; in mlx4_get_slave_from_roce_gid()
1872 dev->persist->num_vfs + 1) - 1; in mlx4_get_slave_from_roce_gid()
1875 if (!memcmp(priv->port[port].gid_table.roce_gids[i].raw, gid, in mlx4_get_slave_from_roce_gid()
1890 slave_gid = ((found_ix - MLX4_ROCE_PF_GIDS) / in mlx4_get_slave_from_roce_gid()
1894 ((found_ix - MLX4_ROCE_PF_GIDS - in mlx4_get_slave_from_roce_gid()
1909 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); in mlx4_get_slave_from_roce_gid()
1910 set_bit(i - 1, exclusive_ports.ports); in mlx4_get_slave_from_roce_gid()
1916 dev->persist->num_vfs + 1); in mlx4_get_slave_from_roce_gid()
1930 actv_ports.ports, dev->caps.num_ports) + in mlx4_get_slave_from_roce_gid()
1932 dev->caps.num_ports) + 1; in mlx4_get_slave_from_roce_gid()
1939 dev->caps.num_ports); in mlx4_get_slave_from_roce_gid()
1940 set_bit(i - 1, exclusive_ports.ports); in mlx4_get_slave_from_roce_gid()
1946 dev->persist->num_vfs + 1); in mlx4_get_slave_from_roce_gid()
1952 return (found_ix >= 0) ? 0 : -EINVAL; in mlx4_get_slave_from_roce_gid()
1962 return -EINVAL; in mlx4_get_roce_gid_from_slave()
1964 memcpy(gid, priv->port[port].gid_table.roce_gids[slave_id].raw, in mlx4_get_roce_gid_from_slave()
2047 inmad = (struct mlx4_mad_ifc *)(inbox->buf); in mlx4_get_module_id()
2048 outmad = (struct mlx4_mad_ifc *)(outbox->buf); in mlx4_get_module_id()
2050 inmad->method = 0x1; /* Get */ in mlx4_get_module_id()
2051 inmad->class_version = 0x1; in mlx4_get_module_id()
2052 inmad->mgmt_class = 0x1; in mlx4_get_module_id()
2053 inmad->base_version = 0x1; in mlx4_get_module_id()
2054 inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */ in mlx4_get_module_id()
2056 cable_info = (struct mlx4_cable_info *)inmad->data; in mlx4_get_module_id()
2057 cable_info->dev_mem_address = 0; in mlx4_get_module_id()
2058 cable_info->page_num = 0; in mlx4_get_module_id()
2059 cable_info->i2c_addr = I2C_ADDR_LOW; in mlx4_get_module_id()
2060 cable_info->size = cpu_to_be16(1); in mlx4_get_module_id()
2062 ret = mlx4_cmd_box(dev, inbox->dma, outbox->dma, port, 3, in mlx4_get_module_id()
2068 if (be16_to_cpu(outmad->status)) { in mlx4_get_module_id()
2070 ret = be16_to_cpu(outmad->status); in mlx4_get_module_id()
2072 … Get Module ID attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n", in mlx4_get_module_id()
2075 ret = -ret; in mlx4_get_module_id()
2078 cable_info = (struct mlx4_cable_info *)outmad->data; in mlx4_get_module_id()
2079 *module_id = cable_info->data[0]; in mlx4_get_module_id()
2095 *offset -= I2C_PAGE_SIZE; in mlx4_sfp_eeprom_params_set()
2100 /* Offsets 0-255 belong to page 0. in mlx4_qsfp_eeprom_params_set()
2101 * Offsets 256-639 belong to pages 01, 02, 03. in mlx4_qsfp_eeprom_params_set()
2102 * For example, offset 400 is page 02: 1 + (400 - 256) / 128 = 2 in mlx4_qsfp_eeprom_params_set()
2107 *page_num = 1 + (*offset - I2C_PAGE_SIZE) / I2C_HIGH_PAGE_SIZE; in mlx4_qsfp_eeprom_params_set()
2109 *offset -= *page_num * I2C_HIGH_PAGE_SIZE; in mlx4_qsfp_eeprom_params_set()
2113 * mlx4_get_module_info - Read cable module eeprom data
2152 return -EINVAL; in mlx4_get_module_info()
2165 inmad = (struct mlx4_mad_ifc *)(inbox->buf); in mlx4_get_module_info()
2166 outmad = (struct mlx4_mad_ifc *)(outbox->buf); in mlx4_get_module_info()
2168 inmad->method = 0x1; /* Get */ in mlx4_get_module_info()
2169 inmad->class_version = 0x1; in mlx4_get_module_info()
2170 inmad->mgmt_class = 0x1; in mlx4_get_module_info()
2171 inmad->base_version = 0x1; in mlx4_get_module_info()
2172 inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */ in mlx4_get_module_info()
2178 size -= offset + size - I2C_PAGE_SIZE; in mlx4_get_module_info()
2180 cable_info = (struct mlx4_cable_info *)inmad->data; in mlx4_get_module_info()
2181 cable_info->dev_mem_address = cpu_to_be16(offset); in mlx4_get_module_info()
2182 cable_info->page_num = page_num; in mlx4_get_module_info()
2183 cable_info->i2c_addr = i2c_addr; in mlx4_get_module_info()
2184 cable_info->size = cpu_to_be16(size); in mlx4_get_module_info()
2186 ret = mlx4_cmd_box(dev, inbox->dma, outbox->dma, port, 3, in mlx4_get_module_info()
2192 if (be16_to_cpu(outmad->status)) { in mlx4_get_module_info()
2194 ret = be16_to_cpu(outmad->status); in mlx4_get_module_info()
2196 …et Module info attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n", in mlx4_get_module_info()
2207 ret = -ret; in mlx4_get_module_info()
2210 cable_info = (struct mlx4_cable_info *)outmad->data; in mlx4_get_module_info()
2211 memcpy(data, cable_info->data, size); in mlx4_get_module_info()
2222 u8 num_tc = dev->caps.max_tc_eth; in mlx4_max_tc()