Commit 992c75ae authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'sfc-further-ef100-encap-tso-features'

Edward Cree says:

====================
sfc: further EF100 encap TSO features

This series adds support for GRE and GRE_CSUM TSO on EF100 NICs, as
 well as improving the handling of UDP tunnel TSO.
====================

Link: https://lore.kernel.org/r/eda2de73-edf2-8b92-edb9-099ebda09ebc@solarflare.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 72ac50b2 c5122cf5
...@@ -289,7 +289,9 @@ typedef union efx_oword { ...@@ -289,7 +289,9 @@ typedef union efx_oword {
field14, value14, \ field14, value14, \
field15, value15, \ field15, value15, \
field16, value16, \ field16, value16, \
field17, value17) \ field17, value17, \
field18, value18, \
field19, value19) \
(EFX_INSERT_FIELD_NATIVE((min), (max), field1, (value1)) | \ (EFX_INSERT_FIELD_NATIVE((min), (max), field1, (value1)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field2, (value2)) | \ EFX_INSERT_FIELD_NATIVE((min), (max), field2, (value2)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field3, (value3)) | \ EFX_INSERT_FIELD_NATIVE((min), (max), field3, (value3)) | \
...@@ -306,7 +308,9 @@ typedef union efx_oword { ...@@ -306,7 +308,9 @@ typedef union efx_oword {
EFX_INSERT_FIELD_NATIVE((min), (max), field14, (value14)) | \ EFX_INSERT_FIELD_NATIVE((min), (max), field14, (value14)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field15, (value15)) | \ EFX_INSERT_FIELD_NATIVE((min), (max), field15, (value15)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field16, (value16)) | \ EFX_INSERT_FIELD_NATIVE((min), (max), field16, (value16)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field17, (value17))) EFX_INSERT_FIELD_NATIVE((min), (max), field17, (value17)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field18, (value18)) | \
EFX_INSERT_FIELD_NATIVE((min), (max), field19, (value19)))
#define EFX_INSERT_FIELDS64(...) \ #define EFX_INSERT_FIELDS64(...) \
cpu_to_le64(EFX_INSERT_FIELDS_NATIVE(__VA_ARGS__)) cpu_to_le64(EFX_INSERT_FIELDS_NATIVE(__VA_ARGS__))
...@@ -348,7 +352,11 @@ typedef union efx_oword { ...@@ -348,7 +352,11 @@ typedef union efx_oword {
#endif #endif
/* Populate an octword field with various numbers of arguments */ /* Populate an octword field with various numbers of arguments */
#define EFX_POPULATE_OWORD_17 EFX_POPULATE_OWORD #define EFX_POPULATE_OWORD_19 EFX_POPULATE_OWORD
#define EFX_POPULATE_OWORD_18(oword, ...) \
EFX_POPULATE_OWORD_19(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_OWORD_17(oword, ...) \
EFX_POPULATE_OWORD_18(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_OWORD_16(oword, ...) \ #define EFX_POPULATE_OWORD_16(oword, ...) \
EFX_POPULATE_OWORD_17(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__) EFX_POPULATE_OWORD_17(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_OWORD_15(oword, ...) \ #define EFX_POPULATE_OWORD_15(oword, ...) \
...@@ -391,7 +399,11 @@ typedef union efx_oword { ...@@ -391,7 +399,11 @@ typedef union efx_oword {
EFX_DWORD_3, 0xffffffff) EFX_DWORD_3, 0xffffffff)
/* Populate a quadword field with various numbers of arguments */ /* Populate a quadword field with various numbers of arguments */
#define EFX_POPULATE_QWORD_17 EFX_POPULATE_QWORD #define EFX_POPULATE_QWORD_19 EFX_POPULATE_QWORD
#define EFX_POPULATE_QWORD_18(qword, ...) \
EFX_POPULATE_QWORD_19(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_QWORD_17(qword, ...) \
EFX_POPULATE_QWORD_18(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_QWORD_16(qword, ...) \ #define EFX_POPULATE_QWORD_16(qword, ...) \
EFX_POPULATE_QWORD_17(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__) EFX_POPULATE_QWORD_17(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_QWORD_15(qword, ...) \ #define EFX_POPULATE_QWORD_15(qword, ...) \
...@@ -432,7 +444,11 @@ typedef union efx_oword { ...@@ -432,7 +444,11 @@ typedef union efx_oword {
EFX_DWORD_1, 0xffffffff) EFX_DWORD_1, 0xffffffff)
/* Populate a dword field with various numbers of arguments */ /* Populate a dword field with various numbers of arguments */
#define EFX_POPULATE_DWORD_17 EFX_POPULATE_DWORD #define EFX_POPULATE_DWORD_19 EFX_POPULATE_DWORD
#define EFX_POPULATE_DWORD_18(dword, ...) \
EFX_POPULATE_DWORD_19(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_DWORD_17(dword, ...) \
EFX_POPULATE_DWORD_18(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_DWORD_16(dword, ...) \ #define EFX_POPULATE_DWORD_16(dword, ...) \
EFX_POPULATE_DWORD_17(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__) EFX_POPULATE_DWORD_17(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
#define EFX_POPULATE_DWORD_15(dword, ...) \ #define EFX_POPULATE_DWORD_15(dword, ...) \
......
...@@ -185,12 +185,16 @@ static int efx_ef100_init_datapath_caps(struct efx_nic *efx) ...@@ -185,12 +185,16 @@ static int efx_ef100_init_datapath_caps(struct efx_nic *efx)
if (efx_ef100_has_cap(nic_data->datapath_caps2, TX_TSO_V3)) { if (efx_ef100_has_cap(nic_data->datapath_caps2, TX_TSO_V3)) {
struct net_device *net_dev = efx->net_dev; struct net_device *net_dev = efx->net_dev;
netdev_features_t tso = NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_PARTIAL | netdev_features_t tso = NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_PARTIAL |
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM; NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM |
NETIF_F_GSO_GRE | NETIF_F_GSO_GRE_CSUM;
net_dev->features |= tso; net_dev->features |= tso;
net_dev->hw_features |= tso; net_dev->hw_features |= tso;
net_dev->hw_enc_features |= tso; net_dev->hw_enc_features |= tso;
net_dev->gso_partial_features |= NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM; /* EF100 HW can only offload outer checksums if they are UDP,
* so for GRE_CSUM we have to use GSO_PARTIAL.
*/
net_dev->gso_partial_features |= NETIF_F_GSO_GRE_CSUM;
} }
efx->num_mac_stats = MCDI_WORD(outbuf, efx->num_mac_stats = MCDI_WORD(outbuf,
GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS); GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
......
...@@ -194,8 +194,10 @@ static void ef100_make_tso_desc(struct efx_nic *efx, ...@@ -194,8 +194,10 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
u16 vlan_tci = skb_vlan_tag_get(skb); u16 vlan_tci = skb_vlan_tag_get(skb);
u32 mss = skb_shinfo(skb)->gso_size; u32 mss = skb_shinfo(skb)->gso_size;
bool encap = skb->encapsulation; bool encap = skb->encapsulation;
bool udp_encap = false;
u16 vlan_enable = 0; u16 vlan_enable = 0;
struct tcphdr *tcp; struct tcphdr *tcp;
bool outer_csum;
u32 paylen; u32 paylen;
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID) if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID)
...@@ -211,24 +213,29 @@ static void ef100_make_tso_desc(struct efx_nic *efx, ...@@ -211,24 +213,29 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
outer_l4_offset = skb_transport_offset(skb); outer_l4_offset = skb_transport_offset(skb);
ip_offset = skb_inner_network_offset(skb); ip_offset = skb_inner_network_offset(skb);
tcp_offset = skb_inner_transport_offset(skb); tcp_offset = skb_inner_transport_offset(skb);
if (skb_shinfo(skb)->gso_type &
(SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL_CSUM))
udp_encap = true;
} else { } else {
ip_offset = skb_network_offset(skb); ip_offset = skb_network_offset(skb);
tcp_offset = skb_transport_offset(skb); tcp_offset = skb_transport_offset(skb);
outer_ip_offset = outer_l4_offset = 0; outer_ip_offset = outer_l4_offset = 0;
} }
outer_csum = skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM;
/* subtract TCP payload length from inner checksum */ /* subtract TCP payload length from inner checksum */
tcp = (void *)skb->data + tcp_offset; tcp = (void *)skb->data + tcp_offset;
paylen = skb->len - tcp_offset; paylen = skb->len - tcp_offset;
csum_replace_by_diff(&tcp->check, (__force __wsum)htonl(paylen)); csum_replace_by_diff(&tcp->check, (__force __wsum)htonl(paylen));
EFX_POPULATE_OWORD_17(*txd, EFX_POPULATE_OWORD_19(*txd,
ESF_GZ_TX_DESC_TYPE, ESE_GZ_TX_DESC_TYPE_TSO, ESF_GZ_TX_DESC_TYPE, ESE_GZ_TX_DESC_TYPE_TSO,
ESF_GZ_TX_TSO_MSS, mss, ESF_GZ_TX_TSO_MSS, mss,
ESF_GZ_TX_TSO_HDR_NUM_SEGS, 1, ESF_GZ_TX_TSO_HDR_NUM_SEGS, 1,
ESF_GZ_TX_TSO_PAYLOAD_NUM_SEGS, payload_segs, ESF_GZ_TX_TSO_PAYLOAD_NUM_SEGS, payload_segs,
ESF_GZ_TX_TSO_HDR_LEN_W, buffer->len >> 1, ESF_GZ_TX_TSO_HDR_LEN_W, buffer->len >> 1,
ESF_GZ_TX_TSO_PAYLOAD_LEN, len, ESF_GZ_TX_TSO_PAYLOAD_LEN, len,
ESF_GZ_TX_TSO_CSO_OUTER_L4, outer_csum,
ESF_GZ_TX_TSO_CSO_INNER_L4, 1, ESF_GZ_TX_TSO_CSO_INNER_L4, 1,
ESF_GZ_TX_TSO_INNER_L3_OFF_W, ip_offset >> 1, ESF_GZ_TX_TSO_INNER_L3_OFF_W, ip_offset >> 1,
ESF_GZ_TX_TSO_INNER_L4_OFF_W, tcp_offset >> 1, ESF_GZ_TX_TSO_INNER_L4_OFF_W, tcp_offset >> 1,
...@@ -236,7 +243,8 @@ static void ef100_make_tso_desc(struct efx_nic *efx, ...@@ -236,7 +243,8 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
ESF_GZ_TX_TSO_ED_INNER_IP_LEN, 1, ESF_GZ_TX_TSO_ED_INNER_IP_LEN, 1,
ESF_GZ_TX_TSO_OUTER_L3_OFF_W, outer_ip_offset >> 1, ESF_GZ_TX_TSO_OUTER_L3_OFF_W, outer_ip_offset >> 1,
ESF_GZ_TX_TSO_OUTER_L4_OFF_W, outer_l4_offset >> 1, ESF_GZ_TX_TSO_OUTER_L4_OFF_W, outer_l4_offset >> 1,
ESF_GZ_TX_TSO_ED_OUTER_UDP_LEN, encap && !gso_partial, ESF_GZ_TX_TSO_ED_OUTER_UDP_LEN, udp_encap && !gso_partial,
ESF_GZ_TX_TSO_ED_OUTER_IP_LEN, encap && !gso_partial,
ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, encap ? mangleid : ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, encap ? mangleid :
ESE_GZ_TX_DESC_IP4_ID_NO_OP, ESE_GZ_TX_DESC_IP4_ID_NO_OP,
ESF_GZ_TX_TSO_VLAN_INSERT_EN, vlan_enable, ESF_GZ_TX_TSO_VLAN_INSERT_EN, vlan_enable,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment