Skip to content

Commit 5ca096d

Browse files
committed
Merge branch 'ksz-dsa-fixes'
Lino Sanfilippo says: ==================== Fixes for KSZ DSA switch These patches fix issues I encountered while using a KSZ9897 as a DSA switch with a broadcom GENET network device as the DSA master device. PATCH 1 fixes an invalid access to an SKB in case it is scattered. PATCH 2 fixes incorrect hardware checksum calculation caused by the DSA tag. Changes in v2: - instead of linearizing the SKBs only for KSZ switches ensure linearized SKBs for all tail taggers by clearing the feature flags NETIF_F_HW_SG and NETIF_F_FRAGLIST (suggested by Vladimir Oltean) The patches have been tested with a KSZ9897 and apply against net-next. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 9f061b9 + 37120f2 commit 5ca096d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

net/dsa/slave.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,7 @@ void dsa_slave_setup_tagger(struct net_device *slave)
18081808
struct dsa_slave_priv *p = netdev_priv(slave);
18091809
const struct dsa_port *cpu_dp = dp->cpu_dp;
18101810
struct net_device *master = cpu_dp->master;
1811+
const struct dsa_switch *ds = dp->ds;
18111812

18121813
slave->needed_headroom = cpu_dp->tag_ops->needed_headroom;
18131814
slave->needed_tailroom = cpu_dp->tag_ops->needed_tailroom;
@@ -1819,6 +1820,14 @@ void dsa_slave_setup_tagger(struct net_device *slave)
18191820
slave->needed_tailroom += master->needed_tailroom;
18201821

18211822
p->xmit = cpu_dp->tag_ops->xmit;
1823+
1824+
slave->features = master->vlan_features | NETIF_F_HW_TC;
1825+
if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
1826+
slave->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1827+
slave->hw_features |= NETIF_F_HW_TC;
1828+
slave->features |= NETIF_F_LLTX;
1829+
if (slave->needed_tailroom)
1830+
slave->features &= ~(NETIF_F_SG | NETIF_F_FRAGLIST);
18221831
}
18231832

18241833
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
@@ -1881,11 +1890,6 @@ int dsa_slave_create(struct dsa_port *port)
18811890
if (slave_dev == NULL)
18821891
return -ENOMEM;
18831892

1884-
slave_dev->features = master->vlan_features | NETIF_F_HW_TC;
1885-
if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
1886-
slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1887-
slave_dev->hw_features |= NETIF_F_HW_TC;
1888-
slave_dev->features |= NETIF_F_LLTX;
18891893
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
18901894
if (!is_zero_ether_addr(port->mac))
18911895
ether_addr_copy(slave_dev->dev_addr, port->mac);

net/dsa/tag_ksz.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
5353
u8 *tag;
5454
u8 *addr;
5555

56+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
57+
return NULL;
58+
5659
/* Tag encoding */
5760
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
5861
addr = skb_mac_header(skb);
@@ -114,6 +117,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
114117
u8 *addr;
115118
u16 val;
116119

120+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
121+
return NULL;
122+
117123
/* Tag encoding */
118124
tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN);
119125
addr = skb_mac_header(skb);
@@ -164,6 +170,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
164170
u8 *addr;
165171
u8 *tag;
166172

173+
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
174+
return NULL;
175+
167176
/* Tag encoding */
168177
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
169178
addr = skb_mac_header(skb);

0 commit comments

Comments
 (0)