1414#include "mcdi_pcol.h"
1515#include "nic.h"
1616#include "workarounds.h"
17+ #include "selftest.h"
1718#include <linux/in.h>
1819#include <linux/jhash.h>
1920#include <linux/wait.h>
@@ -277,11 +278,17 @@ static int efx_ef10_probe(struct efx_nic *efx)
277278
278279static int efx_ef10_free_vis (struct efx_nic * efx )
279280{
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 );
281285
282286 /* -EALREADY means nothing to free, so ignore */
283287 if (rc == - EALREADY )
284288 rc = 0 ;
289+ if (rc )
290+ efx_mcdi_display_error (efx , MC_CMD_FREE_VIS , 0 , outbuf , outlen ,
291+ rc );
285292 return rc ;
286293}
287294
@@ -901,6 +908,7 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx)
901908 return - EAGAIN ;
902909
903910 /* Update derived statistics */
911+ efx_nic_fix_nodesc_drop_stat (efx , & stats [EF10_STAT_rx_nodesc_drops ]);
904912 stats [EF10_STAT_rx_good_bytes ] =
905913 stats [EF10_STAT_rx_bytes ] -
906914 stats [EF10_STAT_rx_bytes_minus_good_bytes ];
@@ -1242,7 +1250,6 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
12421250
12431251fail :
12441252 WARN_ON (true);
1245- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
12461253}
12471254
12481255static 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)
12561263 MCDI_SET_DWORD (inbuf , FINI_TXQ_IN_INSTANCE ,
12571264 tx_queue -> queue );
12581265
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 ),
12601267 outbuf , sizeof (outbuf ), & outlen );
12611268
12621269 if (rc && rc != - EALREADY )
@@ -1265,7 +1272,8 @@ static void efx_ef10_tx_fini(struct efx_tx_queue *tx_queue)
12651272 return ;
12661273
12671274fail :
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 );
12691277}
12701278
12711279static 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)
14801488
14811489 rc = efx_mcdi_rpc (efx , MC_CMD_INIT_RXQ , inbuf , inlen ,
14821490 outbuf , sizeof (outbuf ), & outlen );
1483- if (rc )
1484- goto fail ;
1491+ WARN_ON (rc );
14851492
14861493 return ;
1487-
1488- fail :
1489- WARN_ON (true);
1490- netif_err (efx , hw , efx -> net_dev , "%s: failed rc=%d\n" , __func__ , rc );
14911494}
14921495
14931496static 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)
15011504 MCDI_SET_DWORD (inbuf , FINI_RXQ_IN_INSTANCE ,
15021505 efx_rx_queue_index (rx_queue ));
15031506
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 ),
15051508 outbuf , sizeof (outbuf ), & outlen );
15061509
15071510 if (rc && rc != - EALREADY )
@@ -1510,7 +1513,8 @@ static void efx_ef10_rx_fini(struct efx_rx_queue *rx_queue)
15101513 return ;
15111514
15121515fail :
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 );
15141518}
15151519
15161520static 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)
16471651
16481652 rc = efx_mcdi_rpc (efx , MC_CMD_INIT_EVQ , inbuf , inlen ,
16491653 outbuf , sizeof (outbuf ), & outlen );
1650- if (rc )
1651- goto fail ;
1652-
16531654 /* 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 );
16591655 return rc ;
16601656}
16611657
@@ -1669,7 +1665,7 @@ static void efx_ef10_ev_fini(struct efx_channel *channel)
16691665
16701666 MCDI_SET_DWORD (inbuf , FINI_EVQ_IN_INSTANCE , channel -> channel );
16711667
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 ),
16731669 outbuf , sizeof (outbuf ), & outlen );
16741670
16751671 if (rc && rc != - EALREADY )
@@ -1678,7 +1674,8 @@ static void efx_ef10_ev_fini(struct efx_channel *channel)
16781674 return ;
16791675
16801676fail :
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 );
16821679}
16831680
16841681static void efx_ef10_ev_remove (struct efx_channel * channel )
@@ -1765,17 +1762,22 @@ static int efx_ef10_handle_rx_event(struct efx_channel *channel,
17651762 ((1 << ESF_DZ_RX_DSC_PTR_LBITS_WIDTH ) - 1 ));
17661763
17671764 if (n_descs != rx_queue -> scatter_n + 1 ) {
1765+ struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
1766+
17681767 /* detect rx abort */
17691768 if (unlikely (n_descs == rx_queue -> scatter_n )) {
17701769 WARN_ON (rx_bytes != 0 );
17711770 efx_ef10_handle_rx_abort (rx_queue );
17721771 return 0 ;
17731772 }
17741773
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 ) {
17791781 efx_ef10_handle_rx_bad_lbits (
17801782 rx_queue , next_ptr_lbits ,
17811783 (rx_queue -> removed_count +
@@ -1901,7 +1903,7 @@ static void efx_ef10_handle_driver_generated_event(struct efx_channel *channel,
19011903 * events, so efx_process_channel() won't refill the
19021904 * queue. Refill it here
19031905 */
1904- efx_fast_push_rx_descriptors (& channel -> rx_queue );
1906+ efx_fast_push_rx_descriptors (& channel -> rx_queue , true );
19051907 break ;
19061908 default :
19071909 netif_err (efx , hw , efx -> net_dev ,
@@ -2257,6 +2259,8 @@ static int efx_ef10_filter_push(struct efx_nic *efx,
22572259 outbuf , sizeof (outbuf ), NULL );
22582260 if (rc == 0 )
22592261 * handle = MCDI_QWORD (outbuf , FILTER_OP_OUT_HANDLE );
2262+ if (rc == - ENOSPC )
2263+ rc = - EBUSY ; /* to match efx_farch_filter_insert() */
22602264 return rc ;
22612265}
22622266
@@ -3195,6 +3199,87 @@ static int efx_ef10_mac_reconfigure(struct efx_nic *efx)
31953199 return efx_mcdi_set_mac (efx );
31963200}
31973201
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+
31983283#ifdef CONFIG_SFC_MTD
31993284
32003285struct efx_ef10_nvram_type_info {
@@ -3213,6 +3298,7 @@ static const struct efx_ef10_nvram_type_info efx_ef10_nvram_types[] = {
32133298 { NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT1 , 0 , 1 , "sfc_exp_rom_cfg" },
32143299 { NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT2 , 0 , 2 , "sfc_exp_rom_cfg" },
32153300 { NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT3 , 0 , 3 , "sfc_exp_rom_cfg" },
3301+ { NVRAM_PARTITION_TYPE_LICENSE , 0 , 0 , "sfc_license" },
32163302 { NVRAM_PARTITION_TYPE_PHY_MIN , 0xff , 0 , "sfc_phy_fw" },
32173303};
32183304
@@ -3336,6 +3422,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
33363422 .describe_stats = efx_ef10_describe_stats ,
33373423 .update_stats = efx_ef10_update_stats ,
33383424 .start_stats = efx_mcdi_mac_start_stats ,
3425+ .pull_stats = efx_mcdi_mac_pull_stats ,
33393426 .stop_stats = efx_mcdi_mac_stop_stats ,
33403427 .set_id_led = efx_mcdi_set_id_led ,
33413428 .push_irq_moderation = efx_ef10_push_irq_moderation ,
@@ -3345,7 +3432,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
33453432 .get_wol = efx_ef10_get_wol ,
33463433 .set_wol = efx_ef10_set_wol ,
33473434 .resume_wol = efx_port_dummy_op_void ,
3348- /* TODO: test_chip */
3435+ . test_chip = efx_ef10_test_chip ,
33493436 .test_nvram = efx_mcdi_nvram_test_all ,
33503437 .mcdi_request = efx_ef10_mcdi_request ,
33513438 .mcdi_poll_response = efx_ef10_mcdi_poll_response ,
0 commit comments