Skip to content

Commit ef6c8da

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: cn10K: Reserve LMTST lines per core
This patch reserves the LMTST lines per cpu instead of separate LMTST lines for NPA(buffer free) and NIX(sqe flush). LMTST line of the core on which SQ or RQ is processed is used for LMTST operation. This patch also replace STEOR with STEORL release semantics and updates driver name in ethtool file. Signed-off-by: Geetha sowjanya <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 21274aa commit ef6c8da

File tree

7 files changed

+49
-55
lines changed

7 files changed

+49
-55
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
7173
EXPORT_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

144137
void 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++;

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,11 +1230,6 @@ static int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id,
12301230

12311231
pool->rbsize = buf_size;
12321232

1233-
/* Set LMTST addr for NPA batch free */
1234-
if (test_bit(CN10K_LMTST, &pfvf->hw.cap_flag))
1235-
pool->lmt_addr = (__force u64 *)((u64)pfvf->hw.npa_lmt_base +
1236-
(pool_id * LMT_LINE_SIZE));
1237-
12381233
/* Initialize this pool's context via AF */
12391234
aq = otx2_mbox_alloc_msg_npa_aq_enq(&pfvf->mbox);
12401235
if (!aq) {

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ enum arua_mapped_qtypes {
5353
/* Send skid of 2000 packets required for CQ size of 4K CQEs. */
5454
#define SEND_CQ_SKID 2000
5555

56+
struct otx2_lmt_info {
57+
u64 lmt_addr;
58+
u16 lmt_id;
59+
};
5660
/* RSS configuration */
5761
struct otx2_rss_ctx {
5862
u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
@@ -224,8 +228,7 @@ struct otx2_hw {
224228
#define LMT_LINE_SIZE 128
225229
#define LMT_BURST_SIZE 32 /* 32 LMTST lines for burst SQE flush */
226230
u64 *lmt_base;
227-
u64 *npa_lmt_base;
228-
u64 *nix_lmt_base;
231+
struct otx2_lmt_info __percpu *lmt_info;
229232
};
230233

231234
enum vfperm {
@@ -407,17 +410,18 @@ static inline bool is_96xx_B0(struct pci_dev *pdev)
407410
*/
408411
#define PCI_REVISION_ID_96XX 0x00
409412
#define PCI_REVISION_ID_95XX 0x10
410-
#define PCI_REVISION_ID_LOKI 0x20
413+
#define PCI_REVISION_ID_95XXN 0x20
411414
#define PCI_REVISION_ID_98XX 0x30
412415
#define PCI_REVISION_ID_95XXMM 0x40
416+
#define PCI_REVISION_ID_95XXO 0xE0
413417

414418
static inline bool is_dev_otx2(struct pci_dev *pdev)
415419
{
416420
u8 midr = pdev->revision & 0xF0;
417421

418422
return (midr == PCI_REVISION_ID_96XX || midr == PCI_REVISION_ID_95XX ||
419-
midr == PCI_REVISION_ID_LOKI || midr == PCI_REVISION_ID_98XX ||
420-
midr == PCI_REVISION_ID_95XXMM);
423+
midr == PCI_REVISION_ID_95XXN || midr == PCI_REVISION_ID_98XX ||
424+
midr == PCI_REVISION_ID_95XXMM || midr == PCI_REVISION_ID_95XXO);
421425
}
422426

423427
static inline void otx2_setup_dev_hw_settings(struct otx2_nic *pfvf)
@@ -562,15 +566,16 @@ static inline u64 otx2_atomic64_add(u64 incr, u64 *ptr)
562566
#endif
563567

564568
static inline void __cn10k_aura_freeptr(struct otx2_nic *pfvf, u64 aura,
565-
u64 *ptrs, u64 num_ptrs,
566-
u64 *lmt_addr)
569+
u64 *ptrs, u64 num_ptrs)
567570
{
571+
struct otx2_lmt_info *lmt_info;
568572
u64 size = 0, count_eot = 0;
569573
u64 tar_addr, val = 0;
570574

575+
lmt_info = per_cpu_ptr(pfvf->hw.lmt_info, smp_processor_id());
571576
tar_addr = (__force u64)otx2_get_regaddr(pfvf, NPA_LF_AURA_BATCH_FREE0);
572577
/* LMTID is same as AURA Id */
573-
val = (aura & 0x7FF) | BIT_ULL(63);
578+
val = (lmt_info->lmt_id & 0x7FF) | BIT_ULL(63);
574579
/* Set if [127:64] of last 128bit word has a valid pointer */
575580
count_eot = (num_ptrs % 2) ? 0ULL : 1ULL;
576581
/* Set AURA ID to free pointer */
@@ -586,20 +591,19 @@ static inline void __cn10k_aura_freeptr(struct otx2_nic *pfvf, u64 aura,
586591
size++;
587592
tar_addr |= ((size - 1) & 0x7) << 4;
588593
}
589-
memcpy(lmt_addr, ptrs, sizeof(u64) * num_ptrs);
594+
memcpy((u64 *)lmt_info->lmt_addr, ptrs, sizeof(u64) * num_ptrs);
590595
/* Perform LMTST flush */
591596
cn10k_lmt_flush(val, tar_addr);
592597
}
593598

594599
static inline void cn10k_aura_freeptr(void *dev, int aura, u64 buf)
595600
{
596601
struct otx2_nic *pfvf = dev;
597-
struct otx2_pool *pool;
598602
u64 ptrs[2];
599603

600-
pool = &pfvf->qset.pool[aura];
601604
ptrs[1] = buf;
602-
__cn10k_aura_freeptr(pfvf, aura, ptrs, 2, pool->lmt_addr);
605+
/* Free only one buffer at time during init and teardown */
606+
__cn10k_aura_freeptr(pfvf, aura, ptrs, 2);
603607
}
604608

605609
/* Alloc pointer from pool/aura */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "otx2_common.h"
1717
#include "otx2_ptp.h"
1818

19-
#define DRV_NAME "octeontx2-nicpf"
20-
#define DRV_VF_NAME "octeontx2-nicvf"
19+
#define DRV_NAME "rvu-nicpf"
20+
#define DRV_VF_NAME "rvu-nicvf"
2121

2222
struct otx2_stat {
2323
char name[ETH_GSTRING_LEN];

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,14 +1533,6 @@ int otx2_open(struct net_device *netdev)
15331533
if (!qset->rq)
15341534
goto err_free_mem;
15351535

1536-
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag)) {
1537-
/* Reserve LMT lines for NPA AURA batch free */
1538-
pf->hw.npa_lmt_base = pf->hw.lmt_base;
1539-
/* Reserve LMT lines for NIX TX */
1540-
pf->hw.nix_lmt_base = (u64 *)((u64)pf->hw.npa_lmt_base +
1541-
(pf->npa_lmt_lines * LMT_LINE_SIZE));
1542-
}
1543-
15441536
err = otx2_init_hw_resources(pf);
15451537
if (err)
15461538
goto err_free_mem;
@@ -2668,6 +2660,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
26682660
err_ptp_destroy:
26692661
otx2_ptp_destroy(pf);
26702662
err_detach_rsrc:
2663+
if (pf->hw.lmt_info)
2664+
free_percpu(pf->hw.lmt_info);
26712665
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag))
26722666
qmem_free(pf->dev, pf->dync_lmt);
26732667
otx2_detach_resources(&pf->mbox);
@@ -2811,6 +2805,8 @@ static void otx2_remove(struct pci_dev *pdev)
28112805
otx2_mcam_flow_del(pf);
28122806
otx2_shutdown_tc(pf);
28132807
otx2_detach_resources(&pf->mbox);
2808+
if (pf->hw.lmt_info)
2809+
free_percpu(pf->hw.lmt_info);
28142810
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag))
28152811
qmem_free(pf->dev, pf->dync_lmt);
28162812
otx2_disable_mbox_intr(pf);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ struct otx2_snd_queue {
8080
u16 num_sqbs;
8181
u16 sqe_thresh;
8282
u8 sqe_per_sqb;
83-
u32 lmt_id;
8483
u64 io_addr;
8584
u64 *aura_fc_addr;
8685
u64 *lmt_addr;
@@ -111,7 +110,6 @@ struct otx2_cq_poll {
111110
struct otx2_pool {
112111
struct qmem *stack;
113112
struct qmem *fc_addr;
114-
u64 *lmt_addr;
115113
u16 rbsize;
116114
};
117115

include/linux/soc/marvell/octeontx2/asm.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@
2222
: [rs]"r" (ioaddr)); \
2323
(result); \
2424
})
25+
/*
26+
* STEORL store to memory with release semantics.
27+
* This will avoid using DMB barrier after each LMTST
28+
* operation.
29+
*/
2530
#define cn10k_lmt_flush(val, addr) \
2631
({ \
2732
__asm__ volatile(".cpu generic+lse\n" \
28-
"steor %x[rf],[%[rs]]" \
29-
: [rf]"+r"(val) \
30-
: [rs]"r"(addr)); \
33+
"steorl %x[rf],[%[rs]]" \
34+
: [rf] "+r"(val) \
35+
: [rs] "r"(addr)); \
3136
})
3237
#else
3338
#define otx2_lmt_flush(ioaddr) ({ 0; })

0 commit comments

Comments
 (0)