51
51
#include "nfp_cpp.h"
52
52
#include "nfp_nsp.h"
53
53
54
+ #define NFP_NSP_TIMEOUT_DEFAULT 30
55
+ #define NFP_NSP_TIMEOUT_BOOT 30
56
+
54
57
/* Offsets relative to the CSR base */
55
58
#define NSP_STATUS 0x00
56
59
#define NSP_STATUS_MAGIC GENMASK_ULL(63, 48)
@@ -260,10 +263,10 @@ u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state)
260
263
}
261
264
262
265
static int
263
- nfp_nsp_wait_reg (struct nfp_cpp * cpp , u64 * reg ,
264
- u32 nsp_cpp , u64 addr , u64 mask , u64 val )
266
+ nfp_nsp_wait_reg (struct nfp_cpp * cpp , u64 * reg , u32 nsp_cpp , u64 addr ,
267
+ u64 mask , u64 val , u32 timeout_sec )
265
268
{
266
- const unsigned long wait_until = jiffies + 30 * HZ ;
269
+ const unsigned long wait_until = jiffies + timeout_sec * HZ ;
267
270
int err ;
268
271
269
272
for (;;) {
@@ -285,12 +288,13 @@ nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg,
285
288
}
286
289
287
290
/**
288
- * nfp_nsp_command () - Execute a command on the NFP Service Processor
291
+ * __nfp_nsp_command () - Execute a command on the NFP Service Processor
289
292
* @state: NFP SP state
290
293
* @code: NFP SP Command Code
291
294
* @option: NFP SP Command Argument
292
295
* @buff_cpp: NFP SP Buffer CPP Address info
293
296
* @buff_addr: NFP SP Buffer Host address
297
+ * @timeout_sec:Timeout value to wait for completion in seconds
294
298
*
295
299
* Return: 0 for success with no result
296
300
*
@@ -300,10 +304,11 @@ nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg,
300
304
* -ENODEV if the NSP is not a supported model
301
305
* -EBUSY if the NSP is stuck
302
306
* -EINTR if interrupted while waiting for completion
303
- * -ETIMEDOUT if the NSP took longer than 30 seconds to complete
307
+ * -ETIMEDOUT if the NSP took longer than @timeout_sec seconds to complete
304
308
*/
305
- static int nfp_nsp_command (struct nfp_nsp * state , u16 code , u32 option ,
306
- u32 buff_cpp , u64 buff_addr )
309
+ static int
310
+ __nfp_nsp_command (struct nfp_nsp * state , u16 code , u32 option , u32 buff_cpp ,
311
+ u64 buff_addr , u32 timeout_sec )
307
312
{
308
313
u64 reg , ret_val , nsp_base , nsp_buffer , nsp_status , nsp_command ;
309
314
struct nfp_cpp * cpp = state -> cpp ;
@@ -341,17 +346,17 @@ static int nfp_nsp_command(struct nfp_nsp *state, u16 code, u32 option,
341
346
return err ;
342
347
343
348
/* Wait for NSP_COMMAND_START to go to 0 */
344
- err = nfp_nsp_wait_reg (cpp , & reg ,
345
- nsp_cpp , nsp_command , NSP_COMMAND_START , 0 );
349
+ err = nfp_nsp_wait_reg (cpp , & reg , nsp_cpp , nsp_command ,
350
+ NSP_COMMAND_START , 0 , NFP_NSP_TIMEOUT_DEFAULT );
346
351
if (err ) {
347
352
nfp_err (cpp , "Error %d waiting for code 0x%04x to start\n" ,
348
353
err , code );
349
354
return err ;
350
355
}
351
356
352
357
/* Wait for NSP_STATUS_BUSY to go to 0 */
353
- err = nfp_nsp_wait_reg (cpp , & reg ,
354
- nsp_cpp , nsp_status , NSP_STATUS_BUSY , 0 );
358
+ err = nfp_nsp_wait_reg (cpp , & reg , nsp_cpp , nsp_status , NSP_STATUS_BUSY ,
359
+ 0 , timeout_sec );
355
360
if (err ) {
356
361
nfp_err (cpp , "Error %d waiting for code 0x%04x to complete\n" ,
357
362
err , code );
@@ -374,9 +379,18 @@ static int nfp_nsp_command(struct nfp_nsp *state, u16 code, u32 option,
374
379
return ret_val ;
375
380
}
376
381
377
- static int nfp_nsp_command_buf (struct nfp_nsp * nsp , u16 code , u32 option ,
378
- const void * in_buf , unsigned int in_size ,
379
- void * out_buf , unsigned int out_size )
382
+ static int
383
+ nfp_nsp_command (struct nfp_nsp * state , u16 code , u32 option , u32 buff_cpp ,
384
+ u64 buff_addr )
385
+ {
386
+ return __nfp_nsp_command (state , code , option , buff_cpp , buff_addr ,
387
+ NFP_NSP_TIMEOUT_DEFAULT );
388
+ }
389
+
390
+ static int
391
+ __nfp_nsp_command_buf (struct nfp_nsp * nsp , u16 code , u32 option ,
392
+ const void * in_buf , unsigned int in_size , void * out_buf ,
393
+ unsigned int out_size , u32 timeout_sec )
380
394
{
381
395
struct nfp_cpp * cpp = nsp -> cpp ;
382
396
unsigned int max_size ;
@@ -429,7 +443,8 @@ static int nfp_nsp_command_buf(struct nfp_nsp *nsp, u16 code, u32 option,
429
443
return err ;
430
444
}
431
445
432
- ret = nfp_nsp_command (nsp , code , option , cpp_id , cpp_buf );
446
+ ret = __nfp_nsp_command (nsp , code , option , cpp_id , cpp_buf ,
447
+ timeout_sec );
433
448
if (ret < 0 )
434
449
return ret ;
435
450
@@ -442,12 +457,23 @@ static int nfp_nsp_command_buf(struct nfp_nsp *nsp, u16 code, u32 option,
442
457
return ret ;
443
458
}
444
459
460
+ static int
461
+ nfp_nsp_command_buf (struct nfp_nsp * nsp , u16 code , u32 option ,
462
+ const void * in_buf , unsigned int in_size , void * out_buf ,
463
+ unsigned int out_size )
464
+ {
465
+ return __nfp_nsp_command_buf (nsp , code , option , in_buf , in_size ,
466
+ out_buf , out_size ,
467
+ NFP_NSP_TIMEOUT_DEFAULT );
468
+ }
469
+
445
470
int nfp_nsp_wait (struct nfp_nsp * state )
446
471
{
447
- const unsigned long wait_until = jiffies + 30 * HZ ;
472
+ const unsigned long wait_until = jiffies + NFP_NSP_TIMEOUT_BOOT * HZ ;
448
473
int err ;
449
474
450
- nfp_dbg (state -> cpp , "Waiting for NSP to respond (30 sec max).\n" );
475
+ nfp_dbg (state -> cpp , "Waiting for NSP to respond (%u sec max).\n" ,
476
+ NFP_NSP_TIMEOUT_BOOT );
451
477
452
478
for (;;) {
453
479
const unsigned long start_time = jiffies ;
0 commit comments