@@ -86,6 +86,7 @@ struct mlxsw_pci_queue {
86
86
struct mlxsw_pci * pci ;
87
87
struct {
88
88
enum mlxsw_pci_cqe_v v ;
89
+ struct mlxsw_pci_queue * dq ;
89
90
} cq ;
90
91
};
91
92
@@ -194,13 +195,6 @@ static struct mlxsw_pci_queue *mlxsw_pci_sdq_get(struct mlxsw_pci *mlxsw_pci,
194
195
MLXSW_PCI_QUEUE_TYPE_SDQ , q_num );
195
196
}
196
197
197
- static struct mlxsw_pci_queue * mlxsw_pci_rdq_get (struct mlxsw_pci * mlxsw_pci ,
198
- u8 q_num )
199
- {
200
- return __mlxsw_pci_queue_get (mlxsw_pci ,
201
- MLXSW_PCI_QUEUE_TYPE_RDQ , q_num );
202
- }
203
-
204
198
static struct mlxsw_pci_queue * mlxsw_pci_cq_get (struct mlxsw_pci * mlxsw_pci ,
205
199
u8 q_num )
206
200
{
@@ -265,7 +259,9 @@ static dma_addr_t __mlxsw_pci_queue_page_get(struct mlxsw_pci_queue *q,
265
259
static int mlxsw_pci_sdq_init (struct mlxsw_pci * mlxsw_pci , char * mbox ,
266
260
struct mlxsw_pci_queue * q )
267
261
{
262
+ struct mlxsw_pci_queue * cq ;
268
263
int tclass ;
264
+ u8 cq_num ;
269
265
int lp ;
270
266
int i ;
271
267
int err ;
@@ -278,7 +274,8 @@ static int mlxsw_pci_sdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
278
274
MLXSW_CMD_MBOX_SW2HW_DQ_SDQ_LP_WQE ;
279
275
280
276
/* Set CQ of same number of this SDQ. */
281
- mlxsw_cmd_mbox_sw2hw_dq_cq_set (mbox , q -> num );
277
+ cq_num = q -> num ;
278
+ mlxsw_cmd_mbox_sw2hw_dq_cq_set (mbox , cq_num );
282
279
mlxsw_cmd_mbox_sw2hw_dq_sdq_lp_set (mbox , lp );
283
280
mlxsw_cmd_mbox_sw2hw_dq_sdq_tclass_set (mbox , tclass );
284
281
mlxsw_cmd_mbox_sw2hw_dq_log2_dq_sz_set (mbox , 3 ); /* 8 pages */
@@ -291,6 +288,9 @@ static int mlxsw_pci_sdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
291
288
err = mlxsw_cmd_sw2hw_sdq (mlxsw_pci -> core , mbox , q -> num );
292
289
if (err )
293
290
return err ;
291
+
292
+ cq = mlxsw_pci_cq_get (mlxsw_pci , cq_num );
293
+ cq -> cq .dq = q ;
294
294
mlxsw_pci_queue_doorbell_producer_ring (mlxsw_pci , q );
295
295
return 0 ;
296
296
}
@@ -374,6 +374,8 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
374
374
{
375
375
struct mlxsw_pci_queue_elem_info * elem_info ;
376
376
u8 sdq_count = mlxsw_pci -> num_sdqs ;
377
+ struct mlxsw_pci_queue * cq ;
378
+ u8 cq_num ;
377
379
int i ;
378
380
int err ;
379
381
@@ -383,7 +385,8 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
383
385
/* Set CQ of same number of this RDQ with base
384
386
* above SDQ count as the lower ones are assigned to SDQs.
385
387
*/
386
- mlxsw_cmd_mbox_sw2hw_dq_cq_set (mbox , sdq_count + q -> num );
388
+ cq_num = sdq_count + q -> num ;
389
+ mlxsw_cmd_mbox_sw2hw_dq_cq_set (mbox , cq_num );
387
390
mlxsw_cmd_mbox_sw2hw_dq_log2_dq_sz_set (mbox , 3 ); /* 8 pages */
388
391
for (i = 0 ; i < MLXSW_PCI_AQ_PAGES ; i ++ ) {
389
392
dma_addr_t mapaddr = __mlxsw_pci_queue_page_get (q , i );
@@ -395,6 +398,9 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
395
398
if (err )
396
399
return err ;
397
400
401
+ cq = mlxsw_pci_cq_get (mlxsw_pci , cq_num );
402
+ cq -> cq .dq = q ;
403
+
398
404
mlxsw_pci_queue_doorbell_producer_ring (mlxsw_pci , q );
399
405
400
406
for (i = 0 ; i < q -> count ; i ++ ) {
@@ -415,6 +421,7 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
415
421
elem_info = mlxsw_pci_queue_elem_info_get (q , i );
416
422
mlxsw_pci_rdq_skb_free (mlxsw_pci , elem_info );
417
423
}
424
+ cq -> cq .dq = NULL ;
418
425
mlxsw_cmd_hw2sw_rdq (mlxsw_pci -> core , q -> num );
419
426
420
427
return err ;
@@ -648,6 +655,7 @@ static char *mlxsw_pci_cq_sw_cqe_get(struct mlxsw_pci_queue *q)
648
655
static void mlxsw_pci_cq_rx_tasklet (struct tasklet_struct * t )
649
656
{
650
657
struct mlxsw_pci_queue * q = from_tasklet (q , t , tasklet );
658
+ struct mlxsw_pci_queue * rdq = q -> cq .dq ;
651
659
struct mlxsw_pci * mlxsw_pci = q -> pci ;
652
660
int credits = q -> count >> 1 ;
653
661
int items = 0 ;
@@ -658,17 +666,20 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t)
658
666
u8 sendq = mlxsw_pci_cqe_sr_get (q -> cq .v , cqe );
659
667
u8 dqn = mlxsw_pci_cqe_dqn_get (q -> cq .v , cqe );
660
668
char ncqe [MLXSW_PCI_CQE_SIZE_MAX ];
661
- struct mlxsw_pci_queue * rdq ;
662
669
663
670
if (unlikely (sendq )) {
664
671
WARN_ON_ONCE (1 );
665
672
continue ;
666
673
}
667
674
675
+ if (unlikely (dqn != rdq -> num )) {
676
+ WARN_ON_ONCE (1 );
677
+ continue ;
678
+ }
679
+
668
680
memcpy (ncqe , cqe , q -> elem_size );
669
681
mlxsw_pci_queue_doorbell_consumer_ring (mlxsw_pci , q );
670
682
671
- rdq = mlxsw_pci_rdq_get (mlxsw_pci , dqn );
672
683
mlxsw_pci_cqe_rdq_handle (mlxsw_pci , rdq ,
673
684
wqe_counter , q -> cq .v , ncqe );
674
685
@@ -682,6 +693,7 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t)
682
693
static void mlxsw_pci_cq_tx_tasklet (struct tasklet_struct * t )
683
694
{
684
695
struct mlxsw_pci_queue * q = from_tasklet (q , t , tasklet );
696
+ struct mlxsw_pci_queue * sdq = q -> cq .dq ;
685
697
struct mlxsw_pci * mlxsw_pci = q -> pci ;
686
698
int credits = q -> count >> 1 ;
687
699
int items = 0 ;
@@ -692,17 +704,20 @@ static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t)
692
704
u8 sendq = mlxsw_pci_cqe_sr_get (q -> cq .v , cqe );
693
705
u8 dqn = mlxsw_pci_cqe_dqn_get (q -> cq .v , cqe );
694
706
char ncqe [MLXSW_PCI_CQE_SIZE_MAX ];
695
- struct mlxsw_pci_queue * sdq ;
696
707
697
708
if (unlikely (!sendq )) {
698
709
WARN_ON_ONCE (1 );
699
710
continue ;
700
711
}
701
712
713
+ if (unlikely (dqn != sdq -> num )) {
714
+ WARN_ON_ONCE (1 );
715
+ continue ;
716
+ }
717
+
702
718
memcpy (ncqe , cqe , q -> elem_size );
703
719
mlxsw_pci_queue_doorbell_consumer_ring (mlxsw_pci , q );
704
720
705
- sdq = mlxsw_pci_sdq_get (mlxsw_pci , dqn );
706
721
mlxsw_pci_cqe_sdq_handle (mlxsw_pci , sdq ,
707
722
wqe_counter , q -> cq .v , ncqe );
708
723
0 commit comments