@@ -601,10 +601,14 @@ static int efx_ef10_probe(struct efx_nic *efx)
601601 efx_ef10_read_licensed_features (efx );
602602
603603 /* 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 .
606606 */
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 ;
608612 efx -> max_vis = efx_ef10_mem_map_size (efx ) / efx -> vi_stride ;
609613 if (!efx -> max_vis ) {
610614 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)
13001304static int efx_ef10_init_nic (struct efx_nic * efx )
13011305{
13021306 struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
1307+ netdev_features_t hw_enc_features = 0 ;
13031308 int rc ;
13041309
13051310 if (nic_data -> must_check_datapath_caps ) {
@@ -1344,6 +1349,21 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
13441349 nic_data -> must_restore_piobufs = false;
13451350 }
13461351
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+
13471367 /* don't fail init if RSS setup doesn't work */
13481368 rc = efx -> type -> rx_push_rss_config (efx , false,
13491369 efx -> rss_context .rx_indir_table , NULL );
@@ -2146,6 +2166,9 @@ static int efx_ef10_irq_test_generate(struct efx_nic *efx)
21462166
21472167static int efx_ef10_tx_probe (struct efx_tx_queue * tx_queue )
21482168{
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 ;
21492172 return efx_nic_alloc_buffer (tx_queue -> efx , & tx_queue -> txd .buf ,
21502173 (tx_queue -> ptr_mask + 1 ) *
21512174 sizeof (efx_qword_t ),
@@ -2168,15 +2191,15 @@ static inline void efx_ef10_push_tx_desc(struct efx_tx_queue *tx_queue,
21682191
21692192/* Add Firmware-Assisted TSO v2 option descriptors to a queue.
21702193 */
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 )
21742196{
21752197 struct efx_tx_buffer * buffer ;
2198+ u16 inner_ipv4_id = 0 ;
2199+ u16 outer_ipv4_id = 0 ;
21762200 struct tcphdr * tcp ;
21772201 struct iphdr * ip ;
2178-
2179- u16 ipv4_id ;
2202+ u16 ip_tot_len ;
21802203 u32 seqnum ;
21812204 u32 mss ;
21822205
@@ -2189,21 +2212,43 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
21892212 return - EINVAL ;
21902213 }
21912214
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+
21932244 if (ip -> version == 4 ) {
2194- /* Modify IPv4 header if needed. */
2195- ip -> tot_len = 0 ;
2245+ ip -> tot_len = htons (ip_tot_len );
21962246 ip -> check = 0 ;
2197- ipv4_id = ntohs (ip -> id );
2247+ inner_ipv4_id = ntohs (ip -> id );
21982248 } 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 );
22042250 }
22052251
2206- tcp = tcp_hdr (skb );
22072252 seqnum = ntohl (tcp -> seq );
22082253
22092254 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,
22162261 ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
22172262 ESF_DZ_TX_TSO_OPTION_TYPE ,
22182263 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 ,
22202265 ESF_DZ_TX_TSO_TCP_SEQNO , seqnum
22212266 );
22222267 ++ tx_queue -> insert_count ;
@@ -2226,11 +2271,12 @@ static int efx_ef10_tx_tso_desc(struct efx_tx_queue *tx_queue,
22262271 buffer -> flags = EFX_TX_BUF_OPTION ;
22272272 buffer -> len = 0 ;
22282273 buffer -> unmap_len = 0 ;
2229- EFX_POPULATE_QWORD_4 (buffer -> option ,
2274+ EFX_POPULATE_QWORD_5 (buffer -> option ,
22302275 ESF_DZ_TX_DESC_IS_OPT , 1 ,
22312276 ESF_DZ_TX_OPTION_TYPE , ESE_DZ_TX_OPTION_DESC_TSO ,
22322277 ESF_DZ_TX_TSO_OPTION_TYPE ,
22332278 ESE_DZ_TX_TSO_OPTION_DESC_FATSO2B ,
2279+ ESF_DZ_TX_TSO_OUTER_IPID , outer_ipv4_id ,
22342280 ESF_DZ_TX_TSO_TCP_MSS , mss
22352281 );
22362282 ++ tx_queue -> insert_count ;
@@ -2254,11 +2300,11 @@ static u32 efx_ef10_tso_versions(struct efx_nic *efx)
22542300
22552301static void efx_ef10_tx_init (struct efx_tx_queue * tx_queue )
22562302{
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 ;
22582305 struct efx_channel * channel = tx_queue -> channel ;
22592306 struct efx_nic * efx = tx_queue -> efx ;
22602307 struct efx_ef10_nic_data * nic_data ;
2261- bool tso_v2 = false;
22622308 efx_qword_t * txd ;
22632309 int rc ;
22642310
@@ -2281,15 +2327,18 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
22812327 * TSOv2 cannot be used with Hardware timestamping, and is never needed
22822328 * for XDP tx.
22832329 */
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 ;
22902339 }
22912340
2292- rc = efx_mcdi_tx_init (tx_queue , tso_v2 );
2341+ rc = efx_mcdi_tx_init (tx_queue );
22932342 if (rc )
22942343 goto fail ;
22952344
@@ -2302,22 +2351,19 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
23022351 tx_queue -> buffer [0 ].flags = EFX_TX_BUF_OPTION ;
23032352 tx_queue -> insert_count = 1 ;
23042353 txd = efx_tx_desc (tx_queue , 0 );
2305- EFX_POPULATE_QWORD_5 (* txd ,
2354+ EFX_POPULATE_QWORD_7 (* txd ,
23062355 ESF_DZ_TX_DESC_IS_OPT , true,
23072356 ESF_DZ_TX_OPTION_TYPE ,
23082357 ESE_DZ_TX_OPTION_DESC_CRC_CSUM ,
23092358 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 ,
23112362 ESF_DZ_TX_TIMESTAMP , tx_queue -> timestamping );
23122363 tx_queue -> write_count = 1 ;
23132364
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;
23212367
23222368 wmb ();
23232369 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)
28802926 /* Get the transmit queue */
28812927 tx_ev_q_label = EFX_QWORD_FIELD (* event , ESF_DZ_TX_QLABEL );
28822928 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 );
28842930
28852931 if (!tx_queue -> timestamping ) {
28862932 /* Transmit completion */
0 commit comments