Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/if_ena.c
RevisionDateAuthorComments
 1.43  26-Feb-2025  andvar Fix typos in comments, mainly s/calcurate/calculate/.
 1.42  29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.41  20-Dec-2023  skrll Remove unnecssary #include
 1.40  05-Nov-2023  jdolecek ena(4): stop management first when detaching

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.39  05-Nov-2023  jdolecek ena(4): establish interrupt after setting up resources

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.38  05-Nov-2023  jdolecek ena(4): prevent AENQ handler from use-after-free

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.37  05-Nov-2023  jdolecek ena(4) is MP-ready, always use MPSAFE

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.36  05-Nov-2023  jdolecek ena(4): support RSS and delete FreeBSD-specified code

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.35  05-Nov-2023  jdolecek ena(4): replace malloc(9) to kmem(9)

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.34  21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.33  23-May-2022  rin branches: 1.33.4;
Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.32  23-Sep-2021  jmcneill ena: fix packet reordering issue

A reorder occures when
- memory allocation fails in bus_dmamap_load_mbuf() or
- submission queue is full

This patch makes ena(4) to
- allocate memory in advance (BUS_DMA_ALLOCNOW flag in bus_dmamap_create())
- check if the queue is vacant before pcq_get()

Patch from KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.31  16-Sep-2021  andvar fix typos in word "successfully", mainly s/succesfully/successfully/.
 1.30  24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.29  19-Jul-2021  jmcneill Various ena(4) bug fixes, from KUSABA Takeshi <t-kusaba@iij.ad.jp>:

[PATCH 01/32] include device_xname for evcnt group.
[PATCH 02/32] fix improper NULL check.
[PATCH 03/32] add tx drop counter
[PATCH 04/32] remove unimplemented m_getjcl
[PATCH 05/32] make ENA_MEM_{ALLOC,FREE}_COHERENT symmetric.
[PATCH 06/32] disestablish the correct interrupt.
[PATCH 07/32] fix null check target.
[PATCH 08/32] use if_initialize() and if_register() instead of
[PATCH 09/32] free all pci-related resource.
[PATCH 10/32] no need to call if_free(), but to call if_detach
[PATCH 11/32] add some locking assertions.
[PATCH 12/32] use bus_size_t for bus_dma instead of uint32_t.
[PATCH 13/32] no need to pass interlock, ena_timer_service does not
[PATCH 14/32] enable ena(4) to down I/F
[PATCH 15/32] destroy I/O queues before disestablishing msix
[PATCH 16/32] count input/output packet stats.
[PATCH 17/32] fix missing #ifdef LRO, NetBSD does not support LRO
[PATCH 18/32] MP-ify TX, allocate mbuf queue to each TX ring.
[PATCH 19/32] down the interface first when to detach, to prevent
[PATCH 20/32] default link speed should be unknown.
[PATCH 21/32] protect ena_adapter members only by "global_mtx".
[PATCH 22/32] lower global_mtx interrupt level
[PATCH 23/32] reorder function declaration
[PATCH 24/32] add locking notes and some marking.
[PATCH 25/32] process RX in workqueue context, as same as FreeBSD
[PATCH 26/32] count rx_drops correctly.
[PATCH 27/32] no need to lock when attach/detach, down/up
[PATCH 28/32] fix memory leak.
[PATCH 29/32] add "stopping" flag to ena_ring.
[PATCH 30/32] make the flags atomic.
[PATCH 31/32] do not schedule timer when device is down.
[PATCH 32/32] no need to start timer if I/F is down.
 1.28  01-Jul-2021  jmcneill port-evbarm/56274: no network on ec2 arm64 9.99.85

Remove custom SIOCSIFFLAGS handling and rely on ether_ioctl to DTRT
 1.27  23-Jan-2021  jmcneill branches: 1.27.4;
kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.26  18-Jan-2021  skrll Trailing whitespace
 1.25  03-Aug-2020  jmcneill branches: 1.25.2;
port-arm/55532: kernel panic with ena on AWS a1.2xlarge

Do not mark callout and workqueues as mpsafe unless the NET_MPSAFE option
is present.
 1.24  03-Mar-2020  jdolecek replace #if condition for irq_slot with __diagused on the cleanup path

fixes PR kern/55044 by Uwe Toenjes
 1.23  24-Feb-2020  rin 0x%p --> %p for non-external codes.
 1.22  07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.21  04-Feb-2020  thorpej Use ifmedia_fini().
 1.20  01-Feb-2020  riastradh Use atomic_load/store_* in ena(4), not questionable membar_sync.
 1.19  02-Dec-2019  msaitoh branches: 1.19.2;
Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.18  10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.17  18-Oct-2019  msaitoh s/initalize/initialize/ in comment or printf message.
 1.16  01-Aug-2019  msaitoh If the memory space's BAR and the MSI-X table is on the same BAR,
reserve the space. Almost the same as nvme_pci.c and xhci_pci.c.
Tested by ryoon@.
 1.15  29-May-2019  msaitoh branches: 1.15.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.14  26-Apr-2019  msaitoh Remove duplicated inclusion of sys/bus.h.
 1.13  23-Jan-2019  ryoon Fix no options DEBUG nor DIAGNOSTIC build
 1.12  22-Dec-2018  roy remove needless parens, makes clang happy
 1.11  30-Nov-2018  jmcneill Get this driver into a functional state.
 1.10  30-Nov-2018  jmcneill workqueue and callout fixes
 1.9  28-Nov-2018  jmcneill Add calls to if_attach and if_deferred_start_init
 1.8  28-Nov-2018  jmcneill Our softc is the private data of self, not parent. Spotted by mlelstv@
 1.7  28-Nov-2018  jdolecek whitespace fix, NFC
 1.6  28-Nov-2018  bad Adapt ena_rx_checksum() to NetBSD.
It wasn't ported to the NetBSD conventions of indicating hardware checkum
status.

Compile tested only.
 1.5  26-Jun-2018  msaitoh branches: 1.5.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.4  16-Jun-2018  jdolecek make ena(4) compile, with best efford exercised to convert code to NetBSD
equivalents; where possible left the original code intact to make it
easier to compare against FreeBSD original

made non-working stubs for some functions which don't have direct
equivalent yet - this includes all of <sys/buf_ring.h>, m_getjcl(),
m_append, and m_collapse(); these need to be adressed

left XXX/TODO in if_enavar.h, colocated with the non-working stubs
 1.3  01-Jun-2018  maxv Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).
 1.2  19-May-2018  jdolecek branches: 1.2.2;
Intermediate changes to make it further into actually at least compile, not nearly yet
complete. Committed so that others can possibly pick it off, as discussed
on tech-userlevel@ with Martin
 1.1  19-May-2018  jdolecek branches: 1.1.1;
Initial revision
 1.1.1.1  19-May-2018  jdolecek Import source for FreeBSD Amazon Elastic Network Adapter (ENA) NIC driver
for reference. Needs a lot of work to port over.

Remapped filenames from FreeBSD to NetBSD structure:
sys/dev/ena/ena.c -> sys/dev/pci/if_ena.c
sys/dev/ena/ena.h -> sys/dev/pci/if_enavar.h

ena_sysctl.* not imported, if needed later will be merged into if_ena.c
 1.2.2.6  26-Jan-2019  pgoyette Sync with HEAD
 1.2.2.5  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.2.4  28-Jul-2018  pgoyette Sync with HEAD
 1.2.2.3  25-Jun-2018  pgoyette Sync with HEAD
 1.2.2.2  21-May-2018  pgoyette Sync with HEAD
 1.2.2.1  19-May-2018  pgoyette file if_ena.c was added on branch pgoyette-compat on 2018-05-21 04:36:06 +0000
 1.5.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.2.1  10-Jun-2019  christos Sync with HEAD
 1.15.2.4  23-Jan-2021  martin Pull up following revision(s) (requested by jmcneill in ticket #1186):

sys/dev/pci/if_ena.c: revision 1.27

PR kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi
 1.15.2.3  05-Aug-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #1038):

sys/dev/pci/if_ena.c: revision 1.25

PR port-arm/55532: kernel panic with ena on AWS a1.2xlarge

Do not mark callout and workqueues as mpsafe unless the NET_MPSAFE option
is present.
 1.15.2.2  08-Mar-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #759):

sys/dev/pci/if_ena.c: revision 1.24

replace #if condition for irq_slot with __diagused on the cleanup path

fixes PR kern/55044 by Uwe Toenjes
 1.15.2.1  09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #37):

doc/3RDPARTY: revision 1.1641
sys/dev/pci/if_ena.c: revision 1.16
sys/arch/amd64/conf/GENERIC: revision 1.532

If the memory space's BAR and the MSI-X table is on the same BAR,
reserve the space. Almost the same as nvme_pci.c and xhci_pci.c.
Tested by ryoon@.

Add ena(4).
 1.19.2.1  29-Feb-2020  ad Sync with head.
 1.25.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.27.4.1  01-Aug-2021  thorpej Sync with HEAD.
 1.33.4.1  26-Nov-2023  bouyer Pull up following revision(s) (requested by jdolecek in ticket #460):
sys/dev/pci/if_ena.c: revision 1.35
sys/dev/pci/if_ena.c: revision 1.36
sys/dev/pci/if_ena.c: revision 1.37
sys/dev/pci/if_ena.c: revision 1.38
sys/dev/pci/if_ena.c: revision 1.39
sys/external/bsd/ena-com/ena_plat.h: revision 1.10
sys/dev/pci/if_enavar.h: revision 1.9
sys/external/bsd/ena-com/ena_com.c: revision 1.2
sys/external/bsd/ena-com/ena_com.c: revision 1.3
sys/external/bsd/ena-com/ena_com.c: revision 1.4
sys/dev/pci/if_ena.c: revision 1.40
sys/external/bsd/ena-com/ena_com.h: revision 1.2
ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): support RSS and delete FreeBSD-specified code
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4) is MP-ready, always use MPSAFE
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): establish interrupt after setting up resources
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): stop management first when detaching
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>

RSS XML Feed