@@ -601,10 +601,14 @@ static int efx_ef10_probe(struct efx_nic *efx)
601
601
efx_ef10_read_licensed_features (efx );
602
602
603
603
/* We can have one VI for each vi_stride-byte region.
604
- * However, until we use TX option descriptors we need two TX queues
605
- * per channel.
604
+ * However, until we use TX option descriptors we need up to four
605
+ * TX queues per channel for different checksumming combinations .
606
606
*/
607
- efx -> tx_queues_per_channel = 2 ;
607
+ if (nic_data -> datapath_caps &
608
+ (1 << MC_CMD_GET_CAPABILITIES_OUT_VXLAN_NVGRE_LBN ))
609
+ efx -> tx_queues_per_channel = 4 ;
610
+ else
611
+ efx -> tx_queues_per_channel = 2 ;
608
612
efx -> max_vis = efx_ef10_mem_map_size (efx ) / efx -> vi_stride ;
609
613
if (!efx -> max_vis ) {
610
614
netif_err (efx , drv , efx -> net_dev , "error determining max VIs\n" );
@@ -1300,6 +1304,7 @@ static void efx_ef10_fini_nic(struct efx_nic *efx)
1300
1304
static int efx_ef10_init_nic (struct efx_nic * efx )
1301
1305
{
1302
1306
struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
1307
+ netdev_features_t hw_enc_features = 0 ;
1303
1308
int rc ;
1304
1309
1305
1310
if (nic_data -> must_check_datapath_caps ) {
@@ -1344,6 +1349,21 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
1344
1349
nic_data -> must_restore_piobufs = false;
1345
1350
}
1346
1351
1352
+ /* add encapsulated checksum offload features */
1353
+ if (efx_has_cap (efx , VXLAN_NVGRE ) && !efx_ef10_is_vf (efx ))
1354
+ hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM ;
1355
+ /* add encapsulated TSO features */
1356
+ if (efx_has_cap (efx , TX_TSO_V2_ENCAP )) {
1357
+ netdev_features_t encap_tso_features ;
1358
+
1359
+ encap_tso_features = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
1360
+ NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM ;
1361
+
1362
+ hw_enc_features |= encap_tso_features | NETIF_F_TSO ;
1363
+ efx -> net_dev -> features |= encap_tso_features ;
1364
+ }
1365
+ efx -> net_dev -> hw_enc_features = hw_enc_features ;
1366
+
1347
1367
/* don't fail init if RSS setup doesn't work */
1348
1368
rc = efx -> type -> rx_push_rss_config (efx , false,
1349
1369
efx -> rss_context .rx_indir_table , NULL );
@@ -2146,6 +2166,9 @@ static int efx_ef10_irq_test_generate(struct efx_nic *efx)
2146
2166
2147
2167
static int efx_ef10_tx_probe (struct efx_tx_queue * tx_queue )
2148
2168
{
2169
+ /* low two bits of label are what we want for type */
2170
+ BUILD_BUG_ON ((EFX_TXQ_TYPE_OUTER_CSUM | EFX_TXQ_TYPE_INNER_CSUM ) != 3 );
2171
+ tx_queue -> type = tx_queue -> label & 3 ;
2149
2172
return efx_nic_alloc_buffer (tx_queue -> efx , & tx_queue -> txd .buf ,
2150
2173
(tx_queue -> ptr_mask + 1 ) *
2151
2174
sizeof (efx_qword_t ),
@@ -2168,15 +2191,15 @@ static inline void efx_ef10_push_tx_desc(struct efx_tx_queue *tx_queue,
2168
2191
2169
2192
/* Add Firmware-Assisted TSO v2 option descriptors to a queue.
2170
2193
*/
2171
- static int efx_ef10_tx_tso_desc (struct efx_tx_queue * tx_queue ,
2172
- struct sk_buff * skb ,
2173
- bool * data_mapped )
2194
+ int efx_ef10_tx_tso_desc (struct efx_tx_queue * tx_queue , struct sk_buff * skb ,
2195
+ bool * data_mapped )
2174
2196
{
2175
2197
struct efx_tx_buffer * buffer ;
2198
+ u16 inner_ipv4_id = 0 ;
2199
+ u16 outer_ipv4_id = 0 ;
2176
2200
struct tcphdr * tcp ;
2177
2201
struct iphdr * ip ;
2178
-
2179
- u16 ipv4_id ;
2202
+ u16 ip_tot_len ;
2180
2203
u32 seqnum ;
2181
2204
u32 mss ;
2182
2205
@@ -2189,21 +2212,43 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
2189
2212
return - EINVAL ;
2190
2213
}
2191
2214
2192
- ip = ip_hdr (skb );
2215
+ if (skb -> encapsulation ) {
2216
+ if (!tx_queue -> tso_encap )
2217
+ return - EINVAL ;
2218
+ ip = ip_hdr (skb );
2219
+ if (ip -> version == 4 )
2220
+ outer_ipv4_id = ntohs (ip -> id );
2221
+
2222
+ ip = inner_ip_hdr (skb );
2223
+ tcp = inner_tcp_hdr (skb );
2224
+ } else {
2225
+ ip = ip_hdr (skb );
2226
+ tcp = tcp_hdr (skb );
2227
+ }
2228
+
2229
+ /* 8000-series EF10 hardware requires that IP Total Length be
2230
+ * greater than or equal to the value it will have in each segment
2231
+ * (which is at most mss + 208 + TCP header length), but also less
2232
+ * than (0x10000 - inner_network_header). Otherwise the TCP
2233
+ * checksum calculation will be broken for encapsulated packets.
2234
+ * We fill in ip->tot_len with 0xff30, which should satisfy the
2235
+ * first requirement unless the MSS is ridiculously large (which
2236
+ * should be impossible as the driver max MTU is 9216); it is
2237
+ * guaranteed to satisfy the second as we only attempt TSO if
2238
+ * inner_network_header <= 208.
2239
+ */
2240
+ ip_tot_len = - EFX_TSO2_MAX_HDRLEN ;
2241
+ EFX_WARN_ON_ONCE_PARANOID (mss + EFX_TSO2_MAX_HDRLEN +
2242
+ (tcp -> doff << 2u ) > ip_tot_len );
2243
+
2193
2244
if (ip -> version == 4 ) {
2194
- /* Modify IPv4 header if needed. */
2195
- ip -> tot_len = 0 ;
2245
+ ip -> tot_len = htons (ip_tot_len );
2196
2246
ip -> check = 0 ;
2197
- ipv4_id = ntohs (ip -> id );
2247
+ inner_ipv4_id = ntohs (ip -> id );
2198
2248
} else {
2199
- /* Modify IPv6 header if needed. */
2200
- struct ipv6hdr * ipv6 = ipv6_hdr (skb );
2201
-
2202
- ipv6 -> payload_len = 0 ;
2203
- ipv4_id = 0 ;
2249
+ ((struct ipv6hdr * )ip )-> payload_len = htons (ip_tot_len );
2204
2250
}
2205
2251
2206
- tcp = tcp_hdr (skb );
2207
2252
seqnum = ntohl (tcp -> seq );
2208
2253
2209
2254
buffer = efx_tx_queue_get_insert_buffer (tx_queue );
@@ -2216,7 +2261,7 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
2216
2261
ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
2217
2262
ESF_DZ_TX_TSO_OPTION_TYPE ,
2218
2263
ESE_DZ_TX_TSO_OPTION_DESC_FATSO2A ,
2219
- ESF_DZ_TX_TSO_IP_ID , ipv4_id ,
2264
+ ESF_DZ_TX_TSO_IP_ID , inner_ipv4_id ,
2220
2265
ESF_DZ_TX_TSO_TCP_SEQNO , seqnum
2221
2266
);
2222
2267
++ tx_queue -> insert_count ;
@@ -2226,11 +2271,12 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
2226
2271
buffer -> flags = EFX_TX_BUF_OPTION ;
2227
2272
buffer -> len = 0 ;
2228
2273
buffer -> unmap_len = 0 ;
2229
- EFX_POPULATE_QWORD_4 (buffer -> option ,
2274
+ EFX_POPULATE_QWORD_5 (buffer -> option ,
2230
2275
ESF_DZ_TX_DESC_IS_OPT , 1 ,
2231
2276
ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
2232
2277
ESF_DZ_TX_TSO_OPTION_TYPE ,
2233
2278
ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B ,
2279
+ ESF_DZ_TX_TSO_OUTER_IPID , outer_ipv4_id ,
2234
2280
ESF_DZ_TX_TSO_TCP_MSS , mss
2235
2281
);
2236
2282
++ tx_queue -> insert_count ;
@@ -2254,11 +2300,11 @@ static u32 efx_ef10_tso_versions(struct efx_nic *efx)
2254
2300
2255
2301
static void efx_ef10_tx_init (struct efx_tx_queue * tx_queue )
2256
2302
{
2257
- bool csum_offload = tx_queue -> label & EFX_TXQ_TYPE_OFFLOAD ;
2303
+ bool csum_offload = tx_queue -> type & EFX_TXQ_TYPE_OUTER_CSUM ;
2304
+ bool inner_csum = tx_queue -> type & EFX_TXQ_TYPE_INNER_CSUM ;
2258
2305
struct efx_channel * channel = tx_queue -> channel ;
2259
2306
struct efx_nic * efx = tx_queue -> efx ;
2260
2307
struct efx_ef10_nic_data * nic_data ;
2261
- bool tso_v2 = false;
2262
2308
efx_qword_t * txd ;
2263
2309
int rc ;
2264
2310
@@ -2281,15 +2327,18 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
2281
2327
* TSOv2 cannot be used with Hardware timestamping, and is never needed
2282
2328
* for XDP tx.
2283
2329
*/
2284
- if (csum_offload && (nic_data -> datapath_caps2 &
2285
- (1 << MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN )) &&
2286
- !tx_queue -> timestamping && !tx_queue -> xdp_tx ) {
2287
- tso_v2 = true;
2288
- netif_dbg (efx , hw , efx -> net_dev , "Using TSOv2 for channel %u\n" ,
2289
- channel -> channel );
2330
+ if (efx_has_cap (efx , TX_TSO_V2 )) {
2331
+ if ((csum_offload || inner_csum ) &&
2332
+ !tx_queue -> timestamping && !tx_queue -> xdp_tx ) {
2333
+ tx_queue -> tso_version = 2 ;
2334
+ netif_dbg (efx , hw , efx -> net_dev , "Using TSOv2 for channel %u\n" ,
2335
+ channel -> channel );
2336
+ }
2337
+ } else if (efx_has_cap (efx , TX_TSO )) {
2338
+ tx_queue -> tso_version = 1 ;
2290
2339
}
2291
2340
2292
- rc = efx_mcdi_tx_init (tx_queue , tso_v2 );
2341
+ rc = efx_mcdi_tx_init (tx_queue );
2293
2342
if (rc )
2294
2343
goto fail ;
2295
2344
@@ -2302,22 +2351,19 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
2302
2351
tx_queue -> buffer [0 ].flags = EFX_TX_BUF_OPTION ;
2303
2352
tx_queue -> insert_count = 1 ;
2304
2353
txd = efx_tx_desc (tx_queue , 0 );
2305
- EFX_POPULATE_QWORD_5 (* txd ,
2354
+ EFX_POPULATE_QWORD_7 (* txd ,
2306
2355
ESF_DZ_TX_DESC_IS_OPT , true,
2307
2356
ESF_DZ_TX_OPTION_TYPE ,
2308
2357
ESE_DZ_TX_OPTION_DESC_CRC_CSUM ,
2309
2358
ESF_DZ_TX_OPTION_UDP_TCP_CSUM , csum_offload ,
2310
- ESF_DZ_TX_OPTION_IP_CSUM , csum_offload ,
2359
+ ESF_DZ_TX_OPTION_IP_CSUM , csum_offload && tx_queue -> tso_version != 2 ,
2360
+ ESF_DZ_TX_OPTION_INNER_UDP_TCP_CSUM , inner_csum ,
2361
+ ESF_DZ_TX_OPTION_INNER_IP_CSUM , inner_csum && tx_queue -> tso_version != 2 ,
2311
2362
ESF_DZ_TX_TIMESTAMP , tx_queue -> timestamping );
2312
2363
tx_queue -> write_count = 1 ;
2313
2364
2314
- if (tso_v2 ) {
2315
- tx_queue -> handle_tso = efx_ef10_tx_tso_desc ;
2316
- tx_queue -> tso_version = 2 ;
2317
- } else if (nic_data -> datapath_caps &
2318
- (1 << MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN )) {
2319
- tx_queue -> tso_version = 1 ;
2320
- }
2365
+ if (tx_queue -> tso_version == 2 && efx_has_cap (efx , TX_TSO_V2_ENCAP ))
2366
+ tx_queue -> tso_encap = true;
2321
2367
2322
2368
wmb ();
2323
2369
efx_ef10_push_tx_desc (tx_queue , txd );
@@ -2880,7 +2926,7 @@ efx_ef10_handle_tx_event(struct efx_channel *channel, efx_qword_t *event)
2880
2926
/* Get the transmit queue */
2881
2927
tx_ev_q_label = EFX_QWORD_FIELD (* event , ESF_DZ_TX_QLABEL );
2882
2928
tx_queue = efx_channel_get_tx_queue (channel ,
2883
- tx_ev_q_label % EFX_TXQ_TYPES );
2929
+ tx_ev_q_label % EFX_MAX_TXQ_PER_CHANNEL );
2884
2930
2885
2931
if (!tx_queue -> timestamping ) {
2886
2932
/* Transmit completion */
0 commit comments