Example #1
0
int mlx4_en_timestamp_config(struct net_device *dev, int tx_type, int rx_filter)
{
    struct mlx4_en_priv *priv = netdev_priv(dev);
    struct mlx4_en_dev *mdev = priv->mdev;
    int port_up = 0;
    int err = 0;

    mutex_lock(&mdev->state_lock);
    if (priv->port_up) {
        port_up = 1;
        mlx4_en_stop_port(dev, 1);
    }

    mlx4_en_free_resources(priv);

    en_warn(priv, "Changing Time Stamp configuration\n");

    priv->hwtstamp_config.tx_type = tx_type;
    priv->hwtstamp_config.rx_filter = rx_filter;

    if (rx_filter != HWTSTAMP_FILTER_NONE)
        dev->features &= ~NETIF_F_HW_VLAN_RX;
    else
        dev->features |= NETIF_F_HW_VLAN_RX;

    err = mlx4_en_alloc_resources(priv);
    if (err) {
        en_err(priv, "Failed reallocating port resources\n");
        goto out;
    }
    if (port_up) {
        err = mlx4_en_start_port(dev);
        if (err)
            en_err(priv, "Failed starting port\n");
    }

out:
    mutex_unlock(&mdev->state_lock);
    netdev_features_change(dev);
    return err;
}
Example #2
0
int mlx4_en_timestamp_config(struct net_device *dev, int tx_type, int rx_filter)
{
	struct mlx4_en_priv *priv = netdev_priv(dev);
	struct mlx4_en_dev *mdev = priv->mdev;
	int port_up = 0;
	int n_stats, err = 0;
	u64 *data = NULL;

	err = mlx4_en_pre_config(priv);
	if (err)
		return err;

	mutex_lock(&mdev->state_lock);
	if (priv->port_up) {
		port_up = 1;
		mlx4_en_stop_port(dev);
	}

	/* Cache port statistics */
	n_stats = mlx4_en_get_sset_count(dev, ETH_SS_STATS);
	if (n_stats > 0) {
		data = kmalloc(n_stats * sizeof(u64), GFP_KERNEL);
		if (data)
			mlx4_en_get_ethtool_stats(dev, NULL, data);
	}

	mlx4_en_free_resources(priv);

	en_err(priv, "Changing Time Stamp configuration\n");

	priv->hwtstamp_config.tx_type = tx_type;
	priv->hwtstamp_config.rx_filter = rx_filter;

	if (rx_filter != HWTSTAMP_FILTER_NONE)
		dev->features &= ~NETIF_F_HW_VLAN_RX;
	else
		dev->features |= NETIF_F_HW_VLAN_RX;

	if (tx_type != HWTSTAMP_TX_OFF)
		dev->features &= ~NETIF_F_HW_VLAN_TX;
	else
		dev->features |= NETIF_F_HW_VLAN_TX;

	err = mlx4_en_alloc_resources(priv);
	if (err) {
		en_err(priv, "Failed reallocating port resources\n");
		goto out;
	}

	/* Restore port statistics */
	if (n_stats > 0 && data)
		mlx4_en_restore_ethtool_stats(priv, data);

	if (port_up) {
		err = mlx4_en_start_port(dev);
		if (err)
			en_err(priv, "Failed starting port\n");
	}

out:
	kfree(data);
	mutex_unlock(&mdev->state_lock);
	return err;
}