2021-05-13 16:33:40 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 - 2019 Xilinx, Inc.
|
|
|
|
* Copyright (C) 2021 WangHuachen.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
|
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
|
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the lwIP TCP/IP stack.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <xparameters.h>
|
|
|
|
#include "lwipopts.h"
|
|
|
|
#include "xlwipconfig.h"
|
|
|
|
#include "lwip/opt.h"
|
|
|
|
#include "lwip/def.h"
|
|
|
|
#include "lwip/mem.h"
|
|
|
|
#include "lwip/pbuf.h"
|
|
|
|
#include "lwip/sys.h"
|
|
|
|
#include "lwip/stats.h"
|
|
|
|
#include "lwip/igmp.h"
|
|
|
|
|
|
|
|
#include "netif/etharp.h"
|
|
|
|
#include "netif/xemacpsif.h"
|
|
|
|
#include "netif/xadapter.h"
|
|
|
|
#include "netif/xpqueue.h"
|
|
|
|
#include "xparameters.h"
|
|
|
|
// #include "xscugic.h"
|
|
|
|
#include "xemacps.h"
|
|
|
|
|
|
|
|
#if LWIP_IPV6
|
|
|
|
#include "lwip/ethip6.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYS_ARCH_DECL_PROTECT
|
|
|
|
#undef SYS_ARCH_DECL_PROTECT
|
|
|
|
#endif
|
|
|
|
#define SYS_ARCH_DECL_PROTECT(lev) rt_base_t lev;
|
|
|
|
|
|
|
|
#ifdef SYS_ARCH_PROTECT
|
|
|
|
#undef SYS_ARCH_PROTECT
|
|
|
|
#endif
|
|
|
|
#define SYS_ARCH_PROTECT(lev) lev = rt_hw_interrupt_disable();
|
|
|
|
|
|
|
|
#ifdef SYS_ARCH_UNPROTECT
|
|
|
|
#undef SYS_ARCH_UNPROTECT
|
|
|
|
#endif
|
|
|
|
#define SYS_ARCH_UNPROTECT(lev) rt_hw_interrupt_enable(lev);
|
|
|
|
|
|
|
|
/* Define those to better describe your network interface. */
|
|
|
|
#define IFNAME0 't'
|
|
|
|
#define IFNAME1 'e'
|
|
|
|
|
|
|
|
#if LWIP_IGMP
|
|
|
|
static err_t xemacpsif_mac_filter_update (struct netif *netif,
|
2021-05-14 14:42:21 +08:00
|
|
|
ip_addr_t *group, u8_t action);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
static u8_t xemacps_mcast_entry_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
|
|
|
static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
|
2021-05-14 14:42:21 +08:00
|
|
|
ip_addr_t *group, u8_t action);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
static u8_t xemacps_mld6_mcast_entry_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
XEmacPs_Config *mac_config;
|
|
|
|
struct netif *NetIf;
|
|
|
|
|
|
|
|
#if defined(OS_IS_FREERTOS) && defined(__arm__) && !defined(ARMR5)
|
|
|
|
int32_t lExpireCounter = 0;
|
|
|
|
#define RESETRXTIMEOUT 10
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this function is always called with interrupts off
|
|
|
|
* this function also assumes that there are available BD's
|
|
|
|
*/
|
|
|
|
err_t _unbuffered_low_level_output(xemacpsif_s *xemacpsif,
|
2021-05-14 14:42:21 +08:00
|
|
|
struct pbuf *p)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
XStatus status = 0;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#if ETH_PAD_SIZE
|
2021-05-14 14:42:21 +08:00
|
|
|
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
2021-05-14 14:22:23 +08:00
|
|
|
status = emacps_sgsend(xemacpsif, p);
|
|
|
|
if (status != XST_SUCCESS) {
|
2021-05-13 16:33:40 +08:00
|
|
|
#if LINK_STATS
|
2021-05-14 14:22:23 +08:00
|
|
|
lwip_stats.link.drop++;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
2021-05-14 14:42:21 +08:00
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#if ETH_PAD_SIZE
|
2021-05-14 14:42:21 +08:00
|
|
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LINK_STATS
|
2021-05-14 14:22:23 +08:00
|
|
|
lwip_stats.link.xmit++;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif /* LINK_STATS */
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
return ERR_OK;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* low_level_output():
|
|
|
|
*
|
|
|
|
* Should do the actual transmission of the packet. The packet is
|
|
|
|
* contained in the pbuf that is passed to the function. This pbuf
|
|
|
|
* might be chained.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
err_t err;
|
|
|
|
s32_t freecnt;
|
|
|
|
XEmacPs_BdRing *txring;
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
struct xemac_s *xemac = (struct xemac_s *)(netif->state);
|
|
|
|
xemacpsif_s *xemacpsif = (xemacpsif_s *)(xemac->state);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* check if space is available to send */
|
2021-05-13 16:33:40 +08:00
|
|
|
freecnt = is_tx_space_available(xemacpsif);
|
|
|
|
if (freecnt <= 5) {
|
2021-05-14 14:22:23 +08:00
|
|
|
txring = &(XEmacPs_GetTxRing(&xemacpsif->emacps));
|
2021-05-14 14:42:21 +08:00
|
|
|
process_sent_bds(xemacpsif, txring);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
if (is_tx_space_available(xemacpsif)) {
|
2021-05-14 14:42:21 +08:00
|
|
|
_unbuffered_low_level_output(xemacpsif, p);
|
|
|
|
err = ERR_OK;
|
|
|
|
} else {
|
2021-05-13 16:33:40 +08:00
|
|
|
#if LINK_STATS
|
2021-05-14 14:42:21 +08:00
|
|
|
lwip_stats.link.drop++;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
2021-05-14 14:42:21 +08:00
|
|
|
rt_kprintf("pack dropped, no space\r\n");
|
|
|
|
err = ERR_MEM;
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
|
|
|
return err;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* low_level_input():
|
|
|
|
*
|
|
|
|
* Should allocate a pbuf and transfer the bytes of the incoming
|
|
|
|
* packet from the interface into the pbuf.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static struct pbuf * low_level_input(struct netif *netif)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
struct xemac_s *xemac = (struct xemac_s *)(netif->state);
|
|
|
|
xemacpsif_s *xemacpsif = (xemacpsif_s *)(xemac->state);
|
|
|
|
struct pbuf *p;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* see if there is data to process */
|
2021-05-14 14:22:23 +08:00
|
|
|
if (pq_qlength(xemacpsif->recv_q) == 0)
|
2021-05-14 14:42:21 +08:00
|
|
|
return NULL;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* return one packet from receive q */
|
2021-05-14 14:22:23 +08:00
|
|
|
p = (struct pbuf *)pq_dequeue(xemacpsif->recv_q);
|
|
|
|
return p;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xemacpsif_output():
|
|
|
|
*
|
|
|
|
* This function is called by the TCP/IP stack when an IP packet
|
|
|
|
* should be sent. It calls the function called low_level_output() to
|
|
|
|
* do the actual transmission of the packet.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
|
2021-05-14 14:42:21 +08:00
|
|
|
const ip_addr_t *ipaddr)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:42:21 +08:00
|
|
|
/* resolve hardware address, then send (or queue) packet */
|
2021-05-14 14:22:23 +08:00
|
|
|
return etharp_output(netif, p, ipaddr);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xemacpsif_input():
|
|
|
|
*
|
|
|
|
* This function should be called when a packet is ready to be read
|
|
|
|
* from the interface. It uses the function low_level_input() that
|
|
|
|
* should handle the actual reception of bytes from the network
|
|
|
|
* interface.
|
|
|
|
*
|
|
|
|
* Returns the number of packets read (max 1 packet on success,
|
|
|
|
* 0 if there are no packets)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
s32_t xemacpsif_input(struct netif *netif)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
struct eth_hdr *ethhdr;
|
|
|
|
struct pbuf *p;
|
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#ifdef OS_IS_FREERTOS
|
2021-05-14 14:22:23 +08:00
|
|
|
while (1)
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
2021-05-14 14:42:21 +08:00
|
|
|
{
|
|
|
|
/* move received packet into a new pbuf */
|
|
|
|
SYS_ARCH_PROTECT(lev);
|
|
|
|
p = low_level_input(netif);
|
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
|
|
|
|
|
|
|
/* no packet could be read, silently ignore this */
|
|
|
|
if (p == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* points to packet payload, which starts with an Ethernet header */
|
|
|
|
ethhdr = p->payload;
|
|
|
|
|
|
|
|
#if LINK_STATS
|
|
|
|
lwip_stats.link.recv++;
|
|
|
|
#endif /* LINK_STATS */
|
|
|
|
|
|
|
|
switch (htons(ethhdr->type)) {
|
|
|
|
/* IP or ARP packet? */
|
|
|
|
case ETHTYPE_IP:
|
|
|
|
case ETHTYPE_ARP:
|
|
|
|
#if LWIP_IPV6
|
|
|
|
/*IPv6 Packet?*/
|
|
|
|
case ETHTYPE_IPV6:
|
|
|
|
#endif
|
|
|
|
#if PPPOE_SUPPORT
|
|
|
|
/* PPPoE packet? */
|
|
|
|
case ETHTYPE_PPPOEDISC:
|
|
|
|
case ETHTYPE_PPPOE:
|
|
|
|
#endif /* PPPOE_SUPPORT */
|
|
|
|
/* full packet send to tcpip_thread to process */
|
|
|
|
if (netif->input(p, netif) != ERR_OK) {
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("xemacpsif_input: IP input error\r\n"));
|
|
|
|
pbuf_free(p);
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pbuf_free(p);
|
|
|
|
p = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
return 1;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(OS_IS_FREERTOS) && defined(__arm__) && !defined(ARMR5)
|
|
|
|
void vTimerCallback( TimerHandle_t pxTimer )
|
|
|
|
{
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Do something if the pxTimer parameter is NULL */
|
2021-05-14 14:22:23 +08:00
|
|
|
configASSERT(pxTimer);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
lExpireCounter++;
|
2021-05-14 14:42:21 +08:00
|
|
|
/* If the timer has expired 100 times then reset RX */
|
2021-05-14 14:22:23 +08:00
|
|
|
if(lExpireCounter >= RESETRXTIMEOUT) {
|
2021-05-14 14:42:21 +08:00
|
|
|
lExpireCounter = 0;
|
|
|
|
xemacpsif_resetrx_on_no_rxdata(NetIf);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static err_t low_level_init(struct netif *netif)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
UINTPTR mac_address = (UINTPTR)(netif->state);
|
|
|
|
struct xemac_s *xemac;
|
|
|
|
xemacpsif_s *xemacpsif;
|
|
|
|
u32 dmacrreg;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
s32_t status = XST_SUCCESS;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
NetIf = netif;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
xemacpsif = mem_malloc(sizeof *xemacpsif);
|
|
|
|
if (xemacpsif == NULL) {
|
2021-05-14 14:42:21 +08:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("xemacpsif_init: out of memory\r\n"));
|
|
|
|
return ERR_MEM;
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
xemac = mem_malloc(sizeof *xemac);
|
|
|
|
if (xemac == NULL) {
|
2021-05-14 14:42:21 +08:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG, ("xemacpsif_init: out of memory\r\n"));
|
|
|
|
return ERR_MEM;
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
xemac->state = (void *)xemacpsif;
|
|
|
|
xemac->topology_index = xtopology_find_index(mac_address);
|
|
|
|
xemac->type = xemac_type_emacps;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
xemacpsif->send_q = NULL;
|
|
|
|
xemacpsif->recv_q = pq_create_queue();
|
|
|
|
if (!xemacpsif->recv_q)
|
2021-05-14 14:42:21 +08:00
|
|
|
return ERR_MEM;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* maximum transfer unit */
|
2021-05-13 16:33:40 +08:00
|
|
|
#ifdef ZYNQMP_USE_JUMBO
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->mtu = XEMACPS_MTU_JUMBO - XEMACPS_HDR_SIZE;
|
2021-05-13 16:33:40 +08:00
|
|
|
#else
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->mtu = XEMACPS_MTU - XEMACPS_HDR_SIZE;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LWIP_IGMP
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->igmp_mac_filter = xemacpsif_mac_filter_update;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
|
|
|
netif->mld_mac_filter = xemacpsif_mld6_mac_filter_update;
|
|
|
|
#endif
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP |
|
2021-05-14 14:42:21 +08:00
|
|
|
NETIF_FLAG_LINK_UP;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->flags |= NETIF_FLAG_MLD6;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LWIP_IGMP
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->flags |= NETIF_FLAG_IGMP;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* obtain config of this emac */
|
2021-05-14 14:22:23 +08:00
|
|
|
mac_config = (XEmacPs_Config *)xemacps_lookup_config((unsigned)(UINTPTR)netif->state);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#if EL1_NONSECURE
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Request device to indicate that this library is using it */
|
2021-05-14 14:22:23 +08:00
|
|
|
if (mac_config->BaseAddress == VERSAL_EMACPS_0_BASEADDR) {
|
2021-05-14 14:42:21 +08:00
|
|
|
Xil_Smc(PM_REQUEST_DEVICE_SMC_FID, DEV_GEM_0, 1, 0, 100, 1, 0, 0);
|
|
|
|
}
|
2021-05-14 14:22:23 +08:00
|
|
|
if (mac_config->BaseAddress == VERSAL_EMACPS_0_BASEADDR) {
|
2021-05-14 14:42:21 +08:00
|
|
|
Xil_Smc(PM_REQUEST_DEVICE_SMC_FID, DEV_GEM_1, 1, 0, 100, 1, 0, 0);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
status = XEmacPs_CfgInitialize(&xemacpsif->emacps, mac_config,
|
2021-05-14 14:42:21 +08:00
|
|
|
mac_config->BaseAddress);
|
2021-05-14 14:22:23 +08:00
|
|
|
if (status != XST_SUCCESS) {
|
2021-05-14 14:42:21 +08:00
|
|
|
xil_printf("In %s:EmacPs Configuration Failed....\r\n", __func__);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* initialize the mac */
|
2021-05-14 14:22:23 +08:00
|
|
|
init_emacps(xemacpsif, netif);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
dmacrreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_DMACR_OFFSET);
|
2021-05-14 14:22:23 +08:00
|
|
|
dmacrreg = dmacrreg | (0x00000010);
|
|
|
|
XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_DMACR_OFFSET, dmacrreg);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
|
|
|
#if defined(OS_IS_FREERTOS) && defined(__arm__) && !defined(ARMR5)
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Freertos tick is 10ms by default; set period to the same */
|
2021-05-14 14:22:23 +08:00
|
|
|
xemac->xTimer = xTimerCreate("Timer", 10, pdTRUE, ( void * ) 1, vTimerCallback);
|
|
|
|
if (xemac->xTimer == NULL) {
|
2021-05-14 14:42:21 +08:00
|
|
|
xil_printf("In %s:Timer creation failed....\r\n", __func__);
|
|
|
|
} else {
|
|
|
|
if(xTimerStart(xemac->xTimer, 0) != pdPASS) {
|
|
|
|
xil_printf("In %s:Timer start failed....\r\n", __func__);
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
2021-05-14 14:22:23 +08:00
|
|
|
setup_isr(xemac);
|
|
|
|
init_dma(xemac);
|
|
|
|
start_emacps(xemacpsif);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* replace the state in netif (currently the emac baseaddress)
|
|
|
|
* with the mac instance pointer.
|
|
|
|
*/
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->state = (void *)xemac;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
return ERR_OK;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HandleEmacPsError(struct xemac_s *xemac)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
xemacpsif_s *xemacpsif;
|
|
|
|
s32_t status = XST_SUCCESS;
|
|
|
|
u32 dmacrreg;
|
|
|
|
|
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
|
|
|
SYS_ARCH_PROTECT(lev);
|
|
|
|
|
|
|
|
xemacpsif = (xemacpsif_s *)(xemac->state);
|
|
|
|
free_txrx_pbufs(xemacpsif);
|
|
|
|
status = XEmacPs_CfgInitialize(&xemacpsif->emacps, mac_config,
|
2021-05-14 14:42:21 +08:00
|
|
|
mac_config->BaseAddress);
|
2021-05-14 14:22:23 +08:00
|
|
|
if (status != XST_SUCCESS) {
|
2021-05-14 14:42:21 +08:00
|
|
|
xil_printf("In %s:EmacPs Configuration Failed....\r\n", __func__);
|
|
|
|
}
|
|
|
|
/* initialize the mac */
|
2021-05-14 14:22:23 +08:00
|
|
|
init_emacps_on_error(xemacpsif, NetIf);
|
|
|
|
dmacrreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_DMACR_OFFSET);
|
2021-05-14 14:22:23 +08:00
|
|
|
dmacrreg = dmacrreg | (0x01000000);
|
|
|
|
XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_DMACR_OFFSET, dmacrreg);
|
2021-05-14 14:22:23 +08:00
|
|
|
setup_isr(xemac);
|
|
|
|
init_dma(xemac);
|
|
|
|
start_emacps(xemacpsif);
|
|
|
|
|
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HandleTxErrors(struct xemac_s *xemac)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
xemacpsif_s *xemacpsif;
|
|
|
|
u32 netctrlreg;
|
|
|
|
|
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
|
|
|
SYS_ARCH_PROTECT(lev);
|
|
|
|
xemacpsif = (xemacpsif_s *)(xemac->state);
|
|
|
|
netctrlreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_NWCTRL_OFFSET);
|
2021-05-13 16:33:40 +08:00
|
|
|
netctrlreg = netctrlreg & (~XEMACPS_NWCTRL_TXEN_MASK);
|
2021-05-14 14:22:23 +08:00
|
|
|
XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_NWCTRL_OFFSET, netctrlreg);
|
2021-05-14 14:22:23 +08:00
|
|
|
free_onlytx_pbufs(xemacpsif);
|
|
|
|
|
|
|
|
clean_dma_txdescs(xemac);
|
|
|
|
netctrlreg = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_NWCTRL_OFFSET);
|
2021-05-14 14:22:23 +08:00
|
|
|
netctrlreg = netctrlreg | (XEMACPS_NWCTRL_TXEN_MASK);
|
|
|
|
XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,
|
2021-05-14 14:42:21 +08:00
|
|
|
XEMACPS_NWCTRL_OFFSET, netctrlreg);
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#if LWIP_IPV6 && LWIP_IPV6_MLD
|
|
|
|
static u8_t xemacpsif_ip6_addr_ismulticast(ip6_addr_t* ip_addr)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
if(ip6_addr_ismulticast_linklocal(ip_addr)||
|
2021-05-13 16:33:40 +08:00
|
|
|
ip6_addr_ismulticast_iflocal(ip_addr) ||
|
|
|
|
ip6_addr_ismulticast_adminlocal(ip_addr)||
|
|
|
|
ip6_addr_ismulticast_sitelocal(ip_addr) ||
|
|
|
|
ip6_addr_ismulticast_orglocal(ip_addr) ||
|
|
|
|
ip6_addr_ismulticast_global(ip_addr)) {
|
2021-05-14 14:42:21 +08:00
|
|
|
/*Return TRUE if IPv6 is Multicast type*/
|
2021-05-14 14:22:23 +08:00
|
|
|
return TRUE;
|
2021-05-14 14:42:21 +08:00
|
|
|
} else {
|
2021-05-14 14:22:23 +08:00
|
|
|
return FALSE;
|
2021-05-14 14:42:21 +08:00
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void xemacpsif_mld6_mac_hash_update (struct netif *netif, u8_t *ip_addr,
|
2021-05-14 14:42:21 +08:00
|
|
|
u8_t action)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
u8_t multicast_mac_addr[6];
|
|
|
|
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
|
|
|
|
xemacpsif_s *xemacpsif = (xemacpsif_s *) (xemac->state);
|
|
|
|
XEmacPs_BdRing *txring;
|
|
|
|
txring = &(XEmacPs_GetTxRing(&xemacpsif->emacps));
|
|
|
|
|
|
|
|
multicast_mac_addr[0] = LL_IP6_MULTICAST_ADDR_0;
|
|
|
|
multicast_mac_addr[1] = LL_IP6_MULTICAST_ADDR_1;
|
|
|
|
multicast_mac_addr[2] = ip_addr[12];
|
|
|
|
multicast_mac_addr[3] = ip_addr[13];
|
|
|
|
multicast_mac_addr[4] = ip_addr[14];
|
|
|
|
multicast_mac_addr[5] = ip_addr[15];
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Wait till all sent packets are acknowledged from HW */
|
2021-05-14 14:22:23 +08:00
|
|
|
while(txring->HwCnt);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Stop Ethernet */
|
2021-05-14 14:22:23 +08:00
|
|
|
XEmacPs_Stop(&xemacpsif->emacps);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
if (action == NETIF_ADD_MAC_FILTER) {
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Set Mulitcast mac address in hash table */
|
|
|
|
XEmacPs_SetHash(&xemacpsif->emacps, multicast_mac_addr);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
} else if (action == NETIF_DEL_MAC_FILTER) {
|
|
|
|
/* Remove Mulitcast mac address in hash table */
|
|
|
|
XEmacPs_DeleteHash(&xemacpsif->emacps, multicast_mac_addr);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Reset DMA */
|
2021-05-14 14:22:23 +08:00
|
|
|
reset_dma(xemac);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Start Ethernet */
|
2021-05-14 14:22:23 +08:00
|
|
|
XEmacPs_Start(&xemacpsif->emacps);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif, ip_addr_t *group,
|
2021-05-14 14:42:21 +08:00
|
|
|
u8_t action)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
u8_t temp_mask;
|
|
|
|
unsigned int i;
|
|
|
|
u8_t * ip_addr = (u8_t *) group;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
|
2021-05-14 14:42:21 +08:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: The requested MAC address is not a multicast address.\r\n", __func__)); LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast address add operation failure !!\r\n"));
|
2021-05-13 16:33:40 +08:00
|
|
|
return ERR_ARG;
|
2021-05-14 14:42:21 +08:00
|
|
|
}
|
2021-05-14 14:22:23 +08:00
|
|
|
if (action == NETIF_ADD_MAC_FILTER) {
|
2021-05-14 14:42:21 +08:00
|
|
|
for (i = 0; i < XEMACPS_MAX_MAC_ADDR; i++) {
|
|
|
|
temp_mask = (0x01) << i;
|
|
|
|
if ((xemacps_mld6_mcast_entry_mask & temp_mask) == temp_mask) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
xemacps_mld6_mcast_entry_mask |= temp_mask;
|
|
|
|
|
|
|
|
/* Update mac address in hash table */
|
|
|
|
xemacpsif_mld6_mac_hash_update(netif, ip_addr, action);
|
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: Multicast MAC address successfully added.\r\n", __func__));
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: No multicast address registers left.\r\n", __func__));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast MAC address add operation failure !!\r\n"));
|
|
|
|
return ERR_MEM;
|
|
|
|
} else if (action == NETIF_DEL_MAC_FILTER) {
|
|
|
|
for (i = 0; i < XEMACPS_MAX_MAC_ADDR; i++) {
|
|
|
|
temp_mask = (0x01) << i;
|
|
|
|
if ((xemacps_mld6_mcast_entry_mask & temp_mask) != temp_mask) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
xemacps_mld6_mcast_entry_mask &= (~temp_mask);
|
|
|
|
|
|
|
|
/* Update mac address in hash table */
|
|
|
|
xemacpsif_mld6_mac_hash_update(netif, ip_addr, action);
|
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: Multicast MAC address successfully removed.\r\n", __func__));
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: No multicast address registers present with\r\n", __func__));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("the requested Multicast MAC address.\r\n"));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast MAC address removal failure!!.\r\n"));
|
|
|
|
return ERR_MEM;
|
|
|
|
}
|
2021-05-14 14:22:23 +08:00
|
|
|
return ERR_ARG;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LWIP_IGMP
|
|
|
|
static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip_addr,
|
2021-05-14 14:42:21 +08:00
|
|
|
u8_t action)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
u8_t multicast_mac_addr[6];
|
|
|
|
struct xemac_s *xemac = (struct xemac_s *) (netif->state);
|
|
|
|
xemacpsif_s *xemacpsif = (xemacpsif_s *) (xemac->state);
|
|
|
|
XEmacPs_BdRing *txring;
|
|
|
|
txring = &(XEmacPs_GetTxRing(&xemacpsif->emacps));
|
|
|
|
|
|
|
|
multicast_mac_addr[0] = 0x01;
|
|
|
|
multicast_mac_addr[1] = 0x00;
|
|
|
|
multicast_mac_addr[2] = 0x5E;
|
|
|
|
multicast_mac_addr[3] = ip_addr[1] & 0x7F;
|
|
|
|
multicast_mac_addr[4] = ip_addr[2];
|
|
|
|
multicast_mac_addr[5] = ip_addr[3];
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Wait till all sent packets are acknowledged from HW */
|
2021-05-14 14:22:23 +08:00
|
|
|
while(txring->HwCnt);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_DECL_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_PROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Stop Ethernet */
|
2021-05-14 14:22:23 +08:00
|
|
|
XEmacPs_Stop(&xemacpsif->emacps);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
if (action == IGMP_ADD_MAC_FILTER) {
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Set Mulitcast mac address in hash table */
|
|
|
|
XEmacPs_SetHash(&xemacpsif->emacps, multicast_mac_addr);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
} else if (action == IGMP_DEL_MAC_FILTER) {
|
|
|
|
/* Remove Mulitcast mac address in hash table */
|
|
|
|
XEmacPs_DeleteHash(&xemacpsif->emacps, multicast_mac_addr);
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Reset DMA */
|
2021-05-14 14:22:23 +08:00
|
|
|
reset_dma(xemac);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
/* Start Ethernet */
|
2021-05-14 14:22:23 +08:00
|
|
|
XEmacPs_Start(&xemacpsif->emacps);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
SYS_ARCH_UNPROTECT(lev);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static err_t xemacpsif_mac_filter_update (struct netif *netif, ip_addr_t *group,
|
2021-05-14 14:42:21 +08:00
|
|
|
u8_t action)
|
2021-05-13 16:33:40 +08:00
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
u8_t temp_mask;
|
|
|
|
unsigned int i;
|
|
|
|
u8_t * ip_addr = (u8_t *) group;
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
if ((ip_addr[0] < 224) && (ip_addr[0] > 239)) {
|
2021-05-14 14:42:21 +08:00
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: The requested MAC address is not a multicast address.\r\n", __func__));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast address add operation failure !!\r\n"));
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
return ERR_ARG;
|
|
|
|
}
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
if (action == IGMP_ADD_MAC_FILTER) {
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:42:21 +08:00
|
|
|
for (i = 0; i < XEMACPS_MAX_MAC_ADDR; i++) {
|
|
|
|
temp_mask = (0x01) << i;
|
|
|
|
if ((xemacps_mcast_entry_mask & temp_mask) == temp_mask) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
xemacps_mcast_entry_mask |= temp_mask;
|
|
|
|
|
|
|
|
/* Update mac address in hash table */
|
|
|
|
xemacpsif_mac_hash_update(netif, ip_addr, action);
|
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: Multicast MAC address successfully added.\r\n", __func__));
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
if (i == XEMACPS_MAX_MAC_ADDR) {
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: No multicast address registers left.\r\n", __func__));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast MAC address add operation failure !!\r\n"));
|
|
|
|
|
|
|
|
return ERR_MEM;
|
|
|
|
}
|
|
|
|
} else if (action == IGMP_DEL_MAC_FILTER) {
|
|
|
|
for (i = 0; i < XEMACPS_MAX_MAC_ADDR; i++) {
|
|
|
|
temp_mask = (0x01) << i;
|
|
|
|
if ((xemacps_mcast_entry_mask & temp_mask) != temp_mask) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
xemacps_mcast_entry_mask &= (~temp_mask);
|
|
|
|
|
|
|
|
/* Update mac address in hash table */
|
|
|
|
xemacpsif_mac_hash_update(netif, ip_addr, action);
|
|
|
|
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: Multicast MAC address successfully removed.\r\n", __func__));
|
|
|
|
|
|
|
|
return ERR_OK;
|
|
|
|
}
|
|
|
|
if (i == XEMACPS_MAX_MAC_ADDR) {
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("%s: No multicast address registers present with\r\n", __func__));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("the requested Multicast MAC address.\r\n"));
|
|
|
|
LWIP_DEBUGF(NETIF_DEBUG,
|
|
|
|
("Multicast MAC address removal failure!!.\r\n"));
|
|
|
|
|
|
|
|
return ERR_MEM;
|
|
|
|
}
|
|
|
|
}
|
2021-05-14 14:22:23 +08:00
|
|
|
return ERR_OK;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xemacpsif_init():
|
|
|
|
*
|
|
|
|
* Should be called at the beginning of the program to set up the
|
|
|
|
* network interface. It calls the function low_level_init() to do the
|
|
|
|
* actual setup of the hardware.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
err_t xemacpsif_init(struct netif *netif)
|
|
|
|
{
|
|
|
|
#if LWIP_SNMP
|
2021-05-14 14:42:21 +08:00
|
|
|
/* ifType ethernetCsmacd(6) @see RFC1213 */
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->link_type = 6;
|
2021-05-14 14:42:21 +08:00
|
|
|
/* your link speed here */
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->link_speed = ;
|
|
|
|
netif->ts = 0;
|
|
|
|
netif->ifinoctets = 0;
|
|
|
|
netif->ifinucastpkts = 0;
|
|
|
|
netif->ifinnucastpkts = 0;
|
|
|
|
netif->ifindiscards = 0;
|
|
|
|
netif->ifoutoctets = 0;
|
|
|
|
netif->ifoutucastpkts = 0;
|
|
|
|
netif->ifoutnucastpkts = 0;
|
|
|
|
netif->ifoutdiscards = 0;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->name[0] = IFNAME0;
|
|
|
|
netif->name[1] = IFNAME1;
|
|
|
|
netif->output = xemacpsif_output;
|
|
|
|
netif->linkoutput = low_level_output;
|
2021-05-13 16:33:40 +08:00
|
|
|
#if LWIP_IPV6
|
2021-05-14 14:22:23 +08:00
|
|
|
netif->output_ip6 = ethip6_output;
|
2021-05-13 16:33:40 +08:00
|
|
|
#endif
|
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
low_level_init(netif);
|
|
|
|
return ERR_OK;
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xemacpsif_resetrx_on_no_rxdata():
|
|
|
|
*
|
|
|
|
* Should be called by the user at regular intervals, typically
|
|
|
|
* from a timer (100 msecond). This is to provide a SW workaround
|
|
|
|
* for the HW bug (SI #692601). Please refer to the function header
|
|
|
|
* for the function resetrx_on_no_rxdata in xemacpsif_dma.c to
|
|
|
|
* know more about the SI.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
void xemacpsif_resetrx_on_no_rxdata(struct netif *netif)
|
|
|
|
{
|
2021-05-14 14:22:23 +08:00
|
|
|
struct xemac_s *xemac = (struct xemac_s *)(netif->state);
|
|
|
|
xemacpsif_s *xemacpsif = (xemacpsif_s *)(xemac->state);
|
2021-05-13 16:33:40 +08:00
|
|
|
|
2021-05-14 14:22:23 +08:00
|
|
|
resetrx_on_no_rxdata(xemacpsif);
|
2021-05-13 16:33:40 +08:00
|
|
|
}
|