14
14
#include "mcdi_pcol.h"
15
15
#include "nic.h"
16
16
#include "workarounds.h"
17
+ #include "selftest.h"
17
18
#include <linux/in.h>
18
19
#include <linux/jhash.h>
19
20
#include <linux/wait.h>
@@ -277,11 +278,17 @@ static int efx_ef10_probe(struct efx_nic *efx)
277
278
278
279
static int efx_ef10_free_vis (struct efx_nic * efx )
279
280
{
280
- int rc = efx_mcdi_rpc (efx , MC_CMD_FREE_VIS , NULL , 0 , NULL , 0 , NULL );
281
+ MCDI_DECLARE_BUF_OUT_OR_ERR (outbuf , 0 );
282
+ size_t outlen ;
283
+ int rc = efx_mcdi_rpc_quiet (efx , MC_CMD_FREE_VIS , NULL , 0 ,
284
+ outbuf , sizeof (outbuf ), & outlen );
281
285
282
286
/* -EALREADY means nothing to free, so ignore */
283
287
if (rc == - EALREADY )
284
288
rc = 0 ;
289
+ if (rc )
290
+ efx_mcdi_display_error (efx , MC_CMD_FREE_VIS , 0 , outbuf , outlen ,
291
+ rc );
285
292
return rc ;
286
293
}
287
294
@@ -901,6 +908,7 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx)
901
908
return - EAGAIN ;
902
909
903
910
/* Update derived statistics */
911
+ efx_nic_fix_nodesc_drop_stat (efx , & stats [EF10_STAT_rx_nodesc_drops ]);
904
912
stats [EF10_STAT_rx_good_bytes ] =
905
913
stats [EF10_STAT_rx_bytes ] -
906
914
stats [EF10_STAT_rx_bytes_minus_good_bytes ];
@@ -1242,7 +1250,6 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
1242
1250
1243
1251
fail :
1244
1252
WARN_ON (true);
1245
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1246
1253
}
1247
1254
1248
1255
static void efx_ef10_tx_fini (struct efx_tx_queue * tx_queue )
@@ -1256,7 +1263,7 @@ static void efx_ef10_tx_fini(struct efx_tx_queue *tx_queue)
1256
1263
MCDI_SET_DWORD (inbuf , FINI_TXQ_IN_INSTANCE ,
1257
1264
tx_queue -> queue );
1258
1265
1259
- rc = efx_mcdi_rpc (efx , MC_CMD_FINI_TXQ , inbuf , sizeof (inbuf ),
1266
+ rc = efx_mcdi_rpc_quiet (efx , MC_CMD_FINI_TXQ , inbuf , sizeof (inbuf ),
1260
1267
outbuf , sizeof (outbuf ), & outlen );
1261
1268
1262
1269
if (rc && rc != - EALREADY )
@@ -1265,7 +1272,8 @@ static void efx_ef10_tx_fini(struct efx_tx_queue *tx_queue)
1265
1272
return ;
1266
1273
1267
1274
fail :
1268
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1275
+ efx_mcdi_display_error (efx , MC_CMD_FINI_TXQ , MC_CMD_FINI_TXQ_IN_LEN ,
1276
+ outbuf , outlen , rc );
1269
1277
}
1270
1278
1271
1279
static void efx_ef10_tx_remove (struct efx_tx_queue * tx_queue )
@@ -1480,14 +1488,9 @@ static void efx_ef10_rx_init(struct efx_rx_queue *rx_queue)
1480
1488
1481
1489
rc = efx_mcdi_rpc (efx , MC_CMD_INIT_RXQ , inbuf , inlen ,
1482
1490
outbuf , sizeof (outbuf ), & outlen );
1483
- if (rc )
1484
- goto fail ;
1491
+ WARN_ON (rc );
1485
1492
1486
1493
return ;
1487
-
1488
- fail :
1489
- WARN_ON (true);
1490
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1491
1494
}
1492
1495
1493
1496
static void efx_ef10_rx_fini (struct efx_rx_queue * rx_queue )
@@ -1501,7 +1504,7 @@ static void efx_ef10_rx_fini(struct efx_rx_queue *rx_queue)
1501
1504
MCDI_SET_DWORD (inbuf , FINI_RXQ_IN_INSTANCE ,
1502
1505
efx_rx_queue_index (rx_queue ));
1503
1506
1504
- rc = efx_mcdi_rpc (efx , MC_CMD_FINI_RXQ , inbuf , sizeof (inbuf ),
1507
+ rc = efx_mcdi_rpc_quiet (efx , MC_CMD_FINI_RXQ , inbuf , sizeof (inbuf ),
1505
1508
outbuf , sizeof (outbuf ), & outlen );
1506
1509
1507
1510
if (rc && rc != - EALREADY )
@@ -1510,7 +1513,8 @@ static void efx_ef10_rx_fini(struct efx_rx_queue *rx_queue)
1510
1513
return ;
1511
1514
1512
1515
fail :
1513
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1516
+ efx_mcdi_display_error (efx , MC_CMD_FINI_RXQ , MC_CMD_FINI_RXQ_IN_LEN ,
1517
+ outbuf , outlen , rc );
1514
1518
}
1515
1519
1516
1520
static void efx_ef10_rx_remove (struct efx_rx_queue * rx_queue )
@@ -1647,15 +1651,7 @@ static int efx_ef10_ev_init(struct efx_channel *channel)
1647
1651
1648
1652
rc = efx_mcdi_rpc (efx , MC_CMD_INIT_EVQ , inbuf , inlen ,
1649
1653
outbuf , sizeof (outbuf ), & outlen );
1650
- if (rc )
1651
- goto fail ;
1652
-
1653
1654
/* IRQ return is ignored */
1654
-
1655
- return 0 ;
1656
-
1657
- fail :
1658
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1659
1655
return rc ;
1660
1656
}
1661
1657
@@ -1669,7 +1665,7 @@ static void efx_ef10_ev_fini(struct efx_channel *channel)
1669
1665
1670
1666
MCDI_SET_DWORD (inbuf , FINI_EVQ_IN_INSTANCE , channel -> channel );
1671
1667
1672
- rc = efx_mcdi_rpc (efx , MC_CMD_FINI_EVQ , inbuf , sizeof (inbuf ),
1668
+ rc = efx_mcdi_rpc_quiet (efx , MC_CMD_FINI_EVQ , inbuf , sizeof (inbuf ),
1673
1669
outbuf , sizeof (outbuf ), & outlen );
1674
1670
1675
1671
if (rc && rc != - EALREADY )
@@ -1678,7 +1674,8 @@ static void efx_ef10_ev_fini(struct efx_channel *channel)
1678
1674
return ;
1679
1675
1680
1676
fail :
1681
- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
1677
+ efx_mcdi_display_error (efx , MC_CMD_FINI_EVQ , MC_CMD_FINI_EVQ_IN_LEN ,
1678
+ outbuf , outlen , rc );
1682
1679
}
1683
1680
1684
1681
static void efx_ef10_ev_remove (struct efx_channel * channel )
@@ -1765,17 +1762,22 @@ static int efx_ef10_handle_rx_event(struct efx_channel *channel,
1765
1762
((1 << ESF_DZ_RX_DSC_PTR_LBITS_WIDTH ) - 1 ));
1766
1763
1767
1764
if (n_descs != rx_queue -> scatter_n + 1 ) {
1765
+ struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
1766
+
1768
1767
/* detect rx abort */
1769
1768
if (unlikely (n_descs == rx_queue -> scatter_n )) {
1770
1769
WARN_ON (rx_bytes != 0 );
1771
1770
efx_ef10_handle_rx_abort (rx_queue );
1772
1771
return 0 ;
1773
1772
}
1774
1773
1775
- if (unlikely (rx_queue -> scatter_n != 0 )) {
1776
- /* Scattered packet completions cannot be
1777
- * merged, so something has gone wrong.
1778
- */
1774
+ /* Check that RX completion merging is valid, i.e.
1775
+ * the current firmware supports it and this is a
1776
+ * non-scattered packet.
1777
+ */
1778
+ if (!(nic_data -> datapath_caps &
1779
+ (1 << MC_CMD_GET_CAPABILITIES_OUT_RX_BATCHING_LBN )) ||
1780
+ rx_queue -> scatter_n != 0 || rx_cont ) {
1779
1781
efx_ef10_handle_rx_bad_lbits (
1780
1782
rx_queue , next_ptr_lbits ,
1781
1783
(rx_queue -> removed_count +
@@ -1901,7 +1903,7 @@ static void efx_ef10_handle_driver_generated_event(struct efx_channel *channel,
1901
1903
* events, so efx_process_channel() won't refill the
1902
1904
* queue. Refill it here
1903
1905
*/
1904
- efx_fast_push_rx_descriptors (& channel -> rx_queue );
1906
+ efx_fast_push_rx_descriptors (& channel -> rx_queue , true );
1905
1907
break ;
1906
1908
default :
1907
1909
netif_err (efx , hw , efx -> net_dev ,
@@ -2257,6 +2259,8 @@ static int efx_ef10_filter_push(struct efx_nic *efx,
2257
2259
outbuf , sizeof (outbuf ), NULL );
2258
2260
if (rc == 0 )
2259
2261
* handle = MCDI_QWORD (outbuf , FILTER_OP_OUT_HANDLE );
2262
+ if (rc == - ENOSPC )
2263
+ rc = - EBUSY ; /* to match efx_farch_filter_insert() */
2260
2264
return rc ;
2261
2265
}
2262
2266
@@ -3195,6 +3199,87 @@ static int efx_ef10_mac_reconfigure(struct efx_nic *efx)
3195
3199
return efx_mcdi_set_mac (efx );
3196
3200
}
3197
3201
3202
+ static int efx_ef10_start_bist (struct efx_nic * efx , u32 bist_type )
3203
+ {
3204
+ MCDI_DECLARE_BUF (inbuf , MC_CMD_START_BIST_IN_LEN );
3205
+
3206
+ MCDI_SET_DWORD (inbuf , START_BIST_IN_TYPE , bist_type );
3207
+ return efx_mcdi_rpc (efx , MC_CMD_START_BIST , inbuf , sizeof (inbuf ),
3208
+ NULL , 0 , NULL );
3209
+ }
3210
+
3211
+ /* MC BISTs follow a different poll mechanism to phy BISTs.
3212
+ * The BIST is done in the poll handler on the MC, and the MCDI command
3213
+ * will block until the BIST is done.
3214
+ */
3215
+ static int efx_ef10_poll_bist (struct efx_nic * efx )
3216
+ {
3217
+ int rc ;
3218
+ MCDI_DECLARE_BUF (outbuf , MC_CMD_POLL_BIST_OUT_LEN );
3219
+ size_t outlen ;
3220
+ u32 result ;
3221
+
3222
+ rc = efx_mcdi_rpc (efx , MC_CMD_POLL_BIST , NULL , 0 ,
3223
+ outbuf , sizeof (outbuf ), & outlen );
3224
+ if (rc != 0 )
3225
+ return rc ;
3226
+
3227
+ if (outlen < MC_CMD_POLL_BIST_OUT_LEN )
3228
+ return - EIO ;
3229
+
3230
+ result = MCDI_DWORD (outbuf , POLL_BIST_OUT_RESULT );
3231
+ switch (result ) {
3232
+ case MC_CMD_POLL_BIST_PASSED :
3233
+ netif_dbg (efx , hw , efx -> net_dev , "BIST passed.\n" );
3234
+ return 0 ;
3235
+ case MC_CMD_POLL_BIST_TIMEOUT :
3236
+ netif_err (efx , hw , efx -> net_dev , "BIST timed out\n" );
3237
+ return - EIO ;
3238
+ case MC_CMD_POLL_BIST_FAILED :
3239
+ netif_err (efx , hw , efx -> net_dev , "BIST failed.\n" );
3240
+ return - EIO ;
3241
+ default :
3242
+ netif_err (efx , hw , efx -> net_dev ,
3243
+ "BIST returned unknown result %u" , result );
3244
+ return - EIO ;
3245
+ }
3246
+ }
3247
+
3248
+ static int efx_ef10_run_bist (struct efx_nic * efx , u32 bist_type )
3249
+ {
3250
+ int rc ;
3251
+
3252
+ netif_dbg (efx , drv , efx -> net_dev , "starting BIST type %u\n" , bist_type );
3253
+
3254
+ rc = efx_ef10_start_bist (efx , bist_type );
3255
+ if (rc != 0 )
3256
+ return rc ;
3257
+
3258
+ return efx_ef10_poll_bist (efx );
3259
+ }
3260
+
3261
+ static int
3262
+ efx_ef10_test_chip (struct efx_nic * efx , struct efx_self_tests * tests )
3263
+ {
3264
+ int rc , rc2 ;
3265
+
3266
+ efx_reset_down (efx , RESET_TYPE_WORLD );
3267
+
3268
+ rc = efx_mcdi_rpc (efx , MC_CMD_ENABLE_OFFLINE_BIST ,
3269
+ NULL , 0 , NULL , 0 , NULL );
3270
+ if (rc != 0 )
3271
+ goto out ;
3272
+
3273
+ tests -> memory = efx_ef10_run_bist (efx , MC_CMD_MC_MEM_BIST ) ? -1 : 1 ;
3274
+ tests -> registers = efx_ef10_run_bist (efx , MC_CMD_REG_BIST ) ? -1 : 1 ;
3275
+
3276
+ rc = efx_mcdi_reset (efx , RESET_TYPE_WORLD );
3277
+
3278
+ out :
3279
+ rc2 = efx_reset_up (efx , RESET_TYPE_WORLD , rc == 0 );
3280
+ return rc ? rc : rc2 ;
3281
+ }
3282
+
3198
3283
#ifdef CONFIG_SFC_MTD
3199
3284
3200
3285
struct efx_ef10_nvram_type_info {
@@ -3213,6 +3298,7 @@ static const struct efx_ef10_nvram_type_info efx_ef10_nvram_types[] = {
3213
3298
{ NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT1 , 0 , 1 , "sfc_exp_rom_cfg" },
3214
3299
{ NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT2 , 0 , 2 , "sfc_exp_rom_cfg" },
3215
3300
{ NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT3 , 0 , 3 , "sfc_exp_rom_cfg" },
3301
+ { NVRAM_PARTITION_TYPE_LICENSE , 0 , 0 , "sfc_license" },
3216
3302
{ NVRAM_PARTITION_TYPE_PHY_MIN , 0xff , 0 , "sfc_phy_fw" },
3217
3303
};
3218
3304
@@ -3336,6 +3422,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
3336
3422
.describe_stats = efx_ef10_describe_stats ,
3337
3423
.update_stats = efx_ef10_update_stats ,
3338
3424
.start_stats = efx_mcdi_mac_start_stats ,
3425
+ .pull_stats = efx_mcdi_mac_pull_stats ,
3339
3426
.stop_stats = efx_mcdi_mac_stop_stats ,
3340
3427
.set_id_led = efx_mcdi_set_id_led ,
3341
3428
.push_irq_moderation = efx_ef10_push_irq_moderation ,
@@ -3345,7 +3432,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
3345
3432
.get_wol = efx_ef10_get_wol ,
3346
3433
.set_wol = efx_ef10_set_wol ,
3347
3434
.resume_wol = efx_port_dummy_op_void ,
3348
- /* TODO: test_chip */
3435
+ . test_chip = efx_ef10_test_chip ,
3349
3436
.test_nvram = efx_mcdi_nvram_test_all ,
3350
3437
.mcdi_request = efx_ef10_mcdi_request ,
3351
3438
.mcdi_poll_response = efx_ef10_mcdi_poll_response ,
0 commit comments