diff options
author | Sathya Perla <sathyap@serverengines.com> | 2009-11-22 17:02:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-23 13:44:23 -0500 |
commit | 2243e2e95e24f4c4b1c6575b874ebe0b837d2208 (patch) | |
tree | 0a9c10b30834cad4bc231d59352b8c5f9fc9f546 /drivers/net | |
parent | 01ed30da5d2e718df458f1680fd97751a769c1a2 (diff) |
be2net: Issue fw_init/clean cmds to fw
These cmds are issued to the fw in probe/resume and remove/suspend
paths to help fw execute some initialization and cleanup code.
This change needed the be_hw_up() code to be refactored as be_get_config().
Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/benet/be_cmds.c | 51 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 2 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 50 |
3 files changed, 87 insertions, 16 deletions
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 31980f863d12..2af87f100307 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -357,6 +357,57 @@ static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) | |||
357 | return wrb; | 357 | return wrb; |
358 | } | 358 | } |
359 | 359 | ||
360 | /* Tell fw we're about to start firing cmds by writing a | ||
361 | * special pattern across the wrb hdr; uses mbox | ||
362 | */ | ||
363 | int be_cmd_fw_init(struct be_adapter *adapter) | ||
364 | { | ||
365 | u8 *wrb; | ||
366 | int status; | ||
367 | |||
368 | spin_lock(&adapter->mbox_lock); | ||
369 | |||
370 | wrb = (u8 *)wrb_from_mbox(adapter); | ||
371 | *wrb++ = 0xFF; | ||
372 | *wrb++ = 0x12; | ||
373 | *wrb++ = 0x34; | ||
374 | *wrb++ = 0xFF; | ||
375 | *wrb++ = 0xFF; | ||
376 | *wrb++ = 0x56; | ||
377 | *wrb++ = 0x78; | ||
378 | *wrb = 0xFF; | ||
379 | |||
380 | status = be_mbox_notify_wait(adapter); | ||
381 | |||
382 | spin_unlock(&adapter->mbox_lock); | ||
383 | return status; | ||
384 | } | ||
385 | |||
386 | /* Tell fw we're done with firing cmds by writing a | ||
387 | * special pattern across the wrb hdr; uses mbox | ||
388 | */ | ||
389 | int be_cmd_fw_clean(struct be_adapter *adapter) | ||
390 | { | ||
391 | u8 *wrb; | ||
392 | int status; | ||
393 | |||
394 | spin_lock(&adapter->mbox_lock); | ||
395 | |||
396 | wrb = (u8 *)wrb_from_mbox(adapter); | ||
397 | *wrb++ = 0xFF; | ||
398 | *wrb++ = 0xAA; | ||
399 | *wrb++ = 0xBB; | ||
400 | *wrb++ = 0xFF; | ||
401 | *wrb++ = 0xFF; | ||
402 | *wrb++ = 0xCC; | ||
403 | *wrb++ = 0xDD; | ||
404 | *wrb = 0xFF; | ||
405 | |||
406 | status = be_mbox_notify_wait(adapter); | ||
407 | |||
408 | spin_unlock(&adapter->mbox_lock); | ||
409 | return status; | ||
410 | } | ||
360 | int be_cmd_eq_create(struct be_adapter *adapter, | 411 | int be_cmd_eq_create(struct be_adapter *adapter, |
361 | struct be_queue_info *eq, int eq_delay) | 412 | struct be_queue_info *eq, int eq_delay) |
362 | { | 413 | { |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index 3b31abc01b5c..8ec6528cb054 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -851,3 +851,5 @@ extern int be_cmd_write_flashrom(struct be_adapter *adapter, | |||
851 | struct be_dma_mem *cmd, u32 flash_oper, | 851 | struct be_dma_mem *cmd, u32 flash_oper, |
852 | u32 flash_opcode, u32 buf_size); | 852 | u32 flash_opcode, u32 buf_size); |
853 | extern int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc); | 853 | extern int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc); |
854 | extern int be_cmd_fw_init(struct be_adapter *adapter); | ||
855 | extern int be_cmd_fw_clean(struct be_adapter *adapter); | ||
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index b0ff06e41f75..4635b3fdcc3b 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -1682,6 +1682,8 @@ static int be_clear(struct be_adapter *adapter) | |||
1682 | 1682 | ||
1683 | be_cmd_if_destroy(adapter, adapter->if_handle); | 1683 | be_cmd_if_destroy(adapter, adapter->if_handle); |
1684 | 1684 | ||
1685 | /* tell fw we're done with firing cmds */ | ||
1686 | be_cmd_fw_clean(adapter); | ||
1685 | return 0; | 1687 | return 0; |
1686 | } | 1688 | } |
1687 | 1689 | ||
@@ -2117,25 +2119,28 @@ static void __devexit be_remove(struct pci_dev *pdev) | |||
2117 | free_netdev(adapter->netdev); | 2119 | free_netdev(adapter->netdev); |
2118 | } | 2120 | } |
2119 | 2121 | ||
2120 | static int be_hw_up(struct be_adapter *adapter) | 2122 | static int be_get_config(struct be_adapter *adapter) |
2121 | { | 2123 | { |
2122 | int status; | 2124 | int status; |
2125 | u8 mac[ETH_ALEN]; | ||
2123 | 2126 | ||
2124 | status = be_cmd_POST(adapter); | 2127 | status = be_cmd_get_fw_ver(adapter, adapter->fw_ver); |
2125 | if (status) | 2128 | if (status) |
2126 | return status; | 2129 | return status; |
2127 | 2130 | ||
2128 | status = be_cmd_reset_function(adapter); | 2131 | status = be_cmd_query_fw_cfg(adapter, |
2132 | &adapter->port_num, &adapter->cap); | ||
2129 | if (status) | 2133 | if (status) |
2130 | return status; | 2134 | return status; |
2131 | 2135 | ||
2132 | status = be_cmd_get_fw_ver(adapter, adapter->fw_ver); | 2136 | memset(mac, 0, ETH_ALEN); |
2137 | status = be_cmd_mac_addr_query(adapter, mac, | ||
2138 | MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0); | ||
2133 | if (status) | 2139 | if (status) |
2134 | return status; | 2140 | return status; |
2141 | memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); | ||
2135 | 2142 | ||
2136 | status = be_cmd_query_fw_cfg(adapter, | 2143 | return 0; |
2137 | &adapter->port_num, &adapter->cap); | ||
2138 | return status; | ||
2139 | } | 2144 | } |
2140 | 2145 | ||
2141 | static int __devinit be_probe(struct pci_dev *pdev, | 2146 | static int __devinit be_probe(struct pci_dev *pdev, |
@@ -2144,7 +2149,6 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2144 | int status = 0; | 2149 | int status = 0; |
2145 | struct be_adapter *adapter; | 2150 | struct be_adapter *adapter; |
2146 | struct net_device *netdev; | 2151 | struct net_device *netdev; |
2147 | u8 mac[ETH_ALEN]; | ||
2148 | 2152 | ||
2149 | status = pci_enable_device(pdev); | 2153 | status = pci_enable_device(pdev); |
2150 | if (status) | 2154 | if (status) |
@@ -2164,6 +2168,8 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2164 | adapter->pdev = pdev; | 2168 | adapter->pdev = pdev; |
2165 | pci_set_drvdata(pdev, adapter); | 2169 | pci_set_drvdata(pdev, adapter); |
2166 | adapter->netdev = netdev; | 2170 | adapter->netdev = netdev; |
2171 | be_netdev_init(netdev); | ||
2172 | SET_NETDEV_DEV(netdev, &pdev->dev); | ||
2167 | 2173 | ||
2168 | be_msix_enable(adapter); | 2174 | be_msix_enable(adapter); |
2169 | 2175 | ||
@@ -2182,27 +2188,34 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2182 | if (status) | 2188 | if (status) |
2183 | goto free_netdev; | 2189 | goto free_netdev; |
2184 | 2190 | ||
2185 | status = be_stats_init(adapter); | 2191 | /* sync up with fw's ready state */ |
2192 | status = be_cmd_POST(adapter); | ||
2186 | if (status) | 2193 | if (status) |
2187 | goto ctrl_clean; | 2194 | goto ctrl_clean; |
2188 | 2195 | ||
2189 | status = be_hw_up(adapter); | 2196 | /* tell fw we're ready to fire cmds */ |
2197 | status = be_cmd_fw_init(adapter); | ||
2190 | if (status) | 2198 | if (status) |
2191 | goto stats_clean; | 2199 | goto ctrl_clean; |
2200 | |||
2201 | status = be_cmd_reset_function(adapter); | ||
2202 | if (status) | ||
2203 | goto ctrl_clean; | ||
2192 | 2204 | ||
2193 | status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK, | 2205 | status = be_stats_init(adapter); |
2194 | true /* permanent */, 0); | 2206 | if (status) |
2207 | goto ctrl_clean; | ||
2208 | |||
2209 | status = be_get_config(adapter); | ||
2195 | if (status) | 2210 | if (status) |
2196 | goto stats_clean; | 2211 | goto stats_clean; |
2197 | memcpy(netdev->dev_addr, mac, ETH_ALEN); | ||
2198 | 2212 | ||
2199 | INIT_DELAYED_WORK(&adapter->work, be_worker); | 2213 | INIT_DELAYED_WORK(&adapter->work, be_worker); |
2200 | be_netdev_init(netdev); | ||
2201 | SET_NETDEV_DEV(netdev, &adapter->pdev->dev); | ||
2202 | 2214 | ||
2203 | status = be_setup(adapter); | 2215 | status = be_setup(adapter); |
2204 | if (status) | 2216 | if (status) |
2205 | goto stats_clean; | 2217 | goto stats_clean; |
2218 | |||
2206 | status = register_netdev(netdev); | 2219 | status = register_netdev(netdev); |
2207 | if (status != 0) | 2220 | if (status != 0) |
2208 | goto unsetup; | 2221 | goto unsetup; |
@@ -2262,6 +2275,11 @@ static int be_resume(struct pci_dev *pdev) | |||
2262 | pci_set_power_state(pdev, 0); | 2275 | pci_set_power_state(pdev, 0); |
2263 | pci_restore_state(pdev); | 2276 | pci_restore_state(pdev); |
2264 | 2277 | ||
2278 | /* tell fw we're ready to fire cmds */ | ||
2279 | status = be_cmd_fw_init(adapter); | ||
2280 | if (status) | ||
2281 | return status; | ||
2282 | |||
2265 | be_setup(adapter); | 2283 | be_setup(adapter); |
2266 | if (netif_running(netdev)) { | 2284 | if (netif_running(netdev)) { |
2267 | rtnl_lock(); | 2285 | rtnl_lock(); |