-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
octeontx2-af: NIX block admin queue init
Initialize NIX admin queue (AQ) i.e alloc memory for AQ instructions and for the results. All NIX LFs will submit instructions to AQ to init/write/read RQ/SQ/CQ/RSS contexts and in case of read, get context from result memory. Also before configuring/using NIX block calibrate X2P bus and check if NIX interfaces like CGX and LBK are in active and working state. Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Sunil Goutham
authored and
David S. Miller
committed
Oct 18, 2018
1 parent
57856dd
commit aba53d5
Showing
5 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Marvell OcteonTx2 RVU Admin Function driver | ||
* | ||
* Copyright (C) 2018 Marvell International Ltd. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
|
||
#include "rvu_struct.h" | ||
#include "rvu_reg.h" | ||
#include "rvu.h" | ||
#include "cgx.h" | ||
|
||
static int nix_calibrate_x2p(struct rvu *rvu, int blkaddr) | ||
{ | ||
int idx, err; | ||
u64 status; | ||
|
||
/* Start X2P bus calibration */ | ||
rvu_write64(rvu, blkaddr, NIX_AF_CFG, | ||
rvu_read64(rvu, blkaddr, NIX_AF_CFG) | BIT_ULL(9)); | ||
/* Wait for calibration to complete */ | ||
err = rvu_poll_reg(rvu, blkaddr, | ||
NIX_AF_STATUS, BIT_ULL(10), false); | ||
if (err) { | ||
dev_err(rvu->dev, "NIX X2P bus calibration failed\n"); | ||
return err; | ||
} | ||
|
||
status = rvu_read64(rvu, blkaddr, NIX_AF_STATUS); | ||
/* Check if CGX devices are ready */ | ||
for (idx = 0; idx < cgx_get_cgx_cnt(); idx++) { | ||
if (status & (BIT_ULL(16 + idx))) | ||
continue; | ||
dev_err(rvu->dev, | ||
"CGX%d didn't respond to NIX X2P calibration\n", idx); | ||
err = -EBUSY; | ||
} | ||
|
||
/* Check if LBK is ready */ | ||
if (!(status & BIT_ULL(19))) { | ||
dev_err(rvu->dev, | ||
"LBK didn't respond to NIX X2P calibration\n"); | ||
err = -EBUSY; | ||
} | ||
|
||
/* Clear 'calibrate_x2p' bit */ | ||
rvu_write64(rvu, blkaddr, NIX_AF_CFG, | ||
rvu_read64(rvu, blkaddr, NIX_AF_CFG) & ~BIT_ULL(9)); | ||
if (err || (status & 0x3FFULL)) | ||
dev_err(rvu->dev, | ||
"NIX X2P calibration failed, status 0x%llx\n", status); | ||
if (err) | ||
return err; | ||
return 0; | ||
} | ||
|
||
static int nix_aq_init(struct rvu *rvu, struct rvu_block *block) | ||
{ | ||
u64 cfg; | ||
int err; | ||
|
||
/* Set admin queue endianness */ | ||
cfg = rvu_read64(rvu, block->addr, NIX_AF_CFG); | ||
#ifdef __BIG_ENDIAN | ||
cfg |= BIT_ULL(1); | ||
rvu_write64(rvu, block->addr, NIX_AF_CFG, cfg); | ||
#else | ||
cfg &= ~BIT_ULL(1); | ||
rvu_write64(rvu, block->addr, NIX_AF_CFG, cfg); | ||
#endif | ||
|
||
/* Do not bypass NDC cache */ | ||
cfg = rvu_read64(rvu, block->addr, NIX_AF_NDC_CFG); | ||
cfg &= ~0x3FFEULL; | ||
rvu_write64(rvu, block->addr, NIX_AF_NDC_CFG, cfg); | ||
|
||
/* Result structure can be followed by RQ/SQ/CQ context at | ||
* RES + 128bytes and a write mask at RES + 256 bytes, depending on | ||
* operation type. Alloc sufficient result memory for all operations. | ||
*/ | ||
err = rvu_aq_alloc(rvu, &block->aq, | ||
Q_COUNT(AQ_SIZE), sizeof(struct nix_aq_inst_s), | ||
ALIGN(sizeof(struct nix_aq_res_s), 128) + 256); | ||
if (err) | ||
return err; | ||
|
||
rvu_write64(rvu, block->addr, NIX_AF_AQ_CFG, AQ_SIZE); | ||
rvu_write64(rvu, block->addr, | ||
NIX_AF_AQ_BASE, (u64)block->aq->inst->iova); | ||
return 0; | ||
} | ||
|
||
int rvu_nix_init(struct rvu *rvu) | ||
{ | ||
struct rvu_hwinfo *hw = rvu->hw; | ||
struct rvu_block *block; | ||
int blkaddr, err; | ||
|
||
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0); | ||
if (blkaddr < 0) | ||
return 0; | ||
block = &hw->block[blkaddr]; | ||
|
||
/* Calibrate X2P bus to check if CGX/LBK links are fine */ | ||
err = nix_calibrate_x2p(rvu, blkaddr); | ||
if (err) | ||
return err; | ||
|
||
/* Initialize admin queue */ | ||
err = nix_aq_init(rvu, block); | ||
if (err) | ||
return err; | ||
|
||
/* Restore CINT timer delay to HW reset values */ | ||
rvu_write64(rvu, blkaddr, NIX_AF_CINT_DELAY, 0x0ULL); | ||
|
||
return 0; | ||
} | ||
|
||
void rvu_nix_freemem(struct rvu *rvu) | ||
{ | ||
struct rvu_hwinfo *hw = rvu->hw; | ||
struct rvu_block *block; | ||
int blkaddr; | ||
|
||
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0); | ||
if (blkaddr < 0) | ||
return; | ||
|
||
block = &hw->block[blkaddr]; | ||
rvu_aq_free(rvu, block->aq); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters