Commit 1240989c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: convert all RTsym users to use new read/write helpers

Convert all users of RTsym to the new set of helpers which
handle all targets correctly.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarFrancois H. Theron <francois.theron@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 76196999
...@@ -55,30 +55,21 @@ ...@@ -55,30 +55,21 @@
#define NFP_QMSTAT_DROP 16 #define NFP_QMSTAT_DROP 16
#define NFP_QMSTAT_ECN 24 #define NFP_QMSTAT_ECN 24
static unsigned long long
nfp_abm_q_lvl_thrs(struct nfp_abm_link *alink, unsigned int queue)
{
return alink->abm->q_lvls->addr +
(alink->queue_base + queue) * NFP_QLVL_STRIDE + NFP_QLVL_THRS;
}
static int static int
nfp_abm_ctrl_stat(struct nfp_abm_link *alink, const struct nfp_rtsym *sym, nfp_abm_ctrl_stat(struct nfp_abm_link *alink, const struct nfp_rtsym *sym,
unsigned int stride, unsigned int offset, unsigned int i, unsigned int stride, unsigned int offset, unsigned int i,
bool is_u64, u64 *res) bool is_u64, u64 *res)
{ {
struct nfp_cpp *cpp = alink->abm->app->cpp; struct nfp_cpp *cpp = alink->abm->app->cpp;
u32 val32, mur; u64 val, sym_offset;
u64 val, addr; u32 val32;
int err; int err;
mur = NFP_CPP_ATOMIC_RD(sym->target, sym->domain); sym_offset = (alink->queue_base + i) * stride + offset;
addr = sym->addr + (alink->queue_base + i) * stride + offset;
if (is_u64) if (is_u64)
err = nfp_cpp_readq(cpp, mur, addr, &val); err = __nfp_rtsym_readq(cpp, sym, 3, 0, sym_offset, &val);
else else
err = nfp_cpp_readl(cpp, mur, addr, &val32); err = __nfp_rtsym_readl(cpp, sym, 3, 0, sym_offset, &val32);
if (err) { if (err) {
nfp_err(cpp, nfp_err(cpp,
"RED offload reading stat failed on vNIC %d queue %d\n", "RED offload reading stat failed on vNIC %d queue %d\n",
...@@ -114,13 +105,12 @@ nfp_abm_ctrl_stat_all(struct nfp_abm_link *alink, const struct nfp_rtsym *sym, ...@@ -114,13 +105,12 @@ nfp_abm_ctrl_stat_all(struct nfp_abm_link *alink, const struct nfp_rtsym *sym,
int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int i, u32 val) int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int i, u32 val)
{ {
struct nfp_cpp *cpp = alink->abm->app->cpp; struct nfp_cpp *cpp = alink->abm->app->cpp;
u32 muw; u64 sym_offset;
int err; int err;
muw = NFP_CPP_ATOMIC_WR(alink->abm->q_lvls->target, sym_offset = (alink->queue_base + i) * NFP_QLVL_STRIDE + NFP_QLVL_THRS;
alink->abm->q_lvls->domain); err = __nfp_rtsym_writel(cpp, alink->abm->q_lvls, 4, 0,
sym_offset, val);
err = nfp_cpp_writel(cpp, muw, nfp_abm_q_lvl_thrs(alink, i), val);
if (err) { if (err) {
nfp_err(cpp, "RED offload setting level failed on vNIC %d queue %d\n", nfp_err(cpp, "RED offload setting level failed on vNIC %d queue %d\n",
alink->id, i); alink->id, i);
......
...@@ -116,23 +116,18 @@ nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, ...@@ -116,23 +116,18 @@ nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
void *out_data, u64 out_length) void *out_data, u64 out_length)
{ {
unsigned long long addr;
unsigned long err_at; unsigned long err_at;
u64 max_data_sz; u64 max_data_sz;
u32 val = 0; u32 val = 0;
u32 cpp_id;
int n, err; int n, err;
if (!pf->mbox) if (!pf->mbox)
return -EOPNOTSUPP; return -EOPNOTSUPP;
cpp_id = NFP_CPP_ISLAND_ID(pf->mbox->target, NFP_CPP_ACTION_RW, 0,
pf->mbox->domain);
addr = pf->mbox->addr;
max_data_sz = pf->mbox->size - NFP_MBOX_SYM_MIN_SIZE; max_data_sz = pf->mbox->size - NFP_MBOX_SYM_MIN_SIZE;
/* Check if cmd field is clear */ /* Check if cmd field is clear */
err = nfp_cpp_readl(pf->cpp, cpp_id, addr + NFP_MBOX_CMD, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val);
if (err || val) { if (err || val) {
nfp_warn(pf->cpp, "failed to issue command (%u): %u, err: %d\n", nfp_warn(pf->cpp, "failed to issue command (%u): %u, err: %d\n",
cmd, val, err); cmd, val, err);
...@@ -140,30 +135,29 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, ...@@ -140,30 +135,29 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
} }
in_length = min(in_length, max_data_sz); in_length = min(in_length, max_data_sz);
n = nfp_cpp_write(pf->cpp, cpp_id, addr + NFP_MBOX_DATA, n = nfp_rtsym_write(pf->cpp, pf->mbox, NFP_MBOX_DATA, in_data,
in_data, in_length); in_length);
if (n != in_length) if (n != in_length)
return -EIO; return -EIO;
/* Write data_len and wipe reserved */ /* Write data_len and wipe reserved */
err = nfp_cpp_writeq(pf->cpp, cpp_id, addr + NFP_MBOX_DATA_LEN, err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, in_length);
in_length);
if (err) if (err)
return err; return err;
/* Read back for ordering */ /* Read back for ordering */
err = nfp_cpp_readl(pf->cpp, cpp_id, addr + NFP_MBOX_DATA_LEN, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val);
if (err) if (err)
return err; return err;
/* Write cmd and wipe return value */ /* Write cmd and wipe return value */
err = nfp_cpp_writeq(pf->cpp, cpp_id, addr + NFP_MBOX_CMD, cmd); err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_CMD, cmd);
if (err) if (err)
return err; return err;
err_at = jiffies + 5 * HZ; err_at = jiffies + 5 * HZ;
while (true) { while (true) {
/* Wait for command to go to 0 (NFP_MBOX_NO_CMD) */ /* Wait for command to go to 0 (NFP_MBOX_NO_CMD) */
err = nfp_cpp_readl(pf->cpp, cpp_id, addr + NFP_MBOX_CMD, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val);
if (err) if (err)
return err; return err;
if (!val) if (!val)
...@@ -176,18 +170,18 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, ...@@ -176,18 +170,18 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
} }
/* Copy output if any (could be error info, do it before reading ret) */ /* Copy output if any (could be error info, do it before reading ret) */
err = nfp_cpp_readl(pf->cpp, cpp_id, addr + NFP_MBOX_DATA_LEN, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val);
if (err) if (err)
return err; return err;
out_length = min_t(u32, val, min(out_length, max_data_sz)); out_length = min_t(u32, val, min(out_length, max_data_sz));
n = nfp_cpp_read(pf->cpp, cpp_id, addr + NFP_MBOX_DATA, n = nfp_rtsym_read(pf->cpp, pf->mbox, NFP_MBOX_DATA,
out_data, out_length); out_data, out_length);
if (n != out_length) if (n != out_length)
return -EIO; return -EIO;
/* Check if there is an error */ /* Check if there is an error */
err = nfp_cpp_readl(pf->cpp, cpp_id, addr + NFP_MBOX_RET, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_RET, &val);
if (err) if (err)
return err; return err;
if (val) if (val)
......
...@@ -188,7 +188,6 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl) ...@@ -188,7 +188,6 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
const struct nfp_rtsym *specsym; const struct nfp_rtsym *specsym;
struct nfp_dumpspec *dumpspec; struct nfp_dumpspec *dumpspec;
int bytes_read; int bytes_read;
u32 cpp_id;
specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM); specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM);
if (!specsym) if (!specsym)
...@@ -201,11 +200,8 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl) ...@@ -201,11 +200,8 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
dumpspec->size = specsym->size; dumpspec->size = specsym->size;
cpp_id = NFP_CPP_ISLAND_ID(specsym->target, NFP_CPP_ACTION_RW, 0, bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data,
specsym->domain); specsym->size);
bytes_read = nfp_cpp_read(cpp, cpp_id, specsym->addr, dumpspec->data,
specsym->size);
if (bytes_read != specsym->size) { if (bytes_read != specsym->size) {
vfree(dumpspec); vfree(dumpspec);
nfp_warn(cpp, "Debug dump specification read failed.\n"); nfp_warn(cpp, "Debug dump specification read failed.\n");
...@@ -644,7 +640,6 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec, ...@@ -644,7 +640,6 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
const struct nfp_rtsym *sym; const struct nfp_rtsym *sym;
u32 tl_len, key_len; u32 tl_len, key_len;
int bytes_read; int bytes_read;
u32 cpp_id;
void *dest; void *dest;
int err; int err;
...@@ -683,11 +678,9 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec, ...@@ -683,11 +678,9 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
cpp_params.action = NFP_CPP_ACTION_RW; cpp_params.action = NFP_CPP_ACTION_RW;
cpp_params.token = 0; cpp_params.token = 0;
cpp_params.island = sym->domain; cpp_params.island = sym->domain;
cpp_id = nfp_get_numeric_cpp_id(&cpp_params);
dump_header->cpp.cpp_id = cpp_params; dump_header->cpp.cpp_id = cpp_params;
dump_header->cpp.offset = cpu_to_be32(sym->addr); dump_header->cpp.offset = cpu_to_be32(sym->addr);
bytes_read = nfp_cpp_read(pf->cpp, cpp_id, sym->addr, dest, bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size);
sym_size);
if (bytes_read != sym_size) { if (bytes_read != sym_size) {
if (bytes_read >= 0) if (bytes_read >= 0)
bytes_read = -EIO; bytes_read = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment