Skip to content

Commit 82728b9

Browse files
claudiu-mkuba-moo
authored andcommitted
enetc: Remove Tx checksumming offload code
Tx checksumming has been defeatured and completely removed from the h/w reference manual. Made a little cleanup for the TSE case as this is complementary code. Signed-off-by: Claudiu Manoil <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ebcaa20 commit 82728b9

File tree

5 files changed

+32
-91
lines changed

5 files changed

+32
-91
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,6 @@ netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev)
4747
return NETDEV_TX_OK;
4848
}
4949

50-
static bool enetc_tx_csum(struct sk_buff *skb, union enetc_tx_bd *txbd)
51-
{
52-
int l3_start, l3_hsize;
53-
u16 l3_flags, l4_flags;
54-
55-
if (skb->ip_summed != CHECKSUM_PARTIAL)
56-
return false;
57-
58-
switch (skb->csum_offset) {
59-
case offsetof(struct tcphdr, check):
60-
l4_flags = ENETC_TXBD_L4_TCP;
61-
break;
62-
case offsetof(struct udphdr, check):
63-
l4_flags = ENETC_TXBD_L4_UDP;
64-
break;
65-
default:
66-
skb_checksum_help(skb);
67-
return false;
68-
}
69-
70-
l3_start = skb_network_offset(skb);
71-
l3_hsize = skb_network_header_len(skb);
72-
73-
l3_flags = 0;
74-
if (skb->protocol == htons(ETH_P_IPV6))
75-
l3_flags = ENETC_TXBD_L3_IPV6;
76-
77-
/* write BD fields */
78-
txbd->l3_csoff = enetc_txbd_l3_csoff(l3_start, l3_hsize, l3_flags);
79-
txbd->l4_csoff = l4_flags;
80-
81-
return true;
82-
}
83-
8450
static void enetc_unmap_tx_buff(struct enetc_bdr *tx_ring,
8551
struct enetc_tx_swbd *tx_swbd)
8652
{
@@ -146,22 +112,16 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb,
146112
if (do_vlan || do_tstamp)
147113
flags |= ENETC_TXBD_FLAGS_EX;
148114

149-
if (enetc_tx_csum(skb, &temp_bd))
150-
flags |= ENETC_TXBD_FLAGS_CSUM | ENETC_TXBD_FLAGS_L4CS;
151-
else if (tx_ring->tsd_enable)
115+
if (tx_ring->tsd_enable)
152116
flags |= ENETC_TXBD_FLAGS_TSE | ENETC_TXBD_FLAGS_TXSTART;
153117

154118
/* first BD needs frm_len and offload flags set */
155119
temp_bd.frm_len = cpu_to_le16(skb->len);
156120
temp_bd.flags = flags;
157121

158-
if (flags & ENETC_TXBD_FLAGS_TSE) {
159-
u32 temp;
160-
161-
temp = (skb->skb_mstamp_ns >> 5 & ENETC_TXBD_TXSTART_MASK)
162-
| (flags << ENETC_TXBD_FLAGS_OFFSET);
163-
temp_bd.txstart = cpu_to_le32(temp);
164-
}
122+
if (flags & ENETC_TXBD_FLAGS_TSE)
123+
temp_bd.txstart = enetc_txbd_set_tx_start(skb->skb_mstamp_ns,
124+
flags);
165125

166126
if (flags & ENETC_TXBD_FLAGS_EX) {
167127
u8 e_flags = 0;
@@ -1897,8 +1857,7 @@ static void enetc_kfree_si(struct enetc_si *si)
18971857
static void enetc_detect_errata(struct enetc_si *si)
18981858
{
18991859
if (si->pdev->revision == ENETC_REV1)
1900-
si->errata = ENETC_ERR_TXCSUM | ENETC_ERR_VLAN_ISOL |
1901-
ENETC_ERR_UCMCSWP;
1860+
si->errata = ENETC_ERR_VLAN_ISOL | ENETC_ERR_UCMCSWP;
19021861
}
19031862

19041863
int enetc_pci_probe(struct pci_dev *pdev, const char *name, int sizeof_priv)

drivers/net/ethernet/freescale/enetc/enetc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,8 @@ struct enetc_msg_swbd {
147147

148148
#define ENETC_REV1 0x1
149149
enum enetc_errata {
150-
ENETC_ERR_TXCSUM = BIT(0),
151-
ENETC_ERR_VLAN_ISOL = BIT(1),
152-
ENETC_ERR_UCMCSWP = BIT(2),
150+
ENETC_ERR_VLAN_ISOL = BIT(0),
151+
ENETC_ERR_UCMCSWP = BIT(1),
153152
};
154153

155154
#define ENETC_SI_F_QBV BIT(0)

drivers/net/ethernet/freescale/enetc/enetc_hw.h

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,7 @@ union enetc_tx_bd {
374374
__le16 frm_len;
375375
union {
376376
struct {
377-
__le16 l3_csoff;
378-
u8 l4_csoff;
377+
u8 reserved[3];
379378
u8 flags;
380379
}; /* default layout */
381380
__le32 txstart;
@@ -398,41 +397,37 @@ union enetc_tx_bd {
398397
} wb; /* writeback descriptor */
399398
};
400399

401-
#define ENETC_TXBD_FLAGS_L4CS BIT(0)
402-
#define ENETC_TXBD_FLAGS_TSE BIT(1)
403-
#define ENETC_TXBD_FLAGS_W BIT(2)
404-
#define ENETC_TXBD_FLAGS_CSUM BIT(3)
405-
#define ENETC_TXBD_FLAGS_TXSTART BIT(4)
406-
#define ENETC_TXBD_FLAGS_EX BIT(6)
407-
#define ENETC_TXBD_FLAGS_F BIT(7)
400+
enum enetc_txbd_flags {
401+
ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */
402+
ENETC_TXBD_FLAGS_TSE = BIT(1),
403+
ENETC_TXBD_FLAGS_W = BIT(2),
404+
ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */
405+
ENETC_TXBD_FLAGS_TXSTART = BIT(4),
406+
ENETC_TXBD_FLAGS_EX = BIT(6),
407+
ENETC_TXBD_FLAGS_F = BIT(7)
408+
};
408409
#define ENETC_TXBD_TXSTART_MASK GENMASK(24, 0)
409410
#define ENETC_TXBD_FLAGS_OFFSET 24
411+
412+
static inline __le32 enetc_txbd_set_tx_start(u64 tx_start, u8 flags)
413+
{
414+
u32 temp;
415+
416+
temp = (tx_start >> 5 & ENETC_TXBD_TXSTART_MASK) |
417+
(flags << ENETC_TXBD_FLAGS_OFFSET);
418+
419+
return cpu_to_le32(temp);
420+
}
421+
410422
static inline void enetc_clear_tx_bd(union enetc_tx_bd *txbd)
411423
{
412424
memset(txbd, 0, sizeof(*txbd));
413425
}
414426

415-
/* L3 csum flags */
416-
#define ENETC_TXBD_L3_IPCS BIT(7)
417-
#define ENETC_TXBD_L3_IPV6 BIT(15)
418-
419-
#define ENETC_TXBD_L3_START_MASK GENMASK(6, 0)
420-
#define ENETC_TXBD_L3_SET_HSIZE(val) ((((val) >> 2) & 0x7f) << 8)
421-
422427
/* Extension flags */
423428
#define ENETC_TXBD_E_FLAGS_VLAN_INS BIT(0)
424429
#define ENETC_TXBD_E_FLAGS_TWO_STEP_PTP BIT(2)
425430

426-
static inline __le16 enetc_txbd_l3_csoff(int start, int hdr_sz, u16 l3_flags)
427-
{
428-
return cpu_to_le16(l3_flags | ENETC_TXBD_L3_SET_HSIZE(hdr_sz) |
429-
(start & ENETC_TXBD_L3_START_MASK));
430-
}
431-
432-
/* L4 csum flags */
433-
#define ENETC_TXBD_L4_UDP BIT(5)
434-
#define ENETC_TXBD_L4_TCP BIT(6)
435-
436431
union enetc_rx_bd {
437432
struct {
438433
__le64 addr;

drivers/net/ethernet/freescale/enetc/enetc_pf.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,22 +714,16 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
714714
ndev->watchdog_timeo = 5 * HZ;
715715
ndev->max_mtu = ENETC_MAX_MTU;
716716

717-
ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
717+
ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
718718
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
719719
NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK;
720-
ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
721-
NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
720+
ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM |
722721
NETIF_F_HW_VLAN_CTAG_TX |
723722
NETIF_F_HW_VLAN_CTAG_RX;
724723

725724
if (si->num_rss)
726725
ndev->hw_features |= NETIF_F_RXHASH;
727726

728-
if (si->errata & ENETC_ERR_TXCSUM) {
729-
ndev->hw_features &= ~NETIF_F_HW_CSUM;
730-
ndev->features &= ~NETIF_F_HW_CSUM;
731-
}
732-
733727
ndev->priv_flags |= IFF_UNICAST_FLT;
734728

735729
if (si->hw_features & ENETC_SI_F_QBV)

drivers/net/ethernet/freescale/enetc/enetc_vf.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,16 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
120120
ndev->watchdog_timeo = 5 * HZ;
121121
ndev->max_mtu = ENETC_MAX_MTU;
122122

123-
ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
123+
ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
124124
NETIF_F_HW_VLAN_CTAG_TX |
125125
NETIF_F_HW_VLAN_CTAG_RX;
126-
ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG |
127-
NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
126+
ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM |
128127
NETIF_F_HW_VLAN_CTAG_TX |
129128
NETIF_F_HW_VLAN_CTAG_RX;
130129

131130
if (si->num_rss)
132131
ndev->hw_features |= NETIF_F_RXHASH;
133132

134-
if (si->errata & ENETC_ERR_TXCSUM) {
135-
ndev->hw_features &= ~NETIF_F_HW_CSUM;
136-
ndev->features &= ~NETIF_F_HW_CSUM;
137-
}
138-
139133
/* pick up primary MAC address from SI */
140134
enetc_get_primary_mac_addr(&si->hw, ndev->dev_addr);
141135
}

0 commit comments

Comments
 (0)