be2net: Implement ethtool get_phys_id function.
authorSarveshwar Bandi <sarveshwarb@serverengines.com>
Mon, 12 Oct 2009 11:23:15 +0000 (04:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Oct 2009 20:26:38 +0000 (13:26 -0700)
Signed-off-by: Sarveshwar Bandi <sarveshwarb@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/benet/be_cmds.c
drivers/net/benet/be_cmds.h
drivers/net/benet/be_ethtool.c

index 89876ade5e33c93f584ea84878c72da098643955..25b6602e464cdb57c9c964ca81e2ff72a1a4b89d 100644 (file)
@@ -1118,6 +1118,65 @@ int be_cmd_reset_function(struct be_adapter *adapter)
        return status;
 }
 
+/* Uses sync mcc */
+int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num,
+                       u8 bcn, u8 sts, u8 state)
+{
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_enable_disable_beacon *req;
+       int status;
+
+       spin_lock_bh(&adapter->mcc_lock);
+
+       wrb = wrb_from_mccq(adapter);
+       req = embedded_payload(wrb);
+
+       be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+
+       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
+               OPCODE_COMMON_ENABLE_DISABLE_BEACON, sizeof(*req));
+
+       req->port_num = port_num;
+       req->beacon_state = state;
+       req->beacon_duration = bcn;
+       req->status_duration = sts;
+
+       status = be_mcc_notify_wait(adapter);
+
+       spin_unlock_bh(&adapter->mcc_lock);
+       return status;
+}
+
+/* Uses sync mcc */
+int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state)
+{
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_get_beacon_state *req;
+       int status;
+
+       spin_lock_bh(&adapter->mcc_lock);
+
+       wrb = wrb_from_mccq(adapter);
+       req = embedded_payload(wrb);
+
+       be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+
+       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
+               OPCODE_COMMON_GET_BEACON_STATE, sizeof(*req));
+
+       req->port_num = port_num;
+
+       status = be_mcc_notify_wait(adapter);
+       if (!status) {
+               struct be_cmd_resp_get_beacon_state *resp =
+                                               embedded_payload(wrb);
+               *state = resp->beacon_state;
+       }
+
+       spin_unlock_bh(&adapter->mcc_lock);
+       return status;
+}
+
 int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
                        u32 flash_type, u32 flash_opcode, u32 buf_size)
 {
index a86f917f85f427bc18ea27d79f7062f406107ad9..a1e78cc3e171198b46bb55e278876fb6af0e5332 100644 (file)
@@ -138,6 +138,8 @@ struct be_mcc_mailbox {
 #define OPCODE_COMMON_NTWK_PMAC_ADD                    59
 #define OPCODE_COMMON_NTWK_PMAC_DEL                    60
 #define OPCODE_COMMON_FUNCTION_RESET                   61
+#define OPCODE_COMMON_ENABLE_DISABLE_BEACON            69
+#define OPCODE_COMMON_GET_BEACON_STATE                 70
 
 #define OPCODE_ETH_ACPI_CONFIG                         2
 #define OPCODE_ETH_PROMISCUOUS                         3
@@ -699,6 +701,37 @@ struct be_cmd_resp_query_fw_cfg {
        u32 rsvd[26];
 };
 
+/******************** Port Beacon ***************************/
+
+#define BEACON_STATE_ENABLED           0x1
+#define BEACON_STATE_DISABLED          0x0
+
+struct be_cmd_req_enable_disable_beacon {
+       struct be_cmd_req_hdr hdr;
+       u8  port_num;
+       u8  beacon_state;
+       u8  beacon_duration;
+       u8  status_duration;
+} __packed;
+
+struct be_cmd_resp_enable_disable_beacon {
+       struct be_cmd_resp_hdr resp_hdr;
+       u32 rsvd0;
+} __packed;
+
+struct be_cmd_req_get_beacon_state {
+       struct be_cmd_req_hdr hdr;
+       u8  port_num;
+       u8  rsvd0;
+       u16 rsvd1;
+} __packed;
+
+struct be_cmd_resp_get_beacon_state {
+       struct be_cmd_resp_hdr resp_hdr;
+       u8 beacon_state;
+       u8 rsvd0[3];
+} __packed;
+
 /****************** Firmware Flash ******************/
 struct flashrom_params {
        u32 op_code;
@@ -764,6 +797,10 @@ extern int be_cmd_query_fw_cfg(struct be_adapter *adapter,
                        u32 *port_num, u32 *cap);
 extern int be_cmd_reset_function(struct be_adapter *adapter);
 extern int be_process_mcc(struct be_adapter *adapter);
+extern int be_cmd_set_beacon_state(struct be_adapter *adapter,
+                       u8 port_num, u8 beacon, u8 status, u8 state);
+extern int be_cmd_get_beacon_state(struct be_adapter *adapter,
+                       u8 port_num, u32 *state);
 extern int be_cmd_write_flashrom(struct be_adapter *adapter,
                        struct be_dma_mem *cmd, u32 flash_oper,
                        u32 flash_opcode, u32 buf_size);
index 333729bd6d92b50c897e40d6fb2b0b1f5d88b6d3..280471e1869503345264585db77853c356d9aeaf 100644 (file)
@@ -337,6 +337,35 @@ be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
        return status;
 }
 
+static int
+be_phys_id(struct net_device *netdev, u32 data)
+{
+       struct be_adapter *adapter = netdev_priv(netdev);
+       int status;
+       u32 cur;
+
+       if (!netif_running(netdev))
+               return 0;
+
+       be_cmd_get_beacon_state(adapter, adapter->port_num, &cur);
+
+       if (cur == BEACON_STATE_ENABLED)
+               return 0;
+
+       if (data < 2)
+               data = 2;
+
+       status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0,
+                       BEACON_STATE_ENABLED);
+       set_current_state(TASK_INTERRUPTIBLE);
+       schedule_timeout(data*HZ);
+
+       status = be_cmd_set_beacon_state(adapter, adapter->port_num, 0, 0,
+                       BEACON_STATE_DISABLED);
+
+       return status;
+}
+
 static int
 be_do_flash(struct net_device *netdev, struct ethtool_flash *efl)
 {
@@ -369,6 +398,7 @@ const struct ethtool_ops be_ethtool_ops = {
        .get_tso = ethtool_op_get_tso,
        .set_tso = ethtool_op_set_tso,
        .get_strings = be_get_stat_strings,
+       .phys_id = be_phys_id,
        .get_sset_count = be_get_sset_count,
        .get_ethtool_stats = be_get_ethtool_stats,
        .flash_device = be_do_flash,