lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 18 Nov 2017 12:18:28 -0700
From:   David Ahern <dsa@...ulusnetworks.com>
To:     Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org
Cc:     davem@...emloft.net, mlxsw@...lanox.com, andrew@...n.ch,
        vivien.didelot@...oirfairelinux.com, f.fainelli@...il.com,
        michael.chan@...adcom.com, ganeshgr@...lsio.com,
        saeedm@...lanox.com, matanb@...lanox.com, leonro@...lanox.com,
        idosch@...lanox.com, jakub.kicinski@...ronome.com, ast@...nel.org,
        daniel@...earbox.net, simon.horman@...ronome.com,
        pieter.jansenvanvuuren@...ronome.com, john.hurley@...ronome.com,
        alexander.h.duyck@...el.com, linville@...driver.com,
        gospo@...adcom.com, steven.lin1@...adcom.com, yuvalm@...lanox.com,
        ogerlitz@...lanox.com, roopa@...ulusnetworks.com
Subject: Re: [patch net-next RFC v2 07/11] mlxsw: spectrum: Register KVD
 resources with devlink

On 11/14/17 9:18 AM, Jiri Pirko wrote:
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> index d02c130..f0cbd67 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
> @@ -3927,6 +3927,173 @@ static const struct mlxsw_config_profile mlxsw_sp_config_profile = {
>  	.resource_query_enable		= 1,
>  };
>  
> +static bool
> +mlxsw_sp_resource_kvd_granularity_validate(struct netlink_ext_ack *extack,
> +					   u64 size)
> +{
> +	const struct mlxsw_config_profile *profile;
> +
> +	profile = &mlxsw_sp_config_profile;
> +	if (size % profile->kvd_hash_granularity) {
> +		NL_SET_ERR_MSG(extack, MLXSW_SP_PREFIX "resource set with wrong granularity");
> +		return false;
> +	}
> +	return true;
> +}
> +
> +static int
> +mlxsw_sp_resource_kvd_size_validate(struct devlink *devlink, u64 size,
> +				    struct list_head *resource_list,
> +				    struct netlink_ext_ack *extack)
> +{
> +	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
> +	u32 kvd_size, single_size, double_size, linear_size;
> +	struct devlink_resource *resource;
> +
> +	kvd_size = MLXSW_CORE_RES_GET(mlxsw_core, KVD_SIZE);
> +	if (kvd_size != size) {
> +		NL_SET_ERR_MSG(extack, MLXSW_SP_PREFIX "kvd size cannot be chagned");

s/chagned/changed/

> +		return -EINVAL;
> +	}
> +
> +	list_for_each_entry(resource, resource_list, list) {
> +		switch (resource->id) {
> +		case MLXSW_SP_RESOURCE_KVD_LINEAR:
> +			linear_size = resource->size_new;
> +			break;
> +		case MLXSW_SP_RESOURCE_KVD_HASH_SINGLE:
> +			single_size = resource->size_new;
> +			break;
> +		case MLXSW_SP_RESOURCE_KVD_HASH_DOUBLE:
> +			double_size = resource->size_new;
> +			break;
> +		}
> +	}
> +
> +	/* Overlap is not supported */
> +	if (linear_size + single_size + double_size > kvd_size) {
> +		NL_SET_ERR_MSG(extack, MLXSW_SP_PREFIX "Overlap is not supported");

Overlap? Isn't that sum of the partitions are greater than total size?


> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +mlxsw_sp_resource_kvd_linear_size_validate(struct devlink *devlink, u64 size,
> +					   struct list_head *resource_list,
> +					   struct netlink_ext_ack *extack)
> +{
> +	if (!mlxsw_sp_resource_kvd_granularity_validate(extack, size))
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static int
> +mlxsw_sp_resource_kvd_hash_single_size_validate(struct devlink *devlink, u64 size,
> +						struct list_head *resource_list,
> +						struct netlink_ext_ack *extack)
> +{
> +	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
> +
> +	if (!mlxsw_sp_resource_kvd_granularity_validate(extack, size))
> +		return -EINVAL;
> +
> +	if (size < MLXSW_CORE_RES_GET(mlxsw_core, KVD_SINGLE_MIN_SIZE)) {
> +		NL_SET_ERR_MSG(extack, MLXSW_SP_PREFIX "hash single size is smaller then min");

s/then min/than minimium/

> +		return -EINVAL;
> +	}
> +	return 0;
> +}
> +
> +static int
> +mlxsw_sp_resource_kvd_hash_double_size_validate(struct devlink *devlink, u64 size,
> +						struct list_head *resource_list,
> +						struct netlink_ext_ack *extack)
> +{
> +	struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
> +
> +	if (!mlxsw_sp_resource_kvd_granularity_validate(extack, size))
> +		return -EINVAL;
> +
> +	if (size < MLXSW_CORE_RES_GET(mlxsw_core, KVD_DOUBLE_MIN_SIZE)) {
> +		NL_SET_ERR_MSG(extack, MLXSW_SP_PREFIX "hash double size is smaller then min");

s/then min/than minimium/

How does the user learn the minimum size and the granularity for the KVD
resources? Seems like those could be read-only attributes in the
resource dump to make it easier for the user.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ