aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-07-17 19:38:23 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-17 19:38:23 -0400
commit87b200e11bb50e90471a69fe1af01e8fce8995aa (patch)
treeeaea281954703e6980729feeab4d7667070c4c86
parent23fa5c2caae08f919d906b1064b9fdc352b3024e (diff)
parentc346e6e51fce86714d64e395a966a1d7d91f1c48 (diff)
Merge branch 'be2net-next'
Sathya Perla says: ==================== be2net: patch set Patches 1 to 6 address issues with return values of some ndo/ethtool driver methods. In error scenarios, either an inappropriate error or a +ve return value (where the stack expects a -ve value) was being returned. Patch 7 updates description strings for certain UE bits. Patch 8 cleans up (reduces) argument passing for a few routines in be_cmds.c. Patch 9 removes some unused code (unused definitions.) Patch 10 updates NULL check in the driver to a consistent "if (!foo)" style. Patchs 11 to 13 fix a few minor issues with the earlier patch bec84e6 ("create optimal number of queues on SR-IOV config"): - patch 11 fixes BEx_get_resources() code to use be_max_vfs() macro - patch 12 skips SR-IOV config code for BE2 that doesn't support SRIOV - patch 13 uses adapter->flags to track SRIOV enabled state Patch 14 updates the driver version. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h8
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c23
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h35
-rw-r--r--drivers/net/ethernet/emulex/benet/be_ethtool.c12
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c116
5 files changed, 89 insertions, 105 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index d3d871b28cad..0048ef8e5f35 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -34,7 +34,7 @@
34#include "be_hw.h" 34#include "be_hw.h"
35#include "be_roce.h" 35#include "be_roce.h"
36 36
37#define DRV_VER "10.2u" 37#define DRV_VER "10.4u"
38#define DRV_NAME "be2net" 38#define DRV_NAME "be2net"
39#define BE_NAME "Emulex BladeEngine2" 39#define BE_NAME "Emulex BladeEngine2"
40#define BE3_NAME "Emulex BladeEngine3" 40#define BE3_NAME "Emulex BladeEngine3"
@@ -372,6 +372,7 @@ enum vf_state {
372}; 372};
373 373
374#define BE_FLAGS_LINK_STATUS_INIT 1 374#define BE_FLAGS_LINK_STATUS_INIT 1
375#define BE_FLAGS_SRIOV_ENABLED (1 << 2)
375#define BE_FLAGS_WORKER_SCHEDULED (1 << 3) 376#define BE_FLAGS_WORKER_SCHEDULED (1 << 3)
376#define BE_FLAGS_VLAN_PROMISC (1 << 4) 377#define BE_FLAGS_VLAN_PROMISC (1 << 4)
377#define BE_FLAGS_MCAST_PROMISC (1 << 5) 378#define BE_FLAGS_MCAST_PROMISC (1 << 5)
@@ -525,7 +526,8 @@ struct be_adapter {
525 526
526#define be_physfn(adapter) (!adapter->virtfn) 527#define be_physfn(adapter) (!adapter->virtfn)
527#define be_virtfn(adapter) (adapter->virtfn) 528#define be_virtfn(adapter) (adapter->virtfn)
528#define sriov_enabled(adapter) (adapter->num_vfs > 0) 529#define sriov_enabled(adapter) (adapter->flags & \
530 BE_FLAGS_SRIOV_ENABLED)
529 531
530#define for_all_vfs(adapter, vf_cfg, i) \ 532#define for_all_vfs(adapter, vf_cfg, i) \
531 for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \ 533 for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \
@@ -672,6 +674,8 @@ static inline void swap_dws(void *wrb, int len)
672#endif /* __BIG_ENDIAN */ 674#endif /* __BIG_ENDIAN */
673} 675}
674 676
677#define be_cmd_status(status) (status > 0 ? -EIO : status)
678
675static inline u8 is_tcp_pkt(struct sk_buff *skb) 679static inline u8 is_tcp_pkt(struct sk_buff *skb)
676{ 680{
677 u8 val = 0; 681 u8 val = 0;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 9904bbfd4e93..791094c33535 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1749,8 +1749,7 @@ err:
1749} 1749}
1750 1750
1751/* Uses synchronous mcc */ 1751/* Uses synchronous mcc */
1752int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver, 1752int be_cmd_get_fw_ver(struct be_adapter *adapter)
1753 char *fw_on_flash)
1754{ 1753{
1755 struct be_mcc_wrb *wrb; 1754 struct be_mcc_wrb *wrb;
1756 struct be_cmd_req_get_fw_version *req; 1755 struct be_cmd_req_get_fw_version *req;
@@ -1772,9 +1771,8 @@ int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver,
1772 status = be_mcc_notify_wait(adapter); 1771 status = be_mcc_notify_wait(adapter);
1773 if (!status) { 1772 if (!status) {
1774 struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); 1773 struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb);
1775 strcpy(fw_ver, resp->firmware_version_string); 1774 strcpy(adapter->fw_ver, resp->firmware_version_string);
1776 if (fw_on_flash) 1775 strcpy(adapter->fw_on_flash, resp->fw_on_flash_version_string);
1777 strcpy(fw_on_flash, resp->fw_on_flash_version_string);
1778 } 1776 }
1779err: 1777err:
1780 spin_unlock_bh(&adapter->mcc_lock); 1778 spin_unlock_bh(&adapter->mcc_lock);
@@ -1997,8 +1995,7 @@ err:
1997} 1995}
1998 1996
1999/* Uses mbox */ 1997/* Uses mbox */
2000int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, 1998int be_cmd_query_fw_cfg(struct be_adapter *adapter)
2001 u32 *mode, u32 *caps, u16 *asic_rev)
2002{ 1999{
2003 struct be_mcc_wrb *wrb; 2000 struct be_mcc_wrb *wrb;
2004 struct be_cmd_req_query_fw_cfg *req; 2001 struct be_cmd_req_query_fw_cfg *req;
@@ -2017,10 +2014,10 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num,
2017 status = be_mbox_notify_wait(adapter); 2014 status = be_mbox_notify_wait(adapter);
2018 if (!status) { 2015 if (!status) {
2019 struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); 2016 struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb);
2020 *port_num = le32_to_cpu(resp->phys_port); 2017 adapter->port_num = le32_to_cpu(resp->phys_port);
2021 *mode = le32_to_cpu(resp->function_mode); 2018 adapter->function_mode = le32_to_cpu(resp->function_mode);
2022 *caps = le32_to_cpu(resp->function_caps); 2019 adapter->function_caps = le32_to_cpu(resp->function_caps);
2023 *asic_rev = le32_to_cpu(resp->asic_revision) & 0xFF; 2020 adapter->asic_rev = le32_to_cpu(resp->asic_revision) & 0xFF;
2024 } 2021 }
2025 2022
2026 mutex_unlock(&adapter->mbox_lock); 2023 mutex_unlock(&adapter->mbox_lock);
@@ -2224,7 +2221,7 @@ int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
2224 2221
2225 if (!wait_for_completion_timeout(&adapter->et_cmd_compl, 2222 if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
2226 msecs_to_jiffies(60000))) 2223 msecs_to_jiffies(60000)))
2227 status = -1; 2224 status = -ETIMEDOUT;
2228 else 2225 else
2229 status = adapter->flash_status; 2226 status = adapter->flash_status;
2230 2227
@@ -2320,7 +2317,7 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
2320 2317
2321 if (!wait_for_completion_timeout(&adapter->et_cmd_compl, 2318 if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
2322 msecs_to_jiffies(40000))) 2319 msecs_to_jiffies(40000)))
2323 status = -1; 2320 status = -ETIMEDOUT;
2324 else 2321 else
2325 status = adapter->flash_status; 2322 status = adapter->flash_status;
2326 2323
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index c0f7167049b7..03e8a15c6922 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1081,11 +1081,6 @@ struct be_cmd_req_modify_eq_delay {
1081 struct be_set_eqd set_eqd[MAX_EVT_QS]; 1081 struct be_set_eqd set_eqd[MAX_EVT_QS];
1082} __packed; 1082} __packed;
1083 1083
1084struct be_cmd_resp_modify_eq_delay {
1085 struct be_cmd_resp_hdr hdr;
1086 u32 rsvd0;
1087} __packed;
1088
1089/******************** Get FW Config *******************/ 1084/******************** Get FW Config *******************/
1090/* The HW can come up in either of the following multi-channel modes 1085/* The HW can come up in either of the following multi-channel modes
1091 * based on the skew/IPL. 1086 * based on the skew/IPL.
@@ -1156,11 +1151,6 @@ struct be_cmd_req_enable_disable_beacon {
1156 u8 status_duration; 1151 u8 status_duration;
1157} __packed; 1152} __packed;
1158 1153
1159struct be_cmd_resp_enable_disable_beacon {
1160 struct be_cmd_resp_hdr resp_hdr;
1161 u32 rsvd0;
1162} __packed;
1163
1164struct be_cmd_req_get_beacon_state { 1154struct be_cmd_req_get_beacon_state {
1165 struct be_cmd_req_hdr hdr; 1155 struct be_cmd_req_hdr hdr;
1166 u8 port_num; 1156 u8 port_num;
@@ -1326,11 +1316,6 @@ struct be_cmd_req_set_lmode {
1326 u8 loopback_state; 1316 u8 loopback_state;
1327}; 1317};
1328 1318
1329struct be_cmd_resp_set_lmode {
1330 struct be_cmd_resp_hdr resp_hdr;
1331 u8 rsvd0[4];
1332};
1333
1334/********************** DDR DMA test *********************/ 1319/********************** DDR DMA test *********************/
1335struct be_cmd_req_ddrdma_test { 1320struct be_cmd_req_ddrdma_test {
1336 struct be_cmd_req_hdr hdr; 1321 struct be_cmd_req_hdr hdr;
@@ -1434,11 +1419,6 @@ struct be_cmd_req_set_qos {
1434 u32 rsvd[7]; 1419 u32 rsvd[7];
1435}; 1420};
1436 1421
1437struct be_cmd_resp_set_qos {
1438 struct be_cmd_resp_hdr hdr;
1439 u32 rsvd;
1440};
1441
1442/*********************** Controller Attributes ***********************/ 1422/*********************** Controller Attributes ***********************/
1443struct be_cmd_req_cntl_attribs { 1423struct be_cmd_req_cntl_attribs {
1444 struct be_cmd_req_hdr hdr; 1424 struct be_cmd_req_hdr hdr;
@@ -1572,11 +1552,6 @@ struct be_cmd_req_set_hsw_config {
1572 u8 context[sizeof(struct amap_set_hsw_context) / 8]; 1552 u8 context[sizeof(struct amap_set_hsw_context) / 8];
1573} __packed; 1553} __packed;
1574 1554
1575struct be_cmd_resp_set_hsw_config {
1576 struct be_cmd_resp_hdr hdr;
1577 u32 rsvd;
1578};
1579
1580struct amap_get_hsw_req_context { 1555struct amap_get_hsw_req_context {
1581 u8 interface_id[16]; 1556 u8 interface_id[16];
1582 u8 rsvd0[14]; 1557 u8 rsvd0[14];
@@ -1966,10 +1941,6 @@ struct be_cmd_req_set_profile_config {
1966 u8 desc[2 * RESOURCE_DESC_SIZE_V1]; 1941 u8 desc[2 * RESOURCE_DESC_SIZE_V1];
1967} __packed; 1942} __packed;
1968 1943
1969struct be_cmd_resp_set_profile_config {
1970 struct be_cmd_resp_hdr hdr;
1971};
1972
1973struct be_cmd_req_get_active_profile { 1944struct be_cmd_req_get_active_profile {
1974 struct be_cmd_req_hdr hdr; 1945 struct be_cmd_req_hdr hdr;
1975 u32 rsvd; 1946 u32 rsvd;
@@ -2071,16 +2042,14 @@ int be_cmd_reset(struct be_adapter *adapter);
2071int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd); 2042int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd);
2072int lancer_cmd_get_pport_stats(struct be_adapter *adapter, 2043int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
2073 struct be_dma_mem *nonemb_cmd); 2044 struct be_dma_mem *nonemb_cmd);
2074int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver, 2045int be_cmd_get_fw_ver(struct be_adapter *adapter);
2075 char *fw_on_flash);
2076int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num); 2046int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num);
2077int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, 2047int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
2078 u32 num); 2048 u32 num);
2079int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status); 2049int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status);
2080int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc); 2050int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc);
2081int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc); 2051int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc);
2082int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num, 2052int be_cmd_query_fw_cfg(struct be_adapter *adapter);
2083 u32 *function_mode, u32 *function_caps, u16 *asic_rev);
2084int be_cmd_reset_function(struct be_adapter *adapter); 2053int be_cmd_reset_function(struct be_adapter *adapter);
2085int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, 2054int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
2086 u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey); 2055 u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey);
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index e2da4d20dd3d..25f516d6eb9e 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -643,7 +643,7 @@ be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
643 if (status) 643 if (status)
644 dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); 644 dev_warn(&adapter->pdev->dev, "Pause param set failed.\n");
645 645
646 return status; 646 return be_cmd_status(status);
647} 647}
648 648
649static int be_set_phys_id(struct net_device *netdev, 649static int be_set_phys_id(struct net_device *netdev,
@@ -762,7 +762,7 @@ static int be_test_ddr_dma(struct be_adapter *adapter)
762err: 762err:
763 dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va, 763 dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va,
764 ddrdma_cmd.dma); 764 ddrdma_cmd.dma);
765 return ret; 765 return be_cmd_status(ret);
766} 766}
767 767
768static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type, 768static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type,
@@ -885,7 +885,7 @@ static int be_read_eeprom(struct net_device *netdev,
885 dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va, 885 dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va,
886 eeprom_cmd.dma); 886 eeprom_cmd.dma);
887 887
888 return status; 888 return be_cmd_status(status);
889} 889}
890 890
891static u32 be_get_msg_level(struct net_device *netdev) 891static u32 be_get_msg_level(struct net_device *netdev)
@@ -1042,7 +1042,7 @@ static int be_set_rss_hash_opts(struct be_adapter *adapter,
1042 if (!status) 1042 if (!status)
1043 adapter->rss_info.rss_flags = rss_flags; 1043 adapter->rss_info.rss_flags = rss_flags;
1044 1044
1045 return status; 1045 return be_cmd_status(status);
1046} 1046}
1047 1047
1048static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) 1048static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
@@ -1080,6 +1080,7 @@ static int be_set_channels(struct net_device *netdev,
1080 struct ethtool_channels *ch) 1080 struct ethtool_channels *ch)
1081{ 1081{
1082 struct be_adapter *adapter = netdev_priv(netdev); 1082 struct be_adapter *adapter = netdev_priv(netdev);
1083 int status;
1083 1084
1084 if (ch->rx_count || ch->tx_count || ch->other_count || 1085 if (ch->rx_count || ch->tx_count || ch->other_count ||
1085 !ch->combined_count || ch->combined_count > be_max_qs(adapter)) 1086 !ch->combined_count || ch->combined_count > be_max_qs(adapter))
@@ -1087,7 +1088,8 @@ static int be_set_channels(struct net_device *netdev,
1087 1088
1088 adapter->cfg_num_qs = ch->combined_count; 1089 adapter->cfg_num_qs = ch->combined_count;
1089 1090
1090 return be_update_queues(adapter); 1091 status = be_update_queues(adapter);
1092 return be_cmd_status(status);
1091} 1093}
1092 1094
1093static u32 be_get_rxfh_indir_size(struct net_device *netdev) 1095static u32 be_get_rxfh_indir_size(struct net_device *netdev)
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 9bced68527a9..9c50814f1e95 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -81,10 +81,10 @@ static const char * const ue_status_low_desc[] = {
81 "P1_OB_LINK ", 81 "P1_OB_LINK ",
82 "HOST_GPIO ", 82 "HOST_GPIO ",
83 "MBOX ", 83 "MBOX ",
84 "AXGMAC0", 84 "ERX2 ",
85 "AXGMAC1", 85 "SPARE ",
86 "JTAG", 86 "JTAG ",
87 "MPU_INTPEND" 87 "MPU_INTPEND "
88}; 88};
89/* UE Status High CSR */ 89/* UE Status High CSR */
90static const char * const ue_status_hi_desc[] = { 90static const char * const ue_status_hi_desc[] = {
@@ -109,16 +109,16 @@ static const char * const ue_status_hi_desc[] = {
109 "HOST5", 109 "HOST5",
110 "HOST6", 110 "HOST6",
111 "HOST7", 111 "HOST7",
112 "HOST8", 112 "ECRC",
113 "HOST9", 113 "Poison TLP",
114 "NETC", 114 "NETC",
115 "Unknown", 115 "PERIPH",
116 "Unknown", 116 "LLTXULP",
117 "Unknown", 117 "D2P",
118 "Unknown", 118 "RCON",
119 "Unknown", 119 "LDMA",
120 "Unknown", 120 "LLTXP",
121 "Unknown", 121 "LLTXPB",
122 "Unknown" 122 "Unknown"
123}; 123};
124 124
@@ -1281,13 +1281,15 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
1281 vf + 1); 1281 vf + 1);
1282 } 1282 }
1283 1283
1284 if (status) 1284 if (status) {
1285 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", 1285 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed: %#x",
1286 mac, vf); 1286 mac, vf, status);
1287 else 1287 return be_cmd_status(status);
1288 memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); 1288 }
1289 1289
1290 return status; 1290 ether_addr_copy(vf_cfg->mac_addr, mac);
1291
1292 return 0;
1291} 1293}
1292 1294
1293static int be_get_vf_config(struct net_device *netdev, int vf, 1295static int be_get_vf_config(struct net_device *netdev, int vf,
@@ -1336,12 +1338,16 @@ static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
1336 vf + 1, vf_cfg->if_handle, 0); 1338 vf + 1, vf_cfg->if_handle, 0);
1337 } 1339 }
1338 1340
1339 if (!status) 1341 if (status) {
1340 vf_cfg->vlan_tag = vlan; 1342 dev_err(&adapter->pdev->dev,
1341 else 1343 "VLAN %d config on VF %d failed : %#x\n", vlan,
1342 dev_info(&adapter->pdev->dev, 1344 vf, status);
1343 "VLAN %d config on VF %d failed\n", vlan, vf); 1345 return be_cmd_status(status);
1344 return status; 1346 }
1347
1348 vf_cfg->vlan_tag = vlan;
1349
1350 return 0;
1345} 1351}
1346 1352
1347static int be_set_vf_tx_rate(struct net_device *netdev, int vf, 1353static int be_set_vf_tx_rate(struct net_device *netdev, int vf,
@@ -1372,7 +1378,7 @@ static int be_set_vf_tx_rate(struct net_device *netdev, int vf,
1372 1378
1373 if (!link_status) { 1379 if (!link_status) {
1374 dev_err(dev, "TX-rate setting not allowed when link is down\n"); 1380 dev_err(dev, "TX-rate setting not allowed when link is down\n");
1375 status = -EPERM; 1381 status = -ENETDOWN;
1376 goto err; 1382 goto err;
1377 } 1383 }
1378 1384
@@ -1403,7 +1409,7 @@ config_qos:
1403err: 1409err:
1404 dev_err(dev, "TX-rate setting of %dMbps on VF%d failed\n", 1410 dev_err(dev, "TX-rate setting of %dMbps on VF%d failed\n",
1405 max_tx_rate, vf); 1411 max_tx_rate, vf);
1406 return status; 1412 return be_cmd_status(status);
1407} 1413}
1408static int be_set_vf_link_state(struct net_device *netdev, int vf, 1414static int be_set_vf_link_state(struct net_device *netdev, int vf,
1409 int link_state) 1415 int link_state)
@@ -1418,10 +1424,15 @@ static int be_set_vf_link_state(struct net_device *netdev, int vf,
1418 return -EINVAL; 1424 return -EINVAL;
1419 1425
1420 status = be_cmd_set_logical_link_config(adapter, link_state, vf+1); 1426 status = be_cmd_set_logical_link_config(adapter, link_state, vf+1);
1421 if (!status) 1427 if (status) {
1422 adapter->vf_cfg[vf].plink_tracking = link_state; 1428 dev_err(&adapter->pdev->dev,
1429 "Link state change on VF %d failed: %#x\n", vf, status);
1430 return be_cmd_status(status);
1431 }
1423 1432
1424 return status; 1433 adapter->vf_cfg[vf].plink_tracking = link_state;
1434
1435 return 0;
1425} 1436}
1426 1437
1427static void be_aic_update(struct be_aic_obj *aic, u64 rx_pkts, u64 tx_pkts, 1438static void be_aic_update(struct be_aic_obj *aic, u64 rx_pkts, u64 tx_pkts,
@@ -2023,7 +2034,7 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
2023 */ 2034 */
2024 for (;;) { 2035 for (;;) {
2025 rxcp = be_rx_compl_get(rxo); 2036 rxcp = be_rx_compl_get(rxo);
2026 if (rxcp == NULL) { 2037 if (!rxcp) {
2027 if (lancer_chip(adapter)) 2038 if (lancer_chip(adapter))
2028 break; 2039 break;
2029 2040
@@ -2930,8 +2941,8 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
2930 cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config); 2941 cmd.size = sizeof(struct be_cmd_req_acpi_wol_magic_config);
2931 cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, 2942 cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,
2932 GFP_KERNEL); 2943 GFP_KERNEL);
2933 if (cmd.va == NULL) 2944 if (!cmd.va)
2934 return -1; 2945 return -ENOMEM;
2935 2946
2936 if (enable) { 2947 if (enable) {
2937 status = pci_write_config_dword(adapter->pdev, 2948 status = pci_write_config_dword(adapter->pdev,
@@ -3038,6 +3049,7 @@ static void be_vf_clear(struct be_adapter *adapter)
3038done: 3049done:
3039 kfree(adapter->vf_cfg); 3050 kfree(adapter->vf_cfg);
3040 adapter->num_vfs = 0; 3051 adapter->num_vfs = 0;
3052 adapter->flags &= ~BE_FLAGS_SRIOV_ENABLED;
3041} 3053}
3042 3054
3043static void be_clear_queues(struct be_adapter *adapter) 3055static void be_clear_queues(struct be_adapter *adapter)
@@ -3230,6 +3242,8 @@ static int be_vf_setup(struct be_adapter *adapter)
3230 goto err; 3242 goto err;
3231 } 3243 }
3232 } 3244 }
3245
3246 adapter->flags |= BE_FLAGS_SRIOV_ENABLED;
3233 return 0; 3247 return 0;
3234err: 3248err:
3235 dev_err(dev, "VF setup failed\n"); 3249 dev_err(dev, "VF setup failed\n");
@@ -3301,7 +3315,7 @@ static void BEx_get_resources(struct be_adapter *adapter,
3301 res->max_rx_qs = res->max_rss_qs + 1; 3315 res->max_rx_qs = res->max_rss_qs + 1;
3302 3316
3303 if (be_physfn(adapter)) 3317 if (be_physfn(adapter))
3304 res->max_evt_qs = (res->max_vfs > 0) ? 3318 res->max_evt_qs = (be_max_vfs(adapter) > 0) ?
3305 BE3_SRIOV_MAX_EVT_QS : BE3_MAX_EVT_QS; 3319 BE3_SRIOV_MAX_EVT_QS : BE3_MAX_EVT_QS;
3306 else 3320 else
3307 res->max_evt_qs = 1; 3321 res->max_evt_qs = 1;
@@ -3414,10 +3428,7 @@ static int be_get_config(struct be_adapter *adapter)
3414 u16 profile_id; 3428 u16 profile_id;
3415 int status; 3429 int status;
3416 3430
3417 status = be_cmd_query_fw_cfg(adapter, &adapter->port_num, 3431 status = be_cmd_query_fw_cfg(adapter);
3418 &adapter->function_mode,
3419 &adapter->function_caps,
3420 &adapter->asic_rev);
3421 if (status) 3432 if (status)
3422 return status; 3433 return status;
3423 3434
@@ -3426,7 +3437,9 @@ static int be_get_config(struct be_adapter *adapter)
3426 if (!status) 3437 if (!status)
3427 dev_info(&adapter->pdev->dev, 3438 dev_info(&adapter->pdev->dev,
3428 "Using profile 0x%x\n", profile_id); 3439 "Using profile 0x%x\n", profile_id);
3440 }
3429 3441
3442 if (!BE2_chip(adapter) && be_physfn(adapter)) {
3430 status = be_get_sriov_config(adapter); 3443 status = be_get_sriov_config(adapter);
3431 if (status) 3444 if (status)
3432 return status; 3445 return status;
@@ -3606,7 +3619,7 @@ static int be_setup(struct be_adapter *adapter)
3606 if (status) 3619 if (status)
3607 goto err; 3620 goto err;
3608 3621
3609 be_cmd_get_fw_ver(adapter, adapter->fw_ver, adapter->fw_on_flash); 3622 be_cmd_get_fw_ver(adapter);
3610 3623
3611 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) { 3624 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) {
3612 dev_err(dev, "Firmware on card is old(%s), IRQs may not work.", 3625 dev_err(dev, "Firmware on card is old(%s), IRQs may not work.",
@@ -3956,7 +3969,7 @@ static int be_flash_skyhawk(struct be_adapter *adapter,
3956 fsec = get_fsec_info(adapter, filehdr_size + img_hdrs_size, fw); 3969 fsec = get_fsec_info(adapter, filehdr_size + img_hdrs_size, fw);
3957 if (!fsec) { 3970 if (!fsec) {
3958 dev_err(dev, "Invalid Cookie. FW image may be corrupted\n"); 3971 dev_err(dev, "Invalid Cookie. FW image may be corrupted\n");
3959 return -1; 3972 return -EINVAL;
3960 } 3973 }
3961 3974
3962 for (i = 0; i < le32_to_cpu(fsec->fsec_hdr.num_images); i++) { 3975 for (i = 0; i < le32_to_cpu(fsec->fsec_hdr.num_images); i++) {
@@ -4125,7 +4138,7 @@ lancer_fw_exit:
4125static int be_get_ufi_type(struct be_adapter *adapter, 4138static int be_get_ufi_type(struct be_adapter *adapter,
4126 struct flash_file_hdr_g3 *fhdr) 4139 struct flash_file_hdr_g3 *fhdr)
4127{ 4140{
4128 if (fhdr == NULL) 4141 if (!fhdr)
4129 goto be_get_ufi_exit; 4142 goto be_get_ufi_exit;
4130 4143
4131 if (skyhawk_chip(adapter) && fhdr->build[0] == '4') 4144 if (skyhawk_chip(adapter) && fhdr->build[0] == '4')
@@ -4187,7 +4200,7 @@ static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw)
4187 &flash_cmd, 4200 &flash_cmd,
4188 num_imgs); 4201 num_imgs);
4189 else { 4202 else {
4190 status = -1; 4203 status = -EINVAL;
4191 dev_err(&adapter->pdev->dev, 4204 dev_err(&adapter->pdev->dev,
4192 "Can't load BE3 UFI on BE3R\n"); 4205 "Can't load BE3 UFI on BE3R\n");
4193 } 4206 }
@@ -4198,7 +4211,7 @@ static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw)
4198 if (ufi_type == UFI_TYPE2) 4211 if (ufi_type == UFI_TYPE2)
4199 status = be_flash_BEx(adapter, fw, &flash_cmd, 0); 4212 status = be_flash_BEx(adapter, fw, &flash_cmd, 0);
4200 else if (ufi_type == -1) 4213 else if (ufi_type == -1)
4201 status = -1; 4214 status = -EINVAL;
4202 4215
4203 dma_free_coherent(&adapter->pdev->dev, flash_cmd.size, flash_cmd.va, 4216 dma_free_coherent(&adapter->pdev->dev, flash_cmd.size, flash_cmd.va,
4204 flash_cmd.dma); 4217 flash_cmd.dma);
@@ -4221,7 +4234,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *fw_file)
4221 if (!netif_running(adapter->netdev)) { 4234 if (!netif_running(adapter->netdev)) {
4222 dev_err(&adapter->pdev->dev, 4235 dev_err(&adapter->pdev->dev,
4223 "Firmware load not allowed (interface is down)\n"); 4236 "Firmware load not allowed (interface is down)\n");
4224 return -1; 4237 return -ENETDOWN;
4225 } 4238 }
4226 4239
4227 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); 4240 status = request_firmware(&fw, fw_file, &adapter->pdev->dev);
@@ -4236,8 +4249,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *fw_file)
4236 status = be_fw_download(adapter, fw); 4249 status = be_fw_download(adapter, fw);
4237 4250
4238 if (!status) 4251 if (!status)
4239 be_cmd_get_fw_ver(adapter, adapter->fw_ver, 4252 be_cmd_get_fw_ver(adapter);
4240 adapter->fw_on_flash);
4241 4253
4242fw_exit: 4254fw_exit:
4243 release_firmware(fw); 4255 release_firmware(fw);
@@ -4468,12 +4480,12 @@ static int be_map_pci_bars(struct be_adapter *adapter)
4468 4480
4469 if (BEx_chip(adapter) && be_physfn(adapter)) { 4481 if (BEx_chip(adapter) && be_physfn(adapter)) {
4470 adapter->csr = pci_iomap(adapter->pdev, 2, 0); 4482 adapter->csr = pci_iomap(adapter->pdev, 2, 0);
4471 if (adapter->csr == NULL) 4483 if (!adapter->csr)
4472 return -ENOMEM; 4484 return -ENOMEM;
4473 } 4485 }
4474 4486
4475 addr = pci_iomap(adapter->pdev, db_bar(adapter), 0); 4487 addr = pci_iomap(adapter->pdev, db_bar(adapter), 0);
4476 if (addr == NULL) 4488 if (!addr)
4477 goto pci_map_err; 4489 goto pci_map_err;
4478 adapter->db = addr; 4490 adapter->db = addr;
4479 4491
@@ -4536,7 +4548,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
4536 rx_filter->va = dma_zalloc_coherent(&adapter->pdev->dev, 4548 rx_filter->va = dma_zalloc_coherent(&adapter->pdev->dev,
4537 rx_filter->size, &rx_filter->dma, 4549 rx_filter->size, &rx_filter->dma,
4538 GFP_KERNEL); 4550 GFP_KERNEL);
4539 if (rx_filter->va == NULL) { 4551 if (!rx_filter->va) {
4540 status = -ENOMEM; 4552 status = -ENOMEM;
4541 goto free_mbox; 4553 goto free_mbox;
4542 } 4554 }
@@ -4585,8 +4597,8 @@ static int be_stats_init(struct be_adapter *adapter)
4585 4597
4586 cmd->va = dma_zalloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma, 4598 cmd->va = dma_zalloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma,
4587 GFP_KERNEL); 4599 GFP_KERNEL);
4588 if (cmd->va == NULL) 4600 if (!cmd->va)
4589 return -1; 4601 return -ENOMEM;
4590 return 0; 4602 return 0;
4591} 4603}
4592 4604
@@ -4807,7 +4819,7 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
4807 pci_set_master(pdev); 4819 pci_set_master(pdev);
4808 4820
4809 netdev = alloc_etherdev_mqs(sizeof(*adapter), MAX_TX_QS, MAX_RX_QS); 4821 netdev = alloc_etherdev_mqs(sizeof(*adapter), MAX_TX_QS, MAX_RX_QS);
4810 if (netdev == NULL) { 4822 if (!netdev) {
4811 status = -ENOMEM; 4823 status = -ENOMEM;
4812 goto rel_reg; 4824 goto rel_reg;
4813 } 4825 }