€•°wŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ*/translations/zh_CN/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/zh_TW/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/it_IT/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ja_JP/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ko_KR/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/sp_SP/networking/xfrm_device”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒD/var/lib/git/docbuild/linux/Documentation/networking/xfrm_device.rst”h KubhŒtarget”“”)”}”(hŒ.. _xfrm_device:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œ xfrm-device”uh1h´h KhhhžhhŸh³ubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ/XFRM device - offloading the IPsec computations”h]”hŒ/XFRM device - offloading the IPsec computations”…””}”(hhÉhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhhÄhžhhŸh³h KubhŒ paragraph”“”)”}”(hŒNShannon Nelson Leon Romanovsky ”h]”(hŒShannon Nelson <”…””}”(hhÙhžhhŸNh NubhŒ reference”“”)”}”(hŒshannon.nelson@oracle.com”h]”hŒshannon.nelson@oracle.com”…””}”(hhãhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œ mailto:shannon.nelson@oracle.com”uh1háhhÙubhŒ> Leon Romanovsky <”…””}”(hhÙhžhhŸNh Nubhâ)”}”(hŒleonro@nvidia.com”h]”hŒleonro@nvidia.com”…””}”(hh÷hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:leonro@nvidia.com”uh1háhhÙubhŒ>”…””}”(hhÙhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KhhÄhžhubhÃ)”}”(hhh]”(hÈ)”}”(hŒOverview”h]”hŒOverview”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjhžhhŸh³h K ubhØ)”}”(hX±IPsec is a useful feature for securing network traffic, but the computational cost is high: a 10Gbps link can easily be brought down to under 1Gbps, depending on the traffic and link configuration. Luckily, there are NICs that offer a hardware based IPsec offload which can radically increase throughput and decrease CPU utilization. The XFRM Device interface allows NIC drivers to offer to the stack access to the hardware offload.”h]”hX±IPsec is a useful feature for securing network traffic, but the computational cost is high: a 10Gbps link can easily be brought down to under 1Gbps, depending on the traffic and link configuration. Luckily, there are NICs that offer a hardware based IPsec offload which can radically increase throughput and decrease CPU utilization. The XFRM Device interface allows NIC drivers to offer to the stack access to the hardware offload.”…””}”(hj"hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KhjhžhubhŒdefinition_list”“”)”}”(hhh]”hŒdefinition_list_item”“”)”}”(hXvRight now, there are two types of hardware offload that kernel supports. * IPsec crypto offload: * NIC performs encrypt/decrypt * Kernel does everything else * IPsec packet offload: * NIC performs encrypt/decrypt * NIC does encapsulation * Kernel and NIC have SA and policy in-sync * NIC handles the SA and policies states * The Kernel talks to the keymanager ”h]”(hŒterm”“”)”}”(hŒHRight now, there are two types of hardware offload that kernel supports.”h]”hŒHRight now, there are two types of hardware offload that kernel supports.”…””}”(hj=hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j;hŸh³h K hj7ubhŒ definition”“”)”}”(hhh]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒRIPsec crypto offload: * NIC performs encrypt/decrypt * Kernel does everything else”h]”hØ)”}”(hŒRIPsec crypto offload: * NIC performs encrypt/decrypt * Kernel does everything else”h]”hŒRIPsec crypto offload: * NIC performs encrypt/decrypt * Kernel does everything else”…””}”(hj[hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KhjWubah}”(h]”h ]”h"]”h$]”h&]”uh1jUhjRubjV)”}”(hŒÈIPsec packet offload: * NIC performs encrypt/decrypt * NIC does encapsulation * Kernel and NIC have SA and policy in-sync * NIC handles the SA and policies states * The Kernel talks to the keymanager ”h]”hØ)”}”(hŒÇIPsec packet offload: * NIC performs encrypt/decrypt * NIC does encapsulation * Kernel and NIC have SA and policy in-sync * NIC handles the SA and policies states * The Kernel talks to the keymanager”h]”hŒÇIPsec packet offload: * NIC performs encrypt/decrypt * NIC does encapsulation * Kernel and NIC have SA and policy in-sync * NIC handles the SA and policies states * The Kernel talks to the keymanager”…””}”(hjshžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Khjoubah}”(h]”h ]”h"]”h$]”h&]”uh1jUhjRubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jPhŸh³h KhjMubah}”(h]”h ]”h"]”h$]”h&]”uh1jKhj7ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j5hŸh³h K hj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjhžhhŸNh NubhØ)”}”(hŒîUserland access to the offload is typically through a system such as libreswan or KAME/raccoon, but the iproute2 'ip xfrm' command set can be handy when experimenting. An example command might look something like this for crypto offload:”h]”hŒòUserland access to the offload is typically through a system such as libreswan or KAME/raccoon, but the iproute2 ‘ip xfrm’ command set can be handy when experimenting. An example command might look something like this for crypto offload:”…””}”(hj¡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K"hjhžhubhŒ block_quote”“”)”}”(hX ip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \ reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload dev eth4 dir in ”h]”j1)”}”(hhh]”j6)”}”(hŒýip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \ reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload dev eth4 dir in ”h]”(j<)”}”(hŒJip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \”h]”hŒJip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport ”…””}”(hj¼hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j;hŸh³h K+hj¸ubjL)”}”(hhh]”hØ)”}”(hŒ±reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload dev eth4 dir in”h]”hŒµreqid 0x07 replay-window 32 aead ‘rfc4106(gcm(aes))’ 0x44434241343332312423222114131211f4f3f2f1 128 sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp offload dev eth4 dir in”…””}”(hjÍhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K(hjÊubah}”(h]”h ]”h"]”h$]”h&]”uh1jKhj¸ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j5hŸh³h K+hjµubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hŸh³h K'hjhžhubhØ)”}”(hŒand for packet offload”h]”hŒand for packet offload”…””}”(hjóhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K-hjhžhubj°)”}”(hXip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \ reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload packet dev eth4 dir in ip x p add src 14.0.0.70 dst 14.0.0.52 offload packet dev eth4 dir in tmpl src 14.0.0.70 dst 14.0.0.52 proto esp reqid 10000 mode transport ”h]”(j1)”}”(hhh]”j6)”}”(hXip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \ reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload packet dev eth4 dir in ”h]”(j<)”}”(hŒJip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport \”h]”hŒJip x s add proto esp dst 14.0.0.70 src 14.0.0.52 spi 0x07 mode transport ”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j;hŸh³h K3hjubjL)”}”(hhh]”hØ)”}”(hŒ¸reqid 0x07 replay-window 32 \ aead 'rfc4106(gcm(aes))' 0x44434241343332312423222114131211f4f3f2f1 128 \ sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp \ offload packet dev eth4 dir in”h]”hŒ¼reqid 0x07 replay-window 32 aead ‘rfc4106(gcm(aes))’ 0x44434241343332312423222114131211f4f3f2f1 128 sel src 14.0.0.52/24 dst 14.0.0.70/24 proto tcp offload packet dev eth4 dir in”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K0hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jKhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j5hŸh³h K3hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j0hjubhØ)”}”(hŒ‹ip x p add src 14.0.0.70 dst 14.0.0.52 offload packet dev eth4 dir in tmpl src 14.0.0.70 dst 14.0.0.52 proto esp reqid 10000 mode transport”h]”hŒ‹ip x p add src 14.0.0.70 dst 14.0.0.52 offload packet dev eth4 dir in tmpl src 14.0.0.70 dst 14.0.0.52 proto esp reqid 10000 mode transport”…””}”(hj=hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K5hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j¯hŸh³h K/hjhžhubhØ)”}”(hŒIYes, that's ugly, but that's what shell scripts and/or libreswan are for.”h]”hŒMYes, that’s ugly, but that’s what shell scripts and/or libreswan are for.”…””}”(hjQhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K8hjhžhubeh}”(h]”Œoverview”ah ]”h"]”Œoverview”ah$]”h&]”uh1hÂhhÄhžhhŸh³h K ubhÃ)”}”(hhh]”(hÈ)”}”(hŒCallbacks to implement”h]”hŒCallbacks to implement”…””}”(hjjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjghžhhŸh³h K=ubhŒ literal_block”“”)”}”(hXF/* from include/linux/netdevice.h */ struct xfrmdev_ops { /* Crypto and Packet offload callbacks */ int (*xdo_dev_state_add) (struct xfrm_state *x, struct netlink_ext_ack *extack); void (*xdo_dev_state_delete) (struct xfrm_state *x); void (*xdo_dev_state_free) (struct xfrm_state *x); bool (*xdo_dev_offload_ok) (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); /* Solely packet offload callbacks */ int (*xdo_dev_policy_add) (struct xfrm_policy *x, struct netlink_ext_ack *extack); void (*xdo_dev_policy_delete) (struct xfrm_policy *x); void (*xdo_dev_policy_free) (struct xfrm_policy *x); };”h]”hXF/* from include/linux/netdevice.h */ struct xfrmdev_ops { /* Crypto and Packet offload callbacks */ int (*xdo_dev_state_add) (struct xfrm_state *x, struct netlink_ext_ack *extack); void (*xdo_dev_state_delete) (struct xfrm_state *x); void (*xdo_dev_state_free) (struct xfrm_state *x); bool (*xdo_dev_offload_ok) (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); /* Solely packet offload callbacks */ int (*xdo_dev_policy_add) (struct xfrm_policy *x, struct netlink_ext_ack *extack); void (*xdo_dev_policy_delete) (struct xfrm_policy *x); void (*xdo_dev_policy_free) (struct xfrm_policy *x); };”…””}”hjzsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h KAhjghžhubhØ)”}”(hXThe NIC driver offering ipsec offload will need to implement callbacks relevant to supported offload to make the offload available to the network stack's XFRM subsystem. Additionally, the feature bits NETIF_F_HW_ESP and NETIF_F_HW_ESP_TX_CSUM will signal the availability of the offload.”h]”hX!The NIC driver offering ipsec offload will need to implement callbacks relevant to supported offload to make the offload available to the network stack’s XFRM subsystem. Additionally, the feature bits NETIF_F_HW_ESP and NETIF_F_HW_ESP_TX_CSUM will signal the availability of the offload.”…””}”(hjˆhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KRhjghžhubeh}”(h]”Œcallbacks-to-implement”ah ]”h"]”Œcallbacks to implement”ah$]”h&]”uh1hÂhhÄhžhhŸh³h K=ubhÃ)”}”(hhh]”(hÈ)”}”(hŒFlow”h]”hŒFlow”…””}”(hj¡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjžhžhhŸh³h KZubhØ)”}”(hŒ×At probe time and before the call to register_netdev(), the driver should set up local data structures and XFRM callbacks, and set the feature bits. The XFRM code's listener will finish the setup on NETDEV_REGISTER.”h]”hŒÙAt probe time and before the call to register_netdev(), the driver should set up local data structures and XFRM callbacks, and set the feature bits. The XFRM code’s listener will finish the setup on NETDEV_REGISTER.”…””}”(hj¯hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K\hjžhžhubjy)”}”(hŒ“adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops; adapter->netdev->features |= NETIF_F_HW_ESP; adapter->netdev->hw_enc_features |= NETIF_F_HW_ESP;”h]”hŒ“adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops; adapter->netdev->features |= NETIF_F_HW_ESP; adapter->netdev->hw_enc_features |= NETIF_F_HW_ESP;”…””}”hj½sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h KbhjžhžhubhØ)”}”(hŒËWhen new SAs are set up with a request for "offload" feature, the driver's xdo_dev_state_add() will be given the new SA to be offloaded and an indication of whether it is for Rx or Tx. The driver should”h]”hŒÑWhen new SAs are set up with a request for “offload†feature, the driver’s xdo_dev_state_add() will be given the new SA to be offloaded and an indication of whether it is for Rx or Tx. The driver should”…””}”(hjËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kfhjžhžhubj°)”}”(hXÝ- verify the algorithm is supported for offloads - store the SA information (key, salt, target-ip, protocol, etc) - enable the HW offload of the SA - return status value: =========== =================================== 0 success -EOPNETSUPP offload not supported, try SW IPsec, not applicable for packet offload mode other fail the request =========== =================================== ”h]”jQ)”}”(hhh]”(jV)”}”(hŒ.verify the algorithm is supported for offloads”h]”hØ)”}”(hjâh]”hŒ.verify the algorithm is supported for offloads”…””}”(hjähžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kjhjàubah}”(h]”h ]”h"]”h$]”h&]”uh1jUhjÝubjV)”}”(hŒ>store the SA information (key, salt, target-ip, protocol, etc)”h]”hØ)”}”(hjùh]”hŒ>store the SA information (key, salt, target-ip, protocol, etc)”…””}”(hjûhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kkhj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1jUhjÝubjV)”}”(hŒenable the HW offload of the SA”h]”hØ)”}”(hjh]”hŒenable the HW offload of the SA”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Klhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jUhjÝubjV)”}”(hX;return status value: =========== =================================== 0 success -EOPNETSUPP offload not supported, try SW IPsec, not applicable for packet offload mode other fail the request =========== =================================== ”h]”(hØ)”}”(hŒreturn status value:”h]”hŒreturn status value:”…””}”(hj)hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kmhj%ubj°)”}”(hX=========== =================================== 0 success -EOPNETSUPP offload not supported, try SW IPsec, not applicable for packet offload mode other fail the request =========== =================================== ”h]”hŒtable”“”)”}”(hhh]”hŒtgroup”“”)”}”(hhh]”(hŒcolspec”“”)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K uh1jEhjBubjF)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œcolwidth”K&uh1jEhjBubhŒtbody”“”)”}”(hhh]”(hŒrow”“”)”}”(hhh]”(hŒentry”“”)”}”(hhh]”hØ)”}”(hŒ0”h]”hŒ0”…””}”(hjjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kphjgubah}”(h]”h ]”h"]”h$]”h&]”uh1jehjbubjf)”}”(hhh]”hØ)”}”(hŒsuccess”h]”hŒsuccess”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kphj~ubah}”(h]”h ]”h"]”h$]”h&]”uh1jehjbubeh}”(h]”h ]”h"]”h$]”h&]”uh1j`hj]ubja)”}”(hhh]”(jf)”}”(hhh]”hØ)”}”(hŒ -EOPNETSUPP”h]”hŒ -EOPNETSUPP”…””}”(hj¡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kqhjžubah}”(h]”h ]”h"]”h$]”h&]”uh1jehj›ubjf)”}”(hhh]”hØ)”}”(hŒKoffload not supported, try SW IPsec, not applicable for packet offload mode”h]”hŒKoffload not supported, try SW IPsec, not applicable for packet offload mode”…””}”(hj¸hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kqhjµubah}”(h]”h ]”h"]”h$]”h&]”uh1jehj›ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j`hj]ubja)”}”(hhh]”(jf)”}”(hhh]”hØ)”}”(hŒother”h]”hŒother”…””}”(hjØhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KshjÕubah}”(h]”h ]”h"]”h$]”h&]”uh1jehjÒubjf)”}”(hhh]”hØ)”}”(hŒfail the request”h]”hŒfail the request”…””}”(hjïhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kshjìubah}”(h]”h ]”h"]”h$]”h&]”uh1jehjÒubeh}”(h]”h ]”h"]”h$]”h&]”uh1j`hj]ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j[hjBubeh}”(h]”h ]”h"]”h$]”h&]”Œcols”Kuh1j@hj=ubah}”(h]”h ]”h"]”h$]”h&]”uh1j;hj7ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hŸh³h Kohj%ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jUhjÝubeh}”(h]”h ]”h"]”h$]”h&]”jŒ-”uh1jPhŸh³h KjhjÙubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hŸh³h KjhjžhžhubhØ)”}”(hŒ”The driver can also set an offload_handle in the SA, an opaque void pointer that can be used to convey context into the fast-path offload requests::”h]”hŒ“The driver can also set an offload_handle in the SA, an opaque void pointer that can be used to convey context into the fast-path offload requests:”…””}”(hj5hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kvhjžhžhubjy)”}”(hŒ!xs->xso.offload_handle = context;”h]”hŒ!xs->xso.offload_handle = context;”…””}”hjCsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h KyhjžhžhubhØ)”}”(hXèWhen the network stack is preparing an IPsec packet for an SA that has been setup for offload, it first calls into xdo_dev_offload_ok() with the skb and the intended offload state to ask the driver if the offload will serviceable. This can check the packet information to be sure the offload can be supported (e.g. IPv4 or IPv6, no IPv4 options, etc) and return true or false to signify its support. In case driver doesn't implement this callback, the stack provides reasonable defaults.”h]”hXêWhen the network stack is preparing an IPsec packet for an SA that has been setup for offload, it first calls into xdo_dev_offload_ok() with the skb and the intended offload state to ask the driver if the offload will serviceable. This can check the packet information to be sure the offload can be supported (e.g. IPv4 or IPv6, no IPv4 options, etc) and return true or false to signify its support. In case driver doesn’t implement this callback, the stack provides reasonable defaults.”…””}”(hjQhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K|hjžhžhubhØ)”}”(hŒ¶Crypto offload mode: When ready to send, the driver needs to inspect the Tx packet for the offload information, including the opaque context, and set up the packet send accordingly::”h]”hŒµCrypto offload mode: When ready to send, the driver needs to inspect the Tx packet for the offload information, including the opaque context, and set up the packet send accordingly:”…””}”(hj_hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K„hjžhžhubjy)”}”(hŒPxs = xfrm_input_state(skb); context = xs->xso.offload_handle; set up HW for send”h]”hŒPxs = xfrm_input_state(skb); context = xs->xso.offload_handle; set up HW for send”…””}”hjmsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h K‰hjžhžhubhØ)”}”(hŒšThe stack has already inserted the appropriate IPsec headers in the packet data, the offload just needs to do the encryption and fix up the header values.”h]”hŒšThe stack has already inserted the appropriate IPsec headers in the packet data, the offload just needs to do the encryption and fix up the header values.”…””}”(hj{hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KhjžhžhubhØ)”}”(hX4When a packet is received and the HW has indicated that it offloaded a decryption, the driver needs to add a reference to the decoded SA into the packet's skb. At this point the data should be decrypted but the IPsec headers are still in the packet data; they are removed later up the stack in xfrm_input().”h]”hX6When a packet is received and the HW has indicated that it offloaded a decryption, the driver needs to add a reference to the decoded SA into the packet’s skb. At this point the data should be decrypted but the IPsec headers are still in the packet data; they are removed later up the stack in xfrm_input().”…””}”(hj‰hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K’hjžhžhubj°)”}”(hX2find and hold the SA that was used to the Rx skb:: get spi, protocol, and destination IP from packet headers xs = find xs from (spi, protocol, dest_IP) xfrm_state_hold(xs); store the state information into the skb:: sp = secpath_set(skb); if (!sp) return; sp->xvec[sp->len++] = xs; sp->olen++; indicate the success and/or error status of the offload:: xo = xfrm_offload(skb); xo->flags = CRYPTO_DONE; xo->status = crypto_status; hand the packet to napi_gro_receive() as usual ”h]”(hØ)”}”(hŒ2find and hold the SA that was used to the Rx skb::”h]”hŒ1find and hold the SA that was used to the Rx skb:”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K˜hj—ubjy)”}”(hŒyget spi, protocol, and destination IP from packet headers xs = find xs from (spi, protocol, dest_IP) xfrm_state_hold(xs);”h]”hŒyget spi, protocol, and destination IP from packet headers xs = find xs from (spi, protocol, dest_IP) xfrm_state_hold(xs);”…””}”hj©sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h Kšhj—ubhØ)”}”(hŒ*store the state information into the skb::”h]”hŒ)store the state information into the skb:”…””}”(hj·hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h Kžhj—ubjy)”}”(hŒMsp = secpath_set(skb); if (!sp) return; sp->xvec[sp->len++] = xs; sp->olen++;”h]”hŒMsp = secpath_set(skb); if (!sp) return; sp->xvec[sp->len++] = xs; sp->olen++;”…””}”hjÅsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h K hj—ubhØ)”}”(hŒ9indicate the success and/or error status of the offload::”h]”hŒ8indicate the success and/or error status of the offload:”…””}”(hjÓhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K¥hj—ubjy)”}”(hŒLxo = xfrm_offload(skb); xo->flags = CRYPTO_DONE; xo->status = crypto_status;”h]”hŒLxo = xfrm_offload(skb); xo->flags = CRYPTO_DONE; xo->status = crypto_status;”…””}”hjásbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jxhŸh³h K§hj—ubhØ)”}”(hŒ.hand the packet to napi_gro_receive() as usual”h]”hŒ.hand the packet to napi_gro_receive() as usual”…””}”(hjïhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K«hj—ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j¯hŸh³h K˜hjžhžhubhØ)”}”(hŒÕIn ESN mode, xdo_dev_state_advance_esn() is called from xfrm_replay_advance_esn() for RX, and xfrm_replay_overflow_offload_esn for TX. Driver will check packet seq number and update HW ESN state machine if needed.”h]”hŒÕIn ESN mode, xdo_dev_state_advance_esn() is called from xfrm_replay_advance_esn() for RX, and xfrm_replay_overflow_offload_esn for TX. Driver will check packet seq number and update HW ESN state machine if needed.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K­hjžhžhubhØ)”}”(hŒåPacket offload mode: HW adds and deletes XFRM headers. So in RX path, XFRM stack is bypassed if HW reported success. In TX path, the packet lefts kernel without extra header and not encrypted, the HW is responsible to perform it.”h]”hŒåPacket offload mode: HW adds and deletes XFRM headers. So in RX path, XFRM stack is bypassed if HW reported success. In TX path, the packet lefts kernel without extra header and not encrypted, the HW is responsible to perform it.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K±hjžhžhubhØ)”}”(hXºWhen the SA is removed by the user, the driver's xdo_dev_state_delete() and xdo_dev_policy_delete() are asked to disable the offload. Later, xdo_dev_state_free() and xdo_dev_policy_free() are called from a garbage collection routine after all reference counts to the state and policy have been removed and any remaining resources can be cleared for the offload state. How these are used by the driver will depend on specific hardware needs.”h]”hX¼When the SA is removed by the user, the driver’s xdo_dev_state_delete() and xdo_dev_policy_delete() are asked to disable the offload. Later, xdo_dev_state_free() and xdo_dev_policy_free() are called from a garbage collection routine after all reference counts to the state and policy have been removed and any remaining resources can be cleared for the offload state. How these are used by the driver will depend on specific hardware needs.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K¶hjžhžhubhØ)”}”(hŒÈAs a netdev is set to DOWN the XFRM stack's netdev listener will call xdo_dev_state_delete(), xdo_dev_policy_delete(), xdo_dev_state_free() and xdo_dev_policy_free() on any remaining offloaded states.”h]”hŒÊAs a netdev is set to DOWN the XFRM stack’s netdev listener will call xdo_dev_state_delete(), xdo_dev_policy_delete(), xdo_dev_state_free() and xdo_dev_policy_free() on any remaining offloaded states.”…””}”(hj-hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h K¾hjžhžhubhØ)”}”(hXQOutcome of HW handling packets, the XFRM core can't count hard, soft limits. The HW/driver are responsible to perform it and provide accurate data when xdo_dev_state_update_stats() is called. In case of one of these limits occuried, the driver needs to call to xfrm_state_check_expire() to make sure that XFRM performs rekeying sequence.”h]”hXSOutcome of HW handling packets, the XFRM core can’t count hard, soft limits. The HW/driver are responsible to perform it and provide accurate data when xdo_dev_state_update_stats() is called. In case of one of these limits occuried, the driver needs to call to xfrm_state_check_expire() to make sure that XFRM performs rekeying sequence.”…””}”(hj;hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh³h KÂhjžhžhubeh}”(h]”Œflow”ah ]”h"]”Œflow”ah$]”h&]”uh1hÂhhÄhžhhŸh³h KZubeh}”(h]”(Œ-xfrm-device-offloading-the-ipsec-computations”hÁeh ]”h"]”(Œ/xfrm device - offloading the ipsec computations”Œ xfrm_device”eh$]”h&]”uh1hÂhhhžhhŸh³h KŒexpect_referenced_by_name”}”jWh¶sŒexpect_referenced_by_id”}”hÁh¶subeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÇNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”jeŒfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j€Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”hÁ]”h¶asŒnameids”}”(jWhÁjVjSjdjaj›j˜jNjKuŒ nametypes”}”(jWˆjV‰jd‰j›‰jN‰uh}”(hÁhÄjShÄjajj˜jgjKjžuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)”}”(hhh]”hØ)”}”(hhh]”hŒ1Hyperlink target "xfrm-device" is not referenced.”…””}”hjêsbah}”(h]”h ]”h"]”h$]”h&]”uh1h×hjçubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”h³Œline”Kuh1jåubaŒ transformer”NŒ include_log”]”Œ decoration”Nhžhub.