@@ -22,69 +22,52 @@ static struct dev_hw_ops cn10k_hw_ops = {
2222 .refill_pool_ptrs = cn10k_refill_pool_ptrs ,
2323};
2424
25- int cn10k_pf_lmtst_init (struct otx2_nic * pf )
25+ int cn10k_lmtst_init (struct otx2_nic * pfvf )
2626{
27- int size , num_lines ;
28- u64 base ;
2927
30- if (!test_bit (CN10K_LMTST , & pf -> hw .cap_flag )) {
31- pf -> hw_ops = & otx2_hw_ops ;
28+ struct lmtst_tbl_setup_req * req ;
29+ int qcount , err ;
30+
31+ if (!test_bit (CN10K_LMTST , & pfvf -> hw .cap_flag )) {
32+ pfvf -> hw_ops = & otx2_hw_ops ;
3233 return 0 ;
3334 }
3435
35- pf -> hw_ops = & cn10k_hw_ops ;
36- base = pci_resource_start (pf -> pdev , PCI_MBOX_BAR_NUM ) +
37- (MBOX_SIZE * (pf -> total_vfs + 1 ));
38-
39- size = pci_resource_len (pf -> pdev , PCI_MBOX_BAR_NUM ) -
40- (MBOX_SIZE * (pf -> total_vfs + 1 ));
41-
42- pf -> hw .lmt_base = ioremap (base , size );
36+ pfvf -> hw_ops = & cn10k_hw_ops ;
37+ qcount = pfvf -> hw .max_queues ;
38+ /* LMTST lines allocation
39+ * qcount = num_online_cpus();
40+ * NPA = TX + RX + XDP.
41+ * NIX = TX * 32 (For Burst SQE flush).
42+ */
43+ pfvf -> tot_lmt_lines = (qcount * 3 ) + (qcount * 32 );
44+ pfvf -> npa_lmt_lines = qcount * 3 ;
45+ pfvf -> nix_lmt_size = LMT_BURST_SIZE * LMT_LINE_SIZE ;
4346
44- if (!pf -> hw .lmt_base ) {
45- dev_err (pf -> dev , "Unable to map PF LMTST region\n" );
47+ mutex_lock (& pfvf -> mbox .lock );
48+ req = otx2_mbox_alloc_msg_lmtst_tbl_setup (& pfvf -> mbox );
49+ if (!req ) {
50+ mutex_unlock (& pfvf -> mbox .lock );
4651 return - ENOMEM ;
4752 }
4853
49- /* FIXME: Get the num of LMTST lines from LMT table */
50- pf -> tot_lmt_lines = size / LMT_LINE_SIZE ;
51- num_lines = (pf -> tot_lmt_lines - NIX_LMTID_BASE ) /
52- pf -> hw .tx_queues ;
53- /* Number of LMT lines per SQ queues */
54- pf -> nix_lmt_lines = num_lines > 32 ? 32 : num_lines ;
55-
56- pf -> nix_lmt_size = pf -> nix_lmt_lines * LMT_LINE_SIZE ;
57- return 0 ;
58- }
54+ req -> use_local_lmt_region = true;
5955
60- int cn10k_vf_lmtst_init (struct otx2_nic * vf )
61- {
62- int size , num_lines ;
63-
64- if (!test_bit (CN10K_LMTST , & vf -> hw .cap_flag )) {
65- vf -> hw_ops = & otx2_hw_ops ;
66- return 0 ;
56+ err = qmem_alloc (pfvf -> dev , & pfvf -> dync_lmt , pfvf -> tot_lmt_lines ,
57+ LMT_LINE_SIZE );
58+ if (err ) {
59+ mutex_unlock (& pfvf -> mbox .lock );
60+ return err ;
6761 }
62+ pfvf -> hw .lmt_base = (u64 * )pfvf -> dync_lmt -> base ;
63+ req -> lmt_iova = (u64 )pfvf -> dync_lmt -> iova ;
6864
69- vf -> hw_ops = & cn10k_hw_ops ;
70- size = pci_resource_len (vf -> pdev , PCI_MBOX_BAR_NUM );
71- vf -> hw .lmt_base = ioremap_wc (pci_resource_start (vf -> pdev ,
72- PCI_MBOX_BAR_NUM ),
73- size );
74- if (!vf -> hw .lmt_base ) {
75- dev_err (vf -> dev , "Unable to map VF LMTST region\n" );
76- return - ENOMEM ;
77- }
65+ err = otx2_sync_mbox_msg (& pfvf -> mbox );
66+ mutex_unlock (& pfvf -> mbox .lock );
7867
79- vf -> tot_lmt_lines = size / LMT_LINE_SIZE ;
80- /* LMTST lines per SQ */
81- num_lines = (vf -> tot_lmt_lines - NIX_LMTID_BASE ) /
82- vf -> hw .tx_queues ;
83- vf -> nix_lmt_lines = num_lines > 32 ? 32 : num_lines ;
84- vf -> nix_lmt_size = vf -> nix_lmt_lines * LMT_LINE_SIZE ;
8568 return 0 ;
8669}
87- EXPORT_SYMBOL (cn10k_vf_lmtst_init );
70+ EXPORT_SYMBOL (cn10k_lmtst_init );
8871
8972int cn10k_sq_aq_init (void * dev , u16 qidx , u16 sqb_aura )
9073{
@@ -93,9 +76,11 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
9376 struct otx2_snd_queue * sq ;
9477
9578 sq = & pfvf -> qset .sq [qidx ];
96- sq -> lmt_addr = (__force u64 * )((u64 )pfvf -> hw .nix_lmt_base +
79+ sq -> lmt_addr = (u64 * )((u64 )pfvf -> hw .nix_lmt_base +
9780 (qidx * pfvf -> nix_lmt_size ));
9881
82+ sq -> lmt_id = pfvf -> npa_lmt_lines + (qidx * LMT_BURST_SIZE );
83+
9984 /* Get memory to put this msg */
10085 aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq (& pfvf -> mbox );
10186 if (!aq )
@@ -158,15 +143,13 @@ void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
158143
159144void cn10k_sqe_flush (void * dev , struct otx2_snd_queue * sq , int size , int qidx )
160145{
161- struct otx2_nic * pfvf = dev ;
162- int lmt_id = NIX_LMTID_BASE + (qidx * pfvf -> nix_lmt_lines );
163146 u64 val = 0 , tar_addr = 0 ;
164147
165148 /* FIXME: val[0:10] LMT_ID.
166149 * [12:15] no of LMTST - 1 in the burst.
167150 * [19:63] data size of each LMTST in the burst except first.
168151 */
169- val = (lmt_id & 0x7FF );
152+ val = (sq -> lmt_id & 0x7FF );
170153 /* Target address for LMTST flush tells HW how many 128bit
171154 * words are present.
172155 * tar_addr[6:4] size of first LMTST - 1 in units of 128b.
0 commit comments