@@ -27,23 +27,18 @@ int cn10k_lmtst_init(struct otx2_nic *pfvf)
2727{
2828
2929 struct lmtst_tbl_setup_req * req ;
30- int qcount , err ;
30+ struct otx2_lmt_info * lmt_info ;
31+ int err , cpu ;
3132
3233 if (!test_bit (CN10K_LMTST , & pfvf -> hw .cap_flag )) {
3334 pfvf -> hw_ops = & otx2_hw_ops ;
3435 return 0 ;
3536 }
3637
3738 pfvf -> hw_ops = & cn10k_hw_ops ;
38- qcount = pfvf -> hw .max_queues ;
39- /* LMTST lines allocation
40- * qcount = num_online_cpus();
41- * NPA = TX + RX + XDP.
42- * NIX = TX * 32 (For Burst SQE flush).
43- */
44- pfvf -> tot_lmt_lines = (qcount * 3 ) + (qcount * 32 );
45- pfvf -> npa_lmt_lines = qcount * 3 ;
46- pfvf -> nix_lmt_size = LMT_BURST_SIZE * LMT_LINE_SIZE ;
39+ /* Total LMTLINES = num_online_cpus() * 32 (For Burst flush).*/
40+ pfvf -> tot_lmt_lines = (num_online_cpus () * LMT_BURST_SIZE );
41+ pfvf -> hw .lmt_info = alloc_percpu (struct otx2_lmt_info );
4742
4843 mutex_lock (& pfvf -> mbox .lock );
4944 req = otx2_mbox_alloc_msg_lmtst_tbl_setup (& pfvf -> mbox );
@@ -66,6 +61,13 @@ int cn10k_lmtst_init(struct otx2_nic *pfvf)
6661 err = otx2_sync_mbox_msg (& pfvf -> mbox );
6762 mutex_unlock (& pfvf -> mbox .lock );
6863
64+ for_each_possible_cpu (cpu ) {
65+ lmt_info = per_cpu_ptr (pfvf -> hw .lmt_info , cpu );
66+ lmt_info -> lmt_addr = ((u64 )pfvf -> hw .lmt_base +
67+ (cpu * LMT_BURST_SIZE * LMT_LINE_SIZE ));
68+ lmt_info -> lmt_id = cpu * LMT_BURST_SIZE ;
69+ }
70+
6971 return 0 ;
7072}
7173EXPORT_SYMBOL (cn10k_lmtst_init );
@@ -74,13 +76,6 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
7476{
7577 struct nix_cn10k_aq_enq_req * aq ;
7678 struct otx2_nic * pfvf = dev ;
77- struct otx2_snd_queue * sq ;
78-
79- sq = & pfvf -> qset .sq [qidx ];
80- sq -> lmt_addr = (u64 * )((u64 )pfvf -> hw .nix_lmt_base +
81- (qidx * pfvf -> nix_lmt_size ));
82-
83- sq -> lmt_id = pfvf -> npa_lmt_lines + (qidx * LMT_BURST_SIZE );
8479
8580 /* Get memory to put this msg */
8681 aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq (& pfvf -> mbox );
@@ -125,38 +120,39 @@ void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
125120 if (otx2_alloc_buffer (pfvf , cq , & bufptr )) {
126121 if (num_ptrs -- )
127122 __cn10k_aura_freeptr (pfvf , cq -> cq_idx , ptrs ,
128- num_ptrs ,
129- cq -> rbpool -> lmt_addr );
123+ num_ptrs );
130124 break ;
131125 }
132126 cq -> pool_ptrs -- ;
133127 ptrs [num_ptrs ] = (u64 )bufptr + OTX2_HEAD_ROOM ;
134128 num_ptrs ++ ;
135129 if (num_ptrs == NPA_MAX_BURST || cq -> pool_ptrs == 0 ) {
136130 __cn10k_aura_freeptr (pfvf , cq -> cq_idx , ptrs ,
137- num_ptrs ,
138- cq -> rbpool -> lmt_addr );
131+ num_ptrs );
139132 num_ptrs = 1 ;
140133 }
141134 }
142135}
143136
144137void cn10k_sqe_flush (void * dev , struct otx2_snd_queue * sq , int size , int qidx )
145138{
139+ struct otx2_lmt_info * lmt_info ;
140+ struct otx2_nic * pfvf = dev ;
146141 u64 val = 0 , tar_addr = 0 ;
147142
143+ lmt_info = per_cpu_ptr (pfvf -> hw .lmt_info , smp_processor_id ());
148144 /* FIXME: val[0:10] LMT_ID.
149145 * [12:15] no of LMTST - 1 in the burst.
150146 * [19:63] data size of each LMTST in the burst except first.
151147 */
152- val = (sq -> lmt_id & 0x7FF );
148+ val = (lmt_info -> lmt_id & 0x7FF );
153149 /* Target address for LMTST flush tells HW how many 128bit
154150 * words are present.
155151 * tar_addr[6:4] size of first LMTST - 1 in units of 128b.
156152 */
157153 tar_addr |= sq -> io_addr | (((size / 16 ) - 1 ) & 0x7 ) << 4 ;
158154 dma_wmb ();
159- memcpy (sq -> lmt_addr , sq -> sqe_base , size );
155+ memcpy (( u64 * ) lmt_info -> lmt_addr , sq -> sqe_base , size );
160156 cn10k_lmt_flush (val , tar_addr );
161157
162158 sq -> head ++ ;
0 commit comments