static void nps_enet_send_frame(struct net_device *ndev, struct sk_buff *skb) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 tx_ctrl_value = 0; short length = skb->len; u32 i, len = DIV_ROUND_UP(length, sizeof(u32)); u32 *src = (void *)skb->data; bool src_is_aligned = IS_ALIGNED((unsigned long)src, sizeof(u32)); /* In case src is not aligned we need an intermediate buffer */ if (src_is_aligned) iowrite32_rep(priv->regs_base + NPS_ENET_REG_TX_BUF, src, len); else /* !src_is_aligned */ for (i = 0; i < len; i++, src++) nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, get_unaligned_be32(src)); /* Write the length of the Frame */ tx_ctrl_value |= length << TX_CTL_NT_SHIFT; tx_ctrl_value |= NPS_ENET_ENABLE << TX_CTL_CT_SHIFT; /* Send Frame */ nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, tx_ctrl_value); }
/** * nps_enet_hw_reset - Reset the network device. * @ndev: Pointer to the network device. * * This function reset the PCS and TX fifo. * The programming model is to set the relevant reset bits * wait for some time for this to propagate and then unset * the reset bits. This way we ensure that reset procedure * is done successfully by device. */ static void nps_enet_hw_reset(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_ge_rst ge_rst; struct nps_enet_phase_fifo_ctl phase_fifo_ctl; ge_rst.value = 0; phase_fifo_ctl.value = 0; /* Pcs reset sequence*/ ge_rst.gmac_0 = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_GE_RST, ge_rst.value); usleep_range(10, 20); ge_rst.value = 0; nps_enet_reg_set(priv, NPS_ENET_REG_GE_RST, ge_rst.value); /* Tx fifo reset sequence */ phase_fifo_ctl.rst = NPS_ENET_ENABLE; phase_fifo_ctl.init = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_PHASE_FIFO_CTL, phase_fifo_ctl.value); usleep_range(10, 20); phase_fifo_ctl.value = 0; nps_enet_reg_set(priv, NPS_ENET_REG_PHASE_FIFO_CTL, phase_fifo_ctl.value); }
static void nps_enet_hw_disable_control(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); /* Disable interrupts */ nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0); /* Disable Rx and Tx */ nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_0, 0); }
static void nps_enet_tx_handler(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_tx_ctl tx_ctrl; tx_ctrl.value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL); /* Check if we got TX */ if (!priv->tx_packet_sent || tx_ctrl.ct) return; /* Ack Tx ctrl register */ nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, 0); /* Check Tx transmit error */ if (unlikely(tx_ctrl.et)) { ndev->stats.tx_errors++; } else { ndev->stats.tx_packets++; ndev->stats.tx_bytes += tx_ctrl.nt; } dev_kfree_skb(priv->tx_skb); priv->tx_packet_sent = false; if (netif_queue_stopped(ndev)) netif_wake_queue(ndev); }
static void nps_enet_tx_handler(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL); u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT; u32 tx_ctrl_et = (tx_ctrl_value & TX_CTL_ET_MASK) >> TX_CTL_ET_SHIFT; u32 tx_ctrl_nt = (tx_ctrl_value & TX_CTL_NT_MASK) >> TX_CTL_NT_SHIFT; /* Check if we got TX */ if (!priv->tx_skb || tx_ctrl_ct) return; /* Ack Tx ctrl register */ nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, 0); /* Check Tx transmit error */ if (unlikely(tx_ctrl_et)) { ndev->stats.tx_errors++; } else { ndev->stats.tx_packets++; ndev->stats.tx_bytes += tx_ctrl_nt; } dev_kfree_skb(priv->tx_skb); priv->tx_skb = NULL; if (netif_queue_stopped(ndev)) netif_wake_queue(ndev); }
static void nps_enet_set_hw_mac_address(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_ge_mac_cfg_1 ge_mac_cfg_1; struct nps_enet_ge_mac_cfg_2 *ge_mac_cfg_2 = &priv->ge_mac_cfg_2; /* set MAC address in HW */ ge_mac_cfg_1.octet_0 = ndev->dev_addr[0]; ge_mac_cfg_1.octet_1 = ndev->dev_addr[1]; ge_mac_cfg_1.octet_2 = ndev->dev_addr[2]; ge_mac_cfg_1.octet_3 = ndev->dev_addr[3]; ge_mac_cfg_2->octet_4 = ndev->dev_addr[4]; ge_mac_cfg_2->octet_5 = ndev->dev_addr[5]; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_1, ge_mac_cfg_1.value); nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, ge_mac_cfg_2->value); }
/** * nps_enet_hw_reset - Reset the network device. * @ndev: Pointer to the network device. * * This function reset the PCS and TX fifo. * The programming model is to set the relevant reset bits * wait for some time for this to propagate and then unset * the reset bits. This way we ensure that reset procedure * is done successfully by device. */ static void nps_enet_hw_reset(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 ge_rst_value = 0, phase_fifo_ctl_value = 0; /* Pcs reset sequence*/ ge_rst_value |= NPS_ENET_ENABLE << RST_GMAC_0_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_GE_RST, ge_rst_value); usleep_range(10, 20); ge_rst_value = 0; nps_enet_reg_set(priv, NPS_ENET_REG_GE_RST, ge_rst_value); /* Tx fifo reset sequence */ phase_fifo_ctl_value |= NPS_ENET_ENABLE << PHASE_FIFO_CTL_RST_SHIFT; phase_fifo_ctl_value |= NPS_ENET_ENABLE << PHASE_FIFO_CTL_INIT_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_PHASE_FIFO_CTL, phase_fifo_ctl_value); usleep_range(10, 20); phase_fifo_ctl_value = 0; nps_enet_reg_set(priv, NPS_ENET_REG_PHASE_FIFO_CTL, phase_fifo_ctl_value); }
static void nps_enet_set_hw_mac_address(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 ge_mac_cfg_1_value = 0; u32 *ge_mac_cfg_2_value = &priv->ge_mac_cfg_2_value; /* set MAC address in HW */ ge_mac_cfg_1_value |= ndev->dev_addr[0] << CFG_1_OCTET_0_SHIFT; ge_mac_cfg_1_value |= ndev->dev_addr[1] << CFG_1_OCTET_1_SHIFT; ge_mac_cfg_1_value |= ndev->dev_addr[2] << CFG_1_OCTET_2_SHIFT; ge_mac_cfg_1_value |= ndev->dev_addr[3] << CFG_1_OCTET_3_SHIFT; *ge_mac_cfg_2_value = (*ge_mac_cfg_2_value & ~CFG_2_OCTET_4_MASK) | ndev->dev_addr[4] << CFG_2_OCTET_4_SHIFT; *ge_mac_cfg_2_value = (*ge_mac_cfg_2_value & ~CFG_2_OCTET_5_MASK) | ndev->dev_addr[5] << CFG_2_OCTET_5_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_1, ge_mac_cfg_1_value); nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, *ge_mac_cfg_2_value); }
/** * nps_enet_poll - NAPI poll handler. * @napi: Pointer to napi_struct structure. * @budget: How many frames to process on one call. * * returns: Number of processed frames */ static int nps_enet_poll(struct napi_struct *napi, int budget) { struct net_device *ndev = napi->dev; struct nps_enet_priv *priv = netdev_priv(ndev); u32 work_done; nps_enet_tx_handler(ndev); work_done = nps_enet_rx_handler(ndev); if (work_done < budget) { u32 buf_int_enable_value = 0; u32 tx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL); u32 tx_ctrl_ct = (tx_ctrl_value & TX_CTL_CT_MASK) >> TX_CTL_CT_SHIFT; napi_complete(napi); /* set tx_done and rx_rdy bits */ buf_int_enable_value |= NPS_ENET_ENABLE << RX_RDY_SHIFT; buf_int_enable_value |= NPS_ENET_ENABLE << TX_DONE_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, buf_int_enable_value); /* in case we will get a tx interrupt while interrupts * are masked, we will lose it since the tx is edge interrupt. * specifically, while executing the code section above, * between nps_enet_tx_handler and the interrupts enable, all * tx requests will be stuck until we will get an rx interrupt. * the two code lines below will solve this situation by * re-adding ourselves to the poll list. */ if (priv->tx_skb && !tx_ctrl_ct) { nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0); napi_reschedule(napi); } }
/** * nps_enet_irq_handler - Global interrupt handler for ENET. * @irq: irq number. * @dev_instance: device instance. * * returns: IRQ_HANDLED for all cases. * * EZchip ENET has 2 interrupt causes, and depending on bits raised in * CTRL registers we may tell what is a reason for interrupt to fire up. * We got one for RX and the other for TX (completion). */ static irqreturn_t nps_enet_irq_handler(s32 irq, void *dev_instance) { struct net_device *ndev = dev_instance; struct nps_enet_priv *priv = netdev_priv(ndev); u32 rx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_RX_CTL); u32 rx_ctrl_cr = (rx_ctrl_value & RX_CTL_CR_MASK) >> RX_CTL_CR_SHIFT; if (nps_enet_is_tx_pending(priv) || rx_ctrl_cr) if (likely(napi_schedule_prep(&priv->napi))) { nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0); __napi_schedule(&priv->napi); } return IRQ_HANDLED; }
static void nps_enet_send_frame(struct net_device *ndev, struct sk_buff *skb) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_tx_ctl tx_ctrl; short length = skb->len; u32 i, len = DIV_ROUND_UP(length, sizeof(u32)); u32 *src = (u32 *)virt_to_phys(skb->data); bool src_is_aligned = IS_ALIGNED((unsigned long)src, sizeof(u32)); tx_ctrl.value = 0; /* In case src is not aligned we need an intermediate buffer */ if (src_is_aligned) for (i = 0; i < len; i++, src++) nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, *src); else { /* !src_is_aligned */ for (i = 0; i < len; i++, src++) { u32 buf; /* to accommodate word-unaligned address of "src" * we have to do memcpy_fromio() instead of simple "=" */ memcpy_fromio(&buf, (void __iomem *)src, sizeof(buf)); nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, buf); } } /* Write the length of the Frame */ tx_ctrl.nt = length; /* Indicate SW is done */ priv->tx_packet_sent = true; tx_ctrl.ct = NPS_ENET_ENABLE; /* Send Frame */ nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, tx_ctrl.value); }
/** * nps_enet_set_rx_mode - Change the receive filtering mode. * @ndev: Pointer to the network device. * * This function enables/disables promiscuous mode */ static void nps_enet_set_rx_mode(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_ge_mac_cfg_2 ge_mac_cfg_2; ge_mac_cfg_2.value = priv->ge_mac_cfg_2.value; if (ndev->flags & IFF_PROMISC) { ge_mac_cfg_2.disc_da = NPS_ENET_DISABLE; ge_mac_cfg_2.disc_mc = NPS_ENET_DISABLE; } else { ge_mac_cfg_2.disc_da = NPS_ENET_ENABLE; ge_mac_cfg_2.disc_mc = NPS_ENET_ENABLE; } nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, ge_mac_cfg_2.value); }
/** * nps_enet_irq_handler - Global interrupt handler for ENET. * @irq: irq number. * @dev_instance: device instance. * * returns: IRQ_HANDLED for all cases. * * EZchip ENET has 2 interrupt causes, and depending on bits raised in * CTRL registers we may tell what is a reason for interrupt to fire up. * We got one for RX and the other for TX (completion). */ static irqreturn_t nps_enet_irq_handler(s32 irq, void *dev_instance) { struct net_device *ndev = dev_instance; struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_rx_ctl rx_ctrl; struct nps_enet_tx_ctl tx_ctrl; rx_ctrl.value = nps_enet_reg_get(priv, NPS_ENET_REG_RX_CTL); tx_ctrl.value = nps_enet_reg_get(priv, NPS_ENET_REG_TX_CTL); if ((!tx_ctrl.ct && priv->tx_packet_sent) || rx_ctrl.cr) if (likely(napi_schedule_prep(&priv->napi))) { nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, 0); __napi_schedule(&priv->napi); } return IRQ_HANDLED; }
/** * nps_enet_set_rx_mode - Change the receive filtering mode. * @ndev: Pointer to the network device. * * This function enables/disables promiscuous mode */ static void nps_enet_set_rx_mode(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 ge_mac_cfg_2_value = priv->ge_mac_cfg_2_value; if (ndev->flags & IFF_PROMISC) { ge_mac_cfg_2_value = (ge_mac_cfg_2_value & ~CFG_2_DISK_DA_MASK) | NPS_ENET_DISABLE << CFG_2_DISK_DA_SHIFT; ge_mac_cfg_2_value = (ge_mac_cfg_2_value & ~CFG_2_DISK_MC_MASK) | NPS_ENET_DISABLE << CFG_2_DISK_MC_SHIFT; } else { ge_mac_cfg_2_value = (ge_mac_cfg_2_value & ~CFG_2_DISK_DA_MASK) | NPS_ENET_ENABLE << CFG_2_DISK_DA_SHIFT; ge_mac_cfg_2_value = (ge_mac_cfg_2_value & ~CFG_2_DISK_MC_MASK) | NPS_ENET_ENABLE << CFG_2_DISK_MC_SHIFT; } nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, ge_mac_cfg_2_value); }
/** * nps_enet_poll - NAPI poll handler. * @napi: Pointer to napi_struct structure. * @budget: How many frames to process on one call. * * returns: Number of processed frames */ static int nps_enet_poll(struct napi_struct *napi, int budget) { struct net_device *ndev = napi->dev; struct nps_enet_priv *priv = netdev_priv(ndev); u32 work_done; nps_enet_tx_handler(ndev); work_done = nps_enet_rx_handler(ndev); if (work_done < budget) { struct nps_enet_buf_int_enable buf_int_enable; napi_complete(napi); buf_int_enable.rx_rdy = NPS_ENET_ENABLE; buf_int_enable.tx_done = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, buf_int_enable.value); } return work_done; }
static u32 nps_enet_rx_handler(struct net_device *ndev) { u32 frame_len, err = 0; u32 work_done = 0; struct nps_enet_priv *priv = netdev_priv(ndev); struct sk_buff *skb; u32 rx_ctrl_value = nps_enet_reg_get(priv, NPS_ENET_REG_RX_CTL); u32 rx_ctrl_cr = (rx_ctrl_value & RX_CTL_CR_MASK) >> RX_CTL_CR_SHIFT; u32 rx_ctrl_er = (rx_ctrl_value & RX_CTL_ER_MASK) >> RX_CTL_ER_SHIFT; u32 rx_ctrl_crc = (rx_ctrl_value & RX_CTL_CRC_MASK) >> RX_CTL_CRC_SHIFT; frame_len = (rx_ctrl_value & RX_CTL_NR_MASK) >> RX_CTL_NR_SHIFT; /* Check if we got RX */ if (!rx_ctrl_cr) return work_done; /* If we got here there is a work for us */ work_done++; /* Check Rx error */ if (rx_ctrl_er) { ndev->stats.rx_errors++; err = 1; } /* Check Rx CRC error */ if (rx_ctrl_crc) { ndev->stats.rx_crc_errors++; ndev->stats.rx_dropped++; err = 1; } /* Check Frame length Min 64b */ if (unlikely(frame_len < ETH_ZLEN)) { ndev->stats.rx_length_errors++; ndev->stats.rx_dropped++; err = 1; } if (err) goto rx_irq_clean; /* Skb allocation */ skb = netdev_alloc_skb_ip_align(ndev, frame_len); if (unlikely(!skb)) { ndev->stats.rx_errors++; ndev->stats.rx_dropped++; goto rx_irq_clean; } /* Copy frame from Rx fifo into the skb */ nps_enet_read_rx_fifo(ndev, skb->data, frame_len); skb_put(skb, frame_len); skb->protocol = eth_type_trans(skb, ndev); skb->ip_summed = CHECKSUM_UNNECESSARY; ndev->stats.rx_packets++; ndev->stats.rx_bytes += frame_len; netif_receive_skb(skb); goto rx_irq_frame_done; rx_irq_clean: /* Clean Rx fifo */ nps_enet_clean_rx_fifo(ndev, frame_len); rx_irq_frame_done: /* Ack Rx ctrl register */ nps_enet_reg_set(priv, NPS_ENET_REG_RX_CTL, 0); return work_done; }
static void nps_enet_hw_enable_control(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); u32 ge_mac_cfg_0_value = 0, buf_int_enable_value = 0; u32 *ge_mac_cfg_2_value = &priv->ge_mac_cfg_2_value; u32 *ge_mac_cfg_3_value = &priv->ge_mac_cfg_3_value; s32 max_frame_length; /* Enable Rx and Tx statistics */ *ge_mac_cfg_2_value = (*ge_mac_cfg_2_value & ~CFG_2_STAT_EN_MASK) | NPS_ENET_GE_MAC_CFG_2_STAT_EN << CFG_2_STAT_EN_SHIFT; /* Discard packets with different MAC address */ *ge_mac_cfg_2_value = (*ge_mac_cfg_2_value & ~CFG_2_DISK_DA_MASK) | NPS_ENET_ENABLE << CFG_2_DISK_DA_SHIFT; /* Discard multicast packets */ *ge_mac_cfg_2_value = (*ge_mac_cfg_2_value & ~CFG_2_DISK_MC_MASK) | NPS_ENET_ENABLE << CFG_2_DISK_MC_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, *ge_mac_cfg_2_value); /* Discard Packets bigger than max frame length */ max_frame_length = ETH_HLEN + ndev->mtu + ETH_FCS_LEN; if (max_frame_length <= NPS_ENET_MAX_FRAME_LENGTH) { *ge_mac_cfg_3_value = (*ge_mac_cfg_3_value & ~CFG_3_MAX_LEN_MASK) | max_frame_length << CFG_3_MAX_LEN_SHIFT; } /* Enable interrupts */ buf_int_enable_value |= NPS_ENET_ENABLE << RX_RDY_SHIFT; buf_int_enable_value |= NPS_ENET_ENABLE << TX_DONE_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, buf_int_enable_value); /* Write device MAC address to HW */ nps_enet_set_hw_mac_address(ndev); /* Rx and Tx HW features */ ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_TX_PAD_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_TX_CRC_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_RX_CRC_STRIP_SHIFT; /* IFG configuration */ ge_mac_cfg_0_value |= NPS_ENET_GE_MAC_CFG_0_RX_IFG << CFG_0_RX_IFG_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_GE_MAC_CFG_0_TX_IFG << CFG_0_TX_IFG_SHIFT; /* preamble configuration */ ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_RX_PR_CHECK_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_GE_MAC_CFG_0_TX_PR_LEN << CFG_0_TX_PR_LEN_SHIFT; /* enable flow control frames */ ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_TX_FC_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_RX_FC_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_GE_MAC_CFG_0_TX_FC_RETR << CFG_0_TX_FC_RETR_SHIFT; *ge_mac_cfg_3_value = (*ge_mac_cfg_3_value & ~CFG_3_CF_DROP_MASK) | NPS_ENET_ENABLE << CFG_3_CF_DROP_SHIFT; /* Enable Rx and Tx */ ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_RX_EN_SHIFT; ge_mac_cfg_0_value |= NPS_ENET_ENABLE << CFG_0_TX_EN_SHIFT; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_3, *ge_mac_cfg_3_value); nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_0, ge_mac_cfg_0_value); }
static void nps_enet_hw_enable_control(struct net_device *ndev) { struct nps_enet_priv *priv = netdev_priv(ndev); struct nps_enet_ge_mac_cfg_0 ge_mac_cfg_0; struct nps_enet_buf_int_enable buf_int_enable; struct nps_enet_ge_mac_cfg_2 *ge_mac_cfg_2 = &priv->ge_mac_cfg_2; struct nps_enet_ge_mac_cfg_3 *ge_mac_cfg_3 = &priv->ge_mac_cfg_3; s32 max_frame_length; ge_mac_cfg_0.value = 0; buf_int_enable.value = 0; /* Enable Rx and Tx statistics */ ge_mac_cfg_2->stat_en = NPS_ENET_GE_MAC_CFG_2_STAT_EN; /* Discard packets with different MAC address */ ge_mac_cfg_2->disc_da = NPS_ENET_ENABLE; /* Discard multicast packets */ ge_mac_cfg_2->disc_mc = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_2, ge_mac_cfg_2->value); /* Discard Packets bigger than max frame length */ max_frame_length = ETH_HLEN + ndev->mtu + ETH_FCS_LEN; if (max_frame_length <= NPS_ENET_MAX_FRAME_LENGTH) ge_mac_cfg_3->max_len = max_frame_length; /* Enable interrupts */ buf_int_enable.rx_rdy = NPS_ENET_ENABLE; buf_int_enable.tx_done = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_BUF_INT_ENABLE, buf_int_enable.value); /* Write device MAC address to HW */ nps_enet_set_hw_mac_address(ndev); /* Rx and Tx HW features */ ge_mac_cfg_0.tx_pad_en = NPS_ENET_ENABLE; ge_mac_cfg_0.tx_crc_en = NPS_ENET_ENABLE; ge_mac_cfg_0.rx_crc_strip = NPS_ENET_ENABLE; /* IFG configuration */ ge_mac_cfg_0.rx_ifg = NPS_ENET_GE_MAC_CFG_0_RX_IFG; ge_mac_cfg_0.tx_ifg = NPS_ENET_GE_MAC_CFG_0_TX_IFG; /* preamble configuration */ ge_mac_cfg_0.rx_pr_check_en = NPS_ENET_ENABLE; ge_mac_cfg_0.tx_pr_len = NPS_ENET_GE_MAC_CFG_0_TX_PR_LEN; /* enable flow control frames */ ge_mac_cfg_0.tx_fc_en = NPS_ENET_ENABLE; ge_mac_cfg_0.rx_fc_en = NPS_ENET_ENABLE; ge_mac_cfg_0.tx_fc_retr = NPS_ENET_GE_MAC_CFG_0_TX_FC_RETR; ge_mac_cfg_3->cf_drop = NPS_ENET_ENABLE; /* Enable Rx and Tx */ ge_mac_cfg_0.rx_en = NPS_ENET_ENABLE; ge_mac_cfg_0.tx_en = NPS_ENET_ENABLE; nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_3, ge_mac_cfg_3->value); nps_enet_reg_set(priv, NPS_ENET_REG_GE_MAC_CFG_0, ge_mac_cfg_0.value); }