Skip to content

Commit

Permalink
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/tnguy/net-queue

Tony Nguyen says:

====================
Intel Wired LAN Driver Updates 2021-08-27

This series contains updates to ice driver only.

Jake corrects the iterator used for looping Tx timestamp and removes
dead code related to pin configuration. He also adds locking around
flushing of the Tx tracker and restarts the periodic clock following
time changes.

Brett corrects the locking around updating netdev dev_addr.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 28, 2021
2 parents 0d55649 + b357d97 commit 2619835
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
13 changes: 9 additions & 4 deletions drivers/net/ethernet/intel/ice/ice_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5122,6 +5122,7 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)
struct ice_hw *hw = &pf->hw;
struct sockaddr *addr = pi;
enum ice_status status;
u8 old_mac[ETH_ALEN];
u8 flags = 0;
int err = 0;
u8 *mac;
Expand All @@ -5144,8 +5145,13 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)
}

netif_addr_lock_bh(netdev);
ether_addr_copy(old_mac, netdev->dev_addr);
/* change the netdev's MAC address */
memcpy(netdev->dev_addr, mac, netdev->addr_len);
netif_addr_unlock_bh(netdev);

/* Clean up old MAC filter. Not an error if old filter doesn't exist */
status = ice_fltr_remove_mac(vsi, netdev->dev_addr, ICE_FWD_TO_VSI);
status = ice_fltr_remove_mac(vsi, old_mac, ICE_FWD_TO_VSI);
if (status && status != ICE_ERR_DOES_NOT_EXIST) {
err = -EADDRNOTAVAIL;
goto err_update_filters;
Expand All @@ -5168,13 +5174,12 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)
if (err) {
netdev_err(netdev, "can't set MAC %pM. filter update failed\n",
mac);
netif_addr_lock_bh(netdev);
ether_addr_copy(netdev->dev_addr, old_mac);
netif_addr_unlock_bh(netdev);
return err;
}

/* change the netdev's MAC address */
memcpy(netdev->dev_addr, mac, netdev->addr_len);
netif_addr_unlock_bh(netdev);
netdev_dbg(vsi->netdev, "updated MAC address to %pM\n",
netdev->dev_addr);

Expand Down
66 changes: 54 additions & 12 deletions drivers/net/ethernet/intel/ice/ice_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void ice_set_tx_tstamp(struct ice_pf *pf, bool on)
return;

/* Set the timestamp enable flag for all the Tx rings */
ice_for_each_rxq(vsi, i) {
ice_for_each_txq(vsi, i) {
if (!vsi->tx_rings[i])
continue;
vsi->tx_rings[i]->ptp_tx = on;
Expand Down Expand Up @@ -688,6 +688,41 @@ static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan,
return -EFAULT;
}

/**
* ice_ptp_disable_all_clkout - Disable all currently configured outputs
* @pf: pointer to the PF structure
*
* Disable all currently configured clock outputs. This is necessary before
* certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
* re-enable the clocks again.
*/
static void ice_ptp_disable_all_clkout(struct ice_pf *pf)
{
uint i;

for (i = 0; i < pf->ptp.info.n_per_out; i++)
if (pf->ptp.perout_channels[i].ena)
ice_ptp_cfg_clkout(pf, i, NULL, false);
}

/**
* ice_ptp_enable_all_clkout - Enable all configured periodic clock outputs
* @pf: pointer to the PF structure
*
* Enable all currently configured clock outputs. Use this after
* ice_ptp_disable_all_clkout to reconfigure the output signals according to
* their configuration.
*/
static void ice_ptp_enable_all_clkout(struct ice_pf *pf)
{
uint i;

for (i = 0; i < pf->ptp.info.n_per_out; i++)
if (pf->ptp.perout_channels[i].ena)
ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i],
false);
}

/**
* ice_ptp_gpio_enable_e810 - Enable/disable ancillary features of PHC
* @info: the driver's PTP info structure
Expand Down Expand Up @@ -783,12 +818,17 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
goto exit;
}

/* Disable periodic outputs */
ice_ptp_disable_all_clkout(pf);

err = ice_ptp_write_init(pf, &ts64);
ice_ptp_unlock(hw);

if (!err)
ice_ptp_update_cached_phctime(pf);

/* Reenable periodic outputs */
ice_ptp_enable_all_clkout(pf);
exit:
if (err) {
dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err);
Expand Down Expand Up @@ -842,8 +882,14 @@ static int ice_ptp_adjtime(struct ptp_clock_info *info, s64 delta)
return -EBUSY;
}

/* Disable periodic outputs */
ice_ptp_disable_all_clkout(pf);

err = ice_ptp_write_adj(pf, delta);

/* Reenable periodic outputs */
ice_ptp_enable_all_clkout(pf);

ice_ptp_unlock(hw);

if (err) {
Expand Down Expand Up @@ -1064,17 +1110,6 @@ static long ice_ptp_create_clock(struct ice_pf *pf)
info = &pf->ptp.info;
dev = ice_pf_to_dev(pf);

/* Allocate memory for kernel pins interface */
if (info->n_pins) {
info->pin_config = devm_kcalloc(dev, info->n_pins,
sizeof(*info->pin_config),
GFP_KERNEL);
if (!info->pin_config) {
info->n_pins = 0;
return -ENOMEM;
}
}

/* Attempt to register the clock before enabling the hardware. */
clock = ptp_clock_register(info, dev);
if (IS_ERR(clock))
Expand Down Expand Up @@ -1278,6 +1313,8 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
{
u8 idx;

spin_lock(&tx->lock);

for (idx = 0; idx < tx->len; idx++) {
u8 phy_idx = idx + tx->quad_offset;

Expand All @@ -1290,6 +1327,8 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
tx->tstamps[idx].skb = NULL;
}
}

spin_unlock(&tx->lock);
}

/**
Expand Down Expand Up @@ -1550,6 +1589,9 @@ void ice_ptp_release(struct ice_pf *pf)
if (!pf->ptp.clock)
return;

/* Disable periodic outputs */
ice_ptp_disable_all_clkout(pf);

ice_clear_ptp_clock_index(pf);
ptp_clock_unregister(pf->ptp.clock);
pf->ptp.clock = NULL;
Expand Down

0 comments on commit 2619835

Please sign in to comment.