Merge branch 'devinfo-tweaks'

Jakub Kicinski says:

====================
devlink: minor tweaks to reported device info

This series contains two minor touch ups for devlink code. First
|| is corrected to && in the ethtool compat code. Next patch
decreases the stack allocation size.

On the nfp side after further discussions with the manufacturing
team we decided to realign the serial number contents slightly and
rename one of the other fields from "vendor" to "mfr", short for
"manufacture".

v2: - add patch 3 - move board maker as a generic attribute.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2019-02-11 20:39:56 -08:00
commit 5ed9d4f2e7
4 changed files with 37 additions and 9 deletions

View File

@ -14,6 +14,11 @@ board.rev
Board design revision.
board.manufacture
=================
An identifier of the company or the facility which produced the part.
fw.mgmt
=======

View File

@ -178,7 +178,7 @@ static const struct nfp_devlink_versions_simple {
} nfp_devlink_versions_hwinfo[] = {
{ DEVLINK_INFO_VERSION_GENERIC_BOARD_ID, "assembly.partno", },
{ DEVLINK_INFO_VERSION_GENERIC_BOARD_REV, "assembly.revision", },
{ "board.vendor", /* fab */ "assembly.vendor", },
{ DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE, "assembly.vendor", },
{ "board.model", /* code name */ "assembly.model", },
};
@ -258,18 +258,33 @@ nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
struct netlink_ext_ack *extack)
{
struct nfp_pf *pf = devlink_priv(devlink);
const char *sn, *vendor, *part;
struct nfp_nsp *nsp;
char *buf = NULL;
const char *sn;
int err;
err = devlink_info_driver_name_put(req, "nfp");
if (err)
return err;
vendor = nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor");
part = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno");
sn = nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial");
if (sn) {
err = devlink_info_serial_number_put(req, sn);
if (vendor && part && sn) {
char *buf;
buf = kmalloc(strlen(vendor) + strlen(part) + strlen(sn) + 1,
GFP_KERNEL);
if (!buf)
return -ENOMEM;
buf[0] = '\0';
strcat(buf, vendor);
strcat(buf, part);
strcat(buf, sn);
err = devlink_info_serial_number_put(req, buf);
kfree(buf);
if (err)
return err;
}

View File

@ -435,6 +435,8 @@ enum devlink_param_wol_types {
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_ID "board.id"
/* Revision of board design */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_REV "board.rev"
/* Maker of the board */
#define DEVLINK_INFO_VERSION_GENERIC_BOARD_MANUFACTURE "board.manufacture"
/* Control processor FW version */
#define DEVLINK_INFO_VERSION_GENERIC_FW_MGMT "fw.mgmt"

View File

@ -3629,26 +3629,30 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
u64 ret_offset, start_offset, end_offset = 0;
struct nlattr *attrs[DEVLINK_ATTR_MAX + 1];
const struct genl_ops *ops = cb->data;
struct devlink_region *region;
struct nlattr *chunks_attr;
const char *region_name;
struct devlink *devlink;
struct nlattr **attrs;
bool dump = true;
void *hdr;
int err;
start_offset = *((u64 *)&cb->args[0]);
attrs = kmalloc_array(DEVLINK_ATTR_MAX + 1, sizeof(*attrs), GFP_KERNEL);
if (!attrs)
return -ENOMEM;
err = nlmsg_parse(cb->nlh, GENL_HDRLEN + devlink_nl_family.hdrsize,
attrs, DEVLINK_ATTR_MAX, ops->policy, cb->extack);
if (err)
goto out;
goto out_free;
devlink = devlink_get_from_attrs(sock_net(cb->skb->sk), attrs);
if (IS_ERR(devlink))
goto out;
goto out_free;
mutex_lock(&devlink_mutex);
mutex_lock(&devlink->lock);
@ -3710,6 +3714,7 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
genlmsg_end(skb, hdr);
mutex_unlock(&devlink->lock);
mutex_unlock(&devlink_mutex);
kfree(attrs);
return skb->len;
@ -3718,7 +3723,8 @@ nla_put_failure:
out_unlock:
mutex_unlock(&devlink->lock);
mutex_unlock(&devlink_mutex);
out:
out_free:
kfree(attrs);
return 0;
}
@ -6393,7 +6399,7 @@ void devlink_compat_running_version(struct net_device *dev,
list_for_each_entry(devlink, &devlink_list, list) {
mutex_lock(&devlink->lock);
list_for_each_entry(devlink_port, &devlink->port_list, list) {
if (devlink_port->type == DEVLINK_PORT_TYPE_ETH ||
if (devlink_port->type == DEVLINK_PORT_TYPE_ETH &&
devlink_port->type_dev == dev) {
__devlink_compat_running_version(devlink,
buf, len);