Skip to content

Commit 0caeaf6

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4/cxgb4vf: fix flow control display for auto negotiation
As per 802.3-2005, Section Two, Annex 28B, Table 28B-2 [1], when _only_ Rx pause is enabled, both symmetric and asymmetric pause towards local device must be enabled. Also, firmware returns the local device's flow control pause params as part of advertised capabilities and negotiated params as part of current link attributes. So, fix up ethtool's flow control pause params fetch logic to read from acaps, instead of linkattr. [1] https://standards.ieee.org/standard/802_3-2005.html Fixes: c3168ca ("cxgb4/cxgbvf: Handle 32-bit fw port capabilities") Signed-off-by: Surendra Mobiya <[email protected]> Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3faf6ed commit 0caeaf6

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ struct link_config {
504504

505505
enum cc_pause requested_fc; /* flow control user has requested */
506506
enum cc_pause fc; /* actual link flow control */
507+
enum cc_pause advertised_fc; /* actual advertised flow control */
507508

508509
enum cc_fec requested_fec; /* Forward Error Correction: */
509510
enum cc_fec fec; /* requested and actual in use */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,8 @@ static void get_pauseparam(struct net_device *dev,
807807
struct port_info *p = netdev_priv(dev);
808808

809809
epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
810-
epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0;
811-
epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0;
810+
epause->rx_pause = (p->link_cfg.advertised_fc & PAUSE_RX) != 0;
811+
epause->tx_pause = (p->link_cfg.advertised_fc & PAUSE_TX) != 0;
812812
}
813813

814814
static int set_pauseparam(struct net_device *dev,

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4089,7 +4089,8 @@ static inline fw_port_cap32_t cc_to_fwcap_pause(enum cc_pause cc_pause)
40894089
if (cc_pause & PAUSE_TX)
40904090
fw_pause |= FW_PORT_CAP32_802_3_PAUSE;
40914091
else
4092-
fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR;
4092+
fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR |
4093+
FW_PORT_CAP32_802_3_PAUSE;
40934094
} else if (cc_pause & PAUSE_TX) {
40944095
fw_pause |= FW_PORT_CAP32_802_3_ASM_DIR;
40954096
}
@@ -8563,17 +8564,17 @@ static fw_port_cap32_t lstatus_to_fwcap(u32 lstatus)
85638564
void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl)
85648565
{
85658566
const struct fw_port_cmd *cmd = (const void *)rpl;
8566-
int action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16));
8567-
struct adapter *adapter = pi->adapter;
8567+
fw_port_cap32_t pcaps, acaps, lpacaps, linkattr;
85688568
struct link_config *lc = &pi->link_cfg;
8569-
int link_ok, linkdnrc;
8570-
enum fw_port_type port_type;
8569+
struct adapter *adapter = pi->adapter;
8570+
unsigned int speed, fc, fec, adv_fc;
85718571
enum fw_port_module_type mod_type;
8572-
unsigned int speed, fc, fec;
8573-
fw_port_cap32_t pcaps, acaps, lpacaps, linkattr;
8572+
int action, link_ok, linkdnrc;
8573+
enum fw_port_type port_type;
85748574

85758575
/* Extract the various fields from the Port Information message.
85768576
*/
8577+
action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16));
85778578
switch (action) {
85788579
case FW_PORT_ACTION_GET_PORT_INFO: {
85798580
u32 lstatus = be32_to_cpu(cmd->u.info.lstatus_to_modtype);
@@ -8611,6 +8612,7 @@ void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl)
86118612
}
86128613

86138614
fec = fwcap_to_cc_fec(acaps);
8615+
adv_fc = fwcap_to_cc_pause(acaps);
86148616
fc = fwcap_to_cc_pause(linkattr);
86158617
speed = fwcap_to_speed(linkattr);
86168618

@@ -8667,7 +8669,9 @@ void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl)
86678669
}
86688670

86698671
if (link_ok != lc->link_ok || speed != lc->speed ||
8670-
fc != lc->fc || fec != lc->fec) { /* something changed */
8672+
fc != lc->fc || adv_fc != lc->advertised_fc ||
8673+
fec != lc->fec) {
8674+
/* something changed */
86718675
if (!link_ok && lc->link_ok) {
86728676
lc->link_down_rc = linkdnrc;
86738677
dev_warn_ratelimited(adapter->pdev_dev,
@@ -8677,6 +8681,7 @@ void t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl)
86778681
}
86788682
lc->link_ok = link_ok;
86798683
lc->speed = speed;
8684+
lc->advertised_fc = adv_fc;
86808685
lc->fc = fc;
86818686
lc->fec = fec;
86828687

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,8 @@ static void cxgb4vf_get_pauseparam(struct net_device *dev,
16901690
struct port_info *pi = netdev_priv(dev);
16911691

16921692
pauseparam->autoneg = (pi->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
1693-
pauseparam->rx_pause = (pi->link_cfg.fc & PAUSE_RX) != 0;
1694-
pauseparam->tx_pause = (pi->link_cfg.fc & PAUSE_TX) != 0;
1693+
pauseparam->rx_pause = (pi->link_cfg.advertised_fc & PAUSE_RX) != 0;
1694+
pauseparam->tx_pause = (pi->link_cfg.advertised_fc & PAUSE_TX) != 0;
16951695
}
16961696

16971697
/*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct link_config {
135135

136136
enum cc_pause requested_fc; /* flow control user has requested */
137137
enum cc_pause fc; /* actual link flow control */
138+
enum cc_pause advertised_fc; /* actual advertised flow control */
138139

139140
enum cc_fec auto_fec; /* Forward Error Correction: */
140141
enum cc_fec requested_fec; /* "automatic" (IEEE 802.3), */

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,16 +1913,16 @@ static const char *t4vf_link_down_rc_str(unsigned char link_down_rc)
19131913
static void t4vf_handle_get_port_info(struct port_info *pi,
19141914
const struct fw_port_cmd *cmd)
19151915
{
1916-
int action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16));
1917-
struct adapter *adapter = pi->adapter;
1916+
fw_port_cap32_t pcaps, acaps, lpacaps, linkattr;
19181917
struct link_config *lc = &pi->link_cfg;
1919-
int link_ok, linkdnrc;
1920-
enum fw_port_type port_type;
1918+
struct adapter *adapter = pi->adapter;
1919+
unsigned int speed, fc, fec, adv_fc;
19211920
enum fw_port_module_type mod_type;
1922-
unsigned int speed, fc, fec;
1923-
fw_port_cap32_t pcaps, acaps, lpacaps, linkattr;
1921+
int action, link_ok, linkdnrc;
1922+
enum fw_port_type port_type;
19241923

19251924
/* Extract the various fields from the Port Information message. */
1925+
action = FW_PORT_CMD_ACTION_G(be32_to_cpu(cmd->action_to_len16));
19261926
switch (action) {
19271927
case FW_PORT_ACTION_GET_PORT_INFO: {
19281928
u32 lstatus = be32_to_cpu(cmd->u.info.lstatus_to_modtype);
@@ -1982,6 +1982,7 @@ static void t4vf_handle_get_port_info(struct port_info *pi,
19821982
}
19831983

19841984
fec = fwcap_to_cc_fec(acaps);
1985+
adv_fc = fwcap_to_cc_pause(acaps);
19851986
fc = fwcap_to_cc_pause(linkattr);
19861987
speed = fwcap_to_speed(linkattr);
19871988

@@ -2012,7 +2013,9 @@ static void t4vf_handle_get_port_info(struct port_info *pi,
20122013
}
20132014

20142015
if (link_ok != lc->link_ok || speed != lc->speed ||
2015-
fc != lc->fc || fec != lc->fec) { /* something changed */
2016+
fc != lc->fc || adv_fc != lc->advertised_fc ||
2017+
fec != lc->fec) {
2018+
/* something changed */
20162019
if (!link_ok && lc->link_ok) {
20172020
lc->link_down_rc = linkdnrc;
20182021
dev_warn_ratelimited(adapter->pdev_dev,
@@ -2022,6 +2025,7 @@ static void t4vf_handle_get_port_info(struct port_info *pi,
20222025
}
20232026
lc->link_ok = link_ok;
20242027
lc->speed = speed;
2028+
lc->advertised_fc = adv_fc;
20252029
lc->fc = fc;
20262030
lc->fec = fec;
20272031

0 commit comments

Comments
 (0)