Skip to content

Commit c1de13b

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 40GbE Intel Wired LAN Driver Updates 2018-02-26 This series contains updates to i40e and i40evf only. Mariusz adds a new ethtool private flag for forcing true link state with the requested changes from Jakub Kicinski. Paweł fixes an issue where we were double locking the same resource which would generate a kernel panic after bringing an interface up for i40evf. Alan modifies both drivers to use software values to determine if there are packets stalled on the ring with the added benefit of being less CPU intensive since we do not need to reach into the hardware to get the values. Colin Ian King provides a few fixes detected by Coverity, first was to pass a struct by reference versus by value to be more efficient. Then verify the VSI pointer is not NULL before trying to dereference it. Cleaned up redundant checks that always return true. Dan Carpenter fixes over indented lines of code. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6c6aa15 + 5dd3691 commit c1de13b

File tree

9 files changed

+181
-66
lines changed

9 files changed

+181
-66
lines changed

drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,43 @@ enum i40e_aq_phy_type {
19141914
I40E_PHY_TYPE_DEFAULT = 0xFF,
19151915
};
19161916

1917+
#define I40E_PHY_TYPES_BITMASK (BIT_ULL(I40E_PHY_TYPE_SGMII) | \
1918+
BIT_ULL(I40E_PHY_TYPE_1000BASE_KX) | \
1919+
BIT_ULL(I40E_PHY_TYPE_10GBASE_KX4) | \
1920+
BIT_ULL(I40E_PHY_TYPE_10GBASE_KR) | \
1921+
BIT_ULL(I40E_PHY_TYPE_40GBASE_KR4) | \
1922+
BIT_ULL(I40E_PHY_TYPE_XAUI) | \
1923+
BIT_ULL(I40E_PHY_TYPE_XFI) | \
1924+
BIT_ULL(I40E_PHY_TYPE_SFI) | \
1925+
BIT_ULL(I40E_PHY_TYPE_XLAUI) | \
1926+
BIT_ULL(I40E_PHY_TYPE_XLPPI) | \
1927+
BIT_ULL(I40E_PHY_TYPE_40GBASE_CR4_CU) | \
1928+
BIT_ULL(I40E_PHY_TYPE_10GBASE_CR1_CU) | \
1929+
BIT_ULL(I40E_PHY_TYPE_10GBASE_AOC) | \
1930+
BIT_ULL(I40E_PHY_TYPE_40GBASE_AOC) | \
1931+
BIT_ULL(I40E_PHY_TYPE_UNRECOGNIZED) | \
1932+
BIT_ULL(I40E_PHY_TYPE_UNSUPPORTED) | \
1933+
BIT_ULL(I40E_PHY_TYPE_100BASE_TX) | \
1934+
BIT_ULL(I40E_PHY_TYPE_1000BASE_T) | \
1935+
BIT_ULL(I40E_PHY_TYPE_10GBASE_T) | \
1936+
BIT_ULL(I40E_PHY_TYPE_10GBASE_SR) | \
1937+
BIT_ULL(I40E_PHY_TYPE_10GBASE_LR) | \
1938+
BIT_ULL(I40E_PHY_TYPE_10GBASE_SFPP_CU) | \
1939+
BIT_ULL(I40E_PHY_TYPE_10GBASE_CR1) | \
1940+
BIT_ULL(I40E_PHY_TYPE_40GBASE_CR4) | \
1941+
BIT_ULL(I40E_PHY_TYPE_40GBASE_SR4) | \
1942+
BIT_ULL(I40E_PHY_TYPE_40GBASE_LR4) | \
1943+
BIT_ULL(I40E_PHY_TYPE_1000BASE_SX) | \
1944+
BIT_ULL(I40E_PHY_TYPE_1000BASE_LX) | \
1945+
BIT_ULL(I40E_PHY_TYPE_1000BASE_T_OPTICAL) | \
1946+
BIT_ULL(I40E_PHY_TYPE_20GBASE_KR2) | \
1947+
BIT_ULL(I40E_PHY_TYPE_25GBASE_KR) | \
1948+
BIT_ULL(I40E_PHY_TYPE_25GBASE_CR) | \
1949+
BIT_ULL(I40E_PHY_TYPE_25GBASE_SR) | \
1950+
BIT_ULL(I40E_PHY_TYPE_25GBASE_LR) | \
1951+
BIT_ULL(I40E_PHY_TYPE_25GBASE_AOC) | \
1952+
BIT_ULL(I40E_PHY_TYPE_25GBASE_ACC))
1953+
19171954
#define I40E_LINK_SPEED_100MB_SHIFT 0x1
19181955
#define I40E_LINK_SPEED_1000MB_SHIFT 0x2
19191956
#define I40E_LINK_SPEED_10GB_SHIFT 0x3

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ static const struct i40e_priv_flags i40e_gstrings_priv_flags[] = {
230230
I40E_PRIV_FLAG("flow-director-atr", I40E_FLAG_FD_ATR_ENABLED, 0),
231231
I40E_PRIV_FLAG("veb-stats", I40E_FLAG_VEB_STATS_ENABLED, 0),
232232
I40E_PRIV_FLAG("hw-atr-eviction", I40E_FLAG_HW_ATR_EVICT_ENABLED, 0),
233+
I40E_PRIV_FLAG("link-down-on-close",
234+
I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED, 0),
233235
I40E_PRIV_FLAG("legacy-rx", I40E_FLAG_LEGACY_RX, 0),
234236
I40E_PRIV_FLAG("disable-source-pruning",
235237
I40E_FLAG_SOURCE_PRUNING_DISABLED, 0),

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6546,6 +6546,75 @@ int i40e_up(struct i40e_vsi *vsi)
65466546
return err;
65476547
}
65486548

6549+
/**
6550+
* i40e_force_link_state - Force the link status
6551+
* @pf: board private structure
6552+
* @is_up: whether the link state should be forced up or down
6553+
**/
6554+
static i40e_status i40e_force_link_state(struct i40e_pf *pf, bool is_up)
6555+
{
6556+
struct i40e_aq_get_phy_abilities_resp abilities;
6557+
struct i40e_aq_set_phy_config config = {0};
6558+
struct i40e_hw *hw = &pf->hw;
6559+
i40e_status err;
6560+
u64 mask;
6561+
6562+
/* Get the current phy config */
6563+
err = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
6564+
NULL);
6565+
if (err) {
6566+
dev_err(&pf->pdev->dev,
6567+
"failed to get phy cap., ret = %s last_status = %s\n",
6568+
i40e_stat_str(hw, err),
6569+
i40e_aq_str(hw, hw->aq.asq_last_status));
6570+
return err;
6571+
}
6572+
6573+
/* If link needs to go up, but was not forced to go down,
6574+
* no need for a flap
6575+
*/
6576+
if (is_up && abilities.phy_type != 0)
6577+
return I40E_SUCCESS;
6578+
6579+
/* To force link we need to set bits for all supported PHY types,
6580+
* but there are now more than 32, so we need to split the bitmap
6581+
* across two fields.
6582+
*/
6583+
mask = I40E_PHY_TYPES_BITMASK;
6584+
config.phy_type = is_up ? cpu_to_le32((u32)(mask & 0xffffffff)) : 0;
6585+
config.phy_type_ext = is_up ? (u8)((mask >> 32) & 0xff) : 0;
6586+
/* Copy the old settings, except of phy_type */
6587+
config.abilities = abilities.abilities;
6588+
config.link_speed = abilities.link_speed;
6589+
config.eee_capability = abilities.eee_capability;
6590+
config.eeer = abilities.eeer_val;
6591+
config.low_power_ctrl = abilities.d3_lpan;
6592+
err = i40e_aq_set_phy_config(hw, &config, NULL);
6593+
6594+
if (err) {
6595+
dev_err(&pf->pdev->dev,
6596+
"set phy config ret = %s last_status = %s\n",
6597+
i40e_stat_str(&pf->hw, err),
6598+
i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));
6599+
return err;
6600+
}
6601+
6602+
/* Update the link info */
6603+
err = i40e_update_link_info(hw);
6604+
if (err) {
6605+
/* Wait a little bit (on 40G cards it sometimes takes a really
6606+
* long time for link to come back from the atomic reset)
6607+
* and try once more
6608+
*/
6609+
msleep(1000);
6610+
i40e_update_link_info(hw);
6611+
}
6612+
6613+
i40e_aq_set_link_restart_an(hw, true, NULL);
6614+
6615+
return I40E_SUCCESS;
6616+
}
6617+
65496618
/**
65506619
* i40e_down - Shutdown the connection processing
65516620
* @vsi: the VSI being stopped
@@ -6563,6 +6632,9 @@ void i40e_down(struct i40e_vsi *vsi)
65636632
}
65646633
i40e_vsi_disable_irq(vsi);
65656634
i40e_vsi_stop_rings(vsi);
6635+
if (vsi->type == I40E_VSI_MAIN &&
6636+
vsi->back->flags & I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED)
6637+
i40e_force_link_state(vsi->back, false);
65666638
i40e_napi_disable_all(vsi);
65676639

65686640
for (i = 0; i < vsi->num_queue_pairs; i++) {
@@ -7524,6 +7596,9 @@ int i40e_open(struct net_device *netdev)
75247596

75257597
netif_carrier_off(netdev);
75267598

7599+
if (i40e_force_link_state(pf, true))
7600+
return -EAGAIN;
7601+
75277602
err = i40e_vsi_open(vsi);
75287603
if (err)
75297604
return err;

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,16 +708,22 @@ void i40e_free_tx_resources(struct i40e_ring *tx_ring)
708708
/**
709709
* i40e_get_tx_pending - how many tx descriptors not processed
710710
* @tx_ring: the ring of descriptors
711+
* @in_sw: use SW variables
711712
*
712713
* Since there is no access to the ring head register
713714
* in XL710, we need to use our local copies
714715
**/
715-
u32 i40e_get_tx_pending(struct i40e_ring *ring)
716+
u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw)
716717
{
717718
u32 head, tail;
718719

719-
head = i40e_get_head(ring);
720-
tail = readl(ring->tail);
720+
if (!in_sw) {
721+
head = i40e_get_head(ring);
722+
tail = readl(ring->tail);
723+
} else {
724+
head = ring->next_to_clean;
725+
tail = ring->next_to_use;
726+
}
721727

722728
if (head != tail)
723729
return (head < tail) ?
@@ -774,7 +780,7 @@ void i40e_detect_recover_hung(struct i40e_vsi *vsi)
774780
*/
775781
smp_rmb();
776782
tx_ring->tx_stats.prev_pkt_ctr =
777-
i40e_get_tx_pending(tx_ring) ? packets : -1;
783+
i40e_get_tx_pending(tx_ring, true) ? packets : -1;
778784
}
779785
}
780786
}
@@ -898,7 +904,7 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
898904
* them to be written back in case we stay in NAPI.
899905
* In this mode on X722 we do not enable Interrupt.
900906
*/
901-
unsigned int j = i40e_get_tx_pending(tx_ring);
907+
unsigned int j = i40e_get_tx_pending(tx_ring, false);
902908

903909
if (budget &&
904910
((j / WB_STRIDE) == 0) && (j > 0) &&

drivers/net/ethernet/intel/i40e/i40e_txrx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void i40e_free_tx_resources(struct i40e_ring *tx_ring);
505505
void i40e_free_rx_resources(struct i40e_ring *rx_ring);
506506
int i40e_napi_poll(struct napi_struct *napi, int budget);
507507
void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector);
508-
u32 i40e_get_tx_pending(struct i40e_ring *ring);
508+
u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw);
509509
void i40e_detect_recover_hung(struct i40e_vsi *vsi);
510510
int __i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size);
511511
bool __i40e_chk_linearize(struct sk_buff *skb);

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@ static struct i40e_vsi *i40e_find_vsi_from_seid(struct i40e_vf *vf, u16 seid)
30623062

30633063
for (i = 0; i < vf->num_tc ; i++) {
30643064
vsi = i40e_find_vsi_from_id(pf, vf->ch[i].vsi_id);
3065-
if (vsi->seid == seid)
3065+
if (vsi && vsi->seid == seid)
30663066
return vsi;
30673067
}
30683068
return NULL;
@@ -3146,8 +3146,8 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
31463146
dev_info(&pf->pdev->dev,
31473147
"VF %d: Invalid input, can't apply cloud filter\n",
31483148
vf->vf_id);
3149-
aq_ret = I40E_ERR_PARAM;
3150-
goto err;
3149+
aq_ret = I40E_ERR_PARAM;
3150+
goto err;
31513151
}
31523152

31533153
memset(&cfilter, 0, sizeof(cfilter));

drivers/net/ethernet/intel/i40evf/i40e_txrx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void i40evf_detect_recover_hung(struct i40e_vsi *vsi)
196196
*/
197197
smp_rmb();
198198
tx_ring->tx_stats.prev_pkt_ctr =
199-
i40evf_get_tx_pending(tx_ring, false) ? packets : -1;
199+
i40evf_get_tx_pending(tx_ring, true) ? packets : -1;
200200
}
201201
}
202202
}

0 commit comments

Comments
 (0)