aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qlcnic/qlcnic_ctx.c
diff options
context:
space:
mode:
authorRajesh K Borundia <rajesh.borundia@qlogic.com>2010-06-29 04:01:20 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-29 18:12:36 -0400
commit346fe763d7706cccdf90ba24f04f0facdd79b91a (patch)
tree45ba5093b60ca7ac2df3b56c882fd97fd3413deb /drivers/net/qlcnic/qlcnic_ctx.c
parent45918e2fe582d845a2649ffa015754ae44be9a8b (diff)
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.c90
1 files changed, 25 insertions, 65 deletions
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c
index 7969a7a87c85..cdd44b4136ae 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)
611} 611}
612 612
613/* Get info of a NIC partition */ 613/* Get info of a NIC partition */
614int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id) 614int qlcnic_get_nic_info(struct qlcnic_adapter *adapter,
615 struct qlcnic_info *npar_info, u8 func_id)
615{ 616{
616 int err; 617 int err;
617 dma_addr_t nic_dma_t; 618 dma_addr_t nic_dma_t;
@@ -635,29 +636,23 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id)
635 QLCNIC_CDRP_CMD_GET_NIC_INFO); 636 QLCNIC_CDRP_CMD_GET_NIC_INFO);
636 637
637 if (err == QLCNIC_RCODE_SUCCESS) { 638 if (err == QLCNIC_RCODE_SUCCESS) {
638 adapter->physical_port = le16_to_cpu(nic_info->phys_port); 639 npar_info->phys_port = le16_to_cpu(nic_info->phys_port);
639 adapter->switch_mode = le16_to_cpu(nic_info->switch_mode); 640 npar_info->switch_mode = le16_to_cpu(nic_info->switch_mode);
640 adapter->max_tx_ques = le16_to_cpu(nic_info->max_tx_ques); 641 npar_info->max_tx_ques = le16_to_cpu(nic_info->max_tx_ques);
641 adapter->max_rx_ques = le16_to_cpu(nic_info->max_rx_ques); 642 npar_info->max_rx_ques = le16_to_cpu(nic_info->max_rx_ques);
642 adapter->min_tx_bw = le16_to_cpu(nic_info->min_tx_bw); 643 npar_info->min_tx_bw = le16_to_cpu(nic_info->min_tx_bw);
643 adapter->max_tx_bw = le16_to_cpu(nic_info->max_tx_bw); 644 npar_info->max_tx_bw = le16_to_cpu(nic_info->max_tx_bw);
644 adapter->max_mtu = le16_to_cpu(nic_info->max_mtu); 645 npar_info->capabilities = le32_to_cpu(nic_info->capabilities);
645 adapter->capabilities = le32_to_cpu(nic_info->capabilities); 646 npar_info->max_mtu = le16_to_cpu(nic_info->max_mtu);
646 adapter->max_mac_filters = nic_info->max_mac_filters;
647
648 if (adapter->capabilities & BIT_6)
649 adapter->flags |= QLCNIC_ESWITCH_ENABLED;
650 else
651 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED;
652 647
653 dev_info(&adapter->pdev->dev, 648 dev_info(&adapter->pdev->dev,
654 "phy port: %d switch_mode: %d,\n" 649 "phy port: %d switch_mode: %d,\n"
655 "\tmax_tx_q: %d max_rx_q: %d min_tx_bw: 0x%x,\n" 650 "\tmax_tx_q: %d max_rx_q: %d min_tx_bw: 0x%x,\n"
656 "\tmax_tx_bw: 0x%x max_mtu:0x%x, capabilities: 0x%x\n", 651 "\tmax_tx_bw: 0x%x max_mtu:0x%x, capabilities: 0x%x\n",
657 adapter->physical_port, adapter->switch_mode, 652 npar_info->phys_port, npar_info->switch_mode,
658 adapter->max_tx_ques, adapter->max_rx_ques, 653 npar_info->max_tx_ques, npar_info->max_rx_ques,
659 adapter->min_tx_bw, adapter->max_tx_bw, 654 npar_info->min_tx_bw, npar_info->max_tx_bw,
660 adapter->max_mtu, adapter->capabilities); 655 npar_info->max_mtu, npar_info->capabilities);
661 } else { 656 } else {
662 dev_err(&adapter->pdev->dev, 657 dev_err(&adapter->pdev->dev,
663 "Failed to get nic info%d\n", err); 658 "Failed to get nic info%d\n", err);
@@ -672,7 +667,6 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, u8 func_id)
672int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) 667int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
673{ 668{
674 int err = -EIO; 669 int err = -EIO;
675 u32 func_state;
676 dma_addr_t nic_dma_t; 670 dma_addr_t nic_dma_t;
677 void *nic_info_addr; 671 void *nic_info_addr;
678 struct qlcnic_info *nic_info; 672 struct qlcnic_info *nic_info;
@@ -681,17 +675,6 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
681 if (adapter->op_mode != QLCNIC_MGMT_FUNC) 675 if (adapter->op_mode != QLCNIC_MGMT_FUNC)
682 return err; 676 return err;
683 677
684 if (qlcnic_api_lock(adapter))
685 return err;
686
687 func_state = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT);
688 if (QLC_DEV_CHECK_ACTIVE(func_state, nic->pci_func)) {
689 qlcnic_api_unlock(adapter);
690 return err;
691 }
692
693 qlcnic_api_unlock(adapter);
694
695 nic_info_addr = pci_alloc_consistent(adapter->pdev, nic_size, 678 nic_info_addr = pci_alloc_consistent(adapter->pdev, nic_size,
696 &nic_dma_t); 679 &nic_dma_t);
697 if (!nic_info_addr) 680 if (!nic_info_addr)
@@ -716,7 +699,7 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
716 adapter->fw_hal_version, 699 adapter->fw_hal_version,
717 MSD(nic_dma_t), 700 MSD(nic_dma_t),
718 LSD(nic_dma_t), 701 LSD(nic_dma_t),
719 nic_size, 702 ((nic->pci_func << 16) | nic_size),
720 QLCNIC_CDRP_CMD_SET_NIC_INFO); 703 QLCNIC_CDRP_CMD_SET_NIC_INFO);
721 704
722 if (err != QLCNIC_RCODE_SUCCESS) { 705 if (err != QLCNIC_RCODE_SUCCESS) {
@@ -730,7 +713,8 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic)
730} 713}
731 714
732/* Get PCI Info of a partition */ 715/* Get PCI Info of a partition */
733int qlcnic_get_pci_info(struct qlcnic_adapter *adapter) 716int qlcnic_get_pci_info(struct qlcnic_adapter *adapter,
717 struct qlcnic_pci_info *pci_info)
734{ 718{
735 int err = 0, i; 719 int err = 0, i;
736 dma_addr_t pci_info_dma_t; 720 dma_addr_t pci_info_dma_t;
@@ -745,21 +729,6 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter)
745 return -ENOMEM; 729 return -ENOMEM;
746 memset(pci_info_addr, 0, pci_size); 730 memset(pci_info_addr, 0, pci_size);
747 731
748 if (!adapter->npars)
749 adapter->npars = kzalloc(pci_size, GFP_KERNEL);
750 if (!adapter->npars) {
751 err = -ENOMEM;
752 goto err_npar;
753 }
754
755 if (!adapter->eswitch)
756 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
757 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
758 if (!adapter->eswitch) {
759 err = -ENOMEM;
760 goto err_eswitch;
761 }
762
763 npar = (struct qlcnic_pci_info *) pci_info_addr; 732 npar = (struct qlcnic_pci_info *) pci_info_addr;
764 err = qlcnic_issue_cmd(adapter, 733 err = qlcnic_issue_cmd(adapter,
765 adapter->ahw.pci_func, 734 adapter->ahw.pci_func,
@@ -770,31 +739,24 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter)
770 QLCNIC_CDRP_CMD_GET_PCI_INFO); 739 QLCNIC_CDRP_CMD_GET_PCI_INFO);
771 740
772 if (err == QLCNIC_RCODE_SUCCESS) { 741 if (err == QLCNIC_RCODE_SUCCESS) {
773 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++) { 742 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) {
774 adapter->npars[i].id = le32_to_cpu(npar->id); 743 pci_info->id = le32_to_cpu(npar->id);
775 adapter->npars[i].active = le32_to_cpu(npar->active); 744 pci_info->active = le32_to_cpu(npar->active);
776 adapter->npars[i].type = le32_to_cpu(npar->type); 745 pci_info->type = le32_to_cpu(npar->type);
777 adapter->npars[i].default_port = 746 pci_info->default_port =
778 le32_to_cpu(npar->default_port); 747 le32_to_cpu(npar->default_port);
779 adapter->npars[i].tx_min_bw = 748 pci_info->tx_min_bw =
780 le32_to_cpu(npar->tx_min_bw); 749 le32_to_cpu(npar->tx_min_bw);
781 adapter->npars[i].tx_max_bw = 750 pci_info->tx_max_bw =
782 le32_to_cpu(npar->tx_max_bw); 751 le32_to_cpu(npar->tx_max_bw);
783 memcpy(adapter->npars[i].mac, npar->mac, ETH_ALEN); 752 memcpy(pci_info->mac, npar->mac, ETH_ALEN);
784 } 753 }
785 } else { 754 } else {
786 dev_err(&adapter->pdev->dev, 755 dev_err(&adapter->pdev->dev,
787 "Failed to get PCI Info%d\n", err); 756 "Failed to get PCI Info%d\n", err);
788 kfree(adapter->npars);
789 err = -EIO; 757 err = -EIO;
790 } 758 }
791 goto err_npar;
792
793err_eswitch:
794 kfree(adapter->npars);
795 adapter->npars = NULL;
796 759
797err_npar:
798 pci_free_consistent(adapter->pdev, pci_size, pci_info_addr, 760 pci_free_consistent(adapter->pdev, pci_size, pci_info_addr,
799 pci_info_dma_t); 761 pci_info_dma_t);
800 return err; 762 return err;
@@ -1012,9 +974,7 @@ int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, u8 id,
1012 if (err != QLCNIC_RCODE_SUCCESS) { 974 if (err != QLCNIC_RCODE_SUCCESS) {
1013 dev_err(&adapter->pdev->dev, 975 dev_err(&adapter->pdev->dev,
1014 "Failed to configure eswitch port%d\n", eswitch->port); 976 "Failed to configure eswitch port%d\n", eswitch->port);
1015 eswitch->flags |= QLCNIC_SWITCH_ENABLE;
1016 } else { 977 } else {
1017 eswitch->flags &= ~QLCNIC_SWITCH_ENABLE;
1018 dev_info(&adapter->pdev->dev, 978 dev_info(&adapter->pdev->dev,
1019 "Configured eSwitch for port %d\n", eswitch->port); 979 "Configured eSwitch for port %d\n", eswitch->port);
1020 } 980 }