usleep_range(10, 20);
}
+void fe_reset_fe(struct fe_priv *priv)
+{
+ if (!priv->rst_fe)
+ return;
+
+ reset_control_assert(priv->rst_fe);
+ usleep_range(60, 120);
+ reset_control_deassert(priv->rst_fe);
+ usleep_range(60, 120);
+}
+
static inline void fe_int_disable(u32 mask)
{
fe_reg_w32(fe_reg_r32(FE_REG_FE_INT_ENABLE) & ~mask,
/* TX SG offload */
nr_frags = skb_shinfo(skb)->nr_frags;
for (i = 0; i < nr_frags; i++) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
- struct skb_frag_struct *frag;
-#else
skb_frag_t *frag;
-#endif
frag = &skb_shinfo(skb)->frags[i];
if (fe_tx_dma_map_page(ring, &st, skb_frag_page(frag),
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
- frag->page_offset, skb_frag_size(frag)))
-#else
skb_frag_off(frag), skb_frag_size(frag)))
-#endif
goto err_dma;
}
netif_wake_queue(dev);
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
- if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !head->xmit_more)
-#else
if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !netdev_xmit_more())
-#endif
fe_reg_w32(ring->tx_next_idx, FE_REG_TX_CTX_IDX0);
return 0;
{
struct sk_buff *head = skb;
int i, nfrags = 0;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
- struct skb_frag_struct *frag;
-#else
skb_frag_t *frag;
-#endif
next_frag:
nfrags++;
if (skb_is_gso(skb)) {
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
frag = &skb_shinfo(skb)->frags[i];
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
- nfrags += DIV_ROUND_UP(frag->size, TX_DMA_BUF_LEN);
-#else
nfrags += DIV_ROUND_UP(skb_frag_size(frag), TX_DMA_BUF_LEN);
-#endif
}
} else {
nfrags += skb_shinfo(skb)->nr_frags;
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
RX_DMA_VID(trxd.rxd3));
-#ifdef CONFIG_NET_RALINK_OFFLOAD
- if (mtk_offload_check_rx(priv, skb, trxd.rxd4) == 0) {
-#endif
- stats->rx_packets++;
- stats->rx_bytes += pktlen;
+ stats->rx_packets++;
+ stats->rx_bytes += pktlen;
+
+ napi_gro_receive(napi, skb);
- napi_gro_receive(napi, skb);
-#ifdef CONFIG_NET_RALINK_OFFLOAD
- } else {
- dev_kfree_skb(skb);
- }
-#endif
ring->rx_data[idx] = new_data;
rxd->rxd1 = (unsigned int)dma_addr;
return rx_done;
}
-static void fe_tx_timeout(struct net_device *dev)
+static void fe_tx_timeout(struct net_device *dev, unsigned int txqueue)
{
struct fe_priv *priv = netdev_priv(dev);
struct fe_tx_ring *ring = &priv->tx_ring;
napi_enable(&priv->rx_napi);
fe_int_enable(priv->soc->tx_int | priv->soc->rx_int);
netif_start_queue(dev);
-#ifdef CONFIG_NET_RALINK_OFFLOAD
- mtk_ppe_probe(priv);
-#endif
return 0;
}
fe_free_dma(priv);
-#ifdef CONFIG_NET_RALINK_OFFLOAD
- mtk_ppe_remove(priv);
-#endif
-
return 0;
}
{
struct fe_priv *priv = netdev_priv(dev);
struct device_node *port;
- const char *mac_addr;
int err;
- priv->soc->reset_fe();
+ if (priv->soc->reset_fe)
+ priv->soc->reset_fe(priv);
+ else
+ fe_reset_fe(priv);
+
+ if (priv->soc->switch_init) {
+ err = priv->soc->switch_init(priv);
+ if (err) {
+ if (err == -EPROBE_DEFER)
+ return err;
- if (priv->soc->switch_init)
- if (priv->soc->switch_init(priv)) {
netdev_err(dev, "failed to initialize switch core\n");
return -ENODEV;
}
+ }
fe_reset_phy(priv);
- mac_addr = of_get_mac_address(priv->dev->of_node);
- if (!IS_ERR_OR_NULL(mac_addr))
- ether_addr_copy(dev->dev_addr, mac_addr);
+ of_get_mac_address(priv->dev->of_node, dev->dev_addr);
/* If the mac address is invalid, use random mac address */
if (!is_valid_ether_addr(dev->dev_addr)) {
return fe_open(dev);
}
-#ifdef CONFIG_NET_RALINK_OFFLOAD
-static int
-fe_flow_offload(enum flow_offload_type type, struct flow_offload *flow,
- struct flow_offload_hw_path *src,
- struct flow_offload_hw_path *dest)
-{
- struct fe_priv *priv;
-
- if (src->dev != dest->dev)
- return -EINVAL;
-
- priv = netdev_priv(src->dev);
-
- return mtk_flow_offload(priv, type, flow, src, dest);
-}
-#endif
-
static const struct net_device_ops fe_netdev_ops = {
.ndo_init = fe_init,
.ndo_uninit = fe_uninit,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = fe_poll_controller,
#endif
-#ifdef CONFIG_NET_RALINK_OFFLOAD
- .ndo_flow_offload = fe_flow_offload,
-#endif
};
static void fe_reset_pending(struct fe_priv *priv)
struct clk *sysclk;
int err, napi_weight;
- device_reset(&pdev->dev);
+ err = device_reset(&pdev->dev);
+ if (err)
+ dev_err(&pdev->dev, "failed to reset device\n");
match = of_match_device(of_fe_match, &pdev->dev);
soc = (struct fe_soc_data *)match->data;
goto err_free_dev;
}
+ priv = netdev_priv(netdev);
+ spin_lock_init(&priv->page_lock);
+ priv->rst_fe = devm_reset_control_get(&pdev->dev, "fe");
+ if (IS_ERR(priv->rst_fe))
+ priv->rst_fe = NULL;
+
if (soc->init_data)
soc->init_data(soc, netdev);
netdev->vlan_features = netdev->hw_features &
if (fe_reg_table[FE_REG_FE_DMA_VID_BASE])
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- priv = netdev_priv(netdev);
- spin_lock_init(&priv->page_lock);
if (fe_reg_table[FE_REG_FE_COUNTER_BASE]) {
priv->hw_stats = kzalloc(sizeof(*priv->hw_stats), GFP_KERNEL);
if (!priv->hw_stats) {