Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/ixgbe Fix a bug that if_link_state_change(ifp, L...
details: https://anonhg.NetBSD.org/src/rev/6afb7ac64668
branches: trunk
changeset: 449089:6afb7ac64668
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Fri Feb 22 06:49:15 2019 +0000
description:
Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
diffstat:
sys/dev/pci/ixgbe/ix_txrx.c | 6 +++---
sys/dev/pci/ixgbe/ixgbe.c | 21 +++++++++++++--------
sys/dev/pci/ixgbe/ixgbe.h | 4 ++--
sys/dev/pci/ixgbe/ixv.c | 19 ++++++++++++-------
4 files changed, 30 insertions(+), 20 deletions(-)
diffs (163 lines):
diff -r 3c84e6e6b748 -r 6afb7ac64668 sys/dev/pci/ixgbe/ix_txrx.c
--- a/sys/dev/pci/ixgbe/ix_txrx.c Thu Feb 21 21:54:09 2019 +0000
+++ b/sys/dev/pci/ixgbe/ix_txrx.c Fri Feb 22 06:49:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.51 2018/12/20 09:47:15 knakahara Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.52 2019/02/22 06:49:15 msaitoh Exp $ */
/******************************************************************************
@@ -136,7 +136,7 @@
IXGBE_TX_LOCK_ASSERT(txr);
- if (!adapter->link_active) {
+ if (adapter->link_active != LINK_STATE_UP) {
/*
* discard all packets buffered in IFQ to avoid
* sending old packets at next link up timing.
@@ -282,7 +282,7 @@
struct mbuf *next;
int enqueued = 0, err = 0;
- if (!txr->adapter->link_active) {
+ if (txr->adapter->link_active != LINK_STATE_UP) {
/*
* discard all packets buffered in txr_interq to avoid
* sending old packets at next link up timing.
diff -r 3c84e6e6b748 -r 6afb7ac64668 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Thu Feb 21 21:54:09 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Fri Feb 22 06:49:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.173 2019/01/23 09:47:52 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.174 2019/02/22 06:49:15 msaitoh Exp $ */
/******************************************************************************
@@ -1628,7 +1628,7 @@
stats->mpctotal.ev_count += total_missed_rx;
/* Document says M[LR]FC are valid when link is up and 10Gbps */
- if ((adapter->link_active == TRUE)
+ if ((adapter->link_active == LINK_STATE_UP)
&& (adapter->link_speed == IXGBE_LINK_SPEED_10GB_FULL)) {
stats->mlfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MLFC);
stats->mrfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MRFC);
@@ -2751,7 +2751,7 @@
ifmr->ifm_status = IFM_AVALID;
ifmr->ifm_active = IFM_ETHER;
- if (!adapter->link_active) {
+ if (adapter->link_active != LINK_STATE_UP) {
ifmr->ifm_active |= IFM_NONE;
IXGBE_CORE_UNLOCK(adapter);
return;
@@ -4759,7 +4759,7 @@
KASSERT(mutex_owned(&adapter->core_mtx));
if (adapter->link_up) {
- if (adapter->link_active == FALSE) {
+ if (adapter->link_active != LINK_STATE_UP) {
/*
* To eliminate influence of the previous state
* in the same way as ixgbe_init_locked().
@@ -4808,7 +4808,7 @@
device_printf(dev, "Link is up %s %s \n",
bpsmsg, "Full Duplex");
}
- adapter->link_active = TRUE;
+ adapter->link_active = LINK_STATE_UP;
/* Update any Flow Control changes */
ixgbe_fc_enable(&adapter->hw);
/* Update DMA coalescing config */
@@ -4818,12 +4818,17 @@
if (adapter->feat_en & IXGBE_FEATURE_SRIOV)
ixgbe_ping_all_vfs(adapter);
}
- } else { /* Link down */
- if (adapter->link_active == TRUE) {
+ } else {
+ /*
+ * Do it when link active changes to DOWN. i.e.
+ * a) LINK_STATE_UNKNOWN -> LINK_STATE_DOWN
+ * b) LINK_STATE_UP -> LINK_STATE_DOWN
+ */
+ if (adapter->link_active != LINK_STATE_DOWN) {
if (bootverbose)
device_printf(dev, "Link is Down\n");
if_link_state_change(ifp, LINK_STATE_DOWN);
- adapter->link_active = FALSE;
+ adapter->link_active = LINK_STATE_DOWN;
if (adapter->feat_en & IXGBE_FEATURE_SRIOV)
ixgbe_ping_all_vfs(adapter);
ixgbe_drain_all(adapter);
diff -r 3c84e6e6b748 -r 6afb7ac64668 sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Thu Feb 21 21:54:09 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Fri Feb 22 06:49:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.53 2018/12/06 13:25:02 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.54 2019/02/22 06:49:15 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -492,7 +492,7 @@
/* Info about the interface */
int advertise; /* link speeds */
bool enable_aim; /* adaptive interrupt moderation */
- bool link_active;
+ int link_active; /* Use LINK_STATE_* value */
u16 max_frame_size;
u16 num_segs;
u32 link_speed;
diff -r 3c84e6e6b748 -r 6afb7ac64668 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c Thu Feb 21 21:54:09 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c Fri Feb 22 06:49:15 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.108 2019/01/23 06:56:19 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.109 2019/02/22 06:49:15 msaitoh Exp $*/
/******************************************************************************
@@ -1027,7 +1027,7 @@
ifmr->ifm_status = IFM_AVALID;
ifmr->ifm_active = IFM_ETHER;
- if (!adapter->link_active) {
+ if (adapter->link_active != LINK_STATE_UP) {
ifmr->ifm_active |= IFM_NONE;
IXGBE_CORE_UNLOCK(adapter);
return;
@@ -1302,7 +1302,7 @@
KASSERT(mutex_owned(&adapter->core_mtx));
if (adapter->link_up) {
- if (adapter->link_active == FALSE) {
+ if (adapter->link_active != LINK_STATE_UP) {
if (bootverbose) {
const char *bpsmsg;
@@ -1332,15 +1332,20 @@
device_printf(dev, "Link is up %s %s \n",
bpsmsg, "Full Duplex");
}
- adapter->link_active = TRUE;
+ adapter->link_active = LINK_STATE_UP;
if_link_state_change(ifp, LINK_STATE_UP);
}
- } else { /* Link down */
- if (adapter->link_active == TRUE) {
+ } else {
+ /*
+ * Do it when link active changes to DOWN. i.e.
+ * a) LINK_STATE_UNKNOWN -> LINK_STATE_DOWN
+ * b) LINK_STATE_UP -> LINK_STATE_DOWN
+ */
+ if (adapter->link_active != LINK_STATE_DOWN) {
if (bootverbose)
device_printf(dev, "Link is Down\n");
if_link_state_change(ifp, LINK_STATE_DOWN);
- adapter->link_active = FALSE;
+ adapter->link_active = LINK_STATE_DOWN;
}
}
} /* ixv_update_link_status */
Home |
Main Index |
Thread Index |
Old Index