qed*: Conditions for changing link

There's some inconsistency in current logic determining whether the
link settings of a given interface can be changed; I.e., in all modes
other than the so-called `deault' mode the interfaces are forbidden from
changing the configuration - but even this rule is not applied to all
user APIs that may change the configuration.

Instead, let the core-module [qed] decide whether an interface can change
the configuration by supporting a new API function. We also revise the
current rule, allowing all interfaces to change their configurations while
laying the infrastructure for future modes where an interface would be
blocked from making such a configuration.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Yuval Mintz 2016-04-22 08:41:03 +03:00 committed by David S. Miller
parent f3e72109f0
commit fe7cd2bfda
3 changed files with 26 additions and 4 deletions

View File

@ -915,6 +915,11 @@ static u32 qed_sb_release(struct qed_dev *cdev,
return rc;
}
static bool qed_can_link_change(struct qed_dev *cdev)
{
return true;
}
static int qed_set_link(struct qed_dev *cdev,
struct qed_link_params *params)
{
@ -1177,6 +1182,7 @@ const struct qed_common_ops qed_common_ops_pass = {
.sb_release = &qed_sb_release,
.simd_handler_config = &qed_simd_handler_config,
.simd_handler_clean = &qed_simd_handler_clean,
.can_link_change = &qed_can_link_change,
.set_link = &qed_set_link,
.get_link = &qed_get_current_link,
.drain = &qed_drain,

View File

@ -239,9 +239,9 @@ static int qede_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
struct qed_link_params params;
u32 speed;
if (!edev->dev_info.common.is_mf_default) {
if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
DP_INFO(edev,
"Link parameters can not be changed in non-default mode\n");
"Link settings are not allowed to be changed\n");
return -EOPNOTSUPP;
}
@ -350,6 +350,12 @@ static int qede_nway_reset(struct net_device *dev)
struct qed_link_output current_link;
struct qed_link_params link_params;
if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
DP_INFO(edev,
"Link settings are not allowed to be changed\n");
return -EOPNOTSUPP;
}
if (!netif_running(dev))
return 0;
@ -450,9 +456,9 @@ static int qede_set_pauseparam(struct net_device *dev,
struct qed_link_params params;
struct qed_link_output current_link;
if (!edev->dev_info.common.is_mf_default) {
if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
DP_INFO(edev,
"Pause parameters can not be updated in non-default mode\n");
"Pause settings are not allowed to be changed\n");
return -EOPNOTSUPP;
}

View File

@ -211,6 +211,16 @@ struct qed_common_ops {
void (*simd_handler_clean)(struct qed_dev *cdev,
int index);
/**
* @brief can_link_change - can the instance change the link or not
*
* @param cdev
*
* @return true if link-change is allowed, false otherwise.
*/
bool (*can_link_change)(struct qed_dev *cdev);
/**
* @brief set_link - set links according to params
*