@@ -1768,6 +1768,9 @@ sai_status_t SwitchStateBase::refresh_port_list(
1768
1768
1769
1769
const sai_object_id_t cpu_port_id = attr.value .oid ;
1770
1770
1771
+ std::unordered_set<sai_object_id_t > fabric_port_set (m_fabric_port_list.begin (),
1772
+ m_fabric_port_list.end ());
1773
+
1771
1774
m_port_list.clear ();
1772
1775
1773
1776
// iterate via ASIC state to find all the ports
@@ -1782,6 +1785,10 @@ sai_status_t SwitchStateBase::refresh_port_list(
1782
1785
if (port_id == cpu_port_id)
1783
1786
continue ;
1784
1787
1788
+ // don't put fabric ports on the list
1789
+ if (fabric_port_set.find (port_id) != fabric_port_set.end ())
1790
+ continue ;
1791
+
1785
1792
m_port_list.push_back (port_id);
1786
1793
}
1787
1794
@@ -1907,6 +1914,10 @@ sai_status_t SwitchStateBase::refresh_read_only(
1907
1914
case SAI_SWITCH_ATTR_SYSTEM_PORT_LIST:
1908
1915
return refresh_system_port_list (meta);
1909
1916
1917
+ case SAI_SWITCH_ATTR_NUMBER_OF_FABRIC_PORTS:
1918
+ case SAI_SWITCH_ATTR_FABRIC_PORT_LIST:
1919
+ return SAI_STATUS_SUCCESS;
1920
+
1910
1921
case SAI_SWITCH_ATTR_SUPPORTED_OBJECT_TYPE_LIST:
1911
1922
return SAI_STATUS_SUCCESS;
1912
1923
}
@@ -1934,6 +1945,9 @@ sai_status_t SwitchStateBase::refresh_read_only(
1934
1945
1935
1946
case SAI_PORT_ATTR_OPER_STATUS:
1936
1947
return SAI_STATUS_SUCCESS;
1948
+
1949
+ case SAI_PORT_ATTR_FABRIC_ATTACHED:
1950
+ return SAI_STATUS_SUCCESS;
1937
1951
}
1938
1952
}
1939
1953
@@ -2652,6 +2666,10 @@ sai_status_t SwitchStateBase::initialize_voq_switch_objects(
2652
2666
2653
2667
CHECK_STATUS (set_system_port_list ());
2654
2668
2669
+ CHECK_STATUS (create_fabric_ports ());
2670
+
2671
+ CHECK_STATUS (set_fabric_port_list ());
2672
+
2655
2673
return SAI_STATUS_SUCCESS;
2656
2674
}
2657
2675
@@ -2783,6 +2801,83 @@ sai_status_t SwitchStateBase::refresh_system_port_list(
2783
2801
return SAI_STATUS_SUCCESS;
2784
2802
}
2785
2803
2804
+ sai_status_t SwitchStateBase::create_fabric_ports ()
2805
+ {
2806
+ SWSS_LOG_ENTER ();
2807
+
2808
+ SWSS_LOG_INFO (" create fabric ports" );
2809
+
2810
+ auto map = m_switchConfig->m_fabricLaneMap ;
2811
+
2812
+ if (!map)
2813
+ {
2814
+ SWSS_LOG_ERROR (" fabric lane map for switch %s is NULL" ,
2815
+ sai_serialize_object_id (m_switch_id).c_str ());
2816
+
2817
+ return SAI_STATUS_FAILURE;
2818
+ }
2819
+
2820
+ auto & lanesVector = map->getLaneVector ();
2821
+
2822
+ uint32_t fabric_port_count = (uint32_t )lanesVector.size ();
2823
+
2824
+ m_fabric_port_list.clear ();
2825
+
2826
+ for (uint32_t i = 0 ; i < fabric_port_count; i++)
2827
+ {
2828
+ SWSS_LOG_DEBUG (" create fabric port index %u" , i);
2829
+
2830
+ sai_object_id_t fabric_port_id;
2831
+
2832
+ CHECK_STATUS (create (SAI_OBJECT_TYPE_PORT, &fabric_port_id, m_switch_id, 0 , NULL ));
2833
+ m_fabric_port_list.push_back (fabric_port_id);
2834
+
2835
+ sai_attribute_t attr;
2836
+
2837
+ attr.id = SAI_PORT_ATTR_FABRIC_ATTACHED;
2838
+ attr.value .booldata = false ;
2839
+
2840
+ CHECK_STATUS (set (SAI_OBJECT_TYPE_PORT, fabric_port_id, &attr));
2841
+
2842
+ std::vector<uint32_t > lanes = lanesVector.at (i);
2843
+
2844
+ attr.id = SAI_PORT_ATTR_HW_LANE_LIST;
2845
+ attr.value .u32list .count = (uint32_t )lanes.size ();
2846
+ attr.value .u32list .list = lanes.data ();
2847
+
2848
+ CHECK_STATUS (set (SAI_OBJECT_TYPE_PORT, fabric_port_id, &attr));
2849
+
2850
+ attr.id = SAI_PORT_ATTR_TYPE;
2851
+ attr.value .s32 = SAI_PORT_TYPE_FABRIC;
2852
+
2853
+ CHECK_STATUS (set (SAI_OBJECT_TYPE_PORT, fabric_port_id, &attr));
2854
+ }
2855
+
2856
+ return SAI_STATUS_SUCCESS;
2857
+ }
2858
+
2859
+ sai_status_t SwitchStateBase::set_fabric_port_list ()
2860
+ {
2861
+ SWSS_LOG_ENTER ();
2862
+
2863
+ SWSS_LOG_INFO (" set fabric port list" );
2864
+
2865
+ sai_attribute_t attr;
2866
+
2867
+ uint32_t fabric_port_count = (uint32_t )m_fabric_port_list.size ();
2868
+
2869
+ attr.id = SAI_SWITCH_ATTR_FABRIC_PORT_LIST;
2870
+ attr.value .objlist .count = fabric_port_count;
2871
+ attr.value .objlist .list = m_fabric_port_list.data ();
2872
+
2873
+ CHECK_STATUS (set (SAI_OBJECT_TYPE_SWITCH, m_switch_id, &attr));
2874
+
2875
+ attr.id = SAI_SWITCH_ATTR_NUMBER_OF_FABRIC_PORTS;
2876
+ attr.value .u32 = fabric_port_count;
2877
+
2878
+ return set (SAI_OBJECT_TYPE_SWITCH, m_switch_id, &attr);
2879
+ }
2880
+
2786
2881
sai_status_t SwitchStateBase::createVoqSystemNeighborEntry (
2787
2882
_In_ const std::string &serializedObjectId,
2788
2883
_In_ sai_object_id_t switch_id,
0 commit comments