@@ -1288,26 +1288,22 @@ static int handle_invalid_req_id(struct ena_ring *ring, u16 req_id,
1288
1288
1289
1289
static int validate_tx_req_id (struct ena_ring * tx_ring , u16 req_id )
1290
1290
{
1291
- struct ena_tx_buffer * tx_info = NULL ;
1291
+ struct ena_tx_buffer * tx_info ;
1292
1292
1293
- if (likely (req_id < tx_ring -> ring_size )) {
1294
- tx_info = & tx_ring -> tx_buffer_info [req_id ];
1295
- if (likely (tx_info -> skb ))
1296
- return 0 ;
1297
- }
1293
+ tx_info = & tx_ring -> tx_buffer_info [req_id ];
1294
+ if (likely (tx_info -> skb ))
1295
+ return 0 ;
1298
1296
1299
1297
return handle_invalid_req_id (tx_ring , req_id , tx_info , false);
1300
1298
}
1301
1299
1302
1300
static int validate_xdp_req_id (struct ena_ring * xdp_ring , u16 req_id )
1303
1301
{
1304
- struct ena_tx_buffer * tx_info = NULL ;
1302
+ struct ena_tx_buffer * tx_info ;
1305
1303
1306
- if (likely (req_id < xdp_ring -> ring_size )) {
1307
- tx_info = & xdp_ring -> tx_buffer_info [req_id ];
1308
- if (likely (tx_info -> xdpf ))
1309
- return 0 ;
1310
- }
1304
+ tx_info = & xdp_ring -> tx_buffer_info [req_id ];
1305
+ if (likely (tx_info -> xdpf ))
1306
+ return 0 ;
1311
1307
1312
1308
return handle_invalid_req_id (xdp_ring , req_id , tx_info , true);
1313
1309
}
@@ -1332,9 +1328,14 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
1332
1328
1333
1329
rc = ena_com_tx_comp_req_id_get (tx_ring -> ena_com_io_cq ,
1334
1330
& req_id );
1335
- if (rc )
1331
+ if (rc ) {
1332
+ if (unlikely (rc == - EINVAL ))
1333
+ handle_invalid_req_id (tx_ring , req_id , NULL ,
1334
+ false);
1336
1335
break ;
1336
+ }
1337
1337
1338
+ /* validate that the request id points to a valid skb */
1338
1339
rc = validate_tx_req_id (tx_ring , req_id );
1339
1340
if (rc )
1340
1341
break ;
@@ -1427,6 +1428,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
1427
1428
u16 * next_to_clean )
1428
1429
{
1429
1430
struct ena_rx_buffer * rx_info ;
1431
+ struct ena_adapter * adapter ;
1430
1432
u16 len , req_id , buf = 0 ;
1431
1433
struct sk_buff * skb ;
1432
1434
void * page_addr ;
@@ -1439,8 +1441,14 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
1439
1441
rx_info = & rx_ring -> rx_buffer_info [req_id ];
1440
1442
1441
1443
if (unlikely (!rx_info -> page )) {
1442
- netif_err (rx_ring -> adapter , rx_err , rx_ring -> netdev ,
1443
- "Page is NULL\n" );
1444
+ adapter = rx_ring -> adapter ;
1445
+ netif_err (adapter , rx_err , rx_ring -> netdev ,
1446
+ "Page is NULL. qid %u req_id %u\n" , rx_ring -> qid , req_id );
1447
+ ena_increase_stat (& rx_ring -> rx_stats .bad_req_id , 1 , & rx_ring -> syncp );
1448
+ adapter -> reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID ;
1449
+ /* Make sure reset reason is set before triggering the reset */
1450
+ smp_mb__before_atomic ();
1451
+ set_bit (ENA_FLAG_TRIGGER_RESET , & adapter -> flags );
1444
1452
return NULL ;
1445
1453
}
1446
1454
@@ -1896,9 +1904,14 @@ static int ena_clean_xdp_irq(struct ena_ring *xdp_ring, u32 budget)
1896
1904
1897
1905
rc = ena_com_tx_comp_req_id_get (xdp_ring -> ena_com_io_cq ,
1898
1906
& req_id );
1899
- if (rc )
1907
+ if (rc ) {
1908
+ if (unlikely (rc == - EINVAL ))
1909
+ handle_invalid_req_id (xdp_ring , req_id , NULL ,
1910
+ true);
1900
1911
break ;
1912
+ }
1901
1913
1914
+ /* validate that the request id points to a valid xdp_frame */
1902
1915
rc = validate_xdp_req_id (xdp_ring , req_id );
1903
1916
if (rc )
1904
1917
break ;
@@ -4013,10 +4026,6 @@ static u32 ena_calc_max_io_queue_num(struct pci_dev *pdev,
4013
4026
max_num_io_queues = min_t (u32 , max_num_io_queues , io_tx_cq_num );
4014
4027
/* 1 IRQ for mgmnt and 1 IRQs for each IO direction */
4015
4028
max_num_io_queues = min_t (u32 , max_num_io_queues , pci_msix_vec_count (pdev ) - 1 );
4016
- if (unlikely (!max_num_io_queues )) {
4017
- dev_err (& pdev -> dev , "The device doesn't have io queues\n" );
4018
- return - EFAULT ;
4019
- }
4020
4029
4021
4030
return max_num_io_queues ;
4022
4031
}
0 commit comments