@@ -360,6 +360,8 @@ enum rx_frame_status {
llc_snap = 0x4,
dma_own = 0x8,
rx_not_ls = 0x10,
+ /* Complete frame with a wire error, deliverable only with RXALL. */
+ rx_error_frame = 0x20,
};
/* Tx status */
@@ -321,6 +321,7 @@ struct stmmac_ops {
void (*set_mac)(void __iomem *ioaddr, bool enable);
/* Enable and verify that the IPC module is supported */
int (*rx_ipc)(struct mac_device_info *hw);
+ void (*set_rx_all)(struct stmmac_priv *priv, bool enable);
/* Enable RX Queues */
void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
/* RX Queues Priority */
@@ -5646,10 +5646,12 @@ static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
skb_record_rx_queue(skb, queue);
napi_gro_receive(&ch->rxtx_napi, skb);
- u64_stats_update_begin(&rxq_stats->napi_syncp);
- u64_stats_inc(&rxq_stats->napi.rx_packets);
- u64_stats_add(&rxq_stats->napi.rx_bytes, len);
- u64_stats_update_end(&rxq_stats->napi_syncp);
+ if (likely(!(status & rx_error_frame))) {
+ u64_stats_update_begin(&rxq_stats->napi_syncp);
+ u64_stats_inc(&rxq_stats->napi.rx_packets);
+ u64_stats_add(&rxq_stats->napi.rx_bytes, len);
+ u64_stats_update_end(&rxq_stats->napi_syncp);
+ }
}
static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
@@ -5707,6 +5709,21 @@ static struct stmmac_xdp_buff *xsk_buff_to_stmmac_ctx(struct xdp_buff *xdp)
return (struct stmmac_xdp_buff *)xdp;
}
+static bool stmmac_rx_discard(struct stmmac_priv *priv, int status, u32 *rx_errors)
+{
+ if (likely(!(status & (discard_frame | rx_error_frame))))
+ return false;
+
+ if (status & discard_frame) {
+ if (!priv->hwts_rx_en)
+ (*rx_errors)++;
+ return true;
+ }
+
+ (*rx_errors)++;
+ return !(READ_ONCE(priv->dev->features) & NETIF_F_RXALL);
+}
+
static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
{
struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue];
@@ -5797,11 +5814,8 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
status);
}
- if (unlikely(!error && (status & discard_frame))) {
- error = 1;
- if (!priv->hwts_rx_en)
- rx_errors++;
- }
+ if (!error)
+ error = stmmac_rx_discard(priv, status, &rx_errors);
if (unlikely(error)) {
xsk_buff_free(buf->xdp);
@@ -5995,11 +6009,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
status);
}
- if (unlikely(!error && (status & discard_frame))) {
- error = 1;
- if (!priv->hwts_rx_en)
- rx_errors++;
- }
+ if (!error)
+ error = stmmac_rx_discard(priv, status, &rx_errors);
/* We do not support SG in XDP mode */
if (unlikely(!error && (status & rx_not_ls) &&
@@ -6161,8 +6172,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
skb_record_rx_queue(skb, queue);
napi_gro_receive(&ch->rx_napi, skb);
- rx_packets++;
- rx_bytes += len;
+ if (likely(!(status & rx_error_frame))) {
+ rx_packets++;
+ rx_bytes += len;
+ }
next:
in_progress = false;
skb = NULL;
@@ -6444,6 +6457,11 @@ static int stmmac_set_features(struct net_device *netdev,
{
struct stmmac_priv *priv = netdev_priv(netdev);
+ if (((netdev->features ^ features) & NETIF_F_RXALL) &&
+ netif_running(netdev) && netif_device_present(netdev) &&
+ priv->hw->mac->set_rx_all)
+ priv->hw->mac->set_rx_all(priv, features & NETIF_F_RXALL);
+
/* Keep the COE Type in case of csum is supporting */
if (features & NETIF_F_RXCSUM)
priv->hw->rx_csum = priv->plat->rx_coe;
@@ -8276,6 +8294,8 @@ static int __stmmac_dvr_probe(struct device *device,
}
ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA;
+ if (priv->hw->mac->set_rx_all)
+ ndev->hw_features |= NETIF_F_RXALL;
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
#ifdef STMMAC_VLAN_TAG_USED
/* Both mac100 and gmac support receive VLAN tag detection */