aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2013-08-29 14:04:03 -0400
committerBen Hutchings <bhutchings@solarflare.com>2013-08-29 14:06:34 -0400
commit4c75b43a7795671a52a002034d370ea1352f95c8 (patch)
tree719ce47d6890b39a6b5df759088d237ab7a4dfa4
parentbedca866f854daa1f6b9a9c3e94949567cdc3409 (diff)
sfc: Make efx_mcdi_{init,fini}() call efx_mcdi_drv_attach()
This should be done during MCDI initialisation for any NIC. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--drivers/net/ethernet/sfc/mcdi.c37
-rw-r--r--drivers/net/ethernet/sfc/mcdi.h2
-rw-r--r--drivers/net/ethernet/sfc/siena.c21
3 files changed, 34 insertions, 26 deletions
diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index 8150781b41eb..d8a20f514f80 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -48,6 +48,8 @@ struct efx_mcdi_async_param {
48}; 48};
49 49
50static void efx_mcdi_timeout_async(unsigned long context); 50static void efx_mcdi_timeout_async(unsigned long context);
51static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
52 bool *was_attached_out);
51 53
52static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx) 54static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
53{ 55{
@@ -58,6 +60,8 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
58int efx_mcdi_init(struct efx_nic *efx) 60int efx_mcdi_init(struct efx_nic *efx)
59{ 61{
60 struct efx_mcdi_iface *mcdi; 62 struct efx_mcdi_iface *mcdi;
63 bool already_attached;
64 int rc;
61 65
62 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL); 66 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL);
63 if (!efx->mcdi) 67 if (!efx->mcdi)
@@ -78,12 +82,37 @@ int efx_mcdi_init(struct efx_nic *efx)
78 mcdi->new_epoch = true; 82 mcdi->new_epoch = true;
79 83
80 /* Recover from a failed assertion before probing */ 84 /* Recover from a failed assertion before probing */
81 return efx_mcdi_handle_assertion(efx); 85 rc = efx_mcdi_handle_assertion(efx);
86 if (rc)
87 return rc;
88
89 /* Let the MC (and BMC, if this is a LOM) know that the driver
90 * is loaded. We should do this before we reset the NIC.
91 */
92 rc = efx_mcdi_drv_attach(efx, true, &already_attached);
93 if (rc) {
94 netif_err(efx, probe, efx->net_dev,
95 "Unable to register driver with MCPU\n");
96 return rc;
97 }
98 if (already_attached)
99 /* Not a fatal error */
100 netif_err(efx, probe, efx->net_dev,
101 "Host already registered with MCPU\n");
102
103 return 0;
82} 104}
83 105
84void efx_mcdi_fini(struct efx_nic *efx) 106void efx_mcdi_fini(struct efx_nic *efx)
85{ 107{
86 BUG_ON(efx->mcdi && efx->mcdi->iface.state != MCDI_STATE_QUIESCENT); 108 if (!efx->mcdi)
109 return;
110
111 BUG_ON(efx->mcdi->iface.state != MCDI_STATE_QUIESCENT);
112
113 /* Relinquish the device (back to the BMC, if this is a LOM) */
114 efx_mcdi_drv_attach(efx, false, NULL);
115
87 kfree(efx->mcdi); 116 kfree(efx->mcdi);
88} 117}
89 118
@@ -889,8 +918,8 @@ fail:
889 buf[0] = 0; 918 buf[0] = 0;
890} 919}
891 920
892int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 921static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
893 bool *was_attached) 922 bool *was_attached)
894{ 923{
895 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN); 924 MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN);
896 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN); 925 MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN);
diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h
index e37cf1d6ed46..0ca00a631986 100644
--- a/drivers/net/ethernet/sfc/mcdi.h
+++ b/drivers/net/ethernet/sfc/mcdi.h
@@ -273,8 +273,6 @@ extern void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
273 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) 273 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
274 274
275extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); 275extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
276extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
277 bool *was_attached_out);
278extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 276extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
279 u16 *fw_subtype_list, u32 *capabilities); 277 u16 *fw_subtype_list, u32 *capabilities);
280extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, 278extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart,
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
index 1500405b3a55..e8eef63a55ee 100644
--- a/drivers/net/ethernet/sfc/siena.c
+++ b/drivers/net/ethernet/sfc/siena.c
@@ -196,7 +196,6 @@ static unsigned int siena_mem_map_size(struct efx_nic *efx)
196static int siena_probe_nic(struct efx_nic *efx) 196static int siena_probe_nic(struct efx_nic *efx)
197{ 197{
198 struct siena_nic_data *nic_data; 198 struct siena_nic_data *nic_data;
199 bool already_attached = false;
200 efx_oword_t reg; 199 efx_oword_t reg;
201 int rc; 200 int rc;
202 201
@@ -222,19 +221,6 @@ static int siena_probe_nic(struct efx_nic *efx)
222 if (rc) 221 if (rc)
223 goto fail1; 222 goto fail1;
224 223
225 /* Let the BMC know that the driver is now in charge of link and
226 * filter settings. We must do this before we reset the NIC */
227 rc = efx_mcdi_drv_attach(efx, true, &already_attached);
228 if (rc) {
229 netif_err(efx, probe, efx->net_dev,
230 "Unable to register driver with MCPU\n");
231 goto fail2;
232 }
233 if (already_attached)
234 /* Not a fatal error */
235 netif_err(efx, probe, efx->net_dev,
236 "Host already registered with MCPU\n");
237
238 /* Now we can reset the NIC */ 224 /* Now we can reset the NIC */
239 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL); 225 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL);
240 if (rc) { 226 if (rc) {
@@ -281,8 +267,6 @@ fail5:
281 efx_nic_free_buffer(efx, &efx->irq_status); 267 efx_nic_free_buffer(efx, &efx->irq_status);
282fail4: 268fail4:
283fail3: 269fail3:
284 efx_mcdi_drv_attach(efx, false, NULL);
285fail2:
286 efx_mcdi_fini(efx); 270 efx_mcdi_fini(efx);
287fail1: 271fail1:
288 kfree(efx->nic_data); 272 kfree(efx->nic_data);
@@ -371,14 +355,11 @@ static void siena_remove_nic(struct efx_nic *efx)
371 355
372 efx_mcdi_reset(efx, RESET_TYPE_ALL); 356 efx_mcdi_reset(efx, RESET_TYPE_ALL);
373 357
374 /* Relinquish the device back to the BMC */ 358 efx_mcdi_fini(efx);
375 efx_mcdi_drv_attach(efx, false, NULL);
376 359
377 /* Tear down the private nic state */ 360 /* Tear down the private nic state */
378 kfree(efx->nic_data); 361 kfree(efx->nic_data);
379 efx->nic_data = NULL; 362 efx->nic_data = NULL;
380
381 efx_mcdi_fini(efx);
382} 363}
383 364
384#define SIENA_DMA_STAT(ext_name, mcdi_name) \ 365#define SIENA_DMA_STAT(ext_name, mcdi_name) \