Skip to content

Commit 9deba33

Browse files
claudiu-mdavem330
authored andcommitted
enetc: Fix HW_VLAN_CTAG_TX|RX toggling
VLAN tag insertion/extraction offload is correctly activated at probe time but deactivation of this feature (i.e. via ethtool) is broken. Toggling works only for Tx/Rx ring 0 of a PF, and is ignored for the other rings, including the VF rings. To fix this, the existing VLAN offload toggling code was extended to all the rings assigned to a netdevice, instead of the default ring 0 (likely a leftover from the early validation days of this feature). And the code was moved to the common set_features() function to fix toggling for the VF driver too. Fixes: d4fd040 ("enetc: Introduce basic PF and VF ENETC ethernet drivers") Signed-off-by: Claudiu Manoil <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent faa6208 commit 9deba33

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,24 @@ static int enetc_set_psfp(struct net_device *ndev, int en)
15951595
return 0;
15961596
}
15971597

1598+
static void enetc_enable_rxvlan(struct net_device *ndev, bool en)
1599+
{
1600+
struct enetc_ndev_priv *priv = netdev_priv(ndev);
1601+
int i;
1602+
1603+
for (i = 0; i < priv->num_rx_rings; i++)
1604+
enetc_bdr_enable_rxvlan(&priv->si->hw, i, en);
1605+
}
1606+
1607+
static void enetc_enable_txvlan(struct net_device *ndev, bool en)
1608+
{
1609+
struct enetc_ndev_priv *priv = netdev_priv(ndev);
1610+
int i;
1611+
1612+
for (i = 0; i < priv->num_tx_rings; i++)
1613+
enetc_bdr_enable_txvlan(&priv->si->hw, i, en);
1614+
}
1615+
15981616
int enetc_set_features(struct net_device *ndev,
15991617
netdev_features_t features)
16001618
{
@@ -1604,6 +1622,14 @@ int enetc_set_features(struct net_device *ndev,
16041622
if (changed & NETIF_F_RXHASH)
16051623
enetc_set_rss(ndev, !!(features & NETIF_F_RXHASH));
16061624

1625+
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
1626+
enetc_enable_rxvlan(ndev,
1627+
!!(features & NETIF_F_HW_VLAN_CTAG_RX));
1628+
1629+
if (changed & NETIF_F_HW_VLAN_CTAG_TX)
1630+
enetc_enable_txvlan(ndev,
1631+
!!(features & NETIF_F_HW_VLAN_CTAG_TX));
1632+
16071633
if (changed & NETIF_F_HW_TC)
16081634
err = enetc_set_psfp(ndev, !!(features & NETIF_F_HW_TC));
16091635

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -531,22 +531,22 @@ struct enetc_msg_cmd_header {
531531

532532
/* Common H/W utility functions */
533533

534-
static inline void enetc_enable_rxvlan(struct enetc_hw *hw, int si_idx,
535-
bool en)
534+
static inline void enetc_bdr_enable_rxvlan(struct enetc_hw *hw, int idx,
535+
bool en)
536536
{
537-
u32 val = enetc_rxbdr_rd(hw, si_idx, ENETC_RBMR);
537+
u32 val = enetc_rxbdr_rd(hw, idx, ENETC_RBMR);
538538

539539
val = (val & ~ENETC_RBMR_VTE) | (en ? ENETC_RBMR_VTE : 0);
540-
enetc_rxbdr_wr(hw, si_idx, ENETC_RBMR, val);
540+
enetc_rxbdr_wr(hw, idx, ENETC_RBMR, val);
541541
}
542542

543-
static inline void enetc_enable_txvlan(struct enetc_hw *hw, int si_idx,
544-
bool en)
543+
static inline void enetc_bdr_enable_txvlan(struct enetc_hw *hw, int idx,
544+
bool en)
545545
{
546-
u32 val = enetc_txbdr_rd(hw, si_idx, ENETC_TBMR);
546+
u32 val = enetc_txbdr_rd(hw, idx, ENETC_TBMR);
547547

548548
val = (val & ~ENETC_TBMR_VIH) | (en ? ENETC_TBMR_VIH : 0);
549-
enetc_txbdr_wr(hw, si_idx, ENETC_TBMR, val);
549+
enetc_txbdr_wr(hw, idx, ENETC_TBMR, val);
550550
}
551551

552552
static inline void enetc_set_bdr_prio(struct enetc_hw *hw, int bdr_idx,

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,6 @@ static int enetc_pf_set_features(struct net_device *ndev,
649649
netdev_features_t changed = ndev->features ^ features;
650650
struct enetc_ndev_priv *priv = netdev_priv(ndev);
651651

652-
if (changed & NETIF_F_HW_VLAN_CTAG_RX)
653-
enetc_enable_rxvlan(&priv->si->hw, 0,
654-
!!(features & NETIF_F_HW_VLAN_CTAG_RX));
655-
656-
if (changed & NETIF_F_HW_VLAN_CTAG_TX)
657-
enetc_enable_txvlan(&priv->si->hw, 0,
658-
!!(features & NETIF_F_HW_VLAN_CTAG_TX));
659-
660652
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
661653
struct enetc_pf *pf = enetc_si_priv(priv->si);
662654

0 commit comments

Comments
 (0)