]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
cxgb4/cxgb4vf: Notify link changes to OS-dependent code
authorArjun Vynipadath <arjun@chelsio.com>
Thu, 24 May 2018 14:03:37 +0000 (19:33 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 May 2018 19:10:07 +0000 (15:10 -0400)
We have a confusion of two different abstractions in the Common
Code:  Physical Link (Port) and Logical Network Interface (Virtual
Interface), and we haven't been properly managing the state of the
intersection of those two abstractions.
On the one hand we have the Physical state of the Link -- up or down --
and on the other we have the logical state of the VI, enabled or not.
{ethN} refers to both the Physical and Logical State. In this case,
ifconfig only affects/interrogates the Logical State of a VI,
and ethtool only deals with the Physical State. And these are different.

So, just because we disable the VI, we don't really want to change the
Physical Link Up/Down state.  Thus, the previous hack to set
"lc->link_ok = 0" when we disable a VI is completely incorrect.

Where we get into trouble is where the Physical Link State and the
Logical VI State cross swords.  And that happens in
t4_handle_get_port_info() where we need to manage/safe the Physical
Link State, but we also need to know when the Logical VI State has
changed and pass that back up to the OS-dependent Driver routine
t4_os_link_changed() which is concerned about the Logical Interface.

So we enable a VI and that causes Firmware to send us a new Port
Information message, but if none of the Physical Link State
particulars have changed, we don't call t4_os_link_changed().

This fix uses the existing OS Contract APIs for the Common Code to
inform the OS-dependent portion of the Host Driver when the "Link" (really
Logical Network Interface) is "up" or "down". A new API
t4_enable_pi_params() is added which calls t4_enable_vi_params() and,
if that is successful, then calls back to the OS Contract API
t4_os_link_changed() notifying the OS-dependent layer of the
potential Link State change.

Original Work by : Casey Leedom <leedom@chelsio.com>

Signed-off-by: Santosh Rastapur <santosh@chelsio.com>
Signed-off-by: Arjun Vynipadath <arjun@chelsio.com>
Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c

index 0f305d97f4ee633838c6c12e50bfc3fa901fdd1d..0dbe2d9e22d60d12a2e04770210d2c56fe4279ce 100644 (file)
@@ -1738,6 +1738,9 @@ int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
                     bool ucast, u64 vec, bool sleep_ok);
 int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
                        unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
+int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
+                       struct port_info *pi,
+                       bool rx_en, bool tx_en, bool dcb_en);
 int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
                 bool rx_en, bool tx_en);
 int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
index 903c0af374567e876a23b56a9e60acec37adf0e7..0efae2030e71ba88342e04178449a11c9c20f4f6 100644 (file)
@@ -465,7 +465,7 @@ static int link_start(struct net_device *dev)
                                    &pi->link_cfg);
        if (ret == 0) {
                local_bh_disable();
-               ret = t4_enable_vi_params(pi->adapter, mb, pi->viid, true,
+               ret = t4_enable_pi_params(pi->adapter, mb, pi, true,
                                          true, CXGB4_DCB_ENABLED);
                local_bh_enable();
        }
@@ -2344,7 +2344,8 @@ static int cxgb_close(struct net_device *dev)
 
        netif_tx_stop_all_queues(dev);
        netif_carrier_off(dev);
-       ret = t4_enable_vi(adapter, adapter->pf, pi->viid, false, false);
+       ret = t4_enable_pi_params(adapter, adapter->pf, pi,
+                                 false, false, false);
 #ifdef CONFIG_CHELSIO_T4_DCB
        cxgb4_dcb_reset(dev);
        dcb_tx_queue_prio_enable(dev, false);
index 962384cdd64b535465b9b9787c355c05da2f5c76..39da7e3c804b79cf824ae62b30f5445f96e16ed3 100644 (file)
@@ -8013,6 +8013,34 @@ int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
        return t4_enable_vi_params(adap, mbox, viid, rx_en, tx_en, 0);
 }
 
+/**
+ *     t4_enable_pi_params - enable/disable a Port's Virtual Interface
+ *      @adap: the adapter
+ *      @mbox: mailbox to use for the FW command
+ *      @pi: the Port Information structure
+ *      @rx_en: 1=enable Rx, 0=disable Rx
+ *      @tx_en: 1=enable Tx, 0=disable Tx
+ *      @dcb_en: 1=enable delivery of Data Center Bridging messages.
+ *
+ *      Enables/disables a Port's Virtual Interface.  Note that setting DCB
+ *     Enable only makes sense when enabling a Virtual Interface ...
+ *     If the Virtual Interface enable/disable operation is successful,
+ *     we notify the OS-specific code of a potential Link Status change
+ *     via the OS Contract API t4_os_link_changed().
+ */
+int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
+                       struct port_info *pi,
+                       bool rx_en, bool tx_en, bool dcb_en)
+{
+       int ret = t4_enable_vi_params(adap, mbox, pi->viid,
+                                     rx_en, tx_en, dcb_en);
+       if (ret)
+               return ret;
+       t4_os_link_changed(adap, pi->port_id,
+                          rx_en && tx_en && pi->link_cfg.link_ok);
+       return 0;
+}
+
 /**
  *     t4_identify_port - identify a VI's port by blinking its LED
  *     @adap: the adapter
index 71f13bd2b5e49b525052abc7db133fe41155df5d..ff84791a0ff853bf571aeb89014ec92d66eb6275 100644 (file)
@@ -274,7 +274,7 @@ static int link_start(struct net_device *dev)
         * is enabled on a port.
         */
        if (ret == 0)
-               ret = t4vf_enable_vi(pi->adapter, pi->viid, true, true);
+               ret = t4vf_enable_pi(pi->adapter, pi, true, true);
 
        /* The Virtual Interfaces are connected to an internal switch on the
         * chip which allows VIs attached to the same port to talk to each
@@ -822,8 +822,7 @@ static int cxgb4vf_stop(struct net_device *dev)
 
        netif_tx_stop_all_queues(dev);
        netif_carrier_off(dev);
-       t4vf_enable_vi(adapter, pi->viid, false, false);
-       pi->link_cfg.link_ok = 0;
+       t4vf_enable_pi(adapter, pi, false, false);
 
        clear_bit(pi->port_id, &adapter->open_device_map);
        if (adapter->open_device_map == 0)
index 712e8f0c71b49a890320555006af9317c3d63d81..ccca67cf4487d22d06f7c2b42dc6b16647cec8d0 100644 (file)
@@ -391,7 +391,10 @@ int t4vf_config_rss_range(struct adapter *, unsigned int, int, int,
 
 int t4vf_alloc_vi(struct adapter *, int);
 int t4vf_free_vi(struct adapter *, int);
-int t4vf_enable_vi(struct adapter *, unsigned int, bool, bool);
+int t4vf_enable_vi(struct adapter *adapter, unsigned int viid, bool rx_en,
+                  bool tx_en);
+int t4vf_enable_pi(struct adapter *adapter, struct port_info *pi, bool rx_en,
+                  bool tx_en);
 int t4vf_identify_port(struct adapter *, unsigned int, unsigned int);
 
 int t4vf_set_rxmode(struct adapter *, unsigned int, int, int, int, int, int,
index 8786431a8825bd7e239ccb9496f6ad89e7bc5bf5..5b8c08cf523ff2bb5b39af41a5e0bb662e39da62 100644 (file)
@@ -1399,6 +1399,30 @@ int t4vf_enable_vi(struct adapter *adapter, unsigned int viid,
        return t4vf_wr_mbox(adapter, &cmd, sizeof(cmd), NULL);
 }
 
+/**
+ *     t4vf_enable_pi - enable/disable a Port's virtual interface
+ *     @adapter: the adapter
+ *     @pi: the Port Information structure
+ *     @rx_en: 1=enable Rx, 0=disable Rx
+ *     @tx_en: 1=enable Tx, 0=disable Tx
+ *
+ *     Enables/disables a Port's virtual interface.  If the Virtual
+ *     Interface enable/disable operation is successful, we notify the
+ *     OS-specific code of a potential Link Status change via the OS Contract
+ *     API t4vf_os_link_changed().
+ */
+int t4vf_enable_pi(struct adapter *adapter, struct port_info *pi,
+                  bool rx_en, bool tx_en)
+{
+       int ret = t4vf_enable_vi(adapter, pi->viid, rx_en, tx_en);
+
+       if (ret)
+               return ret;
+       t4vf_os_link_changed(adapter, pi->pidx,
+                            rx_en && tx_en && pi->link_cfg.link_ok);
+       return 0;
+}
+
 /**
  *     t4vf_identify_port - identify a VI's port by blinking its LED
  *     @adapter: the adapter