net: Clean up network stack names used in DM drivers

Take the opportunity to enforce better names on newly written or
retrofitted Ethernet drivers.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Joe Hershberger 2015-03-22 17:09:11 -05:00 committed by Simon Glass
parent 05c3e68f85
commit 2a504df006
2 changed files with 27 additions and 12 deletions

View File

@ -468,7 +468,11 @@ extern uchar NetServerEther[6]; /* Boot server enet address */
extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */ extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */ extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
extern uchar *NetTxPacket; /* THE transmit packet */ extern uchar *NetTxPacket; /* THE transmit packet */
#ifdef CONFIG_DM_ETH
extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
#else
extern uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */ extern uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
#endif
extern uchar *NetRxPacket; /* Current receive packet */ extern uchar *NetRxPacket; /* Current receive packet */
extern int NetRxPacketLen; /* Current rx packet length */ extern int NetRxPacketLen; /* Current rx packet length */
extern unsigned NetIPID; /* IP ID (counting) */ extern unsigned NetIPID; /* IP ID (counting) */
@ -618,8 +622,11 @@ static inline void NetSendPacket(uchar *pkt, int len)
int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport,
int sport, int payload_len); int sport, int payload_len);
#ifndef CONFIG_DM_ETH
#define NetReceive(in_packet, len) net_process_received_packet(in_packet, len)
#endif
/* Processes a received packet */ /* Processes a received packet */
void NetReceive(uchar *, int); void net_process_received_packet(uchar *in_packet, int len);
#ifdef CONFIG_NETCONSOLE #ifdef CONFIG_NETCONSOLE
void NcStart(void); void NcStart(void);

View File

@ -183,10 +183,13 @@ int NetTimeOffset;
#endif #endif
static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN]; static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
#ifdef CONFIG_DM_ETH
/* Receive packets */
uchar *net_rx_packets[PKTBUFSRX];
#else
/* Receive packet */ /* Receive packet */
uchar *NetRxPackets[PKTBUFSRX]; uchar *NetRxPackets[PKTBUFSRX];
#endif
/* Current UDP RX packet handler */ /* Current UDP RX packet handler */
static rxhand_f *udp_packet_handler; static rxhand_f *udp_packet_handler;
/* Current ARP RX packet handler */ /* Current ARP RX packet handler */
@ -304,9 +307,15 @@ void net_init(void)
NetTxPacket = &PktBuf[0] + (PKTALIGN - 1); NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
#ifdef CONFIG_DM_ETH
for (i = 0; i < PKTBUFSRX; i++) {
net_rx_packets[i] = NetTxPacket + (i + 1) *
PKTSIZE_ALIGN;
}
#else
for (i = 0; i < PKTBUFSRX; i++) for (i = 0; i < PKTBUFSRX; i++)
NetRxPackets[i] = NetTxPacket + (i + 1) * PKTSIZE_ALIGN; NetRxPackets[i] = NetTxPacket + (i + 1) * PKTSIZE_ALIGN;
#endif
ArpInit(); ArpInit();
net_clear_handlers(); net_clear_handlers();
@ -952,8 +961,7 @@ static void receive_icmp(struct ip_udp_hdr *ip, int len,
} }
} }
void void net_process_received_packet(uchar *in_packet, int len)
NetReceive(uchar *inpkt, int len)
{ {
struct ethernet_hdr *et; struct ethernet_hdr *et;
struct ip_udp_hdr *ip; struct ip_udp_hdr *ip;
@ -967,9 +975,9 @@ NetReceive(uchar *inpkt, int len)
debug_cond(DEBUG_NET_PKT, "packet received\n"); debug_cond(DEBUG_NET_PKT, "packet received\n");
NetRxPacket = inpkt; NetRxPacket = in_packet;
NetRxPacketLen = len; NetRxPacketLen = len;
et = (struct ethernet_hdr *)inpkt; et = (struct ethernet_hdr *)in_packet;
/* too small packet? */ /* too small packet? */
if (len < ETHER_HDR_SIZE) if (len < ETHER_HDR_SIZE)
@ -977,7 +985,7 @@ NetReceive(uchar *inpkt, int len)
#ifdef CONFIG_API #ifdef CONFIG_API
if (push_packet) { if (push_packet) {
(*push_packet)(inpkt, len); (*push_packet)(in_packet, len);
return; return;
} }
#endif #endif
@ -1004,11 +1012,11 @@ NetReceive(uchar *inpkt, int len)
*/ */
eth_proto = ntohs(et802->et_prot); eth_proto = ntohs(et802->et_prot);
ip = (struct ip_udp_hdr *)(inpkt + E802_HDR_SIZE); ip = (struct ip_udp_hdr *)(in_packet + E802_HDR_SIZE);
len -= E802_HDR_SIZE; len -= E802_HDR_SIZE;
} else if (eth_proto != PROT_VLAN) { /* normal packet */ } else if (eth_proto != PROT_VLAN) { /* normal packet */
ip = (struct ip_udp_hdr *)(inpkt + ETHER_HDR_SIZE); ip = (struct ip_udp_hdr *)(in_packet + ETHER_HDR_SIZE);
len -= ETHER_HDR_SIZE; len -= ETHER_HDR_SIZE;
} else { /* VLAN packet */ } else { /* VLAN packet */
@ -1033,7 +1041,7 @@ NetReceive(uchar *inpkt, int len)
vlanid = cti & VLAN_IDMASK; vlanid = cti & VLAN_IDMASK;
eth_proto = ntohs(vet->vet_type); eth_proto = ntohs(vet->vet_type);
ip = (struct ip_udp_hdr *)(inpkt + VLAN_ETHER_HDR_SIZE); ip = (struct ip_udp_hdr *)(in_packet + VLAN_ETHER_HDR_SIZE);
len -= VLAN_ETHER_HDR_SIZE; len -= VLAN_ETHER_HDR_SIZE;
} }