Page MenuHomeFreeBSD

Add support for Amazon Elastic Network Adapter (ENA) NIC
ClosedPublic

Authored by mk_semihalf.com on Apr 19 2017, 11:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 10:26 AM
Unknown Object (File)
Mon, Apr 8, 4:18 PM
Unknown Object (File)
Mon, Apr 8, 2:12 PM
Unknown Object (File)
Mon, Apr 8, 8:34 AM
Unknown Object (File)
Tue, Apr 2, 7:37 PM
Unknown Object (File)
Mar 6 2024, 2:03 AM
Unknown Object (File)
Mar 6 2024, 2:03 AM
Unknown Object (File)
Feb 23 2024, 6:46 AM

Details

Summary

ENA is a networking interface designed to make good use of modern CPU
features and system architectures.

The ENA device exposes a lightweight management interface with a
minimal set of memory mapped registers and extendable command set
through an Admin Queue.

The driver supports a range of ENA devices, is link-speed independent
(i.e., the same driver is used for 10GbE, 25GbE, 40GbE, etc.), and has
a negotiated and extendable feature set.

Some ENA devices support SR-IOV. This driver is used for both the
SR-IOV Physical Function (PF) and Virtual Function (VF) devices.

ENA devices enable high speed and low overhead network traffic
processing by providing multiple Tx/Rx queue pairs (the maximum number
is advertised by the device via the Admin Queue), a dedicated MSI-X
interrupt vector per Tx/Rx queue pair, and CPU cacheline optimized
data placement.

The ENA driver supports industry standard TCP/IP offload features such
as checksum offload and TCP transmit segmentation offload (TSO).
Receive-side scaling (RSS) is supported for multi-core scaling.

The ENA driver and its corresponding devices implement health
monitoring mechanisms such as watchdog, enabling the device and driver
to recover in a manner transparent to the application, as well as
debug logs.

Some of the ENA devices support a working mode called Low-latency
Queue (LLQ), which saves several more microseconds. This feature will
be implemented for driver in future releases.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

A few cursory comments from a brief look.

  • This will need a man page
  • Should be hooked up in sys/conf/files (or files.amd64) so that it can be compiled into the kernel as well.
sys/dev/ena/ena.h
8–20

Could you check if it's acceptable to Amazon to number these as is conventionally done with BSD licenses, so that it fits a template already included in automated licence search tools? e.g.

* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software
*    without specific prior written permission.

It would be convenient also if they are willing to omit clause 3, in which case it becomes the "Simplified BSD license" or "FreeBSD license".

76–78

Can you rephrase this comment, it's somewhat difficult to understand. As I understand it a smaller buffer would just require too many buffers per packet with a higher MTU. I don't follow the "mtu will be changed" part.

sys/dev/ena/ena_com/ena_admin_defs.h
38–50 ↗(On Diff #27547)

Double spacing seems a bit odd. I guess it's because other enums or structs have per-entry comments?

sys/modules/ena/Makefile
41

Forcing -O2 seems odd here. Is there a reason you can't use regular build infrastructure to have -O2 set when desired by the user?

A few comments on the user-facing sysctl description strings

sys/dev/ena/ena_sysctl.c
93

Maybe "watchdog expiry count" "expire" as a noun sounds a bit odd, and there's a straightforward way to rephrase. Perhaps same below, "interface up count", "interface down count" ?

This is a bit subjective, for example "wakeups" below does not seem objectionable to me. Maybe it's just that "wakeups" has already been used extensively.

123

"buf" is more conventional short form if it's for buffer, but it probably doesn't need to be shortened at all.
Perhaps:
"TX buffer preparation failures" ?
"TX buffer preparation fail count" ?

129

"DMA mapping failures"?

133

It looks like this happens when there are too many descriptors? It's better to provide a specific reason than just "wrong".
Maybe something like "Excessive descriptor failures" or "Excessive descriptor packet discards"?

139

"TX polling" sounds like an enable knob. If it's a polling count, "TX poll count".

148

"Bad request id count"?

162

received

165

received

183

"Bad descriptor count"?

186

"Small copy packet count"?

203

If other descriptions are spelled out in full ought to do so here: "Receive packet drops"

Further to my comment above, I notice an earlier version of the driver posted to LKML has a dual GPL / 2-clause BSD license (https://lkml.org/lkml/2016/3/15/196) so I'm hopeful the standard 2-clause FreeBSD license can be used here.

sys/dev/ena/ena.h
36

Looks like a whitespace typo?

50

These are __STRING and __XSTRING, defined in <sys/cdefs.h>

105

Is _TRESHOLD a typo for _THRESHOLD?

I think this needs a change to sys/modules/Makefile as well in order to connect it to the build?

sys/dev/ena/ena.h
8–20

We are still discussing this and need response from legal team. We will upload it with next patchset (3rd).

36

Ok

50

Ok

76–78

This value is no longer used. We decided to remove it.

105

Ok

sys/dev/ena/ena_com/ena_admin_defs.h
38–50 ↗(On Diff #27547)

ena_com is HAL delivered to us by Amazon. We decided to move it to sys/contrib/ena-com

sys/dev/ena/ena_sysctl.c
93

Ok

123

Ok

129

Ok

133

Ok

139

Ok

148

Ok

162

Ok

165

Ok

183

Ok

186

Ok

203

Ok

sys/modules/ena/Makefile
41

Ok, all unnecessary flags will be deleted

mk_semihalf.com edited the summary of this revision. (Show Details)

Add new patchset. Manual and legal issues will be added in patchset 3.

Changelog patchset1 <-> patchset2:

* Move ena_com (HAL) to sys/contrib/ena-com
  https://svnweb.freebsd.org/changeset/base/317516
  https://svnweb.freebsd.org/changeset/base/317518

* Update include path when including ena-com in driver

* Update Makefile PATH for ena_com and use SRCTOP instead of CURDIR

* Add ENA entries for sys/conf/files

* Remove CFLAGS from Makefile

* Fix panic when booting kernel with ENA module because driver was using
  timers when they are not yet available. To fix this RSS initialization
  was deferred.

* Add rss_support mode to handle failure of deferred RSS initialization.

* Fix compilation error if driver is compiled with flag -DENA_TRACE and
  -DENA_INFO. ena_trace macro was called with extra argument.

* Fix descriptions for sysctls

* Remove ENA_DEFAULT_MIN_RX_BUFF_ALLOC_SIZE which was no longer used

* Minor style fixes (header guardian typo)

* Use __XSTRING instead of stringify macro

* Fix typo in DB_THRESHOLD variable

* Fix memory leaks on detach:
  - release RSS resources
  - destroy mmio_reg_read_request
  • Add manual entry for the driver
  • Change license to BSD 2-clause
  • Add missing changes that were not uploaded with the driver
    • allocate part of software queues resources during interface attachment
    • there were missing error paths and drbr flush
This revision was automatically updated to reflect the committed changes.
wblock added inline comments.
head/share/man/man4/ena.4
105 ↗(On Diff #28673)

Please install textproc/igor and run igor -R ena.4 | less -RS on this file to find this and other misspellings and problems.

igor -Ry ena.4 | less -RS will also show style suggestions.

Please tell me which man page was used as a template for this.

108 ↗(On Diff #28673)

Split the sentence instead of splicing with a semicolon.

112 ↗(On Diff #28673)

s/low/old/

115 ↗(On Diff #28673)

s/transcation/transaction/
Please start new sentences on new lines.

119 ↗(On Diff #28673)

Split the sentence instead of splicing with a semicolon.

178 ↗(On Diff #28673)

Split the sentence instead of splicing with a semicolon. Also, add articles and use active voice:

Error occurred during initialization of one of RSS resources.
The device will work with reduced performance because all RX packets will be
235 ↗(On Diff #28673)

Use a separate sentence rather than splicing with a semicolon:

 IOCTL request for the device to work in promiscuous/allmulti mode.
See
243 ↗(On Diff #28673)

s/adapter/adapter,/

244 ↗(On Diff #28673)
please email specific information related to the issue to
head/share/man/man4/ena.4
105 ↗(On Diff #28673)

Thank you for your suggestions. We will upload updated manual together with bunch of patches that will be probably uploaded within few weeks.
I will add you as a reviewer for the upcoming manual update.

I was using ixgbe.4 and mlx.4 manuals as a template.