* [PATCH (net.git) 1/2] stmmac: fix the rx csum feature
@ 2014-09-01 7:17 Giuseppe Cavallaro
2014-09-01 7:17 ` [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available Giuseppe Cavallaro
2014-09-02 4:52 ` [PATCH (net.git) 1/2] stmmac: fix the rx csum feature David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Giuseppe Cavallaro @ 2014-09-01 7:17 UTC (permalink / raw)
To: netdev; +Cc: Giuseppe Cavallaro
For new GMACs it is possible to turn-on/off the COE.
In the current driver, when disabled the Rx-checksum
via ethtool, the tool reported that csum was disabled
but the HW continued to set the IPC. Indeed this is
because the fix_features allows this. So the patch
fixes this problem by adding the set_features.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 1 +
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 6 +++-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 27 ++++++++++++++++++-
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index bd54238..a2aba1f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -445,6 +445,7 @@ struct mac_device_info {
int multicast_filter_bins;
int unicast_filter_entries;
int mcast_bits_log2;
+ unsigned int rx_csum;
};
struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr, int mcbins,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index d8ef187..5efe60e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -58,7 +58,11 @@ static int dwmac1000_rx_ipc_enable(struct mac_device_info *hw)
void __iomem *ioaddr = hw->pcsr;
u32 value = readl(ioaddr + GMAC_CONTROL);
- value |= GMAC_CONTROL_IPC;
+ if (hw->rx_csum)
+ value |= GMAC_CONTROL_IPC;
+ else
+ value &= ~GMAC_CONTROL_IPC;
+
writel(value, ioaddr + GMAC_CONTROL);
value = readl(ioaddr + GMAC_CONTROL);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index df15f00..56e5c1b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1669,6 +1669,7 @@ static int stmmac_hw_setup(struct net_device *dev)
if (!ret) {
pr_warn(" RX IPC Checksum Offload disabled\n");
priv->plat->rx_coe = STMMAC_RX_COE_NONE;
+ priv->hw->rx_csum = 0;
}
/* Enable the MAC Rx/Tx */
@@ -2107,7 +2108,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
unsigned int entry = priv->cur_rx % rxsize;
unsigned int next_entry;
unsigned int count = 0;
- int coe = priv->plat->rx_coe;
+ int coe = priv->hw->rx_csum;
if (netif_msg_rx_status(priv)) {
pr_debug("%s: descriptor ring:\n", __func__);
@@ -2330,6 +2331,7 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
features &= ~NETIF_F_RXCSUM;
else if (priv->plat->rx_coe == STMMAC_RX_COE_TYPE1)
features &= ~NETIF_F_IPV6_CSUM;
+
if (!priv->plat->tx_coe)
features &= ~NETIF_F_ALL_CSUM;
@@ -2344,6 +2346,24 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
return features;
}
+static int stmmac_set_features(struct net_device *netdev,
+ netdev_features_t features)
+{
+ struct stmmac_priv *priv = netdev_priv(netdev);
+
+ /* Keep the COE Type in case of csum is supporting */
+ if (features & NETIF_F_RXCSUM)
+ priv->hw->rx_csum = priv->plat->rx_coe;
+ else
+ priv->hw->rx_csum = 0;
+ /* No check needed because rx_coe has been set before and it will be
+ * fixed in case of issue.
+ */
+ priv->hw->mac->rx_ipc(priv->hw);
+
+ return 0;
+}
+
/**
* stmmac_interrupt - main ISR
* @irq: interrupt number.
@@ -2624,6 +2644,7 @@ static const struct net_device_ops stmmac_netdev_ops = {
.ndo_stop = stmmac_release,
.ndo_change_mtu = stmmac_change_mtu,
.ndo_fix_features = stmmac_fix_features,
+ .ndo_set_features = stmmac_set_features,
.ndo_set_rx_mode = stmmac_set_rx_mode,
.ndo_tx_timeout = stmmac_tx_timeout,
.ndo_do_ioctl = stmmac_ioctl,
@@ -2700,9 +2721,11 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
/* To use alternate (extended) or normal descriptor structures */
stmmac_selec_desc_mode(priv);
- if (priv->plat->rx_coe)
+ if (priv->plat->rx_coe) {
+ priv->hw->rx_csum = priv->plat->rx_coe;
pr_info(" RX Checksum Offload Engine supported (type %d)\n",
priv->plat->rx_coe);
+ }
if (priv->plat->tx_coe)
pr_info(" TX Checksum insertion supported\n");
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available
2014-09-01 7:17 [PATCH (net.git) 1/2] stmmac: fix the rx csum feature Giuseppe Cavallaro
@ 2014-09-01 7:17 ` Giuseppe Cavallaro
2014-09-02 4:52 ` David Miller
2014-09-02 4:52 ` [PATCH (net.git) 1/2] stmmac: fix the rx csum feature David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Giuseppe Cavallaro @ 2014-09-01 7:17 UTC (permalink / raw)
To: netdev; +Cc: Giuseppe Cavallaro
In case of the HW is not able to do the receive checksum offloading
the only feature to remove is NETIF_F_RXCSUM.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 56e5c1b..8da95d56 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2329,8 +2329,6 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
if (priv->plat->rx_coe == STMMAC_RX_COE_NONE)
features &= ~NETIF_F_RXCSUM;
- else if (priv->plat->rx_coe == STMMAC_RX_COE_TYPE1)
- features &= ~NETIF_F_IPV6_CSUM;
if (!priv->plat->tx_coe)
features &= ~NETIF_F_ALL_CSUM;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH (net.git) 1/2] stmmac: fix the rx csum feature
2014-09-01 7:17 [PATCH (net.git) 1/2] stmmac: fix the rx csum feature Giuseppe Cavallaro
2014-09-01 7:17 ` [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available Giuseppe Cavallaro
@ 2014-09-02 4:52 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-09-02 4:52 UTC (permalink / raw)
To: peppe.cavallaro; +Cc: netdev
From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Mon, 1 Sep 2014 09:17:52 +0200
> For new GMACs it is possible to turn-on/off the COE.
> In the current driver, when disabled the Rx-checksum
> via ethtool, the tool reported that csum was disabled
> but the HW continued to set the IPC. Indeed this is
> because the fix_features allows this. So the patch
> fixes this problem by adding the set_features.
>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available
2014-09-01 7:17 ` [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available Giuseppe Cavallaro
@ 2014-09-02 4:52 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-09-02 4:52 UTC (permalink / raw)
To: peppe.cavallaro; +Cc: netdev
From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Mon, 1 Sep 2014 09:17:53 +0200
> In case of the HW is not able to do the receive checksum offloading
> the only feature to remove is NETIF_F_RXCSUM.
>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-02 4:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-01 7:17 [PATCH (net.git) 1/2] stmmac: fix the rx csum feature Giuseppe Cavallaro
2014-09-01 7:17 ` [PATCH (net.git) 2/2] stmmac: only remove RXCSUM feature if no rx coe is available Giuseppe Cavallaro
2014-09-02 4:52 ` David Miller
2014-09-02 4:52 ` [PATCH (net.git) 1/2] stmmac: fix the rx csum feature David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).