]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
qed*: Conditions for changing link
authorYuval Mintz <Yuval.Mintz@qlogic.com>
Fri, 22 Apr 2016 05:41:03 +0000 (08:41 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Apr 2016 19:59:16 +0000 (15:59 -0400)
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>
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/qlogic/qede/qede_ethtool.c
include/linux/qed/qed_if.h

index 1e9f321f1ac44f6bea4b9a3b1981a93074cb5dbd..d189871e8e23da7dbfebca561c0f7b05b851b759 100644 (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,
index 2ac98d44c1e1addf555c71e8369a0dba30af77ec..f1dd25ac555207769d1492fc4d3e4be4d6a06159 100644 (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;
        }
 
index 82a7fe0110684afe841cbacf6e07d9eb30f4b916..e5de42b6297660a3a088853512c332202a10c19d 100644 (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
  *