Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb50c0d6 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller
Browse files

sfc: Gather link state fields in struct efx_nic into new struct efx_link_state

parent e775fb93
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -543,6 +543,8 @@ void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue, int delay)
 */
static void efx_link_status_changed(struct efx_nic *efx)
{
	struct efx_link_state *link_state = &efx->link_state;

	/* SFC Bug 5356: A net_dev notifier is registered, so we must ensure
	 * that no events are triggered between unregister_netdev() and the
	 * driver unloading. A more general condition is that NETDEV_CHANGE
@@ -555,19 +557,19 @@ static void efx_link_status_changed(struct efx_nic *efx)
		return;
	}

	if (efx->link_up != netif_carrier_ok(efx->net_dev)) {
	if (link_state->up != netif_carrier_ok(efx->net_dev)) {
		efx->n_link_state_changes++;

		if (efx->link_up)
		if (link_state->up)
			netif_carrier_on(efx->net_dev);
		else
			netif_carrier_off(efx->net_dev);
	}

	/* Status message for kernel log */
	if (efx->link_up) {
	if (link_state->up) {
		EFX_INFO(efx, "link up at %uMbps %s-duplex (MTU %d)%s\n",
			 efx->link_speed, efx->link_fd ? "full" : "half",
			 link_state->speed, link_state->fd ? "full" : "half",
			 efx->net_dev->mtu,
			 (efx->promiscuous ? " [PROMISC]" : ""));
	} else {
@@ -758,7 +760,7 @@ static void efx_fini_port(struct efx_nic *efx)
	efx->phy_op->fini(efx);
	efx->port_initialized = false;

	efx->link_up = false;
	efx->link_state.up = false;
	efx_link_status_changed(efx);
}

+2 −2
Original line number Diff line number Diff line
@@ -539,7 +539,7 @@ static u32 efx_ethtool_get_link(struct net_device *net_dev)
{
	struct efx_nic *efx = netdev_priv(net_dev);

	return efx->link_up;
	return efx->link_state.up;
}

static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
@@ -699,7 +699,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
	if (EFX_WORKAROUND_11482(efx) && reset) {
		if (falcon_rev(efx) >= FALCON_REV_B0) {
			/* Recover by resetting the EM block */
			if (efx->link_up)
			if (efx->link_state.up)
				falcon_drain_tx_fifo(efx);
		} else {
			/* Schedule a reset to recover */
+11 −10
Original line number Diff line number Diff line
@@ -1905,7 +1905,7 @@ static int falcon_reset_macs(struct efx_nic *efx)

	/* If we've reset the EM block and the link is up, then
	 * we'll have to kick the XAUI link so the PHY can recover */
	if (efx->link_up && EFX_IS10G(efx) && EFX_WORKAROUND_5147(efx))
	if (efx->link_state.up && EFX_IS10G(efx) && EFX_WORKAROUND_5147(efx))
		falcon_reset_xaui(efx);

	return 0;
@@ -1939,17 +1939,18 @@ void falcon_deconfigure_mac_wrapper(struct efx_nic *efx)
	EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, 0);
	efx_writeo(efx, &reg, FR_AZ_RX_CFG);

	if (!efx->link_up)
	if (!efx->link_state.up)
		falcon_drain_tx_fifo(efx);
}

void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
{
	struct efx_link_state *link_state = &efx->link_state;
	efx_oword_t reg;
	int link_speed;
	bool tx_fc;

	switch (efx->link_speed) {
	switch (link_state->speed) {
	case 10000: link_speed = 3; break;
	case 1000:  link_speed = 2; break;
	case 100:   link_speed = 1; break;
@@ -1969,7 +1970,7 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
	 * discarded. */
	if (falcon_rev(efx) >= FALCON_REV_B0) {
		EFX_SET_OWORD_FIELD(reg, FRF_BB_TXFIFO_DRAIN_EN,
				    !efx->link_up);
				    !link_state->up);
	}

	efx_writeo(efx, &reg, FR_AB_MAC_CTRL);
@@ -1980,7 +1981,7 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
	/* Transmission of pause frames when RX crosses the threshold is
	 * covered by RX_XOFF_MAC_EN and XM_TX_CFG_REG:XM_FCNTL.
	 * Action on receipt of pause frames is controller by XM_DIS_FCNTL */
	tx_fc = !!(efx->link_fc & EFX_FC_TX);
	tx_fc = !!(efx->link_state.fc & EFX_FC_TX);
	efx_reado(efx, &reg, FR_AZ_RX_CFG);
	EFX_SET_OWORD_FIELD(reg, FRF_AZ_RX_XOFF_MAC_EN, tx_fc);

@@ -2175,11 +2176,11 @@ int falcon_switch_mac(struct efx_nic *efx)

	/* Internal loopbacks override the phy speed setting */
	if (efx->loopback_mode == LOOPBACK_GMAC) {
		efx->link_speed = 1000;
		efx->link_fd = true;
		efx->link_state.speed = 1000;
		efx->link_state.fd = true;
	} else if (LOOPBACK_INTERNAL(efx)) {
		efx->link_speed = 10000;
		efx->link_fd = true;
		efx->link_state.speed = 10000;
		efx->link_state.fd = true;
	}

	WARN_ON(!mutex_is_locked(&efx->mac_lock));
@@ -2752,7 +2753,7 @@ static int falcon_probe_nic_variant(struct efx_nic *efx)
	}

	/* Initial assumed speed */
	efx->link_speed = EFX_OWORD_FIELD(nic_stat, FRF_AB_STRAP_10G) ? 10000 : 1000;
	efx->link_state.speed = EFX_OWORD_FIELD(nic_stat, FRF_AB_STRAP_10G) ? 10000 : 1000;

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
	s32 alarms1, alarms2;

	/* If link is up then do not monitor temperature */
	if (EFX_WORKAROUND_7884(efx) && efx->link_up)
	if (EFX_WORKAROUND_7884(efx) && efx->link_state.up)
		return 0;

	alarms1 = i2c_smbus_read_byte_data(client, LM87_REG_ALARMS1);
+7 −6
Original line number Diff line number Diff line
@@ -24,16 +24,17 @@

static void falcon_reconfigure_gmac(struct efx_nic *efx)
{
	struct efx_link_state *link_state = &efx->link_state;
	bool loopback, tx_fc, rx_fc, bytemode;
	int if_mode;
	unsigned int max_frame_len;
	efx_oword_t reg;

	/* Configuration register 1 */
	tx_fc = (efx->link_fc & EFX_FC_TX) || !efx->link_fd;
	rx_fc = !!(efx->link_fc & EFX_FC_RX);
	tx_fc = (link_state->fc & EFX_FC_TX) || !link_state->fd;
	rx_fc = !!(link_state->fc & EFX_FC_RX);
	loopback = (efx->loopback_mode == LOOPBACK_GMAC);
	bytemode = (efx->link_speed == 1000);
	bytemode = (link_state->speed == 1000);

	EFX_POPULATE_OWORD_5(reg,
			     FRF_AB_GM_LOOP, loopback,
@@ -50,7 +51,7 @@ static void falcon_reconfigure_gmac(struct efx_nic *efx)
			     FRF_AB_GM_IF_MODE, if_mode,
			     FRF_AB_GM_PAD_CRC_EN, 1,
			     FRF_AB_GM_LEN_CHK, 1,
			     FRF_AB_GM_FD, efx->link_fd,
			     FRF_AB_GM_FD, link_state->fd,
			     FRF_AB_GM_PAMBL_LEN, 0x7/*datasheet recommended */);

	efx_writeo(efx, &reg, FR_AB_GM_CFG2);
@@ -101,8 +102,8 @@ static void falcon_reconfigure_gmac(struct efx_nic *efx)
	/* FIFO configuration register 5 */
	efx_reado(efx, &reg, FR_AB_GMF_CFG5);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_CFGBYTMODE, bytemode);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_CFGHDPLX, !efx->link_fd);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_HSTDRPLT64, !efx->link_fd);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_CFGHDPLX, !link_state->fd);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_HSTDRPLT64, !link_state->fd);
	EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_HSTFLTRFRMDC_PAUSE, 0);
	efx_writeo(efx, &reg, FR_AB_GMF_CFG5);
	udelay(10);
Loading