Commit fed38e64 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Jakub Kicinski

net: enetc: move enetc_set_psfp() out of the common enetc_set_features()

The VF netdev driver shouldn't respond to changes in the NETIF_F_HW_TC
flag; only PFs should. Moreover, TSN-specific code should go to
enetc_qos.c, which should not be included in the VF driver.

Fixes: 79e49982 ("net: enetc: add hw tc hw offload features for PSPF capability")
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20220916133209.3351399-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0507246d
...@@ -2600,29 +2600,6 @@ static int enetc_set_rss(struct net_device *ndev, int en) ...@@ -2600,29 +2600,6 @@ static int enetc_set_rss(struct net_device *ndev, int en)
return 0; return 0;
} }
static int enetc_set_psfp(struct net_device *ndev, int en)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
int err;
if (en) {
err = enetc_psfp_enable(priv);
if (err)
return err;
priv->active_offloads |= ENETC_F_QCI;
return 0;
}
err = enetc_psfp_disable(priv);
if (err)
return err;
priv->active_offloads &= ~ENETC_F_QCI;
return 0;
}
static void enetc_enable_rxvlan(struct net_device *ndev, bool en) static void enetc_enable_rxvlan(struct net_device *ndev, bool en)
{ {
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
...@@ -2641,11 +2618,9 @@ static void enetc_enable_txvlan(struct net_device *ndev, bool en) ...@@ -2641,11 +2618,9 @@ static void enetc_enable_txvlan(struct net_device *ndev, bool en)
enetc_bdr_enable_txvlan(&priv->si->hw, i, en); enetc_bdr_enable_txvlan(&priv->si->hw, i, en);
} }
int enetc_set_features(struct net_device *ndev, void enetc_set_features(struct net_device *ndev, netdev_features_t features)
netdev_features_t features)
{ {
netdev_features_t changed = ndev->features ^ features; netdev_features_t changed = ndev->features ^ features;
int err = 0;
if (changed & NETIF_F_RXHASH) if (changed & NETIF_F_RXHASH)
enetc_set_rss(ndev, !!(features & NETIF_F_RXHASH)); enetc_set_rss(ndev, !!(features & NETIF_F_RXHASH));
...@@ -2657,11 +2632,6 @@ int enetc_set_features(struct net_device *ndev, ...@@ -2657,11 +2632,6 @@ int enetc_set_features(struct net_device *ndev,
if (changed & NETIF_F_HW_VLAN_CTAG_TX) if (changed & NETIF_F_HW_VLAN_CTAG_TX)
enetc_enable_txvlan(ndev, enetc_enable_txvlan(ndev,
!!(features & NETIF_F_HW_VLAN_CTAG_TX)); !!(features & NETIF_F_HW_VLAN_CTAG_TX));
if (changed & NETIF_F_HW_TC)
err = enetc_set_psfp(ndev, !!(features & NETIF_F_HW_TC));
return err;
} }
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
......
...@@ -393,8 +393,7 @@ void enetc_start(struct net_device *ndev); ...@@ -393,8 +393,7 @@ void enetc_start(struct net_device *ndev);
void enetc_stop(struct net_device *ndev); void enetc_stop(struct net_device *ndev);
netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev); netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev);
struct net_device_stats *enetc_get_stats(struct net_device *ndev); struct net_device_stats *enetc_get_stats(struct net_device *ndev);
int enetc_set_features(struct net_device *ndev, void enetc_set_features(struct net_device *ndev, netdev_features_t features);
netdev_features_t features);
int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd); int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd);
int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type, int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type,
void *type_data); void *type_data);
...@@ -465,6 +464,7 @@ int enetc_setup_tc_block_cb(enum tc_setup_type type, void *type_data, ...@@ -465,6 +464,7 @@ int enetc_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
int enetc_setup_tc_psfp(struct net_device *ndev, void *type_data); int enetc_setup_tc_psfp(struct net_device *ndev, void *type_data);
int enetc_psfp_init(struct enetc_ndev_priv *priv); int enetc_psfp_init(struct enetc_ndev_priv *priv);
int enetc_psfp_clean(struct enetc_ndev_priv *priv); int enetc_psfp_clean(struct enetc_ndev_priv *priv);
int enetc_set_psfp(struct net_device *ndev, bool en);
static inline void enetc_get_max_cap(struct enetc_ndev_priv *priv) static inline void enetc_get_max_cap(struct enetc_ndev_priv *priv)
{ {
...@@ -540,4 +540,9 @@ static inline int enetc_psfp_disable(struct enetc_ndev_priv *priv) ...@@ -540,4 +540,9 @@ static inline int enetc_psfp_disable(struct enetc_ndev_priv *priv)
{ {
return 0; return 0;
} }
static inline int enetc_set_psfp(struct net_device *ndev, bool en)
{
return 0;
}
#endif #endif
...@@ -709,6 +709,13 @@ static int enetc_pf_set_features(struct net_device *ndev, ...@@ -709,6 +709,13 @@ static int enetc_pf_set_features(struct net_device *ndev,
{ {
netdev_features_t changed = ndev->features ^ features; netdev_features_t changed = ndev->features ^ features;
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
int err;
if (changed & NETIF_F_HW_TC) {
err = enetc_set_psfp(ndev, !!(features & NETIF_F_HW_TC));
if (err)
return err;
}
if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
struct enetc_pf *pf = enetc_si_priv(priv->si); struct enetc_pf *pf = enetc_si_priv(priv->si);
...@@ -722,7 +729,9 @@ static int enetc_pf_set_features(struct net_device *ndev, ...@@ -722,7 +729,9 @@ static int enetc_pf_set_features(struct net_device *ndev,
if (changed & NETIF_F_LOOPBACK) if (changed & NETIF_F_LOOPBACK)
enetc_set_loopback(ndev, !!(features & NETIF_F_LOOPBACK)); enetc_set_loopback(ndev, !!(features & NETIF_F_LOOPBACK));
return enetc_set_features(ndev, features); enetc_set_features(ndev, features);
return 0;
} }
static const struct net_device_ops enetc_ndev_ops = { static const struct net_device_ops enetc_ndev_ops = {
......
...@@ -1517,6 +1517,29 @@ int enetc_setup_tc_block_cb(enum tc_setup_type type, void *type_data, ...@@ -1517,6 +1517,29 @@ int enetc_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
} }
} }
int enetc_set_psfp(struct net_device *ndev, bool en)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
int err;
if (en) {
err = enetc_psfp_enable(priv);
if (err)
return err;
priv->active_offloads |= ENETC_F_QCI;
return 0;
}
err = enetc_psfp_disable(priv);
if (err)
return err;
priv->active_offloads &= ~ENETC_F_QCI;
return 0;
}
int enetc_psfp_init(struct enetc_ndev_priv *priv) int enetc_psfp_init(struct enetc_ndev_priv *priv)
{ {
if (epsfp.psfp_sfi_bitmap) if (epsfp.psfp_sfi_bitmap)
......
...@@ -88,7 +88,9 @@ static int enetc_vf_set_mac_addr(struct net_device *ndev, void *addr) ...@@ -88,7 +88,9 @@ static int enetc_vf_set_mac_addr(struct net_device *ndev, void *addr)
static int enetc_vf_set_features(struct net_device *ndev, static int enetc_vf_set_features(struct net_device *ndev,
netdev_features_t features) netdev_features_t features)
{ {
return enetc_set_features(ndev, features); enetc_set_features(ndev, features);
return 0;
} }
/* Probing/ Init */ /* Probing/ Init */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment