qlcnic: Enable beaconing for 83xx/84xx Series adapter.
authorHimanshu Madhani <himanshu.madhani@qlogic.com>
Fri, 10 Jan 2014 16:48:56 +0000 (11:48 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Jan 2014 23:31:19 +0000 (15:31 -0800)
o Refactored code to handle beaconing test for all adapters.
o Use GET_LED_CONFIG mailbox command for 83xx/84xx series adapter
  to detect current beaconing state of the adapter.

Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c

index a68b145b3451dd21de3edbe815294ee658be5ced..27ebe6a3512af740da0067d1516f77feb0fcf8cd 100644 (file)
@@ -970,6 +970,9 @@ struct qlcnic_ipaddr {
 #define QLCNIC_BEACON_EANBLE           0xC
 #define QLCNIC_BEACON_DISABLE          0xD
 
+#define QLCNIC_BEACON_ON               2
+#define QLCNIC_BEACON_OFF              0
+
 #define QLCNIC_MSIX_TBL_SPACE          8192
 #define QLCNIC_PCI_REG_MSIX_TBL        0x44
 #define QLCNIC_MSIX_TBL_PGSIZE         4096
@@ -1641,7 +1644,6 @@ int qlcnic_set_default_offload_settings(struct qlcnic_adapter *);
 int qlcnic_reset_npar_config(struct qlcnic_adapter *);
 int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *);
 void qlcnic_add_lb_filter(struct qlcnic_adapter *, struct sk_buff *, int, u16);
-int qlcnic_get_beacon_state(struct qlcnic_adapter *, u8 *);
 int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
 int qlcnic_read_mac_addr(struct qlcnic_adapter *);
 int qlcnic_setup_netdev(struct qlcnic_adapter *, struct net_device *, int);
@@ -1768,6 +1770,7 @@ struct qlcnic_hardware_ops {
                                               pci_channel_state_t);
        pci_ers_result_t (*io_slot_reset) (struct pci_dev *);
        void (*io_resume) (struct pci_dev *);
+       void (*get_beacon_state)(struct qlcnic_adapter *);
 };
 
 extern struct qlcnic_nic_template qlcnic_vf_ops;
@@ -1994,6 +1997,11 @@ static inline void qlcnic_set_mac_filter_count(struct qlcnic_adapter *adapter)
                adapter->ahw->hw_ops->set_mac_filter_count(adapter);
 }
 
+static inline void qlcnic_get_beacon_state(struct qlcnic_adapter *adapter)
+{
+       adapter->ahw->hw_ops->get_beacon_state(adapter);
+}
+
 static inline void qlcnic_read_phys_port_id(struct qlcnic_adapter *adapter)
 {
        if (adapter->ahw->hw_ops->read_phys_port_id)
index 03f70e8940b3ad9c125cfdf364f4f44009da3eff..a684d28e37af692b5d0db3e480807b352594cd9a 100644 (file)
@@ -181,7 +181,7 @@ static struct qlcnic_hardware_ops qlcnic_83xx_hw_ops = {
        .io_error_detected              = qlcnic_83xx_io_error_detected,
        .io_slot_reset                  = qlcnic_83xx_io_slot_reset,
        .io_resume                      = qlcnic_83xx_io_resume,
-
+       .get_beacon_state               = qlcnic_83xx_get_beacon_state,
 };
 
 static struct qlcnic_nic_template qlcnic_83xx_ops = {
@@ -1388,6 +1388,33 @@ out:
        netif_device_attach(netdev);
 }
 
+void qlcnic_83xx_get_beacon_state(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_cmd_args cmd;
+       u8 beacon_state;
+       int err = 0;
+
+       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_GET_LED_CONFIG);
+       if (!err) {
+               err = qlcnic_issue_cmd(adapter, &cmd);
+               if (!err) {
+                       beacon_state = cmd.rsp.arg[4];
+                       if (beacon_state == QLCNIC_BEACON_DISABLE)
+                               ahw->beacon_state = QLC_83XX_BEACON_OFF;
+                       else if (beacon_state == QLC_83XX_ENABLE_BEACON)
+                               ahw->beacon_state = QLC_83XX_BEACON_ON;
+               }
+       } else {
+               netdev_err(adapter->netdev, "Get beacon state failed, err=%d\n",
+                          err);
+       }
+
+       qlcnic_free_mbx_args(&cmd);
+
+       return;
+}
+
 int qlcnic_83xx_config_led(struct qlcnic_adapter *adapter, u32 state,
                           u32 beacon)
 {
index 34d291168b79d4c0723933d84a7d7f1dc002f7ce..4643b159df867b08603d6ec2c6545f44736cd84f 100644 (file)
@@ -381,6 +381,8 @@ enum qlcnic_83xx_states {
 
 /* LED configuration settings */
 #define QLC_83XX_ENABLE_BEACON         0xe
+#define QLC_83XX_BEACON_ON             1
+#define QLC_83XX_BEACON_OFF            0
 #define QLC_83XX_LED_RATE              0xff
 #define QLC_83XX_LED_ACT               (1 << 10)
 #define QLC_83XX_LED_MOD               (0 << 13)
@@ -559,6 +561,7 @@ void qlcnic_83xx_napi_del(struct qlcnic_adapter *);
 void qlcnic_83xx_napi_enable(struct qlcnic_adapter *);
 void qlcnic_83xx_napi_disable(struct qlcnic_adapter *);
 int qlcnic_83xx_config_led(struct qlcnic_adapter *, u32, u32);
+void qlcnic_83xx_get_beacon_state(struct qlcnic_adapter *);
 void qlcnic_ind_wr(struct qlcnic_adapter *, u32, u32);
 int qlcnic_ind_rd(struct qlcnic_adapter *, u32);
 int qlcnic_83xx_create_rx_ctx(struct qlcnic_adapter *);
index 18cc365bc7ea0dd520f2cae056ad68d99bc5385e..e96b76ddef4724131f05b32402799d351b534353 100644 (file)
@@ -1533,19 +1533,34 @@ int qlcnic_82xx_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate)
        return rv;
 }
 
-int qlcnic_get_beacon_state(struct qlcnic_adapter *adapter, u8 *h_state)
+void qlcnic_82xx_get_beacon_state(struct qlcnic_adapter *adapter)
 {
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct qlcnic_cmd_args cmd;
-       int err;
+       u8 beacon_state;
+       int err = 0;
 
-       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_GET_LED_STATUS);
-       if (!err) {
-               err = qlcnic_issue_cmd(adapter, &cmd);
-               if (!err)
-                       *h_state = cmd.rsp.arg[1];
+       if (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_BEACON) {
+               err = qlcnic_alloc_mbx_args(&cmd, adapter,
+                                           QLCNIC_CMD_GET_LED_STATUS);
+               if (!err) {
+                       err = qlcnic_issue_cmd(adapter, &cmd);
+                       if (err) {
+                               netdev_err(adapter->netdev,
+                                          "Failed to get current beacon state, err=%d\n",
+                                          err);
+                       } else {
+                               beacon_state = cmd.rsp.arg[1];
+                               if (beacon_state == QLCNIC_BEACON_DISABLE)
+                                       ahw->beacon_state = QLCNIC_BEACON_OFF;
+                               else if (beacon_state == QLCNIC_BEACON_EANBLE)
+                                       ahw->beacon_state = QLCNIC_BEACON_ON;
+                       }
+               }
+               qlcnic_free_mbx_args(&cmd);
        }
-       qlcnic_free_mbx_args(&cmd);
-       return err;
+
+       return;
 }
 
 void qlcnic_82xx_get_func_no(struct qlcnic_adapter *adapter)
index 13303e7d1ed7afaec0c5fd41bd530f435cbb62e9..0e739aed1bc621fd0e702388998325c6aab246c0 100644 (file)
@@ -169,6 +169,7 @@ int qlcnic_82xx_config_hw_lro(struct qlcnic_adapter *adapter, int);
 int qlcnic_82xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32);
 int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
                         struct net_device *netdev);
+void qlcnic_82xx_get_beacon_state(struct qlcnic_adapter *);
 void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter,
                               u64 *uaddr, u16 vlan_id);
 void qlcnic_82xx_config_intr_coalesce(struct qlcnic_adapter *adapter);
index eeec83a0e6640bfc62dacc93357e828b18e155d0..a57dfe4ad40e71ea82584d23e7f026fe17fa8001 100644 (file)
@@ -546,6 +546,7 @@ static struct qlcnic_hardware_ops qlcnic_hw_ops = {
        .io_error_detected              = qlcnic_82xx_io_error_detected,
        .io_slot_reset                  = qlcnic_82xx_io_slot_reset,
        .io_resume                      = qlcnic_82xx_io_resume,
+       .get_beacon_state               = qlcnic_82xx_get_beacon_state,
 };
 
 static int qlcnic_check_multi_tx_capability(struct qlcnic_adapter *adapter)
index c9b704deae9313285d42f10659ac33dd83291c79..1c8552f682d604fced1ae0f75b03d7cd4dbef317 100644 (file)
@@ -126,6 +126,8 @@ static int qlcnic_83xx_store_beacon(struct qlcnic_adapter *adapter,
        if (kstrtoul(buf, 2, &h_beacon))
                return -EINVAL;
 
+       qlcnic_get_beacon_state(adapter);
+
        if (ahw->beacon_state == h_beacon)
                return len;
 
@@ -157,7 +159,7 @@ static int qlcnic_82xx_store_beacon(struct qlcnic_adapter *adapter,
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        int err, drv_sds_rings = adapter->drv_sds_rings;
        u16 beacon;
-       u8 h_beacon_state, b_state, b_rate;
+       u8 b_state, b_rate;
 
        if (len != sizeof(u16))
                return QL_STATUS_INVALID_PARAM;
@@ -167,18 +169,7 @@ static int qlcnic_82xx_store_beacon(struct qlcnic_adapter *adapter,
        if (err)
                return err;
 
-       if (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_BEACON) {
-               err = qlcnic_get_beacon_state(adapter, &h_beacon_state);
-               if (err) {
-                       netdev_err(adapter->netdev,
-                                  "Failed to get current beacon state\n");
-               } else {
-                       if (h_beacon_state == QLCNIC_BEACON_DISABLE)
-                               ahw->beacon_state = 0;
-                       else if (h_beacon_state == QLCNIC_BEACON_EANBLE)
-                               ahw->beacon_state = 2;
-               }
-       }
+       qlcnic_get_beacon_state(adapter);
 
        if (ahw->beacon_state == b_state)
                return len;