Add packet-mode ESP offload for Airoha/EIP93
Subsystems (8)
cover Add packet-mode ESP offload for Airoha/EIP93
This series adds the missing plumbing for ESP offload engines that operate on whole ESP packets instead of only exposing AES/HMAC through the crypto API AEAD interface.
The normal ESP software path can already call into accelerated AEAD algorithms, but packet-mode engines such as EIP93 can also generate and consume ESP packet framing: padding, pad length, next header and ICV. That needs a slightly different XFRM offload contract so the netdev driver can hand the skb to a packet backend rather than trying to make hardware fit the software trailer layout.
Patch 1 extends the ESP offload infrastructure for packet engines while preserving the existing behavior for drivers that do not opt in. Patch 2 exposes an EIP93 ESP packet backend for encapsulation and decapsulation.
Patch 3 wires Airoha Ethernet GDM netdevs and DSA user ports to that backend through xfrmdev_ops. ESP GSO and ESP TX checksum offload remain disabled.
Runtime testing was done on a Gemtek W1700K2 running OpenWrt with the same changes applied on top of a 6.18.31-based kernel.
Test parameters:
- Static IPv4 transport-mode XFRM SAs between the AP and host.
- ESP transform: auth hmac(sha1), enc cbc(aes) with a 128-bit AES key.
- iperf3 TCP test, AP as client and host as server:
iperf3 -c <host_ip> -P 4 -t 10
- The host always used normal Linux XFRM software processing.
- With AP ESP offload disabled, the AP also used the Linux XFRM software path; in this setup, EIP93-backed AEAD crypto was still available to that path.
Network-relevant test setup:
- AP: Gemtek W1700K2, Airoha AN7581/EN7581, 4x Arm Cortex-A53 at 1.4 GHz, 2 GiB RAM, airoha_eth wan (GDM2) netdev, 10Gb/s full-duplex, MTU 9200, EIP93 crypto and IPsec packet engine present.
- Host: AMD Ryzen 9 9950X3D, 16 cores/32 threads, Open vSwitch, MTU 9978, backed by a ConnectX-6 Dx 10Gb/s full-duplex link.
AP to host iperf3 result:
AP offload Sender Receiver Retransmits on 918.2 Mbit/s 913.6 Mbit/s 0 off 782.4 Mbit/s 778.6 Mbit/s 3569
This is a 17.3% receiver-side throughput improvement for the AP TX ESP path in this setup, with retransmits eliminated in the offloaded run.
Jihong Min (3):
xfrm: extend ESP offload infrastructure for packet engines
crypto: inside-secure: add EIP93 ESP packet backend
net: airoha: add EIP93-backed ESP XFRM offload
MAINTAINERS | 1 + drivers/crypto/inside-secure/eip93/Kconfig | 10 + drivers/crypto/inside-secure/eip93/Makefile | 1 + .../crypto/inside-secure/eip93/eip93-ipsec.c | 1413 ++++++++++++++++ .../crypto/inside-secure/eip93/eip93-main.c | 69 +- .../crypto/inside-secure/eip93/eip93-main.h | 38 +- drivers/net/ethernet/airoha/Kconfig | 11 + drivers/net/ethernet/airoha/Makefile | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 51 +- drivers/net/ethernet/airoha/airoha_eth.h | 69 + drivers/net/ethernet/airoha/airoha_xfrm.c | 1474 +++++++++++++++++ include/crypto/eip93-ipsec.h | 132 ++ include/linux/netdevice.h | 3 + include/net/xfrm.h | 8 +- net/ipv4/esp4.c | 6 +- net/ipv4/esp4_offload.c | 29 +- net/ipv6/esp6.c | 6 +- net/ipv6/esp6_offload.c | 29 +- 18 files changed, 3324 insertions(+), 27 deletions(-) create mode 100644 drivers/crypto/inside-secure/eip93/eip93-ipsec.c create mode 100644 drivers/net/ethernet/airoha/airoha_xfrm.c create mode 100644 include/crypto/eip93-ipsec.h
Signature · 1 line
2.53.0
PATCH 1/3 xfrm: extend ESP offload infrastructure for packet engines
Some ESP offload engines operate on whole ESP packets rather than the generic software trailer layout. They can generate outbound ESP padding, next-header and ICV bytes in hardware, and inbound decapsulation can return an already-trimmed packet with the recovered next-header value.
Add a netdev offload callback for drivers to opt into hardware-generated ESP TX trailers, carry the reserved ESP TX tail length in xfrm_offload, and let ESP input skip software trailer removal when hardware has already done it.
This keeps the default ESP offload behavior unchanged for existing devices while providing the infrastructure needed by packet-mode ESP engines.
--- include/linux/netdevice.h | 3 +++ include/net/xfrm.h | 8 +++++++- net/ipv4/esp4.c | 6 +++++- net/ipv4/esp4_offload.c | 29 ++++++++++++++++++++++++++++- net/ipv6/esp6.c | 6 +++++- net/ipv6/esp6_offload.c | 29 ++++++++++++++++++++++++++++- 6 files changed, 76 insertions(+), 5 deletions(-)
include/linux/netdevice.h +3 -0
@@ -1043,6 +1043,9 @@ struct xfrmdev_ops { struct xfrm_state *x);bool (*xdo_dev_offload_ok) (struct sk_buff *skb,struct xfrm_state *x); +/* Return true when the device generates the ESP trailer/ICV itself. */ +bool (*xdo_dev_esp_tx_hw_trailer)(struct sk_buff *skb, +struct xfrm_state *x);void (*xdo_dev_state_advance_esn) (struct xfrm_state *x);void (*xdo_dev_state_update_stats) (struct xfrm_state *x);int (*xdo_dev_policy_add) (struct xfrm_policy *x,struct netlink_ext_ack *extack);
include/net/xfrm.h +7 -1
@@ -1141,7 +1141,7 @@ struct xfrm_offload {#define CRYPTO_FALLBACK 8#define XFRM_GSO_SEGMENT 16#define XFRM_GRO 32 -/* 64 is free */ +#define XFRM_ESP_NO_TRAILER 64#define XFRM_DEV_RESUME 128#define XFRM_XMIT 256
@@ -1158,6 +1158,12 @@ struct xfrm_offload {/* Used to keep whole l2 header for transport mode GRO */ __u16 orig_mac_len; +/* +* ESP packet engines can reserve tailroom in the generic ESP path and +* generate padding, next-header and ICV bytes during device TX. +*/ +__u16 esp_tx_tailen; +__u8 proto;__u8 inner_ipproto; };
net/ipv4/esp4.c +5 -1
@@ -720,7 +720,11 @@ int esp_input_done2(struct sk_buff *skb, int err)if (unlikely (err)) goto out; - err =esp_remove_trailer (skb); +/* Hardware ESP decapsulation can already remove pad/trailer/ICV. */ +if (xo && (xo->flags &XFRM_ESP_NO_TRAILER )) + err = xo->proto; +else + err =esp_remove_trailer (skb);if (unlikely (err <0 )) goto out;
net/ipv4/esp4_offload.c +28 -1
@@ -270,8 +270,10 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_struct xfrm_offload *xo;struct ip_esp_hdr *esph;struct crypto_aead *aead; +struct sk_buff *trailer;struct esp_info esp;bool hw_offload = true; +bool hw_trailer = false;__u32 seq;int encap_type =0 ;
@@ -281,6 +283,7 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_if (!xo)return -EINVAL ; + xo->esp_tx_tailen =0 ; if ((!(features & NETIF_F_HW_ESP) && !(skb->dev->gso_partial_features & NETIF_F_HW_ESP)) ||
@@ -303,13 +306,37 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_ esp.clen =ALIGN (skb->len +2 + esp.tfclen, blksize); esp.plen = esp.clen - skb->len - esp.tfclen; esp.tailen = esp.tfclen + esp.plen + alen; +if (esp.tailen >U16_MAX ) +return -EINVAL ; esp.esph =ip_esp_hdr (skb);if (x->encap) encap_type = x->encap->encap_type; -if (!hw_offload || !skb_is_gso (skb) || (hw_offload && encap_type ==UDP_ENCAP_ESPINUDP )) { +if (hw_offload && !skb_is_gso (skb) && !encap_type && x->xso.dev && + x->xso.dev->xfrmdev_ops && + x->xso.dev->xfrmdev_ops->xdo_dev_esp_tx_hw_trailer) + hw_trailer = + x->xso.dev->xfrmdev_ops->xdo_dev_esp_tx_hw_trailer (skb, x); + +if (hw_trailer) { +int esph_offset; + +/* +* The device packet engine will write ESP padding, next-header +* and ICV bytes. Keep skb->len unchanged here, but make sure the +* later DMA writer owns enough linear tailroom. +*/ + esph_offset = (unsigned char *)esp.esph -skb_transport_header (skb); + esp.nfrags =skb_cow_data (skb, esp.tailen, &trailer); +if (esp.nfrags <0 ) +return esp.nfrags; + esp.esph = (struct ip_esp_hdr *)(skb_transport_header (skb) + + esph_offset); + xo->esp_tx_tailen = esp.tailen; + }else if (!hw_offload || !skb_is_gso (skb) || + (hw_offload && encap_type ==UDP_ENCAP_ESPINUDP )) { esp.nfrags =esp_output_head (x, skb, &esp);if (esp.nfrags <0 )return esp.nfrags;
net/ipv6/esp6.c +5 -1
@@ -751,7 +751,11 @@ int esp6_input_done2(struct sk_buff *skb, int err)if (unlikely (err)) goto out; - err =esp_remove_trailer (skb); +/* Hardware ESP decapsulation can already remove pad/trailer/ICV. */ +if (xo && (xo->flags &XFRM_ESP_NO_TRAILER )) + err = xo->proto; +else + err =esp_remove_trailer (skb);if (unlikely (err <0 )) goto out;
net/ipv6/esp6_offload.c +28 -1
@@ -308,8 +308,10 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_featuresint blksize;struct xfrm_offload *xo;struct crypto_aead *aead; +struct sk_buff *trailer;struct esp_info esp;bool hw_offload = true; +bool hw_trailer = false;__u32 seq; esp.inplace = true;
@@ -318,6 +320,7 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_featuresif (!xo)return -EINVAL ; + xo->esp_tx_tailen =0 ;if (!(features &NETIF_F_HW_ESP ) || x->xso.dev != skb->dev) { xo->flags |=CRYPTO_FALLBACK ;
@@ -338,8 +341,32 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features esp.clen =ALIGN (skb->len +2 + esp.tfclen, blksize); esp.plen = esp.clen - skb->len - esp.tfclen; esp.tailen = esp.tfclen + esp.plen + alen; +if (esp.tailen >U16_MAX ) +return -EINVAL ; -if (!hw_offload || !skb_is_gso (skb)) { +if (hw_offload && !skb_is_gso (skb) && !x->encap && x->xso.dev && + x->xso.dev->xfrmdev_ops && + x->xso.dev->xfrmdev_ops->xdo_dev_esp_tx_hw_trailer) + hw_trailer = + x->xso.dev->xfrmdev_ops->xdo_dev_esp_tx_hw_trailer (skb, x); + +if (hw_trailer) { +int esph_offset; + +/* +* The device packet engine will write ESP padding, next-header +* and ICV bytes. Keep skb->len unchanged here, but make sure the +* later DMA writer owns enough linear tailroom. +*/ + esp.esph =ip_esp_hdr (skb); + esph_offset = (unsigned char *)esp.esph -skb_transport_header (skb); + esp.nfrags =skb_cow_data (skb, esp.tailen, &trailer); +if (esp.nfrags <0 ) +return esp.nfrags; + esp.esph = (struct ip_esp_hdr *)(skb_transport_header (skb) + + esph_offset); + xo->esp_tx_tailen = esp.tailen; + }else if (!hw_offload || !skb_is_gso (skb)) { esp.nfrags =esp6_output_head (x, skb, &esp);if (esp.nfrags <0 )return esp.nfrags;
Signature · 1 line
2.53.0
Re: [PATCH 1/3] xfrm: extend ESP offload infrastructure for packet engines
Quoted 4 lines · Jihong Min
Some ESP offload engines operate on whole ESP packets rather than the generic software trailer layout. They can generate outbound ESP padding, next-header and ICV bytes in hardware, and inbound decapsulation can return an already-trimmed packet with the recovered next-header value.
How does this differ from the existing IPsec packet‑offload support in the Linux kernel?
Thanks
Re: [PATCH 1/3] xfrm: extend ESP offload infrastructure for packet engines
Quoted 10 lines · Leon Romanovsky
Quoted 4 lines · Jihong Min
Some ESP offload engines operate on whole ESP packets rather than the generic software trailer layout. They can generate outbound ESP padding, next-header and ICV bytes in hardware, and inbound decapsulation can return an already-trimmed packet with the recovered next-header value.
How does this differ from the existing IPsec packet‑offload support in the Linux kernel?
Thanks
Hi Leon,
The short answer is that the series did not explain the relationship with the existing XFRM packet-offload model clearly enough.
Existing XFRM_DEV_OFFLOAD_PACKET already represents the high-level model where hardware handles ESP packet processing instead of only crypto transforms. What I was trying to handle in this series was a narrower
case: EIP93 is a look-aside crypto/IPsec engine, not the netdev itself, so the Airoha netdev had to attach that engine into its TX/RX path and let it generate or consume the ESP packet framing. The extra hooks in this series were meant for that look-aside integration, but looking back, the split between the existing packet-offload model and the new plumbing was not clean enough.
At this point, though, I think the right thing is to withdraw this EIP93/Airoha series.
The reason is related to the SOE work I mentioned in the other patch
thread. Many Airoha SoCs also have a higher-performance IP block called
SOE (Secure Offload Engine). I recently wrote and tested a driver for
that block, and I am currently carrying it here: [kernel: add bonding
LAG XFRM offload infrastructure and Airoha support](https://github.com/hurryman2212/OpenW1700k-test/commit/fbfe8f919f836bb62b3849f803865a4d9b8dc76f). With the EIP93 path I could get around 1 Gbps, while the SOE path can
reach about 5 Gbps in my current setup. Because of that, integrating
this EIP93 ESP packet path directly into airoha_eth is no longer the
most useful direction for Airoha Ethernet.
That said, SOE exists only on some Airoha SoCs. EIP93 can still be useful on other platforms as a look-aside ESP packet offloader, but I think that needs a cleaner infrastructure than this series had. The look-aside offloader should be able to live as a separate module, not be tied directly to one specific netdev driver, while still allowing compatible netdevs to attach it into the XFRM path. I think that needs a more general infrastructure extension, so I would rather revisit the EIP93 work later on top of that kind of model.
Sincerely,
Jihong Min
PATCH 2/3 crypto: inside-secure: add EIP93 ESP packet backend
In reply to Jihong MinExpose an EIP93 packet-mode IPsec backend for netdev drivers that need ESP encapsulation and decapsulation offload without advertising EIP93 itself as a netdev.
Add provider selection, capability reporting, SA lifecycle management, IPsec request completion, and provider fault notification around the existing EIP93 descriptor path.
--- MAINTAINERS | 1 + drivers/crypto/inside-secure/eip93/Kconfig | 10 + drivers/crypto/inside-secure/eip93/Makefile | 1 + .../crypto/inside-secure/eip93/eip93-ipsec.c | 1413 +++++++++++++++++ .../crypto/inside-secure/eip93/eip93-main.c | 69 +- .../crypto/inside-secure/eip93/eip93-main.h | 38 +- include/crypto/eip93-ipsec.h | 132 ++ 7 files changed, 1643 insertions(+), 21 deletions(-) create mode 100644 drivers/crypto/inside-secure/eip93/eip93-ipsec.c create mode 100644 include/crypto/eip93-ipsec.h
MAINTAINERS +1 -0
@@ -12743,6 +12743,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml F: drivers/crypto/inside-secure/eip93/ +F: include/crypto/eip93-ipsec.h INTEGRITY MEASUREMENT ARCHITECTURE (IMA) M: Mimi Zohar <[email protected]>
drivers/crypto/inside-secure/eip93/Kconfig +10 -0
@@ -18,3 +18,13 @@ config CRYPTO_DEV_EIP93 CTR crypto. Also provide DES and 3DES ECB and CBC. Also provide AEAD authenc(hmac(x), cipher(y)) for supported algo. + +config CRYPTO_DEV_EIP93_IPSEC + bool + depends on CRYPTO_DEV_EIP93 + depends on XFRM_OFFLOAD + default y + help + Select this if a netdev driver should be allowed to use EIP93 for + ESP packet encapsulation and decapsulation rather than only the + crypto transform.
drivers/crypto/inside-secure/eip93/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_CRYPTO_DEV_EIP93) += crypto-hw-eip93.o crypto-hw-eip93-y += eip93-main.o eip93-common.o crypto-hw-eip93-y += eip93-cipher.o eip93-aead.o crypto-hw-eip93-y += eip93-hash.o +crypto-hw-eip93-$(CONFIG_CRYPTO_DEV_EIP93_IPSEC) += eip93-ipsec.o
drivers/crypto/inside-secure/eip93/eip93-ipsec.c new file +1413 -0
1,413 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-main.c +50 -19
133 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-main.h +36 -2
@@ -13,6 +13,7 @@#include <crypto/internal/skcipher.h> #include <linux/bitfield.h> #include <linux/interrupt.h> +#include <linux/kconfig.h> #define EIP93_RING_BUSY_DELAY 500
@@ -92,6 +93,8 @@ EIP93_HASH_SHA224 | \ EIP93_HASH_SHA256)) +struct eip93_ipsec ; +/** * struct eip93_device - crypto engine device structure */
@@ -101,6 +104,7 @@ struct eip93_device {struct clk *clk;int irq;struct eip93_ring *ring; +struct eip93_ipsec *ipsec; };struct eip93_desc_ring {
@@ -124,8 +128,8 @@ struct eip93_ring {/* command/result rings */ struct eip93_desc_ring cdr;struct eip93_desc_ring rdr; -spinlock_t write_lock; -spinlock_t read_lock; +spinlock_t write_lock;/* command descriptor enqueue */ +spinlock_t read_lock;/* result descriptor dequeue */ /* aync idr */ spinlock_t idr_lock;struct idr crypto_async_idr;
@@ -148,4 +152,34 @@ struct eip93_alg_template { } alg; }; +struct eip93_ipsec_request ; + +#if IS_ENABLED (CONFIG_CRYPTO_DEV_EIP93_IPSEC ) +int eip93_ipsec_register (struct eip93_device *eip93); +void eip93_ipsec_unregister (struct eip93_device *eip93); +void eip93_ipsec_handle_result (struct eip93_ipsec_request *req,int err, +u32 pe_ctrl_stat,u32 pe_length); +void eip93_ipsec_report_irq (struct eip93_device *eip93,u32 irq_status); +#else +static inline int eip93_ipsec_register (struct eip93_device *eip93) +{ +return 0 ; +} + +static inline void eip93_ipsec_unregister (struct eip93_device *eip93) +{ +} + +static inline void eip93_ipsec_handle_result (struct eip93_ipsec_request *req, +int err,u32 pe_ctrl_stat, +u32 pe_length) +{ +} + +static inline void eip93_ipsec_report_irq (struct eip93_device *eip93, +u32 irq_status) +{ +} +#endif +#endif /* _EIP93_MAIN_H_ */
include/crypto/eip93-ipsec.h new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.53.0
Simon Horman
reviewerRe: [PATCH 2/3] crypto: inside-secure: add EIP93 ESP packet backend
Quoted 10 lines · Jihong Min
Expose an EIP93 packet-mode IPsec backend for netdev drivers that need ESP encapsulation and decapsulation offload without advertising EIP93 itself as a netdev.
Add provider selection, capability reporting, SA lifecycle management, IPsec request completion, and provider fault notification around the existing EIP93 descriptor path.
Assisted-by Codex:gpt-5.5Signed-off-by Jihong Min <[email protected]>
...
Quoted 1 line
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +0
-0
...
Quoted 17 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +17
-0+static void eip93_ipsec_abort_requests (struct eip93_ipsec *ipsec,int err) +{ +struct eip93_ipsec_sa *sa; + +while (true) { +bool found = false; + +spin_lock_bh (&ipsec->lock); +list_for_each_entry (sa, &ipsec->sa_list, node) { +spin_lock (&sa->lock); +if (sa->aborting) { +spin_unlock (&sa->lock); +continue ; + } + + sa->aborting = true; + found =refcount_inc_not_zero (&sa->refcnt);
drivers/crypto/inside-secure/eip93/eip93-ipsec.c line 953
Quoted 10 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +10
-0+spin_unlock (&sa->lock); +if (found) +break ; + } +spin_unlock_bh (&ipsec->lock); +if (!found) +return ; + +eip93_ipsec_abort_sa (sa, err); +eip93_ipsec_sa_put (sa);
sa is the iterator for the list_for_each_entry loop. However, here it is used outside of that context.
"If list_for_each_entry, etc complete a traversal of the list, the iterator variable ends up pointing to an address at an offset from the list head, and not a meaningful structure. Thus this value should not be used after the end of the iterator.
https://www.spinics.net/lists/linux-kernel-janitors/msg11994.html
Flagged by Coccinelle.
Quoted 2 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +2
-0+ } +}
...
Re: [PATCH 2/3] crypto: inside-secure: add EIP93 ESP packet backend
Quoted 49 lines · Simon Horman
Quoted 10 lines · Jihong Min
Expose an EIP93 packet-mode IPsec backend for netdev drivers that need ESP encapsulation and decapsulation offload without advertising EIP93 itself as a netdev.
Add provider selection, capability reporting, SA lifecycle management, IPsec request completion, and provider fault notification around the existing EIP93 descriptor path.
Assisted-by Codex:gpt-5.5Signed-off-by Jihong Min <[email protected]>...
Quoted 1 line
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +0
-0...
Quoted 17 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +17
-0+static void eip93_ipsec_abort_requests (struct eip93_ipsec *ipsec,int err) +{ +struct eip93_ipsec_sa *sa; + +while (true) { +bool found = false; + +spin_lock_bh (&ipsec->lock); +list_for_each_entry (sa, &ipsec->sa_list, node) { +spin_lock (&sa->lock); +if (sa->aborting) { +spin_unlock (&sa->lock); +continue ; + } + + sa->aborting = true; + found =refcount_inc_not_zero (&sa->refcnt);drivers/crypto/inside-secure/eip93/eip93-ipsec.c line 953
Quoted 10 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +10
-0+spin_unlock (&sa->lock); +if (found) +break ; + } +spin_unlock_bh (&ipsec->lock); +if (!found) +return ; + +eip93_ipsec_abort_sa (sa, err); +eip93_ipsec_sa_put (sa);sa is the iterator for the
list_for_each_entryloop. However, here it is used outside of that context.
Quoted 9 lines
"If
list_for_each_entry, etc complete a traversal of the list, the iterator variable ends up pointing to an address at an offset from the list head, and not a meaningful structure. Thus this value should not be used after the end of the iterator.https://www.spinics.net/lists/linux-kernel-janitors/msg11994.html
Flagged by Coccinelle.
Hi Simon,
Thanks for the feedback, and sorry for noticing this mail so late.
Your point is correct. The list_for_each_entry() iterator should not be used outside the loop like that. If I continued with this series, I would fix it by keeping a separate selected SA pointer before dropping the lock.
At this point, though, I think the right thing is to withdraw this EIP93/Airoha series.
The reason is that many Airoha SoCs also have a higher-performance IP
block called SOE (Secure Offload Engine). I recently wrote and tested a
driver for that block, and I am currently carrying it here: [kernel: add
bonding LAG XFRM offload infrastructure and Airoha support](https://github.com/hurryman2212/OpenW1700k-test/commit/fbfe8f919f836bb62b3849f803865a4d9b8dc76f). With the EIP93 path I could get around 1 Gbps, while the SOE path can
reach about 5 Gbps in my current setup. Because of that, integrating
this EIP93 ESP packet path directly into airoha_eth is no longer the
most useful direction for Airoha Ethernet.
That said, SOE exists only on some Airoha SoCs. EIP93 can still be useful on other platforms as a look-aside ESP packet offloader, but I think that needs a cleaner infrastructure than this series had. The look-aside offloader should be able to live as a separate module, not be tied directly to one specific netdev driver, while still allowing compatible netdevs to attach it into the XFRM path. I think that needs a more general infrastructure extension, so I would rather revisit the EIP93 work later on top of that kind of model.
Sincerely,
Jihong Min
Quoted 4 lines
Quoted 2 lines
drivers/crypto/inside-secure/eip93/eip93-ipsec.c +2
-0+ } +}...
PATCH 3/3 net: airoha: add EIP93-backed ESP XFRM offload
In reply to Jihong MinWire Airoha GDM netdevs and DSA user ports to the EIP93 ESP packet backend through xfrmdev_ops.
Gate netdev feature advertisement on backend capability, add TX and RX submit paths, preserve opt-out builds, and handle SA lifetime across feature changes, DSA detach, and EIP93 provider loss.
--- drivers/net/ethernet/airoha/Kconfig | 11 + drivers/net/ethernet/airoha/Makefile | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 51 +- drivers/net/ethernet/airoha/airoha_eth.h | 69 + drivers/net/ethernet/airoha/airoha_xfrm.c | 1474 +++++++++++++++++++++ 5 files changed, 1605 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/airoha/airoha_xfrm.c
drivers/net/ethernet/airoha/Kconfig +11 -0
@@ -31,4 +31,15 @@ config NET_AIROHA_FLOW_STATS help Enable Aiorha flowtable statistic counters. +config NET_AIROHA_XFRM + bool "Airoha ESP XFRM offload support" + depends on NET_AIROHA + default y + help + Enable ESP XFRM offload support for Airoha Ethernet netdevs. + + If unsure, say Y. Say N to opt out of advertising ESP hardware + offload from the Airoha Ethernet driver even when the EIP93 IPsec + packet backend and XFRM offload support are available. + endif #NET_VENDOR_AIROHA
drivers/net/ethernet/airoha/Makefile +1 -0
@@ -5,5 +5,6 @@ obj-$(CONFIG_NET_AIROHA) += airoha-eth.o airoha-eth-y := airoha_eth.o airoha_ppe.o +airoha-eth-$(CONFIG_NET_AIROHA_XFRM) += airoha_xfrm.o airoha-eth-$(CONFIG_DEBUG_FS) += airoha_ppe_debugfs.o obj-$(CONFIG_NET_AIROHA_NPU) += airoha_npu.o
drivers/net/ethernet/airoha/airoha_eth.c +50 -1
93 lines not on this page · raw message
drivers/net/ethernet/airoha/airoha_eth.h +69 -0
91 lines not on this page · raw message
drivers/net/ethernet/airoha/airoha_xfrm.c new file +1474 -0
1,474 lines not on this page · raw message
Signature · 1 line
2.53.0
Quoted 69 lines · Jihong Min
This series adds the missing plumbing for ESP offload engines that operate on whole ESP packets instead of only exposing AES/HMAC through the crypto API AEAD interface.
The normal ESP software path can already call into accelerated AEAD algorithms, but packet-mode engines such as EIP93 can also generate and consume ESP packet framing: padding, pad length, next header and ICV. That needs a slightly different XFRM offload contract so the netdev driver can hand the skb to a packet backend rather than trying to make hardware fit the software trailer layout.
Patch 1 extends the ESP offload infrastructure for packet engines while preserving the existing behavior for drivers that do not opt in. Patch 2 exposes an EIP93 ESP packet backend for encapsulation and decapsulation.
Patch 3 wires Airoha Ethernet GDM netdevs and DSA user ports to that backend throughxfrmdev_ops. ESP GSO and ESP TX checksum offload remain disabled.Runtime testing was done on a Gemtek W1700K2 running OpenWrt with the same changes applied on top of a 6.18.31-based kernel.
Test parameters:
- Static IPv4 transport-mode XFRM SAs between the AP and host.
- ESP transform: auth hmac(sha1), enc cbc(aes) with a 128-bit AES key.
- iperf3 TCP test, AP as client and host as server:iperf3 -c <host_ip> -P 4 -t 10- The host always used normal Linux XFRM software processing.
- With AP ESP offload disabled, the AP also used the Linux XFRM software path; in this setup, EIP93-backed AEAD crypto was still available to that path.Network-relevant test setup:
- AP: Gemtek W1700K2, Airoha AN7581/EN7581, 4x Arm Cortex-A53 at 1.4 GHz, 2 GiB RAM,
airoha_ethwan (GDM2) netdev, 10Gb/s full-duplex, MTU 9200, EIP93 crypto and IPsec packet engine present.
- Host: AMD Ryzen 9 9950X3D, 16 cores/32 threads, Open vSwitch, MTU 9978, backed by a ConnectX-6 Dx 10Gb/s full-duplex link.AP to host iperf3 result:
AP offload Sender Receiver Retransmits on 918.2 Mbit/s 913.6 Mbit/s 0 off 782.4 Mbit/s 778.6 Mbit/s 3569This is a 17.3% receiver-side throughput improvement for the AP TX ESP path in this setup, with retransmits eliminated in the offloaded run.
Jihong Min (3):
xfrm: extend ESP offload infrastructure for packet engines
crypto: inside-secure: add EIP93 ESP packet backend
net: airoha: add EIP93-backed ESP XFRM offloadMAINTAINERS | 1 + drivers/crypto/inside-secure/eip93/Kconfig | 10 + drivers/crypto/inside-secure/eip93/Makefile | 1 + .../crypto/inside-secure/eip93/eip93-ipsec.c | 1413 ++++++++++++++++ .../crypto/inside-secure/eip93/eip93-main.c | 69 +- .../crypto/inside-secure/eip93/eip93-main.h | 38 +- drivers/net/ethernet/airoha/Kconfig | 11 + drivers/net/ethernet/airoha/Makefile | 1 + drivers/net/ethernet/airoha/airoha_eth.c | 51 +- drivers/net/ethernet/airoha/airoha_eth.h | 69 + drivers/net/ethernet/airoha/airoha_xfrm.c | 1474 +++++++++++++++++ include/crypto/eip93-ipsec.h | 132 ++ include/linux/netdevice.h | 3 + include/net/xfrm.h | 8 +-
Quoted 9 lines
net/ipv4/esp4.c | 6 +- net/ipv4/esp4_offload.c | 29 +- net/ipv6/esp6.c | 6 +- net/ipv6/esp6_offload.c | 29 +- 18 files changed, 3324 insertions(+), 27 deletions(-) create mode 100644 drivers/crypto/inside-secure/eip93/eip93-ipsec.c create mode 100644 drivers/net/ethernet/airoha/airoha_xfrm.c create mode 100644 include/crypto/eip93-ipsec.h
One note I should have included in the cover letter:
The hardware behavior used by this series was studied from the out-of-tree IPsec branch of the mtk-eip93 driver:
https://github.com/vschagen/mtk-eip93/tree/ipsec
That code was useful for understanding the EIP93 packet-mode ESP descriptor programming and SA record values.
This series is not a direct import of that driver. The implementation was rewritten around the current upstream driver layout and the Linux XFRM netdev offload model, with EIP93 exposed as a packet-mode ESP backend used by the Airoha netdev driver.
Sincerely,
Jihong Min