/** * nfp_rtsym_count() - Get the number of RTSYM descriptors * @rtbl: NFP RTsym table * * Return: Number of RTSYM descriptors
*/ int nfp_rtsym_count(struct nfp_rtsym_table *rtbl)
{ if (!rtbl) return -EINVAL; return rtbl->num;
}
/** * nfp_rtsym_get() - Get the Nth RTSYM descriptor * @rtbl: NFP RTsym table * @idx: Index (0-based) of the RTSYM descriptor * * Return: const pointer to a struct nfp_rtsym descriptor, or NULL
*/ conststruct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx)
{ if (!rtbl) return NULL; if (idx >= rtbl->num) return NULL;
return &rtbl->symtab[idx];
}
/** * nfp_rtsym_lookup() - Return the RTSYM descriptor for a symbol name * @rtbl: NFP RTsym table * @name: Symbol name * * Return: const pointer to a struct nfp_rtsym descriptor, or NULL
*/ conststruct nfp_rtsym *
nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, constchar *name)
{ int n;
if (!rtbl) return NULL;
for (n = 0; n < rtbl->num; n++) if (strcmp(name, rtbl->symtab[n].name) == 0) return &rtbl->symtab[n];
return NULL;
}
u64 nfp_rtsym_size(conststruct nfp_rtsym *sym)
{ switch (sym->type) { case NFP_RTSYM_TYPE_NONE:
pr_err("rtsym '%s': type NONE\n", sym->name); return 0; default:
pr_warn("rtsym '%s': unknown type: %d\n", sym->name, sym->type);
fallthrough; case NFP_RTSYM_TYPE_OBJECT: case NFP_RTSYM_TYPE_FUNCTION: return sym->size; case NFP_RTSYM_TYPE_ABS: returnsizeof(u64);
}
}
/** * nfp_rtsym_read_le() - Read a simple unsigned scalar value from symbol * @rtbl: NFP RTsym table * @name: Symbol name * @error: Poniter to error code (optional) * * Lookup a symbol, map, read it and return it's value. Value of the symbol * will be interpreted as a simple little-endian unsigned value. Symbol can * be 4 or 8 bytes in size. * * Return: value read, on error sets the error and returns ~0ULL.
*/
u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, constchar *name, int *error)
{ conststruct nfp_rtsym *sym;
u32 val32;
u64 val; int err;
switch (nfp_rtsym_size(sym)) { case 4:
err = nfp_rtsym_readl(rtbl->cpp, sym, 0, &val32);
val = val32; break; case 8:
err = nfp_rtsym_readq(rtbl->cpp, sym, 0, &val); break; default:
nfp_err(rtbl->cpp, "rtsym '%s': unsupported or non-scalar size: %lld\n",
name, nfp_rtsym_size(sym));
err = -EINVAL; break;
}
exit: if (error)
*error = err;
if (err) return ~0ULL; return val;
}
/** * nfp_rtsym_write_le() - Write an unsigned scalar value to a symbol * @rtbl: NFP RTsym table * @name: Symbol name * @value: Value to write * * Lookup a symbol and write a value to it. Symbol can be 4 or 8 bytes in size. * If 4 bytes then the lower 32-bits of 'value' are used. Value will be * written as simple little-endian unsigned value. * * Return: 0 on success or error code.
*/ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, constchar *name,
u64 value)
{ conststruct nfp_rtsym *sym; int err;
sym = nfp_rtsym_lookup(rtbl, name); if (!sym) return -ENOENT;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.