@@ -478,6 +478,85 @@ static int otx2_set_real_num_queues(struct net_device *netdev,
478
478
return err ;
479
479
}
480
480
481
+ static irqreturn_t otx2_q_intr_handler (int irq , void * data )
482
+ {
483
+ struct otx2_nic * pf = data ;
484
+ u64 val , * ptr ;
485
+ u64 qidx = 0 ;
486
+
487
+ /* CQ */
488
+ for (qidx = 0 ; qidx < pf -> qset .cq_cnt ; qidx ++ ) {
489
+ ptr = otx2_get_regaddr (pf , NIX_LF_CQ_OP_INT );
490
+ val = otx2_atomic64_add ((qidx << 44 ), ptr );
491
+
492
+ otx2_write64 (pf , NIX_LF_CQ_OP_INT , (qidx << 44 ) |
493
+ (val & NIX_CQERRINT_BITS ));
494
+ if (!(val & (NIX_CQERRINT_BITS | BIT_ULL (42 ))))
495
+ continue ;
496
+
497
+ if (val & BIT_ULL (42 )) {
498
+ netdev_err (pf -> netdev , "CQ%lld: error reading NIX_LF_CQ_OP_INT, NIX_LF_ERR_INT 0x%llx\n" ,
499
+ qidx , otx2_read64 (pf , NIX_LF_ERR_INT ));
500
+ } else {
501
+ if (val & BIT_ULL (NIX_CQERRINT_DOOR_ERR ))
502
+ netdev_err (pf -> netdev , "CQ%lld: Doorbell error" ,
503
+ qidx );
504
+ if (val & BIT_ULL (NIX_CQERRINT_CQE_FAULT ))
505
+ netdev_err (pf -> netdev , "CQ%lld: Memory fault on CQE write to LLC/DRAM" ,
506
+ qidx );
507
+ }
508
+
509
+ schedule_work (& pf -> reset_task );
510
+ }
511
+
512
+ /* SQ */
513
+ for (qidx = 0 ; qidx < pf -> hw .tx_queues ; qidx ++ ) {
514
+ ptr = otx2_get_regaddr (pf , NIX_LF_SQ_OP_INT );
515
+ val = otx2_atomic64_add ((qidx << 44 ), ptr );
516
+ otx2_write64 (pf , NIX_LF_SQ_OP_INT , (qidx << 44 ) |
517
+ (val & NIX_SQINT_BITS ));
518
+
519
+ if (!(val & (NIX_SQINT_BITS | BIT_ULL (42 ))))
520
+ continue ;
521
+
522
+ if (val & BIT_ULL (42 )) {
523
+ netdev_err (pf -> netdev , "SQ%lld: error reading NIX_LF_SQ_OP_INT, NIX_LF_ERR_INT 0x%llx\n" ,
524
+ qidx , otx2_read64 (pf , NIX_LF_ERR_INT ));
525
+ } else {
526
+ if (val & BIT_ULL (NIX_SQINT_LMT_ERR )) {
527
+ netdev_err (pf -> netdev , "SQ%lld: LMT store error NIX_LF_SQ_OP_ERR_DBG:0x%llx" ,
528
+ qidx ,
529
+ otx2_read64 (pf ,
530
+ NIX_LF_SQ_OP_ERR_DBG ));
531
+ otx2_write64 (pf , NIX_LF_SQ_OP_ERR_DBG ,
532
+ BIT_ULL (44 ));
533
+ }
534
+ if (val & BIT_ULL (NIX_SQINT_MNQ_ERR )) {
535
+ netdev_err (pf -> netdev , "SQ%lld: Meta-descriptor enqueue error NIX_LF_MNQ_ERR_DGB:0x%llx\n" ,
536
+ qidx ,
537
+ otx2_read64 (pf , NIX_LF_MNQ_ERR_DBG ));
538
+ otx2_write64 (pf , NIX_LF_MNQ_ERR_DBG ,
539
+ BIT_ULL (44 ));
540
+ }
541
+ if (val & BIT_ULL (NIX_SQINT_SEND_ERR )) {
542
+ netdev_err (pf -> netdev , "SQ%lld: Send error, NIX_LF_SEND_ERR_DBG 0x%llx" ,
543
+ qidx ,
544
+ otx2_read64 (pf ,
545
+ NIX_LF_SEND_ERR_DBG ));
546
+ otx2_write64 (pf , NIX_LF_SEND_ERR_DBG ,
547
+ BIT_ULL (44 ));
548
+ }
549
+ if (val & BIT_ULL (NIX_SQINT_SQB_ALLOC_FAIL ))
550
+ netdev_err (pf -> netdev , "SQ%lld: SQB allocation failed" ,
551
+ qidx );
552
+ }
553
+
554
+ schedule_work (& pf -> reset_task );
555
+ }
556
+
557
+ return IRQ_HANDLED ;
558
+ }
559
+
481
560
static irqreturn_t otx2_cq_intr_handler (int irq , void * cq_irq )
482
561
{
483
562
struct otx2_cq_poll * cq_poll = (struct otx2_cq_poll * )cq_irq ;
@@ -759,6 +838,24 @@ int otx2_open(struct net_device *netdev)
759
838
if (err )
760
839
goto err_disable_napi ;
761
840
841
+ /* Register Queue IRQ handlers */
842
+ vec = pf -> hw .nix_msixoff + NIX_LF_QINT_VEC_START ;
843
+ irq_name = & pf -> hw .irq_name [vec * NAME_SIZE ];
844
+
845
+ snprintf (irq_name , NAME_SIZE , "%s-qerr" , pf -> netdev -> name );
846
+
847
+ err = request_irq (pci_irq_vector (pf -> pdev , vec ),
848
+ otx2_q_intr_handler , 0 , irq_name , pf );
849
+ if (err ) {
850
+ dev_err (pf -> dev ,
851
+ "RVUPF%d: IRQ registration failed for QERR\n" ,
852
+ rvu_get_pf (pf -> pcifunc ));
853
+ goto err_disable_napi ;
854
+ }
855
+
856
+ /* Enable QINT IRQ */
857
+ otx2_write64 (pf , NIX_LF_QINTX_ENA_W1S (0 ), BIT_ULL (0 ));
858
+
762
859
/* Register CQ IRQ handlers */
763
860
vec = pf -> hw .nix_msixoff + NIX_LF_CINT_VEC_START ;
764
861
for (qidx = 0 ; qidx < pf -> hw .cint_cnt ; qidx ++ ) {
@@ -803,6 +900,11 @@ int otx2_open(struct net_device *netdev)
803
900
804
901
err_free_cints :
805
902
otx2_free_cints (pf , qidx );
903
+ vec = pci_irq_vector (pf -> pdev ,
904
+ pf -> hw .nix_msixoff + NIX_LF_QINT_VEC_START );
905
+ otx2_write64 (pf , NIX_LF_QINTX_ENA_W1C (0 ), BIT_ULL (0 ));
906
+ synchronize_irq (vec );
907
+ free_irq (vec , pf );
806
908
err_disable_napi :
807
909
otx2_disable_napi (pf );
808
910
otx2_free_hw_resources (pf );
@@ -818,7 +920,7 @@ int otx2_stop(struct net_device *netdev)
818
920
struct otx2_nic * pf = netdev_priv (netdev );
819
921
struct otx2_cq_poll * cq_poll = NULL ;
820
922
struct otx2_qset * qset = & pf -> qset ;
821
- int qidx , vec ;
923
+ int qidx , vec , wrk ;
822
924
823
925
netif_carrier_off (netdev );
824
926
netif_tx_stop_all_queues (netdev );
@@ -830,6 +932,13 @@ int otx2_stop(struct net_device *netdev)
830
932
/* First stop packet Rx/Tx */
831
933
otx2_rxtx_enable (pf , false);
832
934
935
+ /* Cleanup Queue IRQ */
936
+ vec = pci_irq_vector (pf -> pdev ,
937
+ pf -> hw .nix_msixoff + NIX_LF_QINT_VEC_START );
938
+ otx2_write64 (pf , NIX_LF_QINTX_ENA_W1C (0 ), BIT_ULL (0 ));
939
+ synchronize_irq (vec );
940
+ free_irq (vec , pf );
941
+
833
942
/* Cleanup CQ NAPI and IRQ */
834
943
vec = pf -> hw .nix_msixoff + NIX_LF_CINT_VEC_START ;
835
944
for (qidx = 0 ; qidx < pf -> hw .cint_cnt ; qidx ++ ) {
@@ -852,6 +961,10 @@ int otx2_stop(struct net_device *netdev)
852
961
for (qidx = 0 ; qidx < netdev -> num_tx_queues ; qidx ++ )
853
962
netdev_tx_reset_queue (netdev_get_tx_queue (netdev , qidx ));
854
963
964
+ for (wrk = 0 ; wrk < pf -> qset .cq_cnt ; wrk ++ )
965
+ cancel_delayed_work_sync (& pf -> refill_wrk [wrk ].pool_refill_work );
966
+ devm_kfree (pf -> dev , pf -> refill_wrk );
967
+
855
968
kfree (qset -> sq );
856
969
kfree (qset -> cq );
857
970
kfree (qset -> napi );
@@ -931,6 +1044,19 @@ static int otx2_set_features(struct net_device *netdev,
931
1044
return 0 ;
932
1045
}
933
1046
1047
+ static void otx2_reset_task (struct work_struct * work )
1048
+ {
1049
+ struct otx2_nic * pf = container_of (work , struct otx2_nic , reset_task );
1050
+
1051
+ if (!netif_running (pf -> netdev ))
1052
+ return ;
1053
+
1054
+ otx2_stop (pf -> netdev );
1055
+ pf -> reset_count ++ ;
1056
+ otx2_open (pf -> netdev );
1057
+ netif_trans_update (pf -> netdev );
1058
+ }
1059
+
934
1060
static const struct net_device_ops otx2_netdev_ops = {
935
1061
.ndo_open = otx2_open ,
936
1062
.ndo_stop = otx2_stop ,
@@ -939,6 +1065,7 @@ static const struct net_device_ops otx2_netdev_ops = {
939
1065
.ndo_change_mtu = otx2_change_mtu ,
940
1066
.ndo_set_rx_mode = otx2_set_rx_mode ,
941
1067
.ndo_set_features = otx2_set_features ,
1068
+ .ndo_tx_timeout = otx2_tx_timeout ,
942
1069
};
943
1070
944
1071
static int otx2_check_pf_usable (struct otx2_nic * nic )
@@ -1115,12 +1242,16 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1115
1242
1116
1243
netdev -> hw_features |= NETIF_F_LOOPBACK | NETIF_F_RXALL ;
1117
1244
1245
+ netdev -> watchdog_timeo = OTX2_TX_TIMEOUT ;
1246
+
1118
1247
netdev -> netdev_ops = & otx2_netdev_ops ;
1119
1248
1120
1249
/* MTU range: 64 - 9190 */
1121
1250
netdev -> min_mtu = OTX2_MIN_MTU ;
1122
1251
netdev -> max_mtu = OTX2_MAX_MTU ;
1123
1252
1253
+ INIT_WORK (& pf -> reset_task , otx2_reset_task );
1254
+
1124
1255
err = register_netdev (netdev );
1125
1256
if (err ) {
1126
1257
dev_err (dev , "Failed to register netdevice\n" );
0 commit comments