On 4/16/25 17:00, Ivan Malov wrote:
Use new MCDI to select loopback, speed, flow control and FEC.
Signed-off-by: Ivan Malov <ivan.ma...@arknetworks.am>
Reviewed-by: Andy Moreton <andy.more...@amd.com>
Reviewed-by: Pieter Jansen Van Vuuren <pieter.jansen-van-vuu...@amd.com>
[snip]
+static void
+efx_np_cap_sw_mask_to_hw_enum(
+ __in_ecount(hw_sw_map_nentries) const struct efx_np_cap_map *hw_sw_map,
+ __in unsigned int hw_sw_map_nentries,
+ __in_bcount(hw_cap_data_nbytes) const uint8_t *hw_cap_data,
+ __in size_t hw_cap_data_nbytes,
+ __in uint32_t mask_sw,
+ __out boolean_t *supportedp,
+ __out_opt uint16_t *enum_hwp)
+{
+ unsigned int sw_nflags_req = 0;
+ unsigned int sw_nflags_sup = 0;
+ uint32_t sw_check_mask = 0;
+ unsigned int i;
+
+ for (i = 0; i < hw_sw_map_nentries; ++i) {
+ uint32_t flag_sw = 1U << hw_sw_map->encm_sw;
+ unsigned int byte_idx = CAP_BYTE(hw_sw_map);
+ uint8_t flag_hw = CAP_FLAG(hw_sw_map);
+
+ if (byte_idx >= hw_cap_data_nbytes) {
+ ++(hw_sw_map);
+ continue;
+ }
+
+ if ((mask_sw & flag_sw) == flag_sw) {
+ if ((sw_check_mask & flag_sw) == 0)
+ ++(sw_nflags_req);
+
+ sw_check_mask |= flag_sw;
+
+ if ((hw_cap_data[byte_idx] & flag_hw) == flag_hw) {
+ mask_sw &= ~(flag_sw);
+
+ if (enum_hwp != NULL)
+ *enum_hwp = hw_sw_map->encm_hw;
+ }
+ }
+
+ ++(hw_sw_map);
+ }
+
+ /*
+ * FIXME: in the absence of autonegotiation capability, drivers
+ * may still pass multiple capability bits of the same category.
+ * That is supposed to work on EF10; do not enforce below check.
+ */
+#if 0
It looks rather strange when code with #if 0 comes.
+ if (sw_nflags_req != 1) {
+ /*
+ * The mask must contain exactly one relevant
+ * flag which represents some specific choice.
+ */
+ *supportedp = B_FALSE;
+ return;
+ }
+#endif
+
+ if (sw_check_mask != 0 && (mask_sw & sw_check_mask) == sw_check_mask) {
+ /* Failed to select the enum by at least one capability bit. */
+ *supportedp = B_FALSE;
+ return;
+ }
+
+ *supportedp = B_TRUE;
+}
[snip]