]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
qlcnic: make local functions static
[karo-tx-linux.git] / drivers / net / ethernet / qlogic / qlcnic / qlcnic_83xx_hw.c
index 6055d397a29edf70317299e83966aba18b6ff5dc..6e10ac5bfc4000369315e18fcea0de82c621ca85 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/aer.h>
 
+static void __qlcnic_83xx_process_aen(struct qlcnic_adapter *);
+static int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *, u8);
+static void qlcnic_83xx_configure_mac(struct qlcnic_adapter *, u8 *, u8,
+                                     struct qlcnic_cmd_args *);
+static int qlcnic_83xx_get_port_config(struct qlcnic_adapter *);
+static irqreturn_t qlcnic_83xx_handle_aen(int, void *);
+static pci_ers_result_t qlcnic_83xx_io_error_detected(struct pci_dev *,
+                                                     pci_channel_state_t);
+static int qlcnic_83xx_set_port_config(struct qlcnic_adapter *);
+static pci_ers_result_t qlcnic_83xx_io_slot_reset(struct pci_dev *);
+static void qlcnic_83xx_io_resume(struct pci_dev *);
+static int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *, u8);
+static void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *);
+static int qlcnic_83xx_resume(struct qlcnic_adapter *);
+static int qlcnic_83xx_shutdown(struct pci_dev *);
+static void qlcnic_83xx_get_beacon_state(struct qlcnic_adapter *);
+
 #define RSS_HASHTYPE_IP_TCP            0x3
 #define QLC_83XX_FW_MBX_CMD            0
+#define QLC_SKIP_INACTIVE_PCI_REGS     7
 
 static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
        {QLCNIC_CMD_CONFIGURE_IP_ADDR, 6, 1},
@@ -34,7 +52,7 @@ static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
        {QLCNIC_CMD_READ_MAX_MTU, 4, 2},
        {QLCNIC_CMD_READ_MAX_LRO, 4, 2},
        {QLCNIC_CMD_MAC_ADDRESS, 4, 3},
-       {QLCNIC_CMD_GET_PCI_INFO, 1, 66},
+       {QLCNIC_CMD_GET_PCI_INFO, 1, 129},
        {QLCNIC_CMD_GET_NIC_INFO, 2, 19},
        {QLCNIC_CMD_SET_NIC_INFO, 32, 1},
        {QLCNIC_CMD_GET_ESWITCH_CAPABILITY, 4, 3},
@@ -68,7 +86,7 @@ static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
        {QLCNIC_CMD_CONFIG_VPORT, 4, 4},
        {QLCNIC_CMD_BC_EVENT_SETUP, 2, 1},
        {QLCNIC_CMD_DCB_QUERY_CAP, 1, 2},
-       {QLCNIC_CMD_DCB_QUERY_PARAM, 2, 50},
+       {QLCNIC_CMD_DCB_QUERY_PARAM, 1, 50},
 };
 
 const u32 qlcnic_83xx_ext_reg_tbl[] = {
@@ -180,7 +198,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 = {
@@ -289,6 +307,7 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter)
                if (qlcnic_sriov_vf_check(adapter))
                        return -EINVAL;
                num_msix = 1;
+               adapter->drv_tx_rings = QLCNIC_SINGLE_RING;
        }
        /* setup interrupt mapping table for fw */
        ahw->intr_tbl = vzalloc(num_msix *
@@ -315,12 +334,12 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter)
        return 0;
 }
 
-inline void qlcnic_83xx_clear_legacy_intr_mask(struct qlcnic_adapter *adapter)
+static inline void qlcnic_83xx_clear_legacy_intr_mask(struct qlcnic_adapter *adapter)
 {
        writel(0, adapter->tgt_mask_reg);
 }
 
-inline void qlcnic_83xx_set_legacy_intr_mask(struct qlcnic_adapter *adapter)
+static inline void qlcnic_83xx_set_legacy_intr_mask(struct qlcnic_adapter *adapter)
 {
        if (adapter->tgt_mask_reg)
                writel(1, adapter->tgt_mask_reg);
@@ -340,7 +359,7 @@ void qlcnic_83xx_disable_intr(struct qlcnic_adapter *adapter,
        writel(1, sds_ring->crb_intr_mask);
 }
 
-inline void qlcnic_83xx_enable_legacy_msix_mbx_intr(struct qlcnic_adapter
+static inline void qlcnic_83xx_enable_legacy_msix_mbx_intr(struct qlcnic_adapter
                                                    *adapter)
 {
        u32 mask;
@@ -634,10 +653,10 @@ int qlcnic_83xx_get_port_info(struct qlcnic_adapter *adapter)
        return status;
 }
 
-void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *adapter)
+static void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
-       u16 act_pci_fn = ahw->act_pci_func;
+       u16 act_pci_fn = ahw->total_nic_func;
        u16 count;
 
        ahw->max_mc_count = QLC_83XX_MAX_MC_COUNT;
@@ -869,7 +888,7 @@ static void qlcnic_83xx_handle_idc_comp_aen(struct qlcnic_adapter *adapter,
        return;
 }
 
-void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
+static void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        u32 event[QLC_83XX_MBX_AEN_CNT];
@@ -1386,6 +1405,33 @@ out:
        netif_device_attach(netdev);
 }
 
+static 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)
 {
@@ -1498,8 +1544,7 @@ int  qlcnic_83xx_set_led(struct net_device *netdev,
        return err;
 }
 
-void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *adapter,
-                                      int enable)
+void qlcnic_83xx_initialize_nic(struct qlcnic_adapter *adapter, int enable)
 {
        struct qlcnic_cmd_args cmd;
        int status;
@@ -1507,21 +1552,21 @@ void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *adapter,
        if (qlcnic_sriov_vf_check(adapter))
                return;
 
-       if (enable) {
+       if (enable)
                status = qlcnic_alloc_mbx_args(&cmd, adapter,
                                               QLCNIC_CMD_INIT_NIC_FUNC);
-               if (status)
-                       return;
-
-               cmd.req.arg[1] = BIT_0 | BIT_31;
-       } else {
+       else
                status = qlcnic_alloc_mbx_args(&cmd, adapter,
                                               QLCNIC_CMD_STOP_NIC_FUNC);
-               if (status)
-                       return;
 
-               cmd.req.arg[1] = BIT_0 | BIT_31;
-       }
+       if (status)
+               return;
+
+       cmd.req.arg[1] = QLC_REGISTER_LB_IDC | QLC_INIT_FW_RESOURCES;
+
+       if (adapter->dcb)
+               cmd.req.arg[1] |= QLC_REGISTER_DCB_AEN;
+
        status = qlcnic_issue_cmd(adapter, &cmd);
        if (status)
                dev_err(&adapter->pdev->dev,
@@ -1531,7 +1576,7 @@ void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *adapter,
        qlcnic_free_mbx_args(&cmd);
 }
 
-int qlcnic_83xx_set_port_config(struct qlcnic_adapter *adapter)
+static int qlcnic_83xx_set_port_config(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_cmd_args cmd;
        int err;
@@ -1548,7 +1593,7 @@ int qlcnic_83xx_set_port_config(struct qlcnic_adapter *adapter)
        return err;
 }
 
-int qlcnic_83xx_get_port_config(struct qlcnic_adapter *adapter)
+static int qlcnic_83xx_get_port_config(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_cmd_args cmd;
        int err;
@@ -1590,7 +1635,9 @@ static void qlcnic_83xx_set_interface_id_promisc(struct qlcnic_adapter *adapter,
                                                 u32 *interface_id)
 {
        if (qlcnic_sriov_pf_check(adapter)) {
+               qlcnic_alloc_lb_filters_mem(adapter);
                qlcnic_pf_set_interface_id_promisc(adapter, interface_id);
+               adapter->rx_mac_learn = 1;
        } else {
                if (!qlcnic_sriov_vf_check(adapter))
                        *interface_id = adapter->recv_ctx->context_id << 16;
@@ -1617,7 +1664,11 @@ int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode)
 
        cmd->type = QLC_83XX_MBX_CMD_NO_WAIT;
        qlcnic_83xx_set_interface_id_promisc(adapter, &temp);
-       cmd->req.arg[1] = (mode ? 1 : 0) | temp;
+
+       if (qlcnic_84xx_check(adapter) && qlcnic_sriov_pf_check(adapter))
+               mode = VPORT_MISS_MODE_ACCEPT_ALL;
+
+       cmd->req.arg[1] = mode | temp;
        err = qlcnic_issue_cmd(adapter, cmd);
        if (!err)
                return err;
@@ -1684,12 +1735,6 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
                }
        } while ((adapter->ahw->linkup && ahw->has_link_events) != 1);
 
-       /* Make sure carrier is off and queue is stopped during loopback */
-       if (netif_running(netdev)) {
-               netif_carrier_off(netdev);
-               netif_tx_stop_all_queues(netdev);
-       }
-
        ret = qlcnic_do_lb_test(adapter, mode);
 
        qlcnic_83xx_clear_lb_mode(adapter, mode);
@@ -1717,7 +1762,7 @@ static void qlcnic_extend_lb_idc_cmpltn_wait(struct qlcnic_adapter *adapter,
        ahw->extend_lb_time = 0;
 }
 
-int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
+static int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct net_device *netdev = adapter->netdev;
@@ -1786,7 +1831,7 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
        return status;
 }
 
-int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
+static int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        u32 config = ahw->port_config, max_wait_count;
@@ -2121,6 +2166,7 @@ static void qlcnic_83xx_handle_link_aen(struct qlcnic_adapter *adapter,
        ahw->link_autoneg = MSB(MSW(data[3]));
        ahw->module_type = MSB(LSW(data[3]));
        ahw->has_link_events = 1;
+       ahw->lb_mode = data[4] & QLCNIC_LB_MODE_MASK;
        qlcnic_advert_link_change(adapter, link_status);
 }
 
@@ -2273,11 +2319,37 @@ out:
        return err;
 }
 
+int qlcnic_get_pci_func_type(struct qlcnic_adapter *adapter, u16 type,
+                            u16 *nic, u16 *fcoe, u16 *iscsi)
+{
+       struct device *dev = &adapter->pdev->dev;
+       int err = 0;
+
+       switch (type) {
+       case QLCNIC_TYPE_NIC:
+               (*nic)++;
+               break;
+       case QLCNIC_TYPE_FCOE:
+               (*fcoe)++;
+               break;
+       case QLCNIC_TYPE_ISCSI:
+               (*iscsi)++;
+               break;
+       default:
+               dev_err(dev, "%s: Unknown PCI type[%x]\n",
+                       __func__, type);
+               err = -EIO;
+       }
+
+       return err;
+}
+
 int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *adapter,
                             struct qlcnic_pci_info *pci_info)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct device *dev = &adapter->pdev->dev;
+       u16 nic = 0, fcoe = 0, iscsi = 0;
        struct qlcnic_cmd_args cmd;
        int i, err = 0, j = 0;
        u32 temp;
@@ -2288,16 +2360,20 @@ int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *adapter,
 
        err = qlcnic_issue_cmd(adapter, &cmd);
 
-       ahw->act_pci_func = 0;
+       ahw->total_nic_func = 0;
        if (err == QLCNIC_RCODE_SUCCESS) {
                ahw->max_pci_func = cmd.rsp.arg[1] & 0xFF;
-               for (i = 2, j = 0; j < QLCNIC_MAX_PCI_FUNC; j++, pci_info++) {
+               for (i = 2, j = 0; j < ahw->max_vnic_func; j++, pci_info++) {
                        pci_info->id = cmd.rsp.arg[i] & 0xFFFF;
                        pci_info->active = (cmd.rsp.arg[i] & 0xFFFF0000) >> 16;
                        i++;
+                       if (!pci_info->active) {
+                               i += QLC_SKIP_INACTIVE_PCI_REGS;
+                               continue;
+                       }
                        pci_info->type = cmd.rsp.arg[i] & 0xFFFF;
-                       if (pci_info->type == QLCNIC_TYPE_NIC)
-                               ahw->act_pci_func++;
+                       err = qlcnic_get_pci_func_type(adapter, pci_info->type,
+                                                      &nic, &fcoe, &iscsi);
                        temp = (cmd.rsp.arg[i] & 0xFFFF0000) >> 16;
                        pci_info->default_port = temp;
                        i++;
@@ -2315,6 +2391,13 @@ int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *adapter,
                err = -EIO;
        }
 
+       ahw->total_nic_func = nic;
+       ahw->total_pci_func = nic + fcoe + iscsi;
+       if (ahw->total_nic_func == 0 || ahw->total_pci_func == 0) {
+               dev_err(dev, "%s: Invalid function count: total nic func[%x], total pci func[%x]\n",
+                       __func__, ahw->total_nic_func, ahw->total_pci_func);
+               err = -EIO;
+       }
        qlcnic_free_mbx_args(&cmd);
 
        return err;
@@ -3486,7 +3569,7 @@ int qlcnic_83xx_shutdown(struct pci_dev *pdev)
        return 0;
 }
 
-int qlcnic_83xx_resume(struct qlcnic_adapter *adapter)
+static int qlcnic_83xx_resume(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct qlc_83xx_idc *idc = &ahw->idc;