ix, ixv: Update link status with autonegotiated baudrate value

Use autonegotiated link speed value while updating link status
to iflib.

This patch is part of change made in NetBSD kernel
by Masanobu Saitoh, NetBSD maintainer.

Differential Revision:	https://reviews.freebsd.org/D19176
Approved by:	erj
This commit is contained in:
Piotr Pietruszewski 2023-07-11 18:14:26 +02:00 committed by Piotr Kubaj
parent 66f2f9ee08
commit a0302c9231
4 changed files with 38 additions and 2 deletions

View file

@ -3679,7 +3679,8 @@ ixgbe_if_update_admin_status(if_ctx_t ctx)
/* Update DMA coalescing config */
ixgbe_config_dmac(sc);
/* should actually be negotiated value */
iflib_link_state_change(ctx, LINK_STATE_UP, IF_Gbps(10));
iflib_link_state_change(ctx, LINK_STATE_UP,
ixgbe_link_speed_to_baudrate(adapter->link_speed));
if (sc->feat_en & IXGBE_FEATURE_SRIOV)
ixgbe_ping_all_vfs(sc);

View file

@ -937,7 +937,7 @@ ixv_if_update_admin_status(if_ctx_t ctx)
"Full Duplex");
sc->link_active = true;
iflib_link_state_change(ctx, LINK_STATE_UP,
IF_Gbps(10));
ixgbe_link_speed_to_baudrate(adapter->link_speed));
}
} else { /* Link down */
if (sc->link_active == true) {

View file

@ -530,6 +530,8 @@ ixv_check_ether_addr(u8 *addr)
return (status);
}
uint64_t ixgbe_link_speed_to_baudrate(ixgbe_link_speed speed);
/* Shared Prototypes */
int ixgbe_allocate_queues(struct ixgbe_softc *);

View file

@ -76,3 +76,36 @@ ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg, u32 offset, u32 val)
((struct ixgbe_softc *)hw->back)->osdep.mem_bus_space_handle,
reg + (offset << 2), val);
}
uint64_t
ixgbe_link_speed_to_baudrate(ixgbe_link_speed speed)
{
uint64_t baudrate;
switch (speed) {
case IXGBE_LINK_SPEED_10GB_FULL:
baudrate = IF_Gbps(10);
break;
case IXGBE_LINK_SPEED_5GB_FULL:
baudrate = IF_Gbps(5);
break;
case IXGBE_LINK_SPEED_2_5GB_FULL:
baudrate = IF_Mbps(2500);
break;
case IXGBE_LINK_SPEED_1GB_FULL:
baudrate = IF_Gbps(1);
break;
case IXGBE_LINK_SPEED_100_FULL:
baudrate = IF_Mbps(100);
break;
case IXGBE_LINK_SPEED_10_FULL:
baudrate = IF_Mbps(10);
break;
case IXGBE_LINK_SPEED_UNKNOWN:
default:
baudrate = 0;
break;
}
return baudrate;
}