OSDN Git Service

ice: Add ethtool set_phys_id handler
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Wed, 19 Dec 2018 18:03:23 +0000 (10:03 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 15 Jan 2019 18:07:08 +0000 (10:07 -0800)
Add led blinking handler to ethtool. Since led blinking is
controlled by FW/HW only ETHTOOL_ID_ACTIVE and ETHTOOL_ID_INACTIVE
are really needed.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
drivers/net/ethernet/intel/ice/ice_common.c
drivers/net/ethernet/intel/ice/ice_common.h
drivers/net/ethernet/intel/ice/ice_ethtool.c

index 4c7e3af..245068b 100644 (file)
@@ -1048,6 +1048,16 @@ struct ice_aqc_set_event_mask {
        u8      reserved1[6];
 };
 
+/* Set Port Identification LED (direct, 0x06E9) */
+struct ice_aqc_set_port_id_led {
+       u8 lport_num;
+       u8 lport_num_valid;
+       u8 ident_mode;
+#define ICE_AQC_PORT_IDENT_LED_BLINK   BIT(0)
+#define ICE_AQC_PORT_IDENT_LED_ORIG    0
+       u8 rsvd[13];
+};
+
 /* NVM Read command (indirect 0x0701)
  * NVM Erase commands (direct 0x0702)
  * NVM Update commands (indirect 0x0703)
@@ -1334,6 +1344,7 @@ struct ice_aq_desc {
                struct ice_aqc_get_phy_caps get_phy;
                struct ice_aqc_set_phy_cfg set_phy;
                struct ice_aqc_restart_an restart_an;
+               struct ice_aqc_set_port_id_led set_port_id_led;
                struct ice_aqc_get_sw_cfg get_sw_conf;
                struct ice_aqc_sw_rules sw_rules;
                struct ice_aqc_get_topo get_topo;
@@ -1434,6 +1445,7 @@ enum ice_adminq_opc {
        ice_aqc_opc_restart_an                          = 0x0605,
        ice_aqc_opc_get_link_status                     = 0x0607,
        ice_aqc_opc_set_event_mask                      = 0x0613,
+       ice_aqc_opc_set_port_id_led                     = 0x06E9,
 
        /* NVM commands */
        ice_aqc_opc_nvm_read                            = 0x0701,
index 4c1d35d..2bcd823 100644 (file)
@@ -2032,6 +2032,34 @@ ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 }
 
 /**
+ * ice_aq_set_port_id_led
+ * @pi: pointer to the port information
+ * @is_orig_mode: is this LED set to original mode (by the net-list)
+ * @cd: pointer to command details structure or NULL
+ *
+ * Set LED value for the given port (0x06e9)
+ */
+enum ice_status
+ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
+                      struct ice_sq_cd *cd)
+{
+       struct ice_aqc_set_port_id_led *cmd;
+       struct ice_hw *hw = pi->hw;
+       struct ice_aq_desc desc;
+
+       cmd = &desc.params.set_port_id_led;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_port_id_led);
+
+       if (is_orig_mode)
+               cmd->ident_mode = ICE_AQC_PORT_IDENT_LED_ORIG;
+       else
+               cmd->ident_mode = ICE_AQC_PORT_IDENT_LED_BLINK;
+
+       return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+}
+
+/**
  * __ice_aq_get_set_rss_lut
  * @hw: pointer to the hardware structure
  * @vsi_id: VSI FW index
index cf760c2..b86cfe5 100644 (file)
@@ -86,6 +86,10 @@ enum ice_status
 ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
                           struct ice_sq_cd *cd);
 enum ice_status
+ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
+                      struct ice_sq_cd *cd);
+
+enum ice_status
 ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
                u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
                struct ice_sq_cd *cmd_details);
index 3b6e387..6facb0a 100644 (file)
@@ -249,6 +249,29 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
        }
 }
 
+static int
+ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state)
+{
+       struct ice_netdev_priv *np = netdev_priv(netdev);
+       bool led_active;
+
+       switch (state) {
+       case ETHTOOL_ID_ACTIVE:
+               led_active = true;
+               break;
+       case ETHTOOL_ID_INACTIVE:
+               led_active = false;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL))
+               return -EIO;
+
+       return 0;
+}
+
 static int ice_get_sset_count(struct net_device *netdev, int sset)
 {
        switch (sset) {
@@ -1677,6 +1700,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
        .set_msglevel           = ice_set_msglevel,
        .get_link               = ethtool_op_get_link,
        .get_strings            = ice_get_strings,
+       .set_phys_id            = ice_set_phys_id,
        .get_ethtool_stats      = ice_get_ethtool_stats,
        .get_sset_count         = ice_get_sset_count,
        .get_rxnfc              = ice_get_rxnfc,