@@ -20,7 +20,40 @@ static enum ice_status ice_set_mac_type(struct ice_hw *hw)
20
20
if (hw -> vendor_id != PCI_VENDOR_ID_INTEL )
21
21
return ICE_ERR_DEVICE_NOT_SUPPORTED ;
22
22
23
- hw -> mac_type = ICE_MAC_GENERIC ;
23
+ switch (hw -> device_id ) {
24
+ case ICE_DEV_ID_E810C_BACKPLANE :
25
+ case ICE_DEV_ID_E810C_QSFP :
26
+ case ICE_DEV_ID_E810C_SFP :
27
+ case ICE_DEV_ID_E810_XXV_SFP :
28
+ hw -> mac_type = ICE_MAC_E810 ;
29
+ break ;
30
+ case ICE_DEV_ID_E823C_10G_BASE_T :
31
+ case ICE_DEV_ID_E823C_BACKPLANE :
32
+ case ICE_DEV_ID_E823C_QSFP :
33
+ case ICE_DEV_ID_E823C_SFP :
34
+ case ICE_DEV_ID_E823C_SGMII :
35
+ case ICE_DEV_ID_E822C_10G_BASE_T :
36
+ case ICE_DEV_ID_E822C_BACKPLANE :
37
+ case ICE_DEV_ID_E822C_QSFP :
38
+ case ICE_DEV_ID_E822C_SFP :
39
+ case ICE_DEV_ID_E822C_SGMII :
40
+ case ICE_DEV_ID_E822L_10G_BASE_T :
41
+ case ICE_DEV_ID_E822L_BACKPLANE :
42
+ case ICE_DEV_ID_E822L_SFP :
43
+ case ICE_DEV_ID_E822L_SGMII :
44
+ case ICE_DEV_ID_E823L_10G_BASE_T :
45
+ case ICE_DEV_ID_E823L_1GBE :
46
+ case ICE_DEV_ID_E823L_BACKPLANE :
47
+ case ICE_DEV_ID_E823L_QSFP :
48
+ case ICE_DEV_ID_E823L_SFP :
49
+ hw -> mac_type = ICE_MAC_GENERIC ;
50
+ break ;
51
+ default :
52
+ hw -> mac_type = ICE_MAC_UNKNOWN ;
53
+ break ;
54
+ }
55
+
56
+ ice_debug (hw , ICE_DBG_INIT , "mac_type: %d\n" , hw -> mac_type );
24
57
return 0 ;
25
58
}
26
59
@@ -2675,7 +2708,7 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
2675
2708
goto out ;
2676
2709
}
2677
2710
2678
- ice_copy_phy_caps_to_cfg (pcaps , & cfg );
2711
+ ice_copy_phy_caps_to_cfg (pi , pcaps , & cfg );
2679
2712
2680
2713
/* Configure the set PHY data */
2681
2714
status = ice_cfg_phy_fc (pi , & cfg , pi -> fc .req_mode );
@@ -2757,17 +2790,19 @@ ice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *phy_caps,
2757
2790
2758
2791
/**
2759
2792
* ice_copy_phy_caps_to_cfg - Copy PHY ability data to configuration data
2793
+ * @pi: port information structure
2760
2794
* @caps: PHY ability structure to copy date from
2761
2795
* @cfg: PHY configuration structure to copy data to
2762
2796
*
2763
2797
* Helper function to copy AQC PHY get ability data to PHY set configuration
2764
2798
* data structure
2765
2799
*/
2766
2800
void
2767
- ice_copy_phy_caps_to_cfg (struct ice_aqc_get_phy_caps_data * caps ,
2801
+ ice_copy_phy_caps_to_cfg (struct ice_port_info * pi ,
2802
+ struct ice_aqc_get_phy_caps_data * caps ,
2768
2803
struct ice_aqc_set_phy_cfg_data * cfg )
2769
2804
{
2770
- if (!caps || !cfg )
2805
+ if (!pi || ! caps || !cfg )
2771
2806
return ;
2772
2807
2773
2808
memset (cfg , 0 , sizeof (* cfg ));
@@ -2778,6 +2813,19 @@ ice_copy_phy_caps_to_cfg(struct ice_aqc_get_phy_caps_data *caps,
2778
2813
cfg -> eee_cap = caps -> eee_cap ;
2779
2814
cfg -> eeer_value = caps -> eeer_value ;
2780
2815
cfg -> link_fec_opt = caps -> link_fec_options ;
2816
+ cfg -> module_compliance_enforcement =
2817
+ caps -> module_compliance_enforcement ;
2818
+
2819
+ if (ice_fw_supports_link_override (pi -> hw )) {
2820
+ struct ice_link_default_override_tlv tlv ;
2821
+
2822
+ if (ice_get_link_default_override (& tlv , pi ))
2823
+ return ;
2824
+
2825
+ if (tlv .options & ICE_LINK_OVERRIDE_STRICT_MODE )
2826
+ cfg -> module_compliance_enforcement |=
2827
+ ICE_LINK_OVERRIDE_STRICT_MODE ;
2828
+ }
2781
2829
}
2782
2830
2783
2831
/**
@@ -2840,6 +2888,17 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
2840
2888
break ;
2841
2889
}
2842
2890
2891
+ if (fec == ICE_FEC_AUTO && ice_fw_supports_link_override (pi -> hw )) {
2892
+ struct ice_link_default_override_tlv tlv ;
2893
+
2894
+ if (ice_get_link_default_override (& tlv , pi ))
2895
+ goto out ;
2896
+
2897
+ if (!(tlv .options & ICE_LINK_OVERRIDE_STRICT_MODE ) &&
2898
+ (tlv .options & ICE_LINK_OVERRIDE_EN ))
2899
+ cfg -> link_fec_opt = tlv .fec_options ;
2900
+ }
2901
+
2843
2902
out :
2844
2903
kfree (pcaps );
2845
2904
@@ -4043,3 +4102,106 @@ ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
4043
4102
ice_debug (hw , ICE_DBG_SCHED , "query element failed\n" );
4044
4103
return status ;
4045
4104
}
4105
+
4106
+ /**
4107
+ * ice_fw_supports_link_override
4108
+ * @hw: pointer to the hardware structure
4109
+ *
4110
+ * Checks if the firmware supports link override
4111
+ */
4112
+ bool ice_fw_supports_link_override (struct ice_hw * hw )
4113
+ {
4114
+ /* Currently, only supported for E810 devices */
4115
+ if (hw -> mac_type != ICE_MAC_E810 )
4116
+ return false;
4117
+
4118
+ if (hw -> api_maj_ver == ICE_FW_API_LINK_OVERRIDE_MAJ ) {
4119
+ if (hw -> api_min_ver > ICE_FW_API_LINK_OVERRIDE_MIN )
4120
+ return true;
4121
+ if (hw -> api_min_ver == ICE_FW_API_LINK_OVERRIDE_MIN &&
4122
+ hw -> api_patch >= ICE_FW_API_LINK_OVERRIDE_PATCH )
4123
+ return true;
4124
+ } else if (hw -> api_maj_ver > ICE_FW_API_LINK_OVERRIDE_MAJ ) {
4125
+ return true;
4126
+ }
4127
+
4128
+ return false;
4129
+ }
4130
+
4131
+ /**
4132
+ * ice_get_link_default_override
4133
+ * @ldo: pointer to the link default override struct
4134
+ * @pi: pointer to the port info struct
4135
+ *
4136
+ * Gets the link default override for a port
4137
+ */
4138
+ enum ice_status
4139
+ ice_get_link_default_override (struct ice_link_default_override_tlv * ldo ,
4140
+ struct ice_port_info * pi )
4141
+ {
4142
+ u16 i , tlv , tlv_len , tlv_start , buf , offset ;
4143
+ struct ice_hw * hw = pi -> hw ;
4144
+ enum ice_status status ;
4145
+
4146
+ status = ice_get_pfa_module_tlv (hw , & tlv , & tlv_len ,
4147
+ ICE_SR_LINK_DEFAULT_OVERRIDE_PTR );
4148
+ if (status ) {
4149
+ ice_debug (hw , ICE_DBG_INIT ,
4150
+ "Failed to read link override TLV.\n" );
4151
+ return status ;
4152
+ }
4153
+
4154
+ /* Each port has its own config; calculate for our port */
4155
+ tlv_start = tlv + pi -> lport * ICE_SR_PFA_LINK_OVERRIDE_WORDS +
4156
+ ICE_SR_PFA_LINK_OVERRIDE_OFFSET ;
4157
+
4158
+ /* link options first */
4159
+ status = ice_read_sr_word (hw , tlv_start , & buf );
4160
+ if (status ) {
4161
+ ice_debug (hw , ICE_DBG_INIT ,
4162
+ "Failed to read override link options.\n" );
4163
+ return status ;
4164
+ }
4165
+ ldo -> options = buf & ICE_LINK_OVERRIDE_OPT_M ;
4166
+ ldo -> phy_config = (buf & ICE_LINK_OVERRIDE_PHY_CFG_M ) >>
4167
+ ICE_LINK_OVERRIDE_PHY_CFG_S ;
4168
+
4169
+ /* link PHY config */
4170
+ offset = tlv_start + ICE_SR_PFA_LINK_OVERRIDE_FEC_OFFSET ;
4171
+ status = ice_read_sr_word (hw , offset , & buf );
4172
+ if (status ) {
4173
+ ice_debug (hw , ICE_DBG_INIT ,
4174
+ "Failed to read override phy config.\n" );
4175
+ return status ;
4176
+ }
4177
+ ldo -> fec_options = buf & ICE_LINK_OVERRIDE_FEC_OPT_M ;
4178
+
4179
+ /* PHY types low */
4180
+ offset = tlv_start + ICE_SR_PFA_LINK_OVERRIDE_PHY_OFFSET ;
4181
+ for (i = 0 ; i < ICE_SR_PFA_LINK_OVERRIDE_PHY_WORDS ; i ++ ) {
4182
+ status = ice_read_sr_word (hw , (offset + i ), & buf );
4183
+ if (status ) {
4184
+ ice_debug (hw , ICE_DBG_INIT ,
4185
+ "Failed to read override link options.\n" );
4186
+ return status ;
4187
+ }
4188
+ /* shift 16 bits at a time to fill 64 bits */
4189
+ ldo -> phy_type_low |= ((u64 )buf << (i * 16 ));
4190
+ }
4191
+
4192
+ /* PHY types high */
4193
+ offset = tlv_start + ICE_SR_PFA_LINK_OVERRIDE_PHY_OFFSET +
4194
+ ICE_SR_PFA_LINK_OVERRIDE_PHY_WORDS ;
4195
+ for (i = 0 ; i < ICE_SR_PFA_LINK_OVERRIDE_PHY_WORDS ; i ++ ) {
4196
+ status = ice_read_sr_word (hw , (offset + i ), & buf );
4197
+ if (status ) {
4198
+ ice_debug (hw , ICE_DBG_INIT ,
4199
+ "Failed to read override link options.\n" );
4200
+ return status ;
4201
+ }
4202
+ /* shift 16 bits at a time to fill 64 bits */
4203
+ ldo -> phy_type_high |= ((u64 )buf << (i * 16 ));
4204
+ }
4205
+
4206
+ return status ;
4207
+ }
0 commit comments