diff options
author | Ajit Khaparde <ajitk@serverengines.com> | 2010-07-22 21:52:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-23 15:41:41 -0400 |
commit | e1d187353fc0597d24cf3169b1bbc1776058e883 (patch) | |
tree | efde8346b78eae97b743fb05b0e13ea3711e8421 /drivers/net/benet | |
parent | 1da87b7fafebb7874622602f79a5fec0425aede7 (diff) |
be2net: code to support tx rate configuration on virtual functions
Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet')
-rw-r--r-- | drivers/net/benet/be.h | 1 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.c | 33 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 18 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 27 |
4 files changed, 78 insertions, 1 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index f693b9ed68a4..8cfe3c4fea04 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -225,6 +225,7 @@ struct be_vf_cfg { | |||
225 | u32 vf_if_handle; | 225 | u32 vf_if_handle; |
226 | u32 vf_pmac_id; | 226 | u32 vf_pmac_id; |
227 | u16 vf_vlan_tag; | 227 | u16 vf_vlan_tag; |
228 | u32 vf_tx_rate; | ||
228 | }; | 229 | }; |
229 | 230 | ||
230 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ | 231 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 344e062b7f25..408e1f2dd8e8 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -1730,3 +1730,36 @@ err: | |||
1730 | spin_unlock_bh(&adapter->mcc_lock); | 1730 | spin_unlock_bh(&adapter->mcc_lock); |
1731 | return status; | 1731 | return status; |
1732 | } | 1732 | } |
1733 | |||
1734 | int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain) | ||
1735 | { | ||
1736 | struct be_mcc_wrb *wrb; | ||
1737 | struct be_cmd_req_set_qos *req; | ||
1738 | int status; | ||
1739 | |||
1740 | spin_lock_bh(&adapter->mcc_lock); | ||
1741 | |||
1742 | wrb = wrb_from_mccq(adapter); | ||
1743 | if (!wrb) { | ||
1744 | status = -EBUSY; | ||
1745 | goto err; | ||
1746 | } | ||
1747 | |||
1748 | req = embedded_payload(wrb); | ||
1749 | |||
1750 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, | ||
1751 | OPCODE_COMMON_SET_QOS); | ||
1752 | |||
1753 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
1754 | OPCODE_COMMON_SET_QOS, sizeof(*req)); | ||
1755 | |||
1756 | req->hdr.domain = domain; | ||
1757 | req->valid_bits = BE_QOS_BITS_NIC; | ||
1758 | req->max_bps_nic = bps; | ||
1759 | |||
1760 | status = be_mcc_notify_wait(adapter); | ||
1761 | |||
1762 | err: | ||
1763 | spin_unlock_bh(&adapter->mcc_lock); | ||
1764 | return status; | ||
1765 | } | ||
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index 912a0586f060..3b69e71d7d03 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -124,6 +124,7 @@ struct be_mcc_mailbox { | |||
124 | #define OPCODE_COMMON_CQ_CREATE 12 | 124 | #define OPCODE_COMMON_CQ_CREATE 12 |
125 | #define OPCODE_COMMON_EQ_CREATE 13 | 125 | #define OPCODE_COMMON_EQ_CREATE 13 |
126 | #define OPCODE_COMMON_MCC_CREATE 21 | 126 | #define OPCODE_COMMON_MCC_CREATE 21 |
127 | #define OPCODE_COMMON_SET_QOS 28 | ||
127 | #define OPCODE_COMMON_SEEPROM_READ 30 | 128 | #define OPCODE_COMMON_SEEPROM_READ 30 |
128 | #define OPCODE_COMMON_NTWK_RX_FILTER 34 | 129 | #define OPCODE_COMMON_NTWK_RX_FILTER 34 |
129 | #define OPCODE_COMMON_GET_FW_VERSION 35 | 130 | #define OPCODE_COMMON_GET_FW_VERSION 35 |
@@ -894,6 +895,22 @@ struct be_cmd_resp_get_phy_info { | |||
894 | u32 future_use[4]; | 895 | u32 future_use[4]; |
895 | }; | 896 | }; |
896 | 897 | ||
898 | /*********************** Set QOS ***********************/ | ||
899 | |||
900 | #define BE_QOS_BITS_NIC 1 | ||
901 | |||
902 | struct be_cmd_req_set_qos { | ||
903 | struct be_cmd_req_hdr hdr; | ||
904 | u32 valid_bits; | ||
905 | u32 max_bps_nic; | ||
906 | u32 rsvd[7]; | ||
907 | }; | ||
908 | |||
909 | struct be_cmd_resp_set_qos { | ||
910 | struct be_cmd_resp_hdr hdr; | ||
911 | u32 rsvd; | ||
912 | }; | ||
913 | |||
897 | extern int be_pci_fnum_get(struct be_adapter *adapter); | 914 | extern int be_pci_fnum_get(struct be_adapter *adapter); |
898 | extern int be_cmd_POST(struct be_adapter *adapter); | 915 | extern int be_cmd_POST(struct be_adapter *adapter); |
899 | extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, | 916 | extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
@@ -974,4 +991,5 @@ extern int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num, | |||
974 | u8 loopback_type, u8 enable); | 991 | u8 loopback_type, u8 enable); |
975 | extern int be_cmd_get_phy_info(struct be_adapter *adapter, | 992 | extern int be_cmd_get_phy_info(struct be_adapter *adapter, |
976 | struct be_dma_mem *cmd); | 993 | struct be_dma_mem *cmd); |
994 | extern int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain); | ||
977 | 995 | ||
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 46f087e3422b..79adcdd8fc5c 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -695,7 +695,7 @@ static int be_get_vf_config(struct net_device *netdev, int vf, | |||
695 | return -EINVAL; | 695 | return -EINVAL; |
696 | 696 | ||
697 | vi->vf = vf; | 697 | vi->vf = vf; |
698 | vi->tx_rate = 0; | 698 | vi->tx_rate = adapter->vf_cfg[vf].vf_tx_rate; |
699 | vi->vlan = adapter->vf_cfg[vf].vf_vlan_tag; | 699 | vi->vlan = adapter->vf_cfg[vf].vf_vlan_tag; |
700 | vi->qos = 0; | 700 | vi->qos = 0; |
701 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); | 701 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); |
@@ -731,6 +731,30 @@ static int be_set_vf_vlan(struct net_device *netdev, | |||
731 | return status; | 731 | return status; |
732 | } | 732 | } |
733 | 733 | ||
734 | static int be_set_vf_tx_rate(struct net_device *netdev, | ||
735 | int vf, int rate) | ||
736 | { | ||
737 | struct be_adapter *adapter = netdev_priv(netdev); | ||
738 | int status = 0; | ||
739 | |||
740 | if (!adapter->sriov_enabled) | ||
741 | return -EPERM; | ||
742 | |||
743 | if ((vf >= num_vfs) || (rate < 0)) | ||
744 | return -EINVAL; | ||
745 | |||
746 | if (rate > 10000) | ||
747 | rate = 10000; | ||
748 | |||
749 | adapter->vf_cfg[vf].vf_tx_rate = rate; | ||
750 | status = be_cmd_set_qos(adapter, rate / 10, vf); | ||
751 | |||
752 | if (status) | ||
753 | dev_info(&adapter->pdev->dev, | ||
754 | "tx rate %d on VF %d failed\n", rate, vf); | ||
755 | return status; | ||
756 | } | ||
757 | |||
734 | static void be_rx_rate_update(struct be_adapter *adapter) | 758 | static void be_rx_rate_update(struct be_adapter *adapter) |
735 | { | 759 | { |
736 | struct be_drvr_stats *stats = drvr_stats(adapter); | 760 | struct be_drvr_stats *stats = drvr_stats(adapter); |
@@ -2256,6 +2280,7 @@ static struct net_device_ops be_netdev_ops = { | |||
2256 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, | 2280 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, |
2257 | .ndo_set_vf_mac = be_set_vf_mac, | 2281 | .ndo_set_vf_mac = be_set_vf_mac, |
2258 | .ndo_set_vf_vlan = be_set_vf_vlan, | 2282 | .ndo_set_vf_vlan = be_set_vf_vlan, |
2283 | .ndo_set_vf_tx_rate = be_set_vf_tx_rate, | ||
2259 | .ndo_get_vf_config = be_get_vf_config | 2284 | .ndo_get_vf_config = be_get_vf_config |
2260 | }; | 2285 | }; |
2261 | 2286 | ||