diff options
author | Ajit Khaparde <ajitk@serverengines.com> | 2010-07-22 21:50:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-23 15:40:53 -0400 |
commit | 64600ea5f389858e183d3739776f4667265cc77f (patch) | |
tree | 48ae1fda8c3a4628438ceba78418e65d2deb7e34 /drivers | |
parent | 9cd9000bdee9131ffd2ce92ca6ef9c86467edd25 (diff) |
be2net: add support to get vf config
Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/benet/be.h | 9 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 51 |
2 files changed, 47 insertions, 13 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index c730bd64628a..a8e95da23f7b 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -220,6 +220,12 @@ struct be_rx_obj { | |||
220 | struct be_rx_page_info page_info_tbl[RX_Q_LEN]; | 220 | struct be_rx_page_info page_info_tbl[RX_Q_LEN]; |
221 | }; | 221 | }; |
222 | 222 | ||
223 | struct be_vf_cfg { | ||
224 | unsigned char vf_mac_addr[ETH_ALEN]; | ||
225 | u32 vf_if_handle; | ||
226 | u32 vf_pmac_id; | ||
227 | }; | ||
228 | |||
223 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ | 229 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ |
224 | #define BE_INVALID_PMAC_ID 0xffffffff | 230 | #define BE_INVALID_PMAC_ID 0xffffffff |
225 | struct be_adapter { | 231 | struct be_adapter { |
@@ -289,8 +295,7 @@ struct be_adapter { | |||
289 | struct completion flash_compl; | 295 | struct completion flash_compl; |
290 | 296 | ||
291 | bool sriov_enabled; | 297 | bool sriov_enabled; |
292 | u32 vf_if_handle[BE_MAX_VF]; | 298 | struct be_vf_cfg vf_cfg[BE_MAX_VF]; |
293 | u32 vf_pmac_id[BE_MAX_VF]; | ||
294 | u8 base_eq_id; | 299 | u8 base_eq_id; |
295 | u8 is_virtfn; | 300 | u8 is_virtfn; |
296 | }; | 301 | }; |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 899881b5aab9..a8c4548e0d60 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -656,18 +656,44 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) | |||
656 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) | 656 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) |
657 | return -EINVAL; | 657 | return -EINVAL; |
658 | 658 | ||
659 | if (adapter->vf_pmac_id[vf] != BE_INVALID_PMAC_ID) | 659 | if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID) |
660 | status = be_cmd_pmac_del(adapter, adapter->vf_if_handle[vf], | 660 | status = be_cmd_pmac_del(adapter, |
661 | adapter->vf_pmac_id[vf]); | 661 | adapter->vf_cfg[vf].vf_if_handle, |
662 | adapter->vf_cfg[vf].vf_pmac_id); | ||
662 | 663 | ||
663 | status = be_cmd_pmac_add(adapter, mac, adapter->vf_if_handle[vf], | 664 | status = be_cmd_pmac_add(adapter, mac, |
664 | &adapter->vf_pmac_id[vf]); | 665 | adapter->vf_cfg[vf].vf_if_handle, |
665 | if (!status) | 666 | &adapter->vf_cfg[vf].vf_pmac_id); |
667 | |||
668 | if (status) | ||
666 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", | 669 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", |
667 | mac, vf); | 670 | mac, vf); |
671 | else | ||
672 | memcpy(adapter->vf_cfg[vf].vf_mac_addr, mac, ETH_ALEN); | ||
673 | |||
668 | return status; | 674 | return status; |
669 | } | 675 | } |
670 | 676 | ||
677 | static int be_get_vf_config(struct net_device *netdev, int vf, | ||
678 | struct ifla_vf_info *vi) | ||
679 | { | ||
680 | struct be_adapter *adapter = netdev_priv(netdev); | ||
681 | |||
682 | if (!adapter->sriov_enabled) | ||
683 | return -EPERM; | ||
684 | |||
685 | if (vf >= num_vfs) | ||
686 | return -EINVAL; | ||
687 | |||
688 | vi->vf = vf; | ||
689 | vi->tx_rate = 0; | ||
690 | vi->vlan = 0; | ||
691 | vi->qos = 0; | ||
692 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); | ||
693 | |||
694 | return 0; | ||
695 | } | ||
696 | |||
671 | static void be_rx_rate_update(struct be_adapter *adapter) | 697 | static void be_rx_rate_update(struct be_adapter *adapter) |
672 | { | 698 | { |
673 | struct be_drvr_stats *stats = drvr_stats(adapter); | 699 | struct be_drvr_stats *stats = drvr_stats(adapter); |
@@ -1904,14 +1930,15 @@ static int be_setup(struct be_adapter *adapter) | |||
1904 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | 1930 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED |
1905 | | BE_IF_FLAGS_BROADCAST; | 1931 | | BE_IF_FLAGS_BROADCAST; |
1906 | status = be_cmd_if_create(adapter, cap_flags, en_flags, | 1932 | status = be_cmd_if_create(adapter, cap_flags, en_flags, |
1907 | mac, true, &adapter->vf_if_handle[vf], | 1933 | mac, true, |
1934 | &adapter->vf_cfg[vf].vf_if_handle, | ||
1908 | NULL, vf+1); | 1935 | NULL, vf+1); |
1909 | if (status) { | 1936 | if (status) { |
1910 | dev_err(&adapter->pdev->dev, | 1937 | dev_err(&adapter->pdev->dev, |
1911 | "Interface Create failed for VF %d\n", vf); | 1938 | "Interface Create failed for VF %d\n", vf); |
1912 | goto if_destroy; | 1939 | goto if_destroy; |
1913 | } | 1940 | } |
1914 | adapter->vf_pmac_id[vf] = BE_INVALID_PMAC_ID; | 1941 | adapter->vf_cfg[vf].vf_pmac_id = BE_INVALID_PMAC_ID; |
1915 | vf++; | 1942 | vf++; |
1916 | } | 1943 | } |
1917 | } else if (!be_physfn(adapter)) { | 1944 | } else if (!be_physfn(adapter)) { |
@@ -1945,8 +1972,9 @@ tx_qs_destroy: | |||
1945 | be_tx_queues_destroy(adapter); | 1972 | be_tx_queues_destroy(adapter); |
1946 | if_destroy: | 1973 | if_destroy: |
1947 | for (vf = 0; vf < num_vfs; vf++) | 1974 | for (vf = 0; vf < num_vfs; vf++) |
1948 | if (adapter->vf_if_handle[vf]) | 1975 | if (adapter->vf_cfg[vf].vf_if_handle) |
1949 | be_cmd_if_destroy(adapter, adapter->vf_if_handle[vf]); | 1976 | be_cmd_if_destroy(adapter, |
1977 | adapter->vf_cfg[vf].vf_if_handle); | ||
1950 | be_cmd_if_destroy(adapter, adapter->if_handle); | 1978 | be_cmd_if_destroy(adapter, adapter->if_handle); |
1951 | do_none: | 1979 | do_none: |
1952 | return status; | 1980 | return status; |
@@ -2189,7 +2217,8 @@ static struct net_device_ops be_netdev_ops = { | |||
2189 | .ndo_vlan_rx_register = be_vlan_register, | 2217 | .ndo_vlan_rx_register = be_vlan_register, |
2190 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, | 2218 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, |
2191 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, | 2219 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, |
2192 | .ndo_set_vf_mac = be_set_vf_mac | 2220 | .ndo_set_vf_mac = be_set_vf_mac, |
2221 | .ndo_get_vf_config = be_get_vf_config | ||
2193 | }; | 2222 | }; |
2194 | 2223 | ||
2195 | static void be_netdev_init(struct net_device *netdev) | 2224 | static void be_netdev_init(struct net_device *netdev) |