From: Paul Greenwalt <paul.greenw...@intel.com>

E830 introduces a new version of Get Link Status Data which increases
the size of struct ice_aqc_get_link_status_data from 32 bytes to 51
bytes.

Add new link partner fields to ice_aqc_get_link_status_data; PHY type,
FEC, and flow control. Add new ICE_GET_LINK_STATUS_DATA_V2 and
ICE_GET_LINK_STATUS_DATALEN_V2 to support the new version and data
length.

Also, moving ice_get_link_status_datalen and ice_get_link_status_datalen
to ice_common.c

Signed-off-by: Paul Greenwalt <paul.greenw...@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 drivers/net/ice/base/ice_adminq_cmd.h | 35 ++++++++++++++++++++++++++-
 drivers/net/ice/base/ice_common.c     | 20 +++++++++++++--
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/base/ice_adminq_cmd.h 
b/drivers/net/ice/base/ice_adminq_cmd.h
index ef6284f263..a4b45b9fc5 100644
--- a/drivers/net/ice/base/ice_adminq_cmd.h
+++ b/drivers/net/ice/base/ice_adminq_cmd.h
@@ -1566,7 +1566,16 @@ struct ice_aqc_get_link_status {
        __le32 addr_low;
 };
 
+enum ice_get_link_status_data_version {
+       ICE_GET_LINK_STATUS_DATA_V1 = 1,
+       ICE_GET_LINK_STATUS_DATA_V2 = 2,
+};
+
+#define ICE_GET_LINK_STATUS_DATALEN_V1         32
+#define ICE_GET_LINK_STATUS_DATALEN_V2         56
+
 /* Get link status response data structure, also used for Link Status Event */
+#pragma pack(1)
 struct ice_aqc_get_link_status_data {
        u8 topo_media_conflict;
 #define ICE_AQ_LINK_TOPO_CONFLICT      BIT(0)
@@ -1653,11 +1662,35 @@ struct ice_aqc_get_link_status_data {
 #define ICE_AQ_LINK_SPEED_100GB                BIT(10)
 #define ICE_AQ_LINK_SPEED_200GB                BIT(11)
 #define ICE_AQ_LINK_SPEED_UNKNOWN      BIT(15)
-       __le32 reserved3; /* Aligns next field to 8-byte boundary */
+       __le16 reserved3; /* Aligns next field to 8-byte boundary */
+       u8 ext_fec_status;
+#define ICE_AQ_LINK_RS_272_FEC_EN      BIT(0) /* RS 272 FEC enabled */
+       u8 reserved4;
        __le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
        __le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
+       /* Get link status version 2 link partner data */
+       __le64 lp_phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
+       __le64 lp_phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
+       u8 lp_fec_adv;
+#define ICE_AQ_LINK_LP_10G_KR_FEC_CAP  BIT(0)
+#define ICE_AQ_LINK_LP_25G_KR_FEC_CAP  BIT(1)
+#define ICE_AQ_LINK_LP_RS_528_FEC_CAP  BIT(2)
+#define ICE_AQ_LINK_LP_50G_KR_272_FEC_CAP BIT(3)
+#define ICE_AQ_LINK_LP_100G_KR_272_FEC_CAP BIT(4)
+#define ICE_AQ_LINK_LP_200G_KR_272_FEC_CAP BIT(5)
+       u8 lp_fec_req;
+#define ICE_AQ_LINK_LP_10G_KR_FEC_REQ  BIT(0)
+#define ICE_AQ_LINK_LP_25G_KR_FEC_REQ  BIT(1)
+#define ICE_AQ_LINK_LP_RS_528_FEC_REQ  BIT(2)
+#define ICE_AQ_LINK_LP_KR_272_FEC_REQ  BIT(3)
+       u8 lp_flowcontrol;
+#define ICE_AQ_LINK_LP_PAUSE_ADV       BIT(0)
+#define ICE_AQ_LINK_LP_ASM_DIR_ADV     BIT(1)
+       u8 reserved[5];
 };
 
+#pragma pack()
+
 /* Set event mask command (direct 0x0613) */
 struct ice_aqc_set_event_mask {
        u8      lport_num;
diff --git a/drivers/net/ice/base/ice_common.c 
b/drivers/net/ice/base/ice_common.c
index 7b899f0782..d437ab5be6 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -565,6 +565,22 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool 
qual_mods, u8 report_mode,
        return status;
 }
 
+#define ice_get_link_status_data_ver(hw) ((hw)->mac_type == ICE_MAC_E830 ? \
+               ICE_GET_LINK_STATUS_DATA_V2 : ICE_GET_LINK_STATUS_DATA_V1)
+
+/**
+ * ice_get_link_status_datalen
+ * @hw: pointer to the HW struct
+ *
+ * return Get Link Status datalen
+ */
+static u16 ice_get_link_status_datalen(struct ice_hw *hw)
+{
+       return (ice_get_link_status_data_ver(hw) ==
+               ICE_GET_LINK_STATUS_DATA_V1) ? ICE_GET_LINK_STATUS_DATALEN_V1 :
+               ICE_GET_LINK_STATUS_DATALEN_V2;
+}
+
 /**
  * ice_aq_get_netlist_node_pin
  * @hw: pointer to the hw struct
@@ -704,8 +720,8 @@ ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
        resp->cmd_flags = CPU_TO_LE16(cmd_flags);
        resp->lport_num = pi->lport;
 
-       status = ice_aq_send_cmd(hw, &desc, &link_data, sizeof(link_data), cd);
-
+       status = ice_aq_send_cmd(hw, &desc, &link_data,
+                                ice_get_link_status_datalen(hw), cd);
        if (status)
                return status;
 
-- 
2.43.0

Reply via email to