Bug 275260

Summary: "no media types" after re-enabling cxl
Product: Base System Reporter: Zhenlei Huang <zlei>
Component: kernAssignee: Navdeep Parhar <np>
Status: Closed FIXED    
Severity: Affects Some People CC: np
Priority: ---    
Version: 14.0-RELEASE   
Hardware: Any   
OS: Any   

Description Zhenlei Huang freebsd_committer freebsd_triage 2023-11-22 10:23:40 UTC
Spot this while working on https://reviews.freebsd.org/D42678 .

This is a two ports Chelsio T520-CR card, connected to switch via passive twinax cable .

Steps to repeat:
```
# devctl detach cxl1
# devctl attach cxl1
# ifconfig cxl1
cxl1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=6ec07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,HWSTATS,HWRXTSTMP,MEXTPG>
	ether 00:07:43:xx:xx:xx
ifconfig: cxl1: no media types?
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```

Expected media and status:
```
	media: Ethernet 10Gbase-Twinax <full-duplex,rxpause,txpause>
	status: no carrier
```

Also it can not be brought up to RUNNING state by assigning IP addresses.

```
# ifconfig cxl1 inet 192.168.100.1/24
# ifconfig cxl1
cxl1: flags=8803<UP,BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=6ec07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,HWSTATS,HWRXTSTMP,MEXTPG>
	ether 00:07:43:xx:xx:xx
	inet 192.168.100.1 netmask 0xffffff00 broadcast 192.168.100.255
ifconfig: cxl1: no media types?
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```
Comment 1 Navdeep Parhar freebsd_committer freebsd_triage 2023-11-22 17:04:47 UTC
I'm able to reproduce this.
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-01-03 19:26:32 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0201eb29dde9dccbf796f81fbf18f3b21798183d

commit 0201eb29dde9dccbf796f81fbf18f3b21798183d
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-01-02 21:20:45 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-01-03 19:21:46 +0000

    cxgbe(4): Fix virtual interface reattach.

    Replace the DOOMED flag with a transient DETACHING flag that is cleared
    when VI is detached.  This fixes VI reattach when only the VI and not
    the parent nexus is detached.  The old flag was never cleared and
    prevented subsequent synch op's related to the VI.

    PR:             275260
    Reviewed by:    jhb
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D43287
    Sponsored by:   Chelsio Communications

 sys/dev/cxgbe/adapter.h | 10 ++++++----
 sys/dev/cxgbe/t4_main.c | 33 +++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-01-11 05:34:13 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7d98a455a3ea91eadbd3c84c6cd85314f5e29529

commit 7d98a455a3ea91eadbd3c84c6cd85314f5e29529
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-01-02 21:20:45 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-01-11 05:22:31 +0000

    cxgbe(4): Fix virtual interface reattach.

    Replace the DOOMED flag with a transient DETACHING flag that is cleared
    when VI is detached.  This fixes VI reattach when only the VI and not
    the parent nexus is detached.  The old flag was never cleared and
    prevented subsequent synch op's related to the VI.

    PR:             275260
    Reviewed by:    jhb
    Differential Revision: https://reviews.freebsd.org/D43287
    Sponsored by:   Chelsio Communications

    (cherry picked from commit 0201eb29dde9dccbf796f81fbf18f3b21798183d)

 sys/dev/cxgbe/adapter.h | 10 ++++++----
 sys/dev/cxgbe/t4_main.c | 33 +++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-01-11 05:35:15 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3a507508e3657b4946ee401638a043f2f073da81

commit 3a507508e3657b4946ee401638a043f2f073da81
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-01-02 21:20:45 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-01-11 05:06:59 +0000

    cxgbe(4): Fix virtual interface reattach.

    Replace the DOOMED flag with a transient DETACHING flag that is cleared
    when VI is detached.  This fixes VI reattach when only the VI and not
    the parent nexus is detached.  The old flag was never cleared and
    prevented subsequent synch op's related to the VI.

    PR:             275260
    Reviewed by:    jhb
    Differential Revision: https://reviews.freebsd.org/D43287
    Sponsored by:   Chelsio Communications

    (cherry picked from commit 0201eb29dde9dccbf796f81fbf18f3b21798183d)

 sys/dev/cxgbe/adapter.h | 10 ++++++----
 sys/dev/cxgbe/t4_main.c | 33 +++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 18 deletions(-)