Skip to content

Commit fe0c406

Browse files
ecree-solarflaredavem330
authored andcommitted
sfc: select inner-csum-offload TX queues for skbs that need it
Won't actually be exercised until we start advertising the corresponding offload features. Signed-off-by: Edward Cree <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 85d43fd commit fe0c406

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

drivers/net/ethernet/sfc/ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "mcdi_pcol.h"
4444
#include "io.h"
4545
#include "farch_regs.h"
46+
#include "tx.h"
4647
#include "nic.h" /* indirectly includes ptp.h */
4748

4849
/* Maximum number of events expected to make up a PTP event */
@@ -1081,8 +1082,8 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
10811082
/* Transmit a PTP packet via the dedicated hardware timestamped queue. */
10821083
static void efx_ptp_xmit_skb_queue(struct efx_nic *efx, struct sk_buff *skb)
10831084
{
1084-
u8 type = skb->ip_summed == CHECKSUM_PARTIAL ? EFX_TXQ_TYPE_OUTER_CSUM : 0;
10851085
struct efx_ptp_data *ptp_data = efx->ptp_data;
1086+
u8 type = efx_tx_csum_type_skb(skb);
10861087
struct efx_tx_queue *tx_queue;
10871088

10881089
tx_queue = efx_channel_get_tx_queue(ptp_data->channel, type);

drivers/net/ethernet/sfc/tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb,
506506
EFX_WARN_ON_PARANOID(!netif_device_present(net_dev));
507507

508508
index = skb_get_queue_mapping(skb);
509-
type = skb->ip_summed == CHECKSUM_PARTIAL ? EFX_TXQ_TYPE_OUTER_CSUM : 0;
509+
type = efx_tx_csum_type_skb(skb);
510510
if (index >= efx->n_tx_channels) {
511511
index -= efx->n_tx_channels;
512512
type |= EFX_TXQ_TYPE_HIGHPRI;

drivers/net/ethernet/sfc/tx.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,30 @@ unsigned int efx_tx_limit_len(struct efx_tx_queue *tx_queue,
1818
u8 *efx_tx_get_copy_buffer_limited(struct efx_tx_queue *tx_queue,
1919
struct efx_tx_buffer *buffer, size_t len);
2020

21+
/* What TXQ type will satisfy the checksum offloads required for this skb? */
22+
static inline unsigned int efx_tx_csum_type_skb(struct sk_buff *skb)
23+
{
24+
if (skb->ip_summed != CHECKSUM_PARTIAL)
25+
return 0; /* no checksum offload */
26+
27+
if (skb->encapsulation &&
28+
skb_checksum_start_offset(skb) == skb_inner_transport_offset(skb)) {
29+
/* we only advertise features for IPv4 and IPv6 checksums on
30+
* encapsulated packets, so if the checksum is for the inner
31+
* packet, it must be one of them; no further checking required.
32+
*/
33+
34+
/* Do we also need to offload the outer header checksum? */
35+
if (skb_shinfo(skb)->gso_segs > 1 &&
36+
!(skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) &&
37+
(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM))
38+
return EFX_TXQ_TYPE_OUTER_CSUM | EFX_TXQ_TYPE_INNER_CSUM;
39+
return EFX_TXQ_TYPE_INNER_CSUM;
40+
}
41+
42+
/* similarly, we only advertise features for IPv4 and IPv6 checksums,
43+
* so it must be one of them. No need for further checks.
44+
*/
45+
return EFX_TXQ_TYPE_OUTER_CSUM;
46+
}
2147
#endif /* EFX_TX_H */

0 commit comments

Comments
 (0)