diff options
author | Rajesh K Borundia <rajesh.borundia@qlogic.com> | 2010-06-29 08:01:20 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-29 22:12:36 (GMT) |
commit | 346fe763d7706cccdf90ba24f04f0facdd79b91a (patch) | |
tree | 45ba5093b60ca7ac2df3b56c882fd97fd3413deb /drivers/net/qlcnic/qlcnic_ctx.c | |
parent | 45918e2fe582d845a2649ffa015754ae44be9a8b (diff) | |
download | linux-346fe763d7706cccdf90ba24f04f0facdd79b91a.tar.xz |
qlcnic: Add support for configuring eswitch and npars
Following changes are made:
1.Obtain capabilities of Nic partition.
2.Configure tx bandwidth of particular Nic partition.
3.Configure the eswitch for setting port mirroring, enable mac
learning, promiscous mode.
Signed-off-by: Rajesh K Borundia <rajesh.borundia@qlogic.com>
Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/qlcnic/qlcnic_ctx.c')
-rw-r--r-- | drivers/net/qlcnic/qlcnic_ctx.c | 90 |
1 files changed, 25 insertions, 65 deletions
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c index 7969a7a..cdd44b4 100644 --- a/drivers/net/qlcnic/qlcnic_ctx.c +++ b/drivers/net/qlcnic/qlcnic_ctx.c @@ -611,7 +611,8 @@ int qlcnic_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac) } /* Get info of a NIC partition */ -int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id) +int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, + struct qlcnic_info *npar_info, u8 func_id) { int err; dma_addr_t nic_dma_t; @@ -635,29 +636,23 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id) QLCNIC_CDRP_CMD_GET_NIC_INFO); if (err == QLCNIC_RCODE_SUCCESS) { - adapter->physical_port = le16_to_cpu(nic_info->phys_port); - adapter->switch_mode = le16_to_cpu(nic_info->switch_mode); - adapter->max_tx_ques = le16_to_cpu(nic_info->max_tx_ques); - adapter->max_rx_ques = le16_to_cpu(nic_info->max_rx_ques); - adapter->min_tx_bw = le16_to_cpu(nic_info->min_tx_bw); - adapter->max_tx_bw = le16_to_cpu(nic_info->max_tx_bw); - adapter->max_mtu = le16_to_cpu(nic_info->max_mtu); - adapter->capabilities = le32_to_cpu(nic_info->capabilities); - adapter->max_mac_filters = nic_info->max_mac_filters; - - if (adapter->capabilities & BIT_6) - adapter->flags |= QLCNIC_ESWITCH_ENABLED; - else - adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; + npar_info->phys_port = le16_to_cpu(nic_info->phys_port); + npar_info->switch_mode = le16_to_cpu(nic_info->switch_mode); + npar_info->max_tx_ques = le16_to_cpu(nic_info->max_tx_ques); + npar_info->max_rx_ques = le16_to_cpu(nic_info->max_rx_ques); + npar_info->min_tx_bw = le16_to_cpu(nic_info->min_tx_bw); + npar_info->max_tx_bw = le16_to_cpu(nic_info->max_tx_bw); + npar_info->capabilities = le32_to_cpu(nic_info->capabilities); + npar_info->max_mtu = le16_to_cpu(nic_info->max_mtu); dev_info(&adapter->pdev->dev, "phy port: %d switch_mode: %d,\n" "\tmax_tx_q: %d max_rx_q: %d min_tx_bw: 0x%x,\n" "\tmax_tx_bw: 0x%x max_mtu:0x%x, capabilities: 0x%x\n", - adapter->physical_port, adapter->switch_mode, - adapter->max_tx_ques, adapter->max_rx_ques, - adapter->min_tx_bw, adapter->max_tx_bw, - adapter->max_mtu, adapter->capabilities); + npar_info->phys_port, npar_info->switch_mode, + npar_info->max_tx_ques, npar_info->max_rx_ques, + npar_info->min_tx_bw, npar_info->max_tx_bw, + npar_info->max_mtu, npar_info->capabilities); } else { dev_err(&adapter->pdev->dev, "Failed to get nic info%d\n", err); @@ -672,7 +667,6 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id) int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) { int err = -EIO; - u32 func_state; dma_addr_t nic_dma_t; void *nic_info_addr; struct qlcnic_info *nic_info; @@ -681,17 +675,6 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) if (adapter->op_mode != QLCNIC_MGMT_FUNC) return err; - if (qlcnic_api_lock(adapter)) - return err; - - func_state = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); - if (QLC_DEV_CHECK_ACTIVE(func_state, nic->pci_func)) { - qlcnic_api_unlock(adapter); - return err; - } - - qlcnic_api_unlock(adapter); - nic_info_addr = pci_alloc_consistent(adapter->pdev, nic_size, &nic_dma_t); if (!nic_info_addr) @@ -716,7 +699,7 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) adapter->fw_hal_version, MSD(nic_dma_t), LSD(nic_dma_t), - nic_size, + ((nic->pci_func << 16) | nic_size), QLCNIC_CDRP_CMD_SET_NIC_INFO); if (err != QLCNIC_RCODE_SUCCESS) { @@ -730,7 +713,8 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) } /* Get PCI Info of a partition */ -int qlcnic_get_pci_info(struct qlcnic_adapter *adapter) +int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, + struct qlcnic_pci_info *pci_info) { int err = 0, i; dma_addr_t pci_info_dma_t; @@ -745,21 +729,6 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter) return -ENOMEM; memset(pci_info_addr, 0, pci_size); - if (!adapter->npars) - adapter->npars = kzalloc(pci_size, GFP_KERNEL); - if (!adapter->npars) { - err = -ENOMEM; - goto err_npar; - } - - if (!adapter->eswitch) - adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * - QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); - if (!adapter->eswitch) { - err = -ENOMEM; - goto err_eswitch; - } - npar = (struct qlcnic_pci_info *) pci_info_addr; err = qlcnic_issue_cmd(adapter, adapter->ahw.pci_func, @@ -770,31 +739,24 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter) QLCNIC_CDRP_CMD_GET_PCI_INFO); if (err == QLCNIC_RCODE_SUCCESS) { - for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++) { - adapter->npars[i].id = le32_to_cpu(npar->id); - adapter->npars[i].active = le32_to_cpu(npar->active); - adapter->npars[i].type = le32_to_cpu(npar->type); - adapter->npars[i].default_port = + for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) { + pci_info->id = le32_to_cpu(npar->id); + pci_info->active = le32_to_cpu(npar->active); + pci_info->type = le32_to_cpu(npar->type); + pci_info->default_port = le32_to_cpu(npar->default_port); - adapter->npars[i].tx_min_bw = + pci_info->tx_min_bw = le32_to_cpu(npar->tx_min_bw); - adapter->npars[i].tx_max_bw = + pci_info->tx_max_bw = le32_to_cpu(npar->tx_max_bw); - memcpy(adapter->npars[i].mac, npar->mac, ETH_ALEN); + memcpy(pci_info->mac, npar->mac, ETH_ALEN); } } else { dev_err(&adapter->pdev->dev, "Failed to get PCI Info%d\n", err); - kfree(adapter->npars); err = -EIO; } - goto err_npar; - -err_eswitch: - kfree(adapter->npars); - adapter->npars = NULL; -err_npar: pci_free_consistent(adapter->pdev, pci_size, pci_info_addr, pci_info_dma_t); return err; @@ -1012,9 +974,7 @@ int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, u8 id, if (err != QLCNIC_RCODE_SUCCESS) { dev_err(&adapter->pdev->dev, "Failed to configure eswitch port%d\n", eswitch->port); - eswitch->flags |= QLCNIC_SWITCH_ENABLE; } else { - eswitch->flags &= ~QLCNIC_SWITCH_ENABLE; dev_info(&adapter->pdev->dev, "Configured eSwitch for port %d\n", eswitch->port); } |