Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164358623
D58473.id182750.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58473.id182750.diff
View Options
diff --git a/sys/dev/aq/aq_device.h b/sys/dev/aq/aq_device.h
--- a/sys/dev/aq/aq_device.h
+++ b/sys/dev/aq/aq_device.h
@@ -121,6 +121,7 @@
uint32_t tx_rings_count;
uint32_t rx_rings_count;
bool linkup;
+ uint32_t link_speed; /* Mbit/s last announced to the stack */
uint16_t phy_fault_last; /* last fault code reported */
enum aq_thermal_state {
AQ_THERMAL_NORMAL = 0, /* no thermal shutdown pending */
diff --git a/sys/dev/aq/aq_irq.c b/sys/dev/aq/aq_irq.c
--- a/sys/dev/aq/aq_irq.c
+++ b/sys/dev/aq/aq_irq.c
@@ -223,20 +223,34 @@
struct aq_dev *aq_dev = iflib_get_softc(ctx);
struct aq_hw *hw = &aq_dev->hw;
uint32_t link_speed;
+ bool running;
struct aq_hw_fc_info fc_neg;
aq_hw_get_link_state(hw, &link_speed, &fc_neg);
- /* An interface whose initialization did not complete has no link. */
- if (aq_dev->init_failed)
+ /*
+ * iflib keeps running this task while IFF_DRV_OACTIVE is set, which it
+ * is once the interface is stopped; a stopped interface has no link,
+ * and neither has one whose initialization did not complete.
+ */
+ running = (if_getdrvflags(iflib_get_ifp(ctx)) & IFF_DRV_RUNNING) != 0;
+ if (!running || aq_dev->init_failed)
link_speed = 0;
- if (link_speed && !aq_dev->linkup) { /* link was DOWN */
- device_printf(aq_dev->dev, "link UP: speed=%d\n", link_speed);
+ /* A retrain can change the speed without ever dropping the link. */
+ if (link_speed != 0U &&
+ (!aq_dev->linkup || link_speed != aq_dev->link_speed)) {
+ if (!aq_dev->linkup) {
+ device_printf(aq_dev->dev, "link UP: speed=%d\n",
+ link_speed);
+ aq_dev->phy_fault_last = 0;
+ } else
+ device_printf(aq_dev->dev, "link speed=%d\n",
+ link_speed);
aq_dev->linkup = 1;
- aq_dev->phy_fault_last = 0;
+ aq_dev->link_speed = link_speed;
/* turn on/off RX Pause in RPB */
rpb_rx_xoff_en_per_tc_set(hw, fc_neg.fc_rx, 0);
@@ -251,6 +265,7 @@
device_printf(aq_dev->dev, "link DOWN\n");
aq_dev->linkup = 0;
+ aq_dev->link_speed = 0;
/* turn off RX Pause in RPB */
rpb_rx_xoff_en_per_tc_set(hw, 0, 0);
@@ -259,6 +274,10 @@
aq_mediastatus_update(aq_dev, link_speed, &fc_neg);
}
+ /* A stopped interface must not be re-initialized behind the operator. */
+ if (!running)
+ return;
+
/*
* Hardware is not initialized: retry a bounded number of times.
* _task_fn_admin() latches IFC_DO_RESET before calling this and acts
diff --git a/sys/dev/aq/aq_main.c b/sys/dev/aq/aq_main.c
--- a/sys/dev/aq/aq_main.c
+++ b/sys/dev/aq/aq_main.c
@@ -559,6 +559,8 @@
aq_if_stop(ctx);
aq_hw_deinit(&softc->hw);
+ /* iflib_device_suspend() does not stop the interface for us. */
+ if_setdrvflagbits(iflib_get_ifp(ctx), IFF_DRV_OACTIVE, IFF_DRV_RUNNING);
AQ_DBG_EXIT(0);
return (0);
@@ -755,6 +757,9 @@
softc->reset_pending = false;
hw->tx_rings_count = softc->tx_rings_count;
+ /* Pick up a locally administered address set since the last init. */
+ bcopy(if_getlladdr(iflib_get_ifp(ctx)), hw->mac_addr, ETHER_ADDR_LEN);
+
err = aq_hw_init(&softc->hw, softc->hw.mac_addr, softc->msix,
softc->scctx->isc_intr == IFLIB_INTR_MSIX);
if (err != 0) {
@@ -855,8 +860,15 @@
memset(&softc->last_stats, 0, sizeof(softc->last_stats));
/* Each bring-up gets its own budget of re-init attempts. */
softc->init_retries = 0;
- softc->linkup = false;
- aq_if_update_admin_status(ctx);
+ /*
+ * Do not poll the admin status here: the MAC has just been reset, and
+ * a stale link reading would re-announce the link as up.
+ */
+ if (softc->linkup) {
+ softc->linkup = false;
+ softc->link_speed = 0;
+ iflib_link_state_change(ctx, LINK_STATE_DOWN, 0);
+ }
AQ_DBG_EXIT(0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 1, 3:59 AM (1 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35807131
Default Alt Text
D58473.id182750.diff (3 KB)
Attached To
Mode
D58473: aq(4): interface lifecycle and link-state fixes
Attached
Detach File
Event Timeline
Log In to Comment