Skip to content

Commit e2f4f4e

Browse files
arjunvynipadathdavem330
authored andcommitted
cxgb4/cxgb4vf: Notify link changes to OS-dependent code
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>
1 parent e8d4529 commit e2f4f4e

6 files changed

Lines changed: 64 additions & 6 deletions

File tree

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,9 @@ int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
17381738
bool ucast, u64 vec, bool sleep_ok);
17391739
int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
17401740
unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
1741+
int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
1742+
struct port_info *pi,
1743+
bool rx_en, bool tx_en, bool dcb_en);
17411744
int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
17421745
bool rx_en, bool tx_en);
17431746
int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int link_start(struct net_device *dev)
465465
&pi->link_cfg);
466466
if (ret == 0) {
467467
local_bh_disable();
468-
ret = t4_enable_vi_params(pi->adapter, mb, pi->viid, true,
468+
ret = t4_enable_pi_params(pi->adapter, mb, pi, true,
469469
true, CXGB4_DCB_ENABLED);
470470
local_bh_enable();
471471
}
@@ -2344,7 +2344,8 @@ static int cxgb_close(struct net_device *dev)
23442344

23452345
netif_tx_stop_all_queues(dev);
23462346
netif_carrier_off(dev);
2347-
ret = t4_enable_vi(adapter, adapter->pf, pi->viid, false, false);
2347+
ret = t4_enable_pi_params(adapter, adapter->pf, pi,
2348+
false, false, false);
23482349
#ifdef CONFIG_CHELSIO_T4_DCB
23492350
cxgb4_dcb_reset(dev);
23502351
dcb_tx_queue_prio_enable(dev, false);

‎drivers/net/ethernet/chelsio/cxgb4/t4_hw.c‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8013,6 +8013,34 @@ int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
80138013
return t4_enable_vi_params(adap, mbox, viid, rx_en, tx_en, 0);
80148014
}
80158015

8016+
/**
8017+
* t4_enable_pi_params - enable/disable a Port's Virtual Interface
8018+
* @adap: the adapter
8019+
* @mbox: mailbox to use for the FW command
8020+
* @pi: the Port Information structure
8021+
* @rx_en: 1=enable Rx, 0=disable Rx
8022+
* @tx_en: 1=enable Tx, 0=disable Tx
8023+
* @dcb_en: 1=enable delivery of Data Center Bridging messages.
8024+
*
8025+
* Enables/disables a Port's Virtual Interface. Note that setting DCB
8026+
* Enable only makes sense when enabling a Virtual Interface ...
8027+
* If the Virtual Interface enable/disable operation is successful,
8028+
* we notify the OS-specific code of a potential Link Status change
8029+
* via the OS Contract API t4_os_link_changed().
8030+
*/
8031+
int t4_enable_pi_params(struct adapter *adap, unsigned int mbox,
8032+
struct port_info *pi,
8033+
bool rx_en, bool tx_en, bool dcb_en)
8034+
{
8035+
int ret = t4_enable_vi_params(adap, mbox, pi->viid,
8036+
rx_en, tx_en, dcb_en);
8037+
if (ret)
8038+
return ret;
8039+
t4_os_link_changed(adap, pi->port_id,
8040+
rx_en && tx_en && pi->link_cfg.link_ok);
8041+
return 0;
8042+
}
8043+
80168044
/**
80178045
* t4_identify_port - identify a VI's port by blinking its LED
80188046
* @adap: the adapter

‎drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int link_start(struct net_device *dev)
274274
* is enabled on a port.
275275
*/
276276
if (ret == 0)
277-
ret = t4vf_enable_vi(pi->adapter, pi->viid, true, true);
277+
ret = t4vf_enable_pi(pi->adapter, pi, true, true);
278278

279279
/* The Virtual Interfaces are connected to an internal switch on the
280280
* 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)
822822

823823
netif_tx_stop_all_queues(dev);
824824
netif_carrier_off(dev);
825-
t4vf_enable_vi(adapter, pi->viid, false, false);
826-
pi->link_cfg.link_ok = 0;
825+
t4vf_enable_pi(adapter, pi, false, false);
827826

828827
clear_bit(pi->port_id, &adapter->open_device_map);
829828
if (adapter->open_device_map == 0)

‎drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ int t4vf_config_rss_range(struct adapter *, unsigned int, int, int,
391391

392392
int t4vf_alloc_vi(struct adapter *, int);
393393
int t4vf_free_vi(struct adapter *, int);
394-
int t4vf_enable_vi(struct adapter *, unsigned int, bool, bool);
394+
int t4vf_enable_vi(struct adapter *adapter, unsigned int viid, bool rx_en,
395+
bool tx_en);
396+
int t4vf_enable_pi(struct adapter *adapter, struct port_info *pi, bool rx_en,
397+
bool tx_en);
395398
int t4vf_identify_port(struct adapter *, unsigned int, unsigned int);
396399

397400
int t4vf_set_rxmode(struct adapter *, unsigned int, int, int, int, int, int,

‎drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,30 @@ int t4vf_enable_vi(struct adapter *adapter, unsigned int viid,
13991399
return t4vf_wr_mbox(adapter, &cmd, sizeof(cmd), NULL);
14001400
}
14011401

1402+
/**
1403+
* t4vf_enable_pi - enable/disable a Port's virtual interface
1404+
* @adapter: the adapter
1405+
* @pi: the Port Information structure
1406+
* @rx_en: 1=enable Rx, 0=disable Rx
1407+
* @tx_en: 1=enable Tx, 0=disable Tx
1408+
*
1409+
* Enables/disables a Port's virtual interface. If the Virtual
1410+
* Interface enable/disable operation is successful, we notify the
1411+
* OS-specific code of a potential Link Status change via the OS Contract
1412+
* API t4vf_os_link_changed().
1413+
*/
1414+
int t4vf_enable_pi(struct adapter *adapter, struct port_info *pi,
1415+
bool rx_en, bool tx_en)
1416+
{
1417+
int ret = t4vf_enable_vi(adapter, pi->viid, rx_en, tx_en);
1418+
1419+
if (ret)
1420+
return ret;
1421+
t4vf_os_link_changed(adapter, pi->pidx,
1422+
rx_en && tx_en && pi->link_cfg.link_ok);
1423+
return 0;
1424+
}
1425+
14021426
/**
14031427
* t4vf_identify_port - identify a VI's port by blinking its LED
14041428
* @adapter: the adapter

0 commit comments

Comments
 (0)